diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2019-10-30 10:53:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-30 10:53:49 -0400 |
commit | 891497bc9fb23434242dbe92e1f13dd1273fcb21 (patch) | |
tree | a96314794e50c047b580a0e313e62164ae2998a6 /src/components/application_manager | |
parent | ea5960280585d11ee02542b0ab183d4400ed691d (diff) | |
parent | 4d283e625dfa09d166d572fa7bf6e98e91f05050 (diff) | |
download | sdl_core-891497bc9fb23434242dbe92e1f13dd1273fcb21.tar.gz |
Merge pull request #3100 from smartdevicelink/release/6.0.06.0.0
Release 6.0.0
Diffstat (limited to 'src/components/application_manager')
1198 files changed, 32858 insertions, 9258 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index 625e119270..c7f2aede9a 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -142,6 +142,7 @@ set(LIBRARIES formatters dbms Utils + policy_struct bson -L${BSON_LIBS_DIRECTORY} emhashmap -L${EMHASHMAP_LIBS_DIRECTORY} ) @@ -159,7 +160,7 @@ add_library("AMEventEngine" ${EVENT_ENGINE_SOURCES}) target_link_libraries("AMEventEngine" ${LIBRARIES}) add_library("AMPolicyLibrary" ${POLICIES_MANAGER_SOURCES} ) -target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine) +target_link_libraries("AMPolicyLibrary" ${LIBRARIES} AMEventEngine policy_struct) add_library("SystemTimeLibrary" ${SYSTEM_TIME_SOURCES}) target_link_libraries("SystemTimeLibrary" ${LIBRARIES} AMEventEngine) diff --git a/src/components/application_manager/include/application_manager/app_extension.h b/src/components/application_manager/include/application_manager/app_extension.h index e3231de347..5167aa88c0 100644 --- a/src/components/application_manager/include/application_manager/app_extension.h +++ b/src/components/application_manager/include/application_manager/app_extension.h @@ -33,11 +33,13 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_EXTENSION_H_ +#include <memory> + namespace ns_smart_device_link { namespace ns_smart_objects { class SmartObject; } -} +} // namespace ns_smart_device_link namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h index a10963ad82..2dd64a2941 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_CTRL_H_ -#include <string> #include <memory> +#include <string> namespace application_manager { class Application; @@ -49,22 +49,22 @@ namespace app_launch { class AppLaunchCtrl { public: /** - * @brief OnAppRegistered should be called when application registered - * Save application parameters to database - * @param app application to save - */ + * @brief OnAppRegistered should be called when application registered + * Save application parameters to database + * @param app application to save + */ virtual void OnAppRegistered(const application_manager::Application& app) = 0; /** - * @brief OnDeviceConnected shoudl be called on device connected event - * Start launching saaved applications on ios device - * @param device_mac - */ + * @brief OnDeviceConnected shoudl be called on device connected event + * Start launching saaved applications on ios device + * @param device_mac + */ virtual void OnDeviceConnected(const std::string& device_mac) = 0; /** - * @brief OnMasterReset clear database of saved applications - */ + * @brief OnMasterReset clear database of saved applications + */ virtual void OnMasterReset() = 0; virtual ~AppLaunchCtrl() {} }; diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h index 61f3480f77..986f4ad4ff 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h @@ -41,11 +41,11 @@ namespace connection_handler { class ConnectionHandler; -} // connection_handler +} // namespace connection_handler namespace resumption { class ResumeCtrl; -} // resumption +} // namespace resumption namespace app_launch { // TODO(AK) Use unique pointer diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h index 73e9623b62..c1ad8d4003 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_H_ #include <stdint.h> -#include <vector> -#include <string> #include <memory> +#include <string> +#include <vector> namespace app_launch { diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h index ccbf4c7c01..b232d1874c 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_db.h @@ -104,8 +104,8 @@ class AppLaunchDataDB : public AppLaunchDataImpl { bool IsAppDataAlreadyExisted(const ApplicationData& app_data) const OVERRIDE; /** - * @brief returns pointer to data base - */ + * @brief returns pointer to data base + */ utils::dbms::SQLDatabase* db() const; enum ApplicationDataDBIndexes { @@ -151,13 +151,13 @@ class AppLaunchDataDB : public AppLaunchDataImpl { bool WriteDb(); /** - * @brief returns pointer to data base - */ + * @brief returns pointer to data base + */ std::unique_ptr<utils::dbms::SQLDatabase> db_; /** - * @brief indicate initializing status of DB - */ + * @brief indicate initializing status of DB + */ bool init_successeful_; DISALLOW_COPY_AND_ASSIGN(AppLaunchDataDB); diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h index a2b8630bcc..b28c7fdd3d 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_impl.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_IMPL_H_ +#include <memory> #include "application_manager/app_launch/app_launch_data.h" #include "application_manager/app_launch_settings.h" #include "utils/macro.h" -#include <memory> namespace app_launch { diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h index a292b84fc0..9463a349d9 100644 --- a/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h +++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_data_json.h @@ -33,12 +33,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APP_LAUNCH_DATA_JSON_H_ +#include <memory> #include "application_manager/app_launch/app_launch_data_impl.h" -#include "smart_objects/smart_object.h" #include "resumption/last_state.h" +#include "smart_objects/smart_object.h" #include "utils/lock.h" #include "utils/macro.h" -#include <memory> namespace app_launch { diff --git a/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h index 6285514be9..7e360aa460 100644 --- a/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h +++ b/src/components/application_manager/include/application_manager/app_launch/apps_launcher.h @@ -1,9 +1,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_APPS_LAUNCHER_H_ +#include <memory> #include "application_manager/app_launch/app_launch_data.h" #include "connection_handler/connection_handler.h" #include "utils/timer.h" -#include <memory> namespace app_launch { class AppLaunchCtrlImpl; diff --git a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h index f156654215..f27e4569fc 100644 --- a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h +++ b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h @@ -1,12 +1,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APP_LAUNCH_DEVICE_APPS_LAUNCHER_H_ #include <stdint.h> -#include <vector> -#include <string> #include <memory> +#include <string> +#include <vector> #include "application_manager/app_launch/app_launch_data.h" -#include "application_manager/application_manager.h" #include "application_manager/app_launch_settings.h" +#include "application_manager/application_manager.h" namespace app_launch { class AppLaunchCtrlImpl; diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index b4d8ca857e..e9dcf2bcb0 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -33,23 +33,23 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_H_ -#include <string> +#include <list> #include <map> +#include <memory> #include <set> -#include <list> +#include <string> #include <vector> -#include <memory> -#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" #include "application_manager/help_prompt_manager.h" +#include "application_manager/hmi_state.h" +#include "application_manager/message.h" +#include "connection_handler/device.h" +#include "interfaces/MOBILE_API.h" #include "protocol_handler/protocol_handler.h" #include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" #include "utils/macro.h" #include "utils/semantic_version.h" @@ -62,13 +62,17 @@ typedef int32_t ErrorCode; class UsageStatistics; +class DisplayCapabilitiesBuilder; + enum APIVersion { kUnknownAPI = -1, kAPIV0 = 0, kAPIV1 = 1, kAPIV2 = 2, kAPIV3 = 3, - kAPIV4 = 4 + kAPIV4 = 4, + kAPIV5 = 5, + kAPIV6 = 6 }; enum TLimitSource { POLICY_TABLE = 0, CONFIG_FILE }; @@ -146,6 +150,12 @@ typedef std::map<uint32_t, smart_objects::SmartObject*> SubMenuMap; typedef std::map<uint32_t, smart_objects::SmartObject*> ChoiceSetMap; /* + * @brief Typedef for map of window ids to data used as parameters + * to CreateWindow request. + */ +typedef std::map<WindowID, smart_objects::SmartObjectSPtr> WindowParamsMap; + +/* * @brief Typedef for perform interaction choice * @param choice id * @param SmartObject choice @@ -162,7 +172,7 @@ typedef std::map<uint32_t, PerformChoice> PerformChoiceSetMap; /** * @brief Defines id of SoftButton */ -typedef std::set<uint32_t> SoftButtonID; +typedef std::set<std::pair<uint32_t, WindowID> > SoftButtonID; /** * @brief Defines set of buttons subscription @@ -188,9 +198,25 @@ class DynamicApplicationData { virtual const smart_objects::SmartObject* keyboard_props() const = 0; virtual const smart_objects::SmartObject* menu_title() const = 0; virtual const smart_objects::SmartObject* menu_icon() const = 0; - virtual const smart_objects::SmartObject* day_color_scheme() const = 0; - virtual const smart_objects::SmartObject* night_color_scheme() const = 0; - virtual const std::string& display_layout() const = 0; + virtual smart_objects::SmartObject day_color_scheme() const = 0; + virtual smart_objects::SmartObject night_color_scheme() const = 0; + virtual std::string display_layout() const = 0; + + /** + * @brief Specific display capabilities of application + * @return display capabilities of application or NULL-initialized pointer if + * not specified + */ + virtual smart_objects::SmartObjectSPtr display_capabilities() const = 0; + + /** + * @brief Specific display capabilities of application + * @param window id - id of an affected widget + * @return display capabilities of application or NULL-initialized pointer if + * not specified + */ + virtual smart_objects::SmartObjectSPtr display_capabilities( + const WindowID window_id) const = 0; virtual void load_global_properties(const smart_objects::SmartObject& so) = 0; virtual void set_help_prompt( @@ -222,12 +248,84 @@ class DynamicApplicationData { virtual void set_video_stream_retry_number( const uint32_t& video_stream_retry_number) = 0; + virtual void set_display_layout(const std::string& layout) = 0; virtual void set_day_color_scheme( const smart_objects::SmartObject& color_scheme) = 0; virtual void set_night_color_scheme( const smart_objects::SmartObject& color_scheme) = 0; - virtual void set_display_layout(const std::string& layout) = 0; + /** + * @brief Set specific application display capabilities + * @param display_capabilities new display capabilities of application + */ + virtual void set_display_capabilities( + const smart_objects::SmartObject& display_capabilities) = 0; + + /** + * @brief deletes stored window capability for given window id + * @param window id of capability to remove + */ + virtual void remove_window_capability(const WindowID window_id) = 0; + + /** + * @brief checks whether a specific menu layout is supported + * @param menu layout to check + */ + virtual bool menu_layout_supported( + const mobile_apis::MenuLayout::eType layout) const = 0; + + /** + * @brief Sets layout for application's specific window + * @param window_id window id for which layout should be set + * @param layout - layout to be set + */ + virtual void set_window_layout(const WindowID window_id, + const std::string& layout) = 0; + + /** + * @brief Sets day color scheme for application's specific window + * @param window_id window id for which day color scheme should be set + * @param color_scheme - color scheme to be set + */ + virtual void set_day_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) = 0; + + /** + * @brief Sets night color scheme for application's specific window + * @param window_id window id for which night color scheme should be set + * @param color_scheme - color scheme to be set + */ + virtual void set_night_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) = 0; + + /** + * @brief Gets window layout for application's specific window_id + * @param window_id window id for which display layout should be returned + * @return string containing set display layout, + * if no display layout is set - empty string is returned + */ + virtual std::string window_layout(const WindowID window_id) const = 0; + + /** + * @brief Gets day color scheme for application's specific window_id + * @param window_id window id for which color scheme should be returned + * @return day color scheme which is set for specified app window, + * if no day color scheme is set - Smart object with NullType is returned + */ + virtual smart_objects::SmartObject day_color_scheme( + const WindowID window_id) const = 0; + + /** + * @brief Gets night color scheme for application's specific window_id + * @param window_id window id for which color scheme should be returned + * @return night color scheme which is set for specified app window + * if no night color scheme is set - Smart object with NullType is returned + */ + virtual smart_objects::SmartObject night_color_scheme( + const WindowID window_id) const = 0; + /** * @brief Checks if application is media, voice communication or navigation * @return true if application is media, voice communication or navigation, @@ -236,8 +334,8 @@ class DynamicApplicationData { virtual bool is_audio() const = 0; /* - * @brief Adds a command to the in application menu - */ + * @brief Adds a command to the in application menu + */ virtual void AddCommand(uint32_t cmd_id, const smart_objects::SmartObject& command) = 0; @@ -290,6 +388,20 @@ class DynamicApplicationData { virtual void RemoveChoiceSet(uint32_t choice_set_id) = 0; /* + * @brief Adds window info + * @param window_id unique id of a window + * @param window_info SmartObject that represent window info + */ + virtual void SetWindowInfo(const WindowID window_id, + const smart_objects::SmartObject& window_info) = 0; + + /* + * @brief Removes window info + * @param window_id unique id of a window + */ + virtual void RemoveWindowInfo(const WindowID window_id) = 0; + + /* * @brief Finds choice set with the specified choice_set_id id * * @param choice_set_id Unique ID of the interaction choice set @@ -324,6 +436,16 @@ class DynamicApplicationData { const = 0; /* + * @brief Retrieves window info map + */ + virtual DataAccessor<WindowParamsMap> window_optional_params_map() const = 0; + + /* + * @brief Retrieves display capabilities builder + */ + virtual DisplayCapabilitiesBuilder& display_capabilities_builder() = 0; + + /* * @brief Retrieve application commands */ virtual DataAccessor<CommandsMap> commands_map() const = 0; @@ -353,10 +475,10 @@ class DynamicApplicationData { virtual uint32_t is_perform_interaction_active() const = 0; /* - * @brief Set perform interaction layout - * - * @param Current Interaction layout of the perform interaction - */ + * @brief Set perform interaction layout + * + * @param Current Interaction layout of the perform interaction + */ virtual void set_perform_interaction_layout( mobile_api::LayoutMode::eType layout) = 0; @@ -366,10 +488,10 @@ class DynamicApplicationData { virtual mobile_api::LayoutMode::eType perform_interaction_layout() const = 0; /* - * @brief Sets the mode for perform interaction: UI/VR/BOTH - * - * @param mode Mode that was selected (MENU; VR; BOTH) - */ + * @brief Sets the mode for perform interaction: UI/VR/BOTH + * + * @param mode Mode that was selected (MENU; VR; BOTH) + */ virtual void set_perform_interaction_mode(int32_t mode) = 0; /* @@ -449,6 +571,20 @@ class Application : public virtual InitialApplicationData, */ virtual void set_is_application_data_changed(bool state_application_data) = 0; + /** + * @brief Checks if application data is allowed to be resumed + * @return TRUE if data of application is allowed to be resumed, otherwise + * return FALSE + */ + virtual bool is_app_data_resumption_allowed() const = 0; + + /** + * @brief Sets resumption allowance for application data + * @param allowed - true if app data allowed to be resumed, + * false value means that app data is disallowed for resumption + */ + virtual void set_app_data_resumption_allowance(const bool allowed) = 0; + virtual void CloseActiveMessage() = 0; virtual bool IsFullscreen() const = 0; virtual void ChangeSupportingAppHMIType() = 0; @@ -520,8 +656,10 @@ class Application : public virtual InitialApplicationData, /** * @brief Wakes up streaming process for application * @param service_type Type of streaming service + * @param timer_len The amount of time in ms the timer will wait */ - virtual void WakeUpStreaming(protocol_handler::ServiceType service_type) = 0; + virtual void WakeUpStreaming(protocol_handler::ServiceType service_type, + uint32_t timer_len = 0) = 0; virtual bool is_voice_communication_supported() const = 0; virtual void set_voice_communication_supported( @@ -545,11 +683,26 @@ class Application : public virtual InitialApplicationData, virtual bool is_media_application() const = 0; virtual bool is_foreground() const = 0; virtual void set_foreground(const bool is_foreground) = 0; - virtual const mobile_api::HMILevel::eType hmi_level() const = 0; + + /** + * @brief hmi_level current HMI level of application's window + * @param window_id id of application's window to get + * @return HMI level of application's window + */ + virtual const mobile_api::HMILevel::eType hmi_level( + const WindowID window_id) const = 0; + virtual const uint32_t put_file_in_none_count() const = 0; virtual const uint32_t delete_file_in_none_count() const = 0; virtual const uint32_t list_files_in_none_count() const = 0; - virtual const mobile_api::SystemContext::eType system_context() const = 0; + + /** + * @brief system_context current system context of application's window + * @param window_id id of application's window to get + * @return system context of application's window + */ + virtual const mobile_api::SystemContext::eType system_context( + const WindowID window_id) const = 0; virtual const mobile_api::AudioStreamingState::eType audio_streaming_state() const = 0; virtual const mobile_api::VideoStreamingState::eType video_streaming_state() @@ -694,58 +847,91 @@ class Application : public virtual InitialApplicationData, /** * @brief SetInitialState sets initial HMI state for application on * registration + * @param window_id window id for HMI state + * @param window_name name of inited window * @param state Hmi state value */ - virtual void SetInitialState(HmiStatePtr state) = 0; + virtual void SetInitialState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) = 0; /** * @brief SetRegularState set permanent state of application - * + * @param window_id window id for HMI state * @param state state to setup */ - virtual void SetRegularState(HmiStatePtr state) = 0; + virtual void SetRegularState(const WindowID window_id, HmiStatePtr state) = 0; /** - * @brief SetPostponedState sets postponed state to application. - * This state could be set as regular later - * - * @param state state to setup - */ - virtual void SetPostponedState(HmiStatePtr state) = 0; + * @brief SetPostponedState sets postponed state to application. + * This state could be set as regular later + * @param window_id window id for HMI state + * @param state state to setup + */ + virtual void SetPostponedState(const WindowID window_id, + HmiStatePtr state) = 0; - virtual void RemovePostponedState() = 0; + /** + * @brief RemovePostponedState removes postponed state for application + * After removal, this state will not be set as regular later + * @param window_id window id for HMI state + */ + virtual void RemovePostponedState(const WindowID window_id) = 0; /** * @brief AddHMIState the function that will change application's * hmi state. * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state * * @param state new hmi state for certain application. */ - virtual void AddHMIState(HmiStatePtr state) = 0; + virtual void AddHMIState(const WindowID window_id, HmiStatePtr state) = 0; /** * @brief RemoveHMIState the function that will turn back hmi_level after end * of some event * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state * * @param state_id that should be removed */ - virtual void RemoveHMIState(HmiState::StateID state_id) = 0; + virtual void RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) = 0; /** * @brief HmiState of application within active events PhoneCall, TTS< etc ... + * @param window_id window id for HMI state * @return Active HmiState of application */ - virtual const HmiStatePtr CurrentHmiState() const = 0; + virtual const HmiStatePtr CurrentHmiState(const WindowID window_id) const = 0; + + /** + * @brief Getter for a list of available application windows including the + * main + * @return list of available window IDs created by application + */ + virtual WindowIds GetWindowIds() const = 0; + + /** + * @brief Getter for a list of all existing window names + * @return list of available window names created by application + */ + virtual WindowNames GetWindowNames() const = 0; + + /** + * @brief Check if application has specified window + * @param window_id - id of window to check + * @return true if app has specified window , otherwise false + */ + virtual bool WindowIdExists(const WindowID window_id) const = 0; /** * @brief RegularHmiState of application without active events VR, TTS etc ... + * @param window_id window id for HMI state * @return HmiState of application */ - virtual const HmiStatePtr RegularHmiState() const = 0; + virtual const HmiStatePtr RegularHmiState(const WindowID window_id) const = 0; /** * @brief Checks if app is allowed to change audio source @@ -756,10 +942,11 @@ class Application : public virtual InitialApplicationData, /** * @brief PostponedHmiState returns postponed hmi state of application * if it's present - * + * @param window_id window id for HMI state * @return Postponed hmi state of application */ - virtual const HmiStatePtr PostponedHmiState() const = 0; + virtual const HmiStatePtr PostponedHmiState( + const WindowID window_id) const = 0; /** * @brief Keeps id of softbuttons which is created in commands: @@ -772,6 +959,13 @@ class Application : public virtual InitialApplicationData, const SoftButtonID& softbuttons_id) = 0; /** + * @brief Retreives window id on which given button is created + * @param button_id identifier of a button + * @param window id of a widget containing button + */ + virtual WindowID GetSoftButtonWindowID(const uint32_t button_id) = 0; + + /** * @brief Determine the existence of softbutton * @param Softbutton_id contains id of softbutton * @return Returns true if application contains softbutton id otherwise @@ -901,9 +1095,11 @@ class Application : public virtual InitialApplicationData, /** * @brief set_system_context Set system context for application + * @param window_id window id for HMI state * @param system_context Current context */ virtual void set_system_context( + const WindowID window_id, const mobile_api::SystemContext::eType& system_context) = 0; /** @@ -915,9 +1111,11 @@ class Application : public virtual InitialApplicationData, /** * @brief set_hmi_level Set HMI level for application + * @param window_id window id for HMI state * @param hmi_level Current HMI level */ - virtual void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) = 0; + virtual void set_hmi_level(const WindowID window_id, + const mobile_api::HMILevel::eType& hmi_level) = 0; /** * @brief Return pointer to extension by uid @@ -1013,6 +1211,19 @@ class Application : public virtual InitialApplicationData, */ virtual void set_cloud_app_certificate(const std::string& certificate) = 0; + /** + * @brief Set user location + * @param smart object of user location + */ + virtual void set_user_location( + const smart_objects::SmartObject& user_location) = 0; + + /** + * @brief Get user location + * @return smart object of user location + */ + virtual const smart_objects::SmartObject& get_user_location() const = 0; + protected: mutable sync_primitives::Lock hmi_states_lock_; diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h index 8f24f124f9..5c4f868fc9 100644 --- a/src/components/application_manager/include/application_manager/application_data_impl.h +++ b/src/components/application_manager/include/application_manager/application_data_impl.h @@ -34,11 +34,12 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_DATA_IMPL_H_ #include <string> -#include "utils/lock.h" -#include "utils/semantic_version.h" -#include "smart_objects/smart_object.h" #include "application_manager/application.h" +#include "application_manager/display_capabilities_builder.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/lock.h" +#include "utils/semantic_version.h" namespace application_manager { @@ -88,6 +89,7 @@ class InitialApplicationDataImpl : public virtual Application { class DynamicApplicationDataImpl : public virtual Application { public: + typedef std::map<WindowID, smart_objects::SmartObject> AppWindowsTemplates; DynamicApplicationDataImpl(); ~DynamicApplicationDataImpl(); const smart_objects::SmartObject* help_prompt() const; @@ -100,9 +102,31 @@ class DynamicApplicationDataImpl : public virtual Application { const smart_objects::SmartObject* keyboard_props() const; const smart_objects::SmartObject* menu_title() const; const smart_objects::SmartObject* menu_icon() const; - const smart_objects::SmartObject* day_color_scheme() const; - const smart_objects::SmartObject* night_color_scheme() const; - const std::string& display_layout() const; + + smart_objects::SmartObject day_color_scheme() const OVERRIDE; + smart_objects::SmartObject night_color_scheme() const OVERRIDE; + std::string display_layout() const OVERRIDE; + smart_objects::SmartObjectSPtr display_capabilities() const OVERRIDE; + smart_objects::SmartObjectSPtr display_capabilities( + const WindowID window_id) const OVERRIDE; + + void set_window_layout(const WindowID window_id, + const std::string& layout) OVERRIDE; + + void set_day_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) OVERRIDE; + void set_night_color_scheme( + const WindowID window_id, + const smart_objects::SmartObject& color_scheme) OVERRIDE; + + std::string window_layout(const WindowID window_id) const OVERRIDE; + + smart_objects::SmartObject day_color_scheme( + const WindowID window_id) const OVERRIDE; + + smart_objects::SmartObject night_color_scheme( + const WindowID window_id) const OVERRIDE; void load_global_properties(const smart_objects::SmartObject& properties_so); void set_help_prompt(const smart_objects::SmartObject& help_prompt); @@ -120,6 +144,17 @@ class DynamicApplicationDataImpl : public virtual Application { void set_day_color_scheme(const smart_objects::SmartObject& color_scheme); void set_night_color_scheme(const smart_objects::SmartObject& color_scheme); void set_display_layout(const std::string& layout); + void set_display_capabilities( + const smart_objects::SmartObject& display_capabilities) OVERRIDE; + void remove_window_capability(const WindowID window_id) OVERRIDE; + + /** + * @brief checks whether a specific menu layout is supported + * @param menu layout to check + */ + bool menu_layout_supported( + const mobile_apis::MenuLayout::eType layout) const OVERRIDE; + /* * @brief Adds a command to the in application menu */ @@ -156,6 +191,11 @@ class DynamicApplicationDataImpl : public virtual Application { */ bool IsSubMenuNameAlreadyExist(const std::string& name); + void SetWindowInfo(const WindowID window_id, + const smart_objects::SmartObject& window_info) OVERRIDE; + + void RemoveWindowInfo(const WindowID window_id) OVERRIDE; + /* * @brief Adds a interaction choice set to the application * @@ -221,6 +261,10 @@ class DynamicApplicationDataImpl : public virtual Application { */ inline DataAccessor<ChoiceSetMap> choice_set_map() const; + DataAccessor<WindowParamsMap> window_optional_params_map() const; + + DisplayCapabilitiesBuilder& display_capabilities_builder(); + /* * @brief Sets perform interaction state * @@ -274,9 +318,8 @@ class DynamicApplicationDataImpl : public virtual Application { smart_objects::SmartObject* menu_title_; smart_objects::SmartObject* menu_icon_; smart_objects::SmartObject* tbt_show_command_; - smart_objects::SmartObject* day_color_scheme_; - smart_objects::SmartObject* night_color_scheme_; - std::string display_layout_; + smart_objects::SmartObjectSPtr display_capabilities_; + AppWindowsTemplates window_templates_; CommandsMap commands_; mutable std::shared_ptr<sync_primitives::RecursiveLock> commands_lock_ptr_; @@ -287,9 +330,12 @@ class DynamicApplicationDataImpl : public virtual Application { PerformChoiceSetMap performinteraction_choice_set_map_; mutable std::shared_ptr<sync_primitives::RecursiveLock> performinteraction_choice_set_lock_ptr_; + WindowParamsMap window_params_map_; + mutable std::shared_ptr<sync_primitives::Lock> window_params_map_lock_ptr_; uint32_t is_perform_interaction_active_; bool is_reset_global_properties_active_; int32_t perform_interaction_mode_; + DisplayCapabilitiesBuilder display_capabilities_builder_; private: void SetGlobalProperties( 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 ff34d2a96a..27b6c8123e 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -33,28 +33,28 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_IMPL_H_ +#include <stdint.h> +#include <forward_list> +#include <list> #include <map> #include <set> -#include <vector> #include <utility> -#include <list> -#include <forward_list> -#include <stdint.h> +#include <vector> #include "application_manager/application.h" #include "application_manager/application_data_impl.h" -#include "application_manager/usage_statistics.h" #include "application_manager/help_prompt_manager_impl.h" #include "application_manager/hmi_state.h" +#include "application_manager/usage_statistics.h" #include "protocol_handler/protocol_handler.h" -#include "connection_handler/device.h" -#include "utils/lock.h" #include <atomic> +#include "connection_handler/device.h" #include "utils/custom_string.h" -#include "utils/timer.h" -#include "utils/macro.h" #include "utils/date_time.h" +#include "utils/lock.h" +#include "utils/macro.h" +#include "utils/timer.h" namespace usage_statistics { @@ -139,7 +139,8 @@ class ApplicationImpl : public virtual Application, void StopStreamingForce(protocol_handler::ServiceType service_type); void StopStreaming(protocol_handler::ServiceType service_type); void SuspendStreaming(protocol_handler::ServiceType service_type); - void WakeUpStreaming(protocol_handler::ServiceType service_type); + void WakeUpStreaming(protocol_handler::ServiceType service_type, + uint32_t timer_len = 0); virtual bool is_voice_communication_supported() const; virtual void set_voice_communication_supported( @@ -158,11 +159,13 @@ class ApplicationImpl : public virtual Application, bool is_media_application() const; bool is_foreground() const OVERRIDE; void set_foreground(const bool is_foreground) OVERRIDE; - const mobile_apis::HMILevel::eType hmi_level() const; + const mobile_apis::HMILevel::eType hmi_level( + const WindowID window_id) const OVERRIDE; const uint32_t put_file_in_none_count() const; const uint32_t delete_file_in_none_count() const; const uint32_t list_files_in_none_count() const; - const mobile_api::SystemContext::eType system_context() const; + const mobile_api::SystemContext::eType system_context( + const WindowID window_id) const OVERRIDE; inline const mobile_apis::AudioStreamingState::eType audio_streaming_state() const; inline const mobile_apis::VideoStreamingState::eType video_streaming_state() @@ -229,6 +232,8 @@ class ApplicationImpl : public virtual Application, bool IsSubscribedToButton(mobile_apis::ButtonName::eType btn_name); bool UnsubscribeFromButton(mobile_apis::ButtonName::eType btn_name); + WindowID GetSoftButtonWindowID(const uint32_t button_id) OVERRIDE; + inline bool IsRegistered() const OVERRIDE; /** @@ -279,6 +284,9 @@ class ApplicationImpl : public virtual Application, virtual bool is_application_data_changed() const; + bool is_app_data_resumption_allowed() const OVERRIDE; + void set_app_data_resumption_allowance(const bool allowed) OVERRIDE; + virtual void set_is_application_data_changed(bool state_application_data); /** @@ -299,26 +307,35 @@ class ApplicationImpl : public virtual Application, /** * @brief SetInitialState sets initial HMI state for application on * registration + * @param window_id window id for HMI state + * @param window_name name of inited window * @param state Hmi state value */ - void SetInitialState(HmiStatePtr state) FINAL; + void SetInitialState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) FINAL; /** - * @brief SetRegularState set permanent state of application - * - * @param state state to setup - */ - virtual void SetRegularState(HmiStatePtr state); + * @brief SetRegularState set permanent state of application + * @param window_id window id for HMI state + * @param state state to setup + */ + void SetRegularState(const WindowID window_id, HmiStatePtr state) FINAL; /** - * @brief SetPostponedState sets postponed state to application. - * This state could be set as regular later - * - * @param state state to setup - */ - virtual void SetPostponedState(HmiStatePtr state); + * @brief SetPostponedState sets postponed state to application. + * This state could be set as regular later + * @param window_id window id for HMI state + * @param state state to setup + */ + void SetPostponedState(const WindowID window_id, HmiStatePtr state) FINAL; - virtual void RemovePostponedState(); + /** + * @brief RemovePostponedState removes postponed state for application + * After removal, this state will not be set as regular later + * @param window_id window id for HMI state + */ + void RemovePostponedState(const WindowID window_id) FINAL; /** * @brief AddHMIState the function that will change application's @@ -328,7 +345,7 @@ class ApplicationImpl : public virtual Application, * * @param state new hmi state for certain application. */ - virtual void AddHMIState(HmiStatePtr state); + void AddHMIState(const WindowID window_id, HmiStatePtr state) FINAL; /** * @brief RemoveHMIState the function that will turn back hmi_level after end @@ -338,13 +355,20 @@ class ApplicationImpl : public virtual Application, * * @param state_id that should be removed */ - virtual void RemoveHMIState(HmiState::StateID state_id); + void RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) FINAL; /** * @brief HmiState of application within active events PhoneCall, TTS< etc ... * @return Active HmiState of application */ - virtual const HmiStatePtr CurrentHmiState() const; + const HmiStatePtr CurrentHmiState(const WindowID window_i) const FINAL; + + WindowNames GetWindowNames() const FINAL; + + WindowIds GetWindowIds() const FINAL; + + bool WindowIdExists(const WindowID window_id) const FINAL; /** * @brief Checks if app is allowed to change audio source @@ -356,7 +380,7 @@ class ApplicationImpl : public virtual Application, * @brief RegularHmiState of application without active events VR, TTS etc ... * @return HmiState of application */ - virtual const HmiStatePtr RegularHmiState() const; + const HmiStatePtr RegularHmiState(const WindowID window_id) const FINAL; /** * @brief PostponedHmiState returns postponed hmi state of application @@ -364,7 +388,7 @@ class ApplicationImpl : public virtual Application, * * @return Postponed hmi state of application */ - virtual const HmiStatePtr PostponedHmiState() const; + const HmiStatePtr PostponedHmiState(const WindowID window_id) const FINAL; uint32_t audio_stream_retry_number() const; @@ -391,6 +415,7 @@ class ApplicationImpl : public virtual Application, * @param system_context new system context */ void set_system_context( + const WindowID window_id, const mobile_api::SystemContext::eType& system_context) OVERRIDE; /** * @brief Sets current audio streaming state @@ -402,7 +427,8 @@ class ApplicationImpl : public virtual Application, * @brief Sets current HMI level * @param hmi_level new HMI level */ - void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) OVERRIDE; + void set_hmi_level(const WindowID window_id, + const mobile_api::HMILevel::eType& hmi_level) OVERRIDE; void PushMobileMessage( smart_objects::SmartObjectSPtr mobile_message) OVERRIDE; @@ -475,6 +501,11 @@ class ApplicationImpl : public virtual Application, */ void set_cloud_app_certificate(const std::string& certificate) OVERRIDE; + void set_user_location( + const smart_objects::SmartObject& user_location) OVERRIDE; + + const smart_objects::SmartObject& get_user_location() const OVERRIDE; + protected: /** * @brief Clean up application folder. Persistent files will stay @@ -546,6 +577,7 @@ class ApplicationImpl : public virtual Application, sync_primitives::Lock streaming_stop_lock_; bool is_app_allowed_; + bool is_app_data_resumption_allowed_; bool has_been_activated_; bool tts_properties_in_none_; bool tts_properties_in_full_; @@ -585,6 +617,7 @@ class ApplicationImpl : public virtual Application, std::string cloud_transport_type_; mobile_apis::HybridAppPreference::eType hybrid_app_preference_; std::string certificate_; + smart_objects::SmartObject user_location_; /** * @brief Defines number per time in seconds limits @@ -632,7 +665,8 @@ uint32_t ApplicationImpl::app_id() const { const mobile_api::AudioStreamingState::eType ApplicationImpl::audio_streaming_state() const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); return hmi_state ? hmi_state->audio_streaming_state() : AudioStreamingState::INVALID_ENUM; } @@ -640,7 +674,8 @@ ApplicationImpl::audio_streaming_state() const { const mobile_api::VideoStreamingState::eType ApplicationImpl::video_streaming_state() const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = + CurrentHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); return hmi_state ? hmi_state->video_streaming_state() : VideoStreamingState::INVALID_ENUM; } 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 738458ef26..e88c954c18 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 @@ -34,41 +34,44 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_H_ #include <stdint.h> -#include <vector> -#include <map> -#include <set> -#include <deque> #include <algorithm> +#include <deque> +#include <map> #include <memory> +#include <set> +#include <vector> -#include "application_manager/application_manager.h" +#include "application_manager/app_launch/app_launch_data.h" #include "application_manager/app_service_manager.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_manager_settings.h" +#include "application_manager/command_factory.h" +#include "application_manager/command_holder.h" +#include "application_manager/event_engine/event_dispatcher_impl.h" #include "application_manager/hmi_capabilities.h" +#include "application_manager/hmi_interfaces_impl.h" #include "application_manager/message.h" #include "application_manager/message_helper.h" #include "application_manager/request_controller.h" #include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/state_controller_impl.h" -#include "application_manager/app_launch/app_launch_data.h" -#include "application_manager/application_manager_settings.h" -#include "application_manager/event_engine/event_dispatcher_impl.h" -#include "application_manager/hmi_interfaces_impl.h" -#include "application_manager/command_holder.h" -#include "application_manager/command_factory.h" +#include "application_manager/rpc_handler.h" #include "application_manager/rpc_service.h" +#include "application_manager/state_controller_impl.h" + #include "application_manager/rpc_handler.h" -#include "protocol_handler/protocol_observer.h" -#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" #include "connection_handler/device.h" #include "formatters/CSmartFactory.h" +#include "hmi_message_handler/hmi_message_observer.h" +#include "hmi_message_handler/hmi_message_sender.h" #include "policies/policy_handler.h" +#include "protocol_handler/protocol_handler.h" +#include "protocol_handler/protocol_observer.h" +#include "protocol_handler/service_status_update_handler_listener.h" #include "interfaces/HMI_API.h" #include "interfaces/HMI_API_schema.h" @@ -88,14 +91,14 @@ #include "utils/macro.h" +#include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" +#include "utils/lock.h" #include "utils/message_queue.h" #include "utils/prioritized_queue.h" -#include "utils/threads/thread.h" #include "utils/threads/message_loop_thread.h" -#include "utils/lock.h" -#include "utils/data_accessor.h" +#include "utils/threads/thread.h" #include "utils/timer.h" -#include "smart_objects/smart_object.h" struct BsonObject; @@ -132,16 +135,17 @@ typedef std::shared_ptr<timer::Timer> TimerSPtr; class ApplicationManagerImpl : public ApplicationManager, public connection_handler::ConnectionHandlerObserver, - public policy::PolicyHandlerObserver + public policy::PolicyHandlerObserver, + public protocol_handler::ServiceStatusUpdateHandlerListener #ifdef ENABLE_SECURITY - , + , public security_manager::SecurityManagerListener #endif // ENABLE_SECURITY #ifdef TELEMETRY_MONITOR - , + , public telemetry_monitor::TelemetryObservable<AMTelemetryObserver> #endif // TELEMETRY_MONITOR - { +{ friend class ResumeCtrl; friend class CommandImpl; @@ -166,6 +170,7 @@ class ApplicationManagerImpl DataAccessor<ApplicationSet> applications() const OVERRIDE; DataAccessor<AppsWaitRegistrationSet> pending_applications() const OVERRIDE; + DataAccessor<ReregisterWaitList> reregister_applications() const OVERRIDE; ApplicationSharedPtr application(uint32_t app_id) const OVERRIDE; ApplicationSharedPtr active_application() const OVERRIDE; @@ -178,6 +183,8 @@ class ApplicationManagerImpl const std::string& app_name) const OVERRIDE; ApplicationSharedPtr pending_application_by_policy_id( const std::string& policy_app_id) const OVERRIDE; + ApplicationSharedPtr reregister_application_by_policy_id( + const std::string& policy_app_id) const OVERRIDE; std::vector<ApplicationSharedPtr> applications_by_button( uint32_t button) OVERRIDE; @@ -203,9 +210,6 @@ class ApplicationManagerImpl mobile_apis::HMILevel::eType from, mobile_apis::HMILevel::eType to) OVERRIDE; - void SendHMIStatusNotification( - const std::shared_ptr<Application> app) OVERRIDE; - void SendDriverDistractionState(ApplicationSharedPtr application); void SendGetIconUrlNotifications(const uint32_t connection_key, @@ -288,8 +292,7 @@ class ApplicationManagerImpl * @param vehicle_info Enum value of type of vehicle data * @param new value (for integer values currently) of vehicle data */ - void IviInfoUpdated(mobile_apis::VehicleDataType::eType vehicle_info, - int value) OVERRIDE; + void IviInfoUpdated(const std::string& vehicle_info, int value) OVERRIDE; void OnApplicationRegistered(ApplicationSharedPtr app) OVERRIDE; @@ -324,8 +327,9 @@ class ApplicationManagerImpl void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE; #endif // TELEMETRY_MONITOR - ApplicationSharedPtr RegisterApplication(const std::shared_ptr< - smart_objects::SmartObject>& request_for_registration) OVERRIDE; + ApplicationSharedPtr RegisterApplication( + const std::shared_ptr<smart_objects::SmartObject>& + request_for_registration) OVERRIDE; /* * @brief Closes application by id * @@ -342,9 +346,9 @@ class ApplicationManagerImpl bool is_unexpected_disconnect = false) OVERRIDE; /** - * @brief Handle sequence for unauthorized application - * @param app_id Application id - */ + * @brief Handle sequence for unauthorized application + * @param app_id Application id + */ void OnAppUnauthorized(const uint32_t& app_id) OVERRIDE; /* @@ -475,6 +479,7 @@ class ApplicationManagerImpl /** * @brief CreateRegularState create regular HMI state for application * @param app Application + * @param window_type type of window * @param hmi_level of returned state * @param audio_state of returned state * @param system_context of returned state @@ -482,16 +487,17 @@ class ApplicationManagerImpl */ HmiStatePtr CreateRegularState( std::shared_ptr<Application> app, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::VideoStreamingState::eType video_state, - mobile_apis::SystemContext::eType system_context) const OVERRIDE; + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, + const mobile_apis::SystemContext::eType system_context) const OVERRIDE; /** * @brief Checks, if given RPC is allowed at current HMI level for specific * application in policy table * @param app Application - * @param hmi_level Current HMI level of application + * @param window_id id of application's window * @param function_id FunctionID of RPC * @param params_permissions Permissions for RPC parameters (e.g. * SubscribeVehicleData) defined in policy table @@ -499,6 +505,7 @@ class ApplicationManagerImpl */ mobile_apis::Result::eType CheckPolicyPermissions( const ApplicationSharedPtr app, + const WindowID window_id, const std::string& function_id, const RPCParams& rpc_params, CommandParametersPermissions* params_permissions = NULL) OVERRIDE; @@ -516,32 +523,6 @@ class ApplicationManagerImpl bool IsApplicationForbidden(uint32_t connection_key, const std::string& mobile_app_id); - struct ApplicationsAppIdSorter { - bool operator()(const ApplicationSharedPtr lhs, - const ApplicationSharedPtr rhs) { - return lhs->app_id() < rhs->app_id(); - } - }; - - struct ApplicationsMobileAppIdSorter { - bool operator()(const ApplicationSharedPtr lhs, - const ApplicationSharedPtr rhs) { - if (lhs->policy_app_id() == rhs->policy_app_id()) { - return lhs->device() < rhs->device(); - } - return lhs->policy_app_id() < rhs->policy_app_id(); - } - }; - - // typedef for Applications list - typedef std::set<ApplicationSharedPtr, ApplicationsAppIdSorter> ApplictionSet; - - // typedef for Applications list iterator - typedef ApplictionSet::iterator ApplictionSetIt; - - // typedef for Applications list const iterator - typedef ApplictionSet::const_iterator ApplictionSetConstIt; - /** * @brief Notification from PolicyHandler about PTU. * Compares AppHMIType between saved in app and received from PTU. If they are @@ -563,6 +544,52 @@ class ApplicationManagerImpl */ void OnPTUFinished(const bool ptu_result) FINAL; +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) + /** + * @brief OnCertDecryptFailed is called when certificate decryption fails in + * external flow + * @return since this callback is a part of SecurityManagerListener, bool + * return value is used to indicate whether listener instance can be deleted + * by calling entity. if true - listener can be deleted and removed from + * listeners by SecurityManager, false - listener retains its place within + * SecurityManager. + */ + bool OnCertDecryptFailed() FINAL; + + /** + * @brief OnCertDecryptFinished is called when certificate decryption is + * finished in the external flow + * @param decrypt_result bool value indicating whether decryption was + * successful + */ + void OnCertDecryptFinished(const bool decrypt_result) FINAL; +#endif + + /** + * @brief OnPTUTimeoutExceeded is called on policy table update timed out + */ + void OnPTUTimeoutExceeded() FINAL; + + /** + *@brief ProcessServiceStatusUpdate callback that is invoked in case of + *service status update + *@param connection_key - connection key + *@param service_type enum value containing type of service. + *@param service_event enum value containing event that occured during service + *start. + *@param service_update_reason enum value containing reason why service_event + *occured. + **/ + void ProcessServiceStatusUpdate( + const uint32_t connection_key, + hmi_apis::Common_ServiceType::eType service_type, + hmi_apis::Common_ServiceEvent::eType service_event, + utils::Optional<hmi_apis::Common_ServiceStatusUpdateReason::eType> + service_update_reason) FINAL; + +#ifdef ENABLE_SECURITY + bool OnPTUFailed() FINAL; +#endif // ENABLE_SECURITY /* * @brief Starts audio pass thru thread * @@ -682,7 +709,7 @@ class ApplicationManagerImpl * @brief Notification about handshake failure * @return true on success notification handling or false otherwise */ - bool OnHandshakeFailed() OVERRIDE; + bool OnGetSystemTimeFailed() OVERRIDE; /** * @brief Notification that certificate update is required. @@ -827,9 +854,9 @@ class ApplicationManagerImpl ApplicationConstSharedPtr application) const; /** - * Getter for resume_controller - * @return Resume Controller - */ + * Getter for resume_controller + * @return Resume Controller + */ resumption::ResumeCtrl& resume_controller() OVERRIDE { return *resume_ctrl_.get(); } @@ -998,8 +1025,7 @@ class ApplicationManagerImpl AppV4DevicePredicate(const connection_handler::DeviceHandle handle) : handle_(handle) {} bool operator()(const ApplicationSharedPtr app) const { - return app - ? handle_ == app->device() && + return app ? handle_ == app->device() && Message::is_sufficient_version( protocol_handler::MajorProtocolVersion:: PROTOCOL_VERSION_4, @@ -1065,24 +1091,26 @@ class ApplicationManagerImpl * @brief IsAppInReconnectMode check if application belongs to session * affected by transport switching at the moment by checking internal * waiting list prepared on switching start + * @param device_id device identifier * @param policy_app_id Application id * @return True if application is in the waiting list, otherwise - false */ - bool IsAppInReconnectMode(const std::string& policy_app_id) const FINAL; + bool IsAppInReconnectMode(const connection_handler::DeviceHandle& device_id, + const std::string& policy_app_id) const FINAL; bool IsStopping() const OVERRIDE { return is_stopping_; } /** - * @brief ProcessReconnection handles reconnection flow for application on - * transport switch - * @param application Pointer to switched application, must be validated - * before passing - * @param connection_key Connection key from registration request of - * switched - * application - */ + * @brief ProcessReconnection handles reconnection flow for application on + * transport switch + * @param application Pointer to switched application, must be validated + * before passing + * @param connection_key Connection key from registration request of + * switched + * application + */ void ProcessReconnection(ApplicationSharedPtr application, const uint32_t connection_key) FINAL; @@ -1110,6 +1138,14 @@ class ApplicationManagerImpl private: /** + * @brief Removes service status record for service that failed to start + * @param app Application whose service status record should be removed + * @param Service type which status record should be removed + */ + bool HandleRejectedServiceStatus( + ApplicationSharedPtr app, + const hmi_apis::Common_ServiceType::eType service_type); + /** * @brief PullLanguagesInfo allows to pull information about languages. * * @param app_data entry to parse @@ -1411,12 +1447,14 @@ class ApplicationManagerImpl ApplicationSet applications_; AppsWaitRegistrationSet apps_to_register_; ForbiddenApps forbidden_applications; + ReregisterWaitList reregister_wait_list_; // Lock for applications list mutable std::shared_ptr<sync_primitives::RecursiveLock> applications_list_lock_ptr_; mutable std::shared_ptr<sync_primitives::Lock> apps_to_register_list_lock_ptr_; + mutable std::shared_ptr<sync_primitives::Lock> reregister_wait_list_lock_ptr_; mutable sync_primitives::Lock subscribed_way_points_apps_lock_; /** @@ -1452,8 +1490,8 @@ class ApplicationManagerImpl connection_handler::ConnectionHandler* connection_handler_; std::unique_ptr<policy::PolicyHandlerInterface> policy_handler_; protocol_handler::ProtocolHandler* protocol_handler_; - request_controller::RequestController request_ctrl_; std::unique_ptr<plugin_manager::RPCPluginManager> plugin_manager_; + request_controller::RequestController request_ctrl_; std::unique_ptr<application_manager::AppServiceManager> app_service_manager_; /** @@ -1508,15 +1546,6 @@ class ApplicationManagerImpl std::unique_ptr<app_launch::AppLaunchData> app_launch_dto_; std::unique_ptr<app_launch::AppLaunchCtrl> app_launch_ctrl_; - /** - * @brief ReregisterWaitList is list of applications expected to be - * re-registered after transport switching is complete - */ - typedef std::vector<ApplicationSharedPtr> ReregisterWaitList; - ReregisterWaitList reregister_wait_list_; - - mutable sync_primitives::Lock reregister_wait_list_lock_; - // This is a cache to remember DeviceHandle of secondary transports. Only used // during RegisterApplication(). typedef std::map<int32_t, connection_handler::DeviceHandle> DeviceMap; diff --git a/src/components/application_manager/include/application_manager/application_state.h b/src/components/application_manager/include/application_manager/application_state.h index bf894eaf94..8c4d2d49d6 100644 --- a/src/components/application_manager/include/application_manager/application_state.h +++ b/src/components/application_manager/include/application_manager/application_state.h @@ -32,14 +32,21 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_STATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_STATE_H_ + +#include <map> #include <vector> + +#include "application_manager/hmi_state.h" #include "utils/lock.h" #include "utils/macro.h" -#include "application_manager/hmi_state.h" namespace application_manager { +typedef std::vector<WindowID> WindowIds; typedef std::vector<HmiStatePtr> HmiStates; +typedef std::map<WindowID, HmiStates> HmiStatesMap; +typedef std::vector<std::string> WindowNames; +typedef std::map<WindowID, std::string> WindowNamesMap; /* * Class represents application state, i.e. current HMI level, audio streaming @@ -63,97 +70,140 @@ class ApplicationState { /** * @brief Init state + * @param window_id window id for HMI state + * @param window_name name of inited window * @param state Initial state */ - void InitState(HmiStatePtr state); + void InitState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state); /** * @brief Adds state to states storage + * @param window_id window id for HMI state * @param state State of application */ - void AddState(HmiStatePtr state); + void AddState(const WindowID window_id, HmiStatePtr state); /** * @brief Removes state from states storage + * @param window_id window id for HMI state * @param state State of application */ - void RemoveState(HmiState::StateID state); + void RemoveState(const WindowID window_id, HmiState::StateID state); /** * @brief Gets state by state id + * @param window_id window id for HMI state * @param state_id State id * @return Pointer to application state */ - HmiStatePtr GetState(HmiState::StateID state_id) const; + HmiStatePtr GetState(const WindowID window_id, + HmiState::StateID state_id) const; + + /** + * @brief Gets the list of all states matches provided state id + * @param state_id state id to get + * @return list of all states matches provided state id + */ + HmiStates GetStates(const HmiState::StateID state_id) const; + + /** + * @brief Getter for a list of available application windows including the + * main + * @return list of available window ids + */ + WindowIds GetWindowIds() const; + + /** + * @brief Getter f0r a list of all existing window names + * @return list of available window names + */ + WindowNames GetWindowNames() const; private: /** * @brief AddHMIState the function that will change application's * hmi state. * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state * * @param state new hmi state for certain application. */ - void AddHMIState(HmiStatePtr state); + void AddHMIState(const WindowID window_id, HmiStatePtr state); /** * @brief RemoveHMIState the function that will turn back hmi_level after end * of some event * - * @param app_id id of the application whose hmi level should be changed. + * @param window_id window id for HMI state. * * @param state_id that should be removed */ - void RemoveHMIState(HmiState::StateID state_id); + void RemoveHMIState(const WindowID window_id, HmiState::StateID state_id); + + /** + * @brief RemoveWindowHMIStates removes all HMI states related to specified + * window + * @param window_id window ID to remove + */ + void RemoveWindowHMIStates(const WindowID window_id); /** * @brief Removes postponed state + * @param window_id window id for HMI state */ - void RemovePostponedState(); + void RemovePostponedState(const WindowID window_id); /** * @brief Sets regular state of application + * @param window_id window id for HMI state * @param state State of application */ - void SetRegularState(HmiStatePtr state); + void SetRegularState(const WindowID window_id, HmiStatePtr state); /** - * @brief Sets postponed state of application. - * This state could be set as regular later on - * - * @param state state to setup - */ - void SetPostponedState(HmiStatePtr state); + * @brief Sets postponed state of application. + * This state could be set as regular later on + * @param window_id window id for HMI state + * @param state state to setup + */ + void SetPostponedState(const WindowID window_id, HmiStatePtr state); /** * @brief HmiState of application within active events PhoneCall, TTS< etc ... + * @param window_id window id for HMI state * @return Active HmiState of application */ - HmiStatePtr CurrentHmiState() const; + HmiStatePtr CurrentHmiState(const WindowID window_id) const; /** * @brief RegularHmiState of application without active events VR, TTS etc ... + * @param window_id window id for HMI state * @return HmiState of application */ - HmiStatePtr RegularHmiState() const; + HmiStatePtr RegularHmiState(const WindowID window_id) const; /** * @brief PostponedHmiState returns postponed hmi state of application * if it's present - * + * @param window_id window id for HMI state * @return Postponed hmi state of application */ - HmiStatePtr PostponedHmiState() const; + HmiStatePtr PostponedHmiState(const WindowID window_id) const; /** * @brief Active states of application */ - HmiStates hmi_states_; - mutable sync_primitives::Lock hmi_states_lock_; + HmiStatesMap hmi_states_map_; + + /** + * @brief hmi_states_map_lock_ + */ + mutable sync_primitives::Lock hmi_states_map_lock_; DISALLOW_COPY_AND_ASSIGN(ApplicationState); }; -} +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_STATE_H_ diff --git a/src/components/application_manager/include/application_manager/command_factory.h b/src/components/application_manager/include/application_manager/command_factory.h index 7dc8a0cfc1..f479ee7f37 100644 --- a/src/components/application_manager/include/application_manager/command_factory.h +++ b/src/components/application_manager/include/application_manager/command_factory.h @@ -33,10 +33,11 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMAND_FACTORY_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMAND_FACTORY_H -#include "application_manager/commands/command.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" +#include "application_manager/commands/command.h" +#include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" #include "utils/macro.h" namespace application_manager { @@ -63,10 +64,10 @@ class CommandFactory { const commands::MessageSharedPtr& message, commands::Command::CommandSource source) = 0; /** - * @param int32_t command id - * @param CommandSource source - * @return return true if command can be create, else return false - **/ + * @param int32_t command id + * @param CommandSource source + * @return return true if command can be create, else return false + **/ virtual bool IsAbleToProcess( const int32_t, const application_manager::commands::Command::CommandSource source) diff --git a/src/components/application_manager/include/application_manager/command_holder.h b/src/components/application_manager/include/application_manager/command_holder.h index 8cfe5f0889..3f5f657a0e 100644 --- a/src/components/application_manager/include/application_manager/command_holder.h +++ b/src/components/application_manager/include/application_manager/command_holder.h @@ -35,6 +35,7 @@ #include <string> #include "application_manager/application.h" +#include "application_manager/commands/command.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -59,10 +60,12 @@ class CommandHolder { * internally * @param application Application pointer * @param type Command type + * @param source The source of suspended command * @param command Command */ virtual void Suspend(ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, smart_objects::SmartObjectSPtr command) = 0; /** diff --git a/src/components/application_manager/include/application_manager/command_holder_impl.h b/src/components/application_manager/include/application_manager/command_holder_impl.h index 18a1de7526..530aae47d2 100644 --- a/src/components/application_manager/include/application_manager/command_holder_impl.h +++ b/src/components/application_manager/include/application_manager/command_holder_impl.h @@ -35,9 +35,9 @@ #include "application_manager/command_holder.h" +#include <map> #include <string> #include <vector> -#include <map> #include "application_manager/application.h" #include "application_manager/rpc_service.h" #include "smart_objects/smart_object.h" @@ -64,10 +64,12 @@ class CommandHolderImpl : public CommandHolder { * @brief Suspend collects command for specific application id internally * @param application Application pointer * @param type Command type + * @param source The source of suspended command * @param command Command */ void Suspend(ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, smart_objects::SmartObjectSPtr command) FINAL; /** @@ -97,9 +99,17 @@ class CommandHolderImpl : public CommandHolder { */ void ResumeMobileCommand(ApplicationSharedPtr application); + /** + * @brief Descriptor of each suspended command containing all necessary + * command info + */ + struct AppCommandInfo { + std::shared_ptr<smart_objects::SmartObject> command_ptr_; + commands::Command::CommandSource command_source_; + }; + using AppCommands = - std::map<ApplicationSharedPtr, - std::vector<std::shared_ptr<smart_objects::SmartObject> > >; + std::map<ApplicationSharedPtr, std::vector<AppCommandInfo> >; ApplicationManager& app_manager_; sync_primitives::Lock commands_lock_; diff --git a/src/components/application_manager/include/application_manager/commands/command.h b/src/components/application_manager/include/application_manager/commands/command.h index d832995b8d..0536c7aee1 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_H_ #include <stdint.h> +#include "application_manager/hmi_state.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -93,6 +94,11 @@ class Command { virtual int32_t function_id() const = 0; /* + * @brief Retrieves Window ID + */ + virtual WindowID window_id() const = 0; + + /* * @brief Function is called by RequestController when request execution time * has exceed it's limit * @@ -100,16 +106,16 @@ class Command { virtual void onTimeOut() = 0; /** - * @brief AllowedToTerminate tells if request controller is allowed - * to terminate this command - * @return - */ + * @brief AllowedToTerminate tells if request controller is allowed + * to terminate this command + * @return + */ virtual bool AllowedToTerminate() = 0; /** - * @brief SetAllowedToTerminate set up allowed to terminate flag. - * If true, request controller will terminate request on response - */ + * @brief SetAllowedToTerminate set up allowed to terminate flag. + * If true, request controller will terminate request on response + */ virtual void SetAllowedToTerminate(const bool allowed) = 0; enum CommandSource { diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h index dd1592c4aa..a526fede6e 100644 --- a/src/components/application_manager/include/application_manager/commands/command_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_impl.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_IMPL_H_ +#include "application_manager/application_manager.h" #include "application_manager/commands/command.h" #include "application_manager/event_engine/event_observer.h" -#include "application_manager/application_manager.h" #include "application_manager/smart_object_keys.h" #include "policy/policy_types.h" #include "utils/logger.h" @@ -118,6 +118,11 @@ class CommandImpl : public Command { int32_t function_id() const OVERRIDE; /* + * @brief Retrieves Window ID + */ + WindowID window_id() const OVERRIDE; + + /* * @brief Function is called by RequestController when request execution time * has exceed it's limit * @@ -125,18 +130,19 @@ class CommandImpl : public Command { void onTimeOut() OVERRIDE; /** - * @brief AllowedToTerminate tells request Controller if it can terminate this - * request by response. - * By default, RequestCtrl should terminate all requests by their responses. - * If request need to terminate itself, it should override this function false - * @return allowed_to_terminate_ value - */ + * @brief AllowedToTerminate tells request Controller if it can terminate this + * request by response. + * By default, RequestCtrl should terminate all requests by their responses. + * If request need to terminate itself, it should override this function + * false + * @return allowed_to_terminate_ value + */ bool AllowedToTerminate() OVERRIDE; /** - * @brief SetAllowedToTerminate set up allowed to terminate flag. - * If true, request controller will terminate request on response - */ + * @brief SetAllowedToTerminate set up allowed to terminate flag. + * If true, request controller will terminate request on response + */ void SetAllowedToTerminate(const bool allowed) OVERRIDE; // members 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 e12c6de3ab..293366f91a 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 @@ -34,10 +34,10 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_IMPL_H_ #include "application_manager/commands/command_impl.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" -#include "utils/lock.h" +#include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" +#include "utils/lock.h" namespace application_manager { namespace commands { @@ -214,6 +214,24 @@ class CommandRequestImpl : public CommandImpl, mobile_apis::Result::eType GetMobileResultCode( const hmi_apis::Common_Result::eType& hmi_code) const; + /** + * @brief Checks Mobile result code for single RPC + * @param result_code contains result code from response to Mobile + * @return true if result code complies to successful result codes, + * false otherwise. + */ + static bool IsMobileResultSuccess( + const mobile_apis::Result::eType result_code); + + /** + * @brief Checks HMI result code for single RPC + * @param result_code contains result code from HMI response + * @return true if result code complies to successful result codes, + * false otherwise. + */ + static bool IsHMIResultSuccess( + const hmi_apis::Common_Result::eType result_code); + protected: /** * @brief Checks message permissions and parameters according to policy table @@ -249,14 +267,6 @@ class CommandRequestImpl : public CommandImpl, bool HasDisallowedParams() const; /** - * @brief Checks result code from Mobile for single RPC - * @param result_code contains result code from Mobile response - * @return true if result code complies successful result codes, - * false otherwise. - */ - bool IsMobileResultSuccess(mobile_apis::Result::eType result_code) const; - - /** * @brief Checks result code from HMI for single RPC * and returns parameter for sending to mobile app. * @param result_code contains result code from HMI response @@ -317,6 +327,16 @@ class CommandRequestImpl : public CommandImpl, bool IsResultCodeUnsupported(const ResponseInfo& first, const ResponseInfo& second) const; + /** + * @brief CheckResult checks whether the overall result + * of the responses is successful + * @param first response + * @param second response + * @return true if the overall result is successful + * otherwise - false + */ + bool CheckResult(const ResponseInfo& first, const ResponseInfo& second) const; + protected: /** * @brief Returns policy parameters permissions @@ -335,7 +355,7 @@ class CommandRequestImpl : public CommandImpl, * @param interface_id interface which SDL awaits for response in given time * @return true if SDL awaits for response from given interface in * interface_id - */ + */ bool IsInterfaceAwaited(const HmiInterfaces::InterfaceID& interface_id) const; /** @@ -346,7 +366,7 @@ class CommandRequestImpl : public CommandImpl, void EndAwaitForInterface(const HmiInterfaces::InterfaceID& interface_id); /** - * @brief This set stores all the interfaces which are awaited by SDL to + * @brief This set stores all the interfaces which are awaited by SDL to * return a response on some request */ std::set<HmiInterfaces::InterfaceID> awaiting_response_interfaces_; @@ -387,10 +407,10 @@ class CommandRequestImpl : public CommandImpl, 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 - */ + * @brief UpdateHash updates hash field for application and sends + * OnHashChanged notification to mobile side in case of approriate hash mode + * is set + */ void UpdateHash(); /** diff --git a/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h index a1e63561bf..430e549523 100644 --- a/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h +++ b/src/components/application_manager/include/application_manager/commands/command_request_to_mobile.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_REQUEST_TO_MOBILE_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" diff --git a/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h index 65983d82f8..1401888890 100644 --- a/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h +++ b/src/components/application_manager/include/application_manager/commands/command_response_from_mobile.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_RESPONSE_TO_MOBILE_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" diff --git a/src/components/application_manager/include/application_manager/commands/pending.h b/src/components/application_manager/include/application_manager/commands/pending.h index bbfc246659..9083d81d73 100644 --- a/src/components/application_manager/include/application_manager/commands/pending.h +++ b/src/components/application_manager/include/application_manager/commands/pending.h @@ -35,9 +35,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_PENDING_H_ #include <set> -#include "utils/macro.h" -#include "utils/lock.h" #include "interfaces/HMI_API.h" +#include "utils/lock.h" +#include "utils/macro.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/commands/request_to_hmi.h b/src/components/application_manager/include/application_manager/commands/request_to_hmi.h index 91586a74ce..e8850fbe8d 100644 --- a/src/components/application_manager/include/application_manager/commands/request_to_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/request_to_hmi.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_REQUEST_TO_HMI_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_REQUEST_TO_HMI_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/commands/response_from_hmi.h b/src/components/application_manager/include/application_manager/commands/response_from_hmi.h index 605d04067e..6c00957d3f 100644 --- a/src/components/application_manager/include/application_manager/commands/response_from_hmi.h +++ b/src/components/application_manager/include/application_manager/commands/response_from_hmi.h @@ -1,40 +1,40 @@ /* -* Copyright (c) 2018, Ford Motor Company -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following -* disclaimer in the documentation and/or other materials provided with the -* distribution. -* -* Neither the name of the Ford Motor Company nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_RESPONSE_FROM_HMI_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_RESPONSE_FROM_HMI_H_ -#include "application_manager/commands/command_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_impl.h" #include "interfaces/HMI_API.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/display_capabilities_builder.h b/src/components/application_manager/include/application_manager/display_capabilities_builder.h new file mode 100644 index 0000000000..529c9a32c1 --- /dev/null +++ b/src/components/application_manager/include/application_manager/display_capabilities_builder.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DISPLAY_CAPABILITIES_BUILDER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DISPLAY_CAPABILITIES_BUILDER_H_ +#include "application_manager/application.h" + +namespace application_manager { +/** + * @brief DisplayCapabilitiesBuilder utility class used for building cached + * notification, which is sent to mobile on resumption finish + */ +class DisplayCapabilitiesBuilder { + typedef std::function<void(Application&, const smart_objects::SmartObject)> + ResumeCallback; + + public: + /** + * @brief DisplayCapabilitiesBuilder class constructor + * @param Application reference to application owner + */ + DisplayCapabilitiesBuilder(Application& application); + + /** + * @brief InitBuilder initialize builder with callback and windows to be + * restored + * @param resume_callback callback to be called when notifications for all + * windows have been received + * @param windows_info SO containing data of windows to be restored + */ + void InitBuilder(ResumeCallback resume_callback, + const smart_objects::SmartObject& windows_info); + + /** + * @brief UpdateDisplayCapabilities update cached notification + * @param display_capabilities to update cached notification with + */ + void UpdateDisplayCapabilities( + const smart_objects::SmartObject& display_capabilities); + + /** + * @brief ResetDisplayCapabilities resets stored notification + */ + void ResetDisplayCapabilities(); + + /** + * @brief StopWaitingForWindow stop waiting for window resumption by removing + * window_id from windows pending resumption + * @param window_id window id to be removed + */ + void StopWaitingForWindow(const WindowID window_id); + + /** + * @brief retreives stored notification data + */ + const smart_objects::SmartObjectSPtr display_capabilities() const; + + private: + smart_objects::SmartObjectSPtr display_capabilities_; + typedef std::set<WindowID> WindowIDsToResume; + WindowIDsToResume window_ids_to_resume_; + Application& owner_; + ResumeCallback resume_callback_; + sync_primitives::Lock display_capabilities_lock_; +}; +} // namespace application_manager +#endif diff --git a/src/components/application_manager/include/application_manager/event_engine/event.h b/src/components/application_manager/include/application_manager/event_engine/event.h index 14595cd293..e7382e01a4 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event.h +++ b/src/components/application_manager/include/application_manager/event_engine/event.h @@ -36,8 +36,8 @@ #include <interfaces/HMI_API.h> #include <interfaces/MOBILE_API.h> -#include "smart_objects/smart_object.h" #include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace application_manager { namespace event_engine { diff --git a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h index 75e77e603c..3644299499 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_dispatcher_impl.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_ENGINE_EVENT_DISPATCHER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_EVENT_ENGINE_EVENT_DISPATCHER_IMPL_H_ -#include <vector> #include <map> +#include <vector> #include "utils/lock.h" diff --git a/src/components/application_manager/include/application_manager/event_engine/event_observer.h b/src/components/application_manager/include/application_manager/event_engine/event_observer.h index 7a7fe7c2ec..1f4eccaf46 100644 --- a/src/components/application_manager/include/application_manager/event_engine/event_observer.h +++ b/src/components/application_manager/include/application_manager/event_engine/event_observer.h @@ -96,12 +96,6 @@ class EventObserver { * @brief Unsubscribes the observer from all events * */ - DEPRECATED void unsubscribe_from_all_events(); - - /* - * @brief Unsubscribes the observer from all events - * - */ void unsubscribe_from_all_hmi_events(); // Mobile Events diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager.h b/src/components/application_manager/include/application_manager/help_prompt_manager.h index a0c34e77d7..eb45705d9f 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager.h @@ -28,7 +28,7 @@ * 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_HELP_PROMPT_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_H_ diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h index 81754a60b0..3cd22a6afc 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h @@ -28,7 +28,7 @@ * 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_HELP_PROMPT_MANAGER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HELP_PROMPT_MANAGER_IMPL_H_ @@ -56,7 +56,7 @@ class HelpPromptManagerImpl : public HelpPromptManager { public: /** * @brief Container for buffering VR help commands - */ + */ typedef std::pair<uint32_t, smart_objects::SmartObjectSPtr> VRCommandPair; typedef std::vector<VRCommandPair> VRCommandPairs; @@ -94,12 +94,12 @@ class HelpPromptManagerImpl : public HelpPromptManager { const bool is_resumption) OVERRIDE; /** - * @brief Stop constructing vrHelp and/or helpPrompt if they are present in - * message - * @param msg containing GlobalProperties - * @param is_response determines is the request or response for the for - * the SetGlobalPropertiesRequest - */ + * @brief Stop constructing vrHelp and/or helpPrompt if they are present in + * message + * @param msg containing GlobalProperties + * @param is_response determines is the request or response for the for + * the SetGlobalPropertiesRequest + */ void OnSetGlobalPropertiesReceived(const smart_objects::SmartObject& msg, const bool is_response) OVERRIDE; diff --git a/src/components/application_manager/include/application_manager/helpers/application_helper.h b/src/components/application_manager/include/application_manager/helpers/application_helper.h index 18267c9e7f..a7933c2451 100644 --- a/src/components/application_manager/include/application_manager/helpers/application_helper.h +++ b/src/components/application_manager/include/application_manager/helpers/application_helper.h @@ -69,6 +69,19 @@ ApplicationSharedPtr FindPendingApp( return app; } +template <class UnaryPredicate> +ApplicationSharedPtr FindReregisterApp( + DataAccessor<ReregisterWaitList> accessor, UnaryPredicate finder) { + ReregisterWaitList::const_iterator begin = accessor.GetData().begin(); + ReregisterWaitList::const_iterator end = accessor.GetData().end(); + ReregisterWaitList::const_iterator it = std::find_if(begin, end, finder); + if (accessor.GetData().end() == it) { + return ApplicationSharedPtr(); + } + ApplicationSharedPtr app = *it; + return app; +} + /** * Helper function for lookup through applications list and returning all * applications satisfying predicate logic 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 9380fb41ac..b4610f0375 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 @@ -28,18 +28,18 @@ * 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_HMI_CAPABILITIES_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_CAPABILITIES_IMPL_H_ #include "application_manager/hmi_capabilities.h" +#include "application_manager/hmi_language_handler.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "json/json.h" -#include "utils/macro.h" -#include "application_manager/hmi_language_handler.h" #include "smart_objects/smart_object.h" +#include "utils/macro.h" namespace resumption { class LastState; @@ -230,6 +230,20 @@ class HMICapabilitiesImpl : public HMICapabilities { const smart_objects::SmartObject& display_capabilities) OVERRIDE; /* + * @brief Retrieves information about the display capability + * @return Currently supported display capability + */ + const smart_objects::SmartObjectSPtr system_display_capabilities() + const OVERRIDE; + + /* + * @brief Sets supported display capability + * @param display_capabilities supported display capability + */ + void set_system_display_capabilities( + const smart_objects::SmartObject& display_capabilities); + + /* * @brief Retrieves information about the HMI zone capabilities * * @return Currently supported HMI zone capabilities @@ -493,6 +507,11 @@ class HMICapabilitiesImpl : public HMICapabilities { const smart_objects::SmartObject* rc_capability() const OVERRIDE; + void set_seat_location_capability( + const smart_objects::SmartObject& seat_location_capability) OVERRIDE; + + const smart_objects::SmartObject* seat_location_capability() const OVERRIDE; + void Init(resumption::LastState* last_state) OVERRIDE; /* @@ -542,6 +561,18 @@ class HMICapabilitiesImpl : public HMICapabilities { const Json::Value& json_languages, smart_objects::SmartObject& languages) const OVERRIDE; + /* + * @brief function that converts a single entry of audio pass thru capability + * to smart object + * + * @param capability json object that represents a single entry of audio pass + * thru capability + * @param output_so the converted object + */ + void convert_audio_capability_to_obj( + const Json::Value& capability, + smart_objects::SmartObject& output_so) const OVERRIDE; + private: bool is_vr_cooperating_; bool is_tts_cooperating_; @@ -558,7 +589,13 @@ class HMICapabilitiesImpl : public HMICapabilities { smart_objects::SmartObject* ui_supported_languages_; smart_objects::SmartObject* tts_supported_languages_; smart_objects::SmartObject* vr_supported_languages_; + /* + * display_capabilities_ is deprecated and replaced by + * system_display_capabilities_. For backward compatibility + * display_capabilities_ is not removed. + */ smart_objects::SmartObject* display_capabilities_; + smart_objects::SmartObjectSPtr system_display_capabilities_; smart_objects::SmartObject* hmi_zone_capabilities_; smart_objects::SmartObject* soft_buttons_capabilities_; smart_objects::SmartObject* button_capabilities_; @@ -577,6 +614,7 @@ class HMICapabilitiesImpl : public HMICapabilities { smart_objects::SmartObject* phone_capability_; smart_objects::SmartObject* video_streaming_capability_; smart_objects::SmartObject* rc_capability_; + smart_objects::SmartObject* seat_location_capability_; ApplicationManager& app_mngr_; HMILanguageHandler hmi_language_handler_; diff --git a/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h b/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h index 2b2d1e1361..3202d44e1e 100644 --- a/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h +++ b/src/components/application_manager/include/application_manager/hmi_interfaces_impl.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_INTERFACES_IMPL_H_ #include <map> #include "application_manager/hmi_interfaces.h" -#include "utils/macro.h" #include "utils/lock.h" +#include "utils/macro.h" /** * @brief The HmiInterfacesImpl class handles * hmi interfaces states diff --git a/src/components/application_manager/include/application_manager/hmi_language_handler.h b/src/components/application_manager/include/application_manager/hmi_language_handler.h index 6158cb4585..edf0759114 100644 --- a/src/components/application_manager/include/application_manager/hmi_language_handler.h +++ b/src/components/application_manager/include/application_manager/hmi_language_handler.h @@ -28,15 +28,15 @@ * 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_HMI_LANGUAGE_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_LANGUAGE_HANDLER_H_ #include "application_manager/event_engine/event_observer.h" -#include "utils/lock.h" #include "interfaces/HMI_API.h" #include "smart_objects/smart_object.h" +#include "utils/lock.h" namespace resumption { class LastState; @@ -56,8 +56,8 @@ class HMILanguageHandler : public event_engine::EventObserver { typedef std::map<uint32_t, bool> Apps; /** - * @brief System interfaces - */ + * @brief System interfaces + */ enum Interface { INTERFACE_UI, INTERFACE_VR, INTERFACE_TTS }; /** 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 774376b249..5b9e201391 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -46,13 +46,14 @@ class ApplicationManager; class Application; typedef std::shared_ptr<HmiState> HmiStatePtr; +typedef int32_t WindowID; /** -* @brief The HmiState class -* Handle Hmi state of application (hmi level, -* audio streaming state, system context) -* -*/ + * @brief The HmiState class + * Handle Hmi state of application (hmi level, + * audio streaming state, system context) + * + */ class HmiState { friend std::ostream& operator<<(std::ostream& os, const HmiState& src); @@ -62,18 +63,18 @@ class HmiState { * If no events occurred STATE_ID_DEFAULT should be presented */ enum StateID { - STATE_ID_CURRENT, - STATE_ID_REGULAR, - STATE_ID_POSTPONED, - STATE_ID_PHONE_CALL, - STATE_ID_SAFETY_MODE, - STATE_ID_VR_SESSION, - STATE_ID_TTS_SESSION, - STATE_ID_VIDEO_STREAMING, - STATE_ID_NAVI_STREAMING, - STATE_ID_DEACTIVATE_HMI, - STATE_ID_AUDIO_SOURCE, - STATE_ID_EMBEDDED_NAVI + STATE_ID_CURRENT = 1, + STATE_ID_REGULAR = 2, + STATE_ID_POSTPONED = 3, + STATE_ID_PHONE_CALL = 4, + STATE_ID_SAFETY_MODE = 5, + STATE_ID_VR_SESSION = 6, + STATE_ID_TTS_SESSION = 7, + STATE_ID_VIDEO_STREAMING = 8, + STATE_ID_NAVI_STREAMING = 9, + STATE_ID_DEACTIVATE_HMI = 10, + STATE_ID_AUDIO_SOURCE = 11, + STATE_ID_EMBEDDED_NAVI = 12 }; /** @@ -206,11 +207,24 @@ class HmiState { state_id_ = state_id; } + /** + * @brief window_type getter for a window type for this type + * @return current state window type + */ + mobile_apis::WindowType::eType window_type() const; + + /** + * @brief set_window_type sets current state window type + * @param window_type new window type + */ + void set_window_type(const mobile_apis::WindowType::eType window_type); + protected: uint32_t hmi_app_id_; StateID state_id_; const ApplicationManager& app_mngr_; HmiStatePtr parent_; + mobile_apis::WindowType::eType window_type_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; mobile_apis::VideoStreamingState::eType video_streaming_state_; diff --git a/src/components/application_manager/include/application_manager/message.h b/src/components/application_manager/include/application_manager/message.h index 1c319cf204..1ce7596bf2 100644 --- a/src/components/application_manager/include/application_manager/message.h +++ b/src/components/application_manager/include/application_manager/message.h @@ -36,9 +36,9 @@ #include <string> #include <vector> +#include "protocol/common.h" #include "protocol/message_priority.h" #include "protocol/rpc_type.h" -#include "protocol/common.h" #include "smart_objects/smart_object.h" namespace application_manager { @@ -71,6 +71,12 @@ class Message { int32_t correlation_id() const; int32_t connection_key() const; + /** + * @brief retreives message's protection flag + * @return true if message is encrypted, otherwise returns false + */ + bool is_message_encrypted() const; + MessageType type() const; protocol_handler::MajorProtocolVersion protocol_version() const; @@ -95,6 +101,13 @@ class Message { void set_data_size(size_t data_size); void set_payload_size(size_t payload_size); + /** + * @brief sets message's protection flag + * @param protection - bool value, if message is encrypted - true, otherwise + * - false + */ + void set_message_encryption(const bool protection); + static bool is_sufficient_version( protocol_handler::MajorProtocolVersion minVersion, protocol_handler::MajorProtocolVersion version); @@ -122,6 +135,8 @@ class Message { size_t data_size_; size_t payload_size_; protocol_handler::MajorProtocolVersion version_; + + bool is_message_encrypted_; }; typedef std::shared_ptr<application_manager::Message> MobileMessage; 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 ac84bcfaa5..aff4659323 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -37,20 +37,21 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MESSAGE_HELPER_H_ #include <map> -#include <vector> #include <string> +#include <vector> -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" -#include "utils/macro.h" -#include "connection_handler/device.h" +#include <application_manager/smart_object_keys.h> #include "application_manager/application.h" +#include "application_manager/hmi_capabilities.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "connection_handler/device.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "policy/policy_types.h" #include "protocol_handler/session_observer.h" -#include "application_manager/policies/policy_handler_interface.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" -#include <application_manager/smart_object_keys.h> +#include "utils/macro.h" namespace policy { class PolicyHandlerInterface; @@ -73,25 +74,33 @@ typedef std::map<std::string, mobile_apis::VehicleDataType::eType> VehicleData; class MessageHelper { public: /** - * @brief CreateNotification creates basic mobile notification smart object - * @param function_id Notification function ID - * @param app_id application to send notification - * @return basic mobile notification smart object - */ + * @brief CreateNotification creates basic mobile notification smart object + * @param function_id Notification function ID + * @param app_id application to send notification + * @return basic mobile notification smart object + */ static smart_objects::SmartObjectSPtr CreateNotification( mobile_apis::FunctionID::eType function_id, uint32_t app_id); /** - * @brief CreateHMINotification creates basic hmi notification smart object - * @param function_id Notification function ID - * @return basic hmi notification smart object - */ + * @brief CreateHMINotification creates basic hmi notification smart object + * @param function_id Notification function ID + * @return basic hmi notification smart object + */ static smart_objects::SmartObjectSPtr CreateHMINotification( hmi_apis::FunctionID::eType function_id); + static smart_objects::SmartObjectSPtr CreateOnServiceUpdateNotification( + const hmi_apis::Common_ServiceType::eType type, + const hmi_apis::Common_ServiceEvent::eType event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType reason = + hmi_apis::Common_ServiceStatusUpdateReason::INVALID_ENUM, + const uint32_t app_id = 0); + /** * @brief Creates request for different interfaces(JSON) * @param correlation_id unique ID - * @param params Vector of arguments that we need in GetVehicleData request + * @param params Vector of arguments that we need in GetVehicleData + * request * (e.g. gps, odometer, fuel_level) */ static void CreateGetVehicleDataRequest( @@ -118,18 +127,18 @@ class MessageHelper { static void SendOnLanguageChangeToMobile(uint32_t connection_key); /** - * @brief Sends DecryptCertificate request to HMI - * @param file_name path to file containing encrypted certificate - */ + * @brief Sends DecryptCertificate request to HMI + * @param file_name path to file containing encrypted certificate + */ static void SendDecryptCertificateToHMI(const std::string& file_name, ApplicationManager& app_mngr); /** - * @brief SendGetSystemTimeRequest sends mentioned request to HMI. - * @param correlation_id the message correlation id, required for proper - * response processing. - * @param app_mngr - */ + * @brief SendGetSystemTimeRequest sends mentioned request to HMI. + * @param correlation_id the message correlation id, required for proper + * response processing. + * @param app_mngr + */ static void SendGetSystemTimeRequest(const uint32_t correlation_id, ApplicationManager& app_mngr); @@ -205,17 +214,17 @@ class MessageHelper { const std::string& hmi_level); /* - * @brief Used to obtain string representation of app's - * HMI Level. - * @param hmi_level Desired HMI Level - */ + * @brief Used to obtain string representation of app's + * HMI Level. + * @param hmi_level Desired HMI Level + */ static std::string StringifiedHMILevel( const mobile_apis::HMILevel::eType hmi_level); /* - * @brief Used to obtain function name by its id - * @param function_id Function ID - */ + * @brief Used to obtain function name by its id + * @param function_id Function ID + */ static std::string StringifiedFunctionID( mobile_apis::FunctionID::eType function_id); @@ -302,6 +311,30 @@ class MessageHelper { const uint32_t app_id, ApplicationManager& app_mngr); + /** + * @brief Creates UI.CreateWindow request + * @param application application instance + * @param app_mngr reference to application manager + * @param windows_info smart object containing saved windows info + * @return smart object with UI.CreateWindow request + */ + static smart_objects::SmartObjectSPtr CreateUICreateWindowRequestToHMI( + ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& window_info); + + /** + * @brief Creates UI.CreateWindow requests + * @param application application instance + * @param app_mngr reference to application manager + * @param windows_info smart object containing saved windows info + * @return list of smart objects with UI.CreateWindow requests + */ + static smart_objects::SmartObjectList CreateUICreateWindowRequestsToHMI( + application_manager::ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& windows_info); + /* * @brief Create Common.DeviceInfo struct from device handle * @param device_handle device handle of the app @@ -348,40 +381,41 @@ class MessageHelper { bool is_unexpected_disconnect, ApplicationManager& app_mngr); - static ns_smart_device_link::ns_smart_objects::SmartObjectSPtr - GetBCActivateAppRequestToHMI( + static smart_objects::SmartObjectSPtr GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr); + static smart_objects::SmartObjectSPtr GetBCCloseApplicationRequestToHMI( + ApplicationConstSharedPtr app, ApplicationManager& app_mngr); + static void SendOnResumeAudioSourceToHMI(const uint32_t app_id, ApplicationManager& app_mngr); /** - * @brief Send SDL_ActivateApp response to HMI - * @param permissions response parameters - */ + * @brief Send SDL_ActivateApp response to HMI + * @param permissions response parameters + */ static void SendSDLActivateAppResponse(policy::AppPermissions& permissions, uint32_t correlation_id, ApplicationManager& app_mngr); /** - * @brief Send OnSDLConsentNeeded to HMI for device data consent by user - * @param device_info Device info, e.g. mac, handle, name - */ + * @brief Send OnSDLConsentNeeded to HMI for device data consent by user + * @param device_info Device info, e.g. mac, handle, name + */ static void SendOnSDLConsentNeeded(const policy::DeviceParams& device_info, ApplicationManager& app_man); /** - * @brief Send request to SyncP process to read file and send - * Policy Table Snapshot using Retry Strategy - * @param file_path Path to file with PTS - * @param timeout Timeout to wait for PTU in seconds - * @param retries Seconds between retries - */ + * @brief Send request to SyncP process to read file and send + * Policy Table Snapshot using Retry Strategy + * @param file_path Path to file with PTS + * @param timeout Timeout to wait for PTU in seconds + * @param retries Seconds between retries + */ static void SendPolicyUpdate(const std::string& file_path, const uint32_t timeout, const std::vector<int>& retries, @@ -445,13 +479,13 @@ class MessageHelper { static void SendNaviStopStream(int32_t app_id, ApplicationManager& app_mngr); /* - * @brief Send notification for Update of Policy Table - * with PT Snapshot. - * @param connection_key Id of application to send message to - * @param policy_data PT Snapshot - * @param url If empty string, no URL is provided - * @param timeout If -1 no timeout is provdied - */ + * @brief Send notification for Update of Policy Table + * with PT Snapshot. + * @param connection_key Id of application to send message to + * @param policy_data PT Snapshot + * @param url If empty string, no URL is provided + * @param timeout If -1 no timeout is provdied + */ static void SendPolicySnapshotNotification( uint32_t connection_key, const std::vector<uint8_t>& policy_data, @@ -485,20 +519,23 @@ class MessageHelper { ApplicationManager& app_man); /* - * @brief Send notification to mobile on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - */ + * @brief Send notification to mobile on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + * @param app_mngr reference to application manager + * @param require_encryption require encryption flag + */ static void SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr); + ApplicationManager& app_mngr, + const policy::EncryptionRequired encryprion_required); /* - * @brief Send notification to HMI on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - */ + * @brief Send notification to HMI on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + */ static void SendOnAppPermissionsChangedNotification( uint32_t connection_key, const policy::AppPermissions& permissions, @@ -610,12 +647,12 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Verify image and add image file full path - * and add path, although the image doesn't exist - * @param SmartObject with image - * @param app current application - * @return verification result - */ + * @brief Verify image and add image file full path + * and add path, although the image doesn't exist + * @param SmartObject with image + * @param app current application + * @return verification result + */ static void ApplyImagePath(smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); @@ -636,10 +673,10 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Stores whether each choice in a set has the vrCommands parameter - * MIXED means some choices have vrCommands and others don't - * ALL means all do, NONE means none do - */ + * @brief Stores whether each choice in a set has the vrCommands parameter + * MIXED means some choices have vrCommands and others don't + * ALL means all do, NONE means none do + */ enum ChoiceSetVRCommandsStatus { MIXED, ALL, NONE }; /** @@ -694,6 +731,23 @@ class MessageHelper { * @param app current application * * @param function_id Unique command id from mobile API + * + * @param window_id window id containing soft buttons + */ + static void SubscribeApplicationToSoftButton( + smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id, + const WindowID window_id); + + /* + * @brief subscribe application to softbutton + * + * @param message_params contains data of request + * + * @param app current application + * + * @param function_id Unique command id from mobile API */ static void SubscribeApplicationToSoftButton( smart_objects::SmartObject& message_params, @@ -710,6 +764,15 @@ class MessageHelper { */ static bool PrintSmartObject(const smart_objects::SmartObject& object); + /** + * @brief Extract window unique ID from message, this id is used for identify + * the window + * @param s_map contains application's window id + * @return window id from current message + */ + static WindowID ExtractWindowIdFromSmartObject( + const smart_objects::SmartObject& s_map); + template <typename From, typename To> static To ConvertEnumAPINoCheck(const From& input) { return static_cast<To>(input); @@ -725,6 +788,14 @@ class MessageHelper { hmi_apis::Common_Language::eType language); /** + * @brief Converts mobile language to string representation + * @param language Mobile UI language + * @return Mobile language string representation + */ + static std::string MobileLanguageToString( + mobile_apis::Language::eType language); + + /** * @brief Converts string to mobile language enum value * @param language language as string * @return Mobile language enum value @@ -855,10 +926,13 @@ class MessageHelper { /** * @brief Sends HMI status notification to mobile - * @param application_impl application with changed HMI status + * @param application application with changed HMI status + * @param window_id id of affected window + * @param application_manager reference to application manager **/ static void SendHMIStatusNotification( - const Application& application_impl, + ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager); /** @@ -892,6 +966,16 @@ class MessageHelper { static void BroadcastCapabilityUpdate(smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr); + /** + * @brief CreateDisplayCapabilityUpdateToMobile creates notification with + * updated display capabilities acccoring to message type + * @param system_capabilities SO containing notification data + * @param app reference to application + * @return shared ptr to notification SO + */ + static smart_objects::SmartObjectSPtr CreateDisplayCapabilityUpdateToMobile( + const smart_objects::SmartObject& system_capabilities, Application& app); + private: /** * @brief Allows to fill SO according to the current permissions. diff --git a/src/components/application_manager/include/application_manager/mobile_message_handler.h b/src/components/application_manager/include/application_manager/mobile_message_handler.h index b2ad963f46..3b02424e1f 100644 --- a/src/components/application_manager/include/application_manager/mobile_message_handler.h +++ b/src/components/application_manager/include/application_manager/mobile_message_handler.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MOBILE_MESSAGE_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MOBILE_MESSAGE_HANDLER_H_ -#include "utils/macro.h" -#include "protocol/common.h" #include "application_manager/message.h" +#include "protocol/common.h" +#include "utils/macro.h" namespace application_manager { typedef std::shared_ptr<application_manager::Message> MobileMessage; diff --git a/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h index 11a7d353f6..96a7f27064 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/plugin_keys.h @@ -41,7 +41,7 @@ extern const char* vehicle_info_rpc_plugin; extern const char* app_service_rpc_plugin; extern const char* rc_rpc_plugin; extern const char* sdl_rpc_plugin; -} +} // namespace plugin_names } // namespace plugin_manager } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h index 09a412b2ac..61b146f024 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin.h @@ -33,12 +33,19 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_H #include <memory> -#include "utils/macro.h" -#include "application_manager/commands/command.h" #include "application_manager/application.h" -#include "application_manager/rpc_service.h" +#include "application_manager/commands/command.h" #include "application_manager/hmi_capabilities.h" -#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" +#include "utils/macro.h" + +namespace policy { +class PolicyHandlerInterface; +} + +namespace resumption { +class LastState; +} namespace application_manager { class CommandFactory; @@ -57,7 +64,8 @@ enum ApplicationEvent { kApplicationExit = 0, kApplicationRegistered, kApplicationUnregistered, - kDeleteApplicationData + kDeleteApplicationData, + kGlobalPropertiesUpdated }; class RPCPlugin { @@ -68,17 +76,18 @@ class RPCPlugin { virtual ~RPCPlugin() {} /** - * @brief Command initialization function - * @param app_manager ApplicationManager - * @param rpc_service RPCService - * @param hmi_capabilities HMICapabilities - * @param policy_handler PolicyHandlerInterface - * @return true in case initialization was succesful, false otherwise. - **/ + * @brief Command initialization function + * @param app_manager ApplicationManager + * @param rpc_service RPCService + * @param hmi_capabilities HMICapabilities + * @param policy_handler PolicyHandlerInterface + * @return true in case initialization was succesful, false otherwise. + **/ virtual bool Init(ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) = 0; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) = 0; /** * @brief IsAbleToProcess check if plugin is able to process function * @param function_id RPC identifier @@ -117,7 +126,6 @@ class RPCPlugin { ApplicationEvent event, application_manager::ApplicationSharedPtr application) = 0; }; -typedef std::unique_ptr<RPCPlugin> RPCPluginPtr; } // namespace plugin_manager } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h index 692d296607..eb14f26ae6 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_H #include <cstdint> -#include <string> +#include <functional> #include <memory> +#include <string> #include <vector> -#include <functional> #include "application_manager/plugin_manager/rpc_plugin.h" #include "utils/optional.h" @@ -44,6 +44,10 @@ namespace application_manager { namespace plugin_manager { class RPCPluginManager { + protected: + typedef std::unique_ptr<RPCPlugin, std::function<void(RPCPlugin*)> > + RPCPluginPtr; + public: virtual ~RPCPluginManager() {} /** @@ -56,12 +60,6 @@ class RPCPluginManager { virtual uint32_t LoadPlugins(const std::string& plugins_path) = 0; /** - * @brief GetPlugins get list of plugins - * @return list of loaded plugins - */ - virtual std::vector<RPCPluginPtr>& GetPlugins() = 0; - - /** * @brief FindPluginToProcess find plugin to process message * @param function_id RPC identifier to process * @param message_source message_source source of message to process diff --git a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h index 5f85d45b6e..5495c44e05 100644 --- a/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h +++ b/src/components/application_manager/include/application_manager/plugin_manager/rpc_plugin_manager_impl.h @@ -32,13 +32,17 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_IMPL_H #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_RPC_PLUGIN_MANAGER_IMPL_H -#include "application_manager/plugin_manager/rpc_plugin_manager.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" +#include "application_manager/plugin_manager/rpc_plugin_manager.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" #include "utils/optional.h" +namespace resumption { +class LastState; +} + namespace application_manager { namespace plugin_manager { @@ -55,20 +59,24 @@ class RPCPluginManagerImpl : public RPCPluginManager { RPCPluginManagerImpl(ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state); uint32_t LoadPlugins(const std::string& plugins_path) OVERRIDE; - std::vector<RPCPluginPtr>& GetPlugins() OVERRIDE; + utils::Optional<RPCPlugin> FindPluginToProcess( const int32_t function_id, const commands::Command::CommandSource message_source) OVERRIDE; private: + RPCPluginPtr LoadPlugin(const std::string& full_plugin_path) const; + std::vector<RPCPluginPtr> loaded_plugins_; ApplicationManager& app_manager_; rpc_service::RPCService& rpc_service_; HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + resumption::LastState& last_state_; // RPCPluginManager interface public: diff --git a/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h b/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h new file mode 100644 index 0000000000..307f0b93df --- /dev/null +++ b/src/components/application_manager/include/application_manager/policies/custom_vehicle_data_provider.h @@ -0,0 +1,32 @@ +#ifndef CUSTOM_VEHICLE_DATA_PROVIDER_H +#define CUSTOM_VEHICLE_DATA_PROVIDER_H + +#include <vector> + +namespace rpc { +namespace policy_table_interface_base { +struct VehicleDataItem; +} +} // namespace rpc + +namespace policy { + +class VehicleDataItemProvider { + public: + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + virtual const std::vector<rpc::policy_table_interface_base::VehicleDataItem> + GetVehicleDataItems() const = 0; + + /** + * @brief Gets vehicle data items removed by policies + * @return Structure with vehicle data items + */ + virtual std::vector<rpc::policy_table_interface_base::VehicleDataItem> + GetRemovedVehicleDataItems() const = 0; +}; +} // namespace policy + +#endif // CUSTOM_VEHICLE_DATA_PROVIDER_H diff --git a/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h b/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h index f501598e0f..114b4e2d77 100644 --- a/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/external/delegates/app_permission_delegate.h @@ -33,19 +33,19 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_DELEGATES_APP_PERMISSION_DELEGATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_DELEGATES_APP_PERMISSION_DELEGATE_H_ +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "policy/policy_types.h" #include "application_manager/policies/policy_handler_interface.h" +#include "policy/policy_types.h" namespace policy { class PolicyHandler; /** -*@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent -*in async way. -*/ + *@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent + *in async way. + */ class AppPermissionDelegate : public threads::ThreadDelegate { public: /** diff --git a/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h b/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h index 2fe4265f54..38a60b29c4 100644 --- a/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/external/delegates/statistics_delegate.h @@ -35,10 +35,10 @@ #include <string> +#include "application_manager/usage_statistics.h" +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "application_manager/usage_statistics.h" namespace policy { diff --git a/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h b/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h index 3168b80b5a..7d71611a3c 100644 --- a/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h +++ b/src/components/application_manager/include/application_manager/policies/external/policy_event_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_EVENT_OBSERVER_H_ -#include "smart_objects/smart_object.h" #include "application_manager/event_engine/event_observer.h" +#include "smart_objects/smart_object.h" #include "utils/lock.h" namespace policy { 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 a33bb640ad..e4d4cd7fa2 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 @@ -33,28 +33,30 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICIES_POLICY_HANDLER_H_ -#include <string> +#include <stdint.h> +#include <list> #include <map> #include <set> +#include <string> #include <vector> -#include <list> -#include <stdint.h> -#include "policy/policy_manager.h" #include "application_manager/application.h" -#include "application_manager/policies/policy_handler_interface.h" -#include "application_manager/policies/policy_event_observer.h" #include "application_manager/policies/delegates/statistics_delegate.h" +#include "application_manager/policies/policy_event_observer.h" +#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/policy_handler_observer.h" -#include "utils/logger.h" -#include "utils/threads/thread.h" -#include "utils/threads/thread_delegate.h" + +#include "application_manager/policies/custom_vehicle_data_provider.h" +#include "policy/policy_manager.h" +#include "policy/policy_settings.h" +#include "policy/usage_statistics/statistics_manager.h" #include "utils/conditional_variable.h" -#include "utils/rwlock.h" #include "utils/custom_string.h" -#include "policy/usage_statistics/statistics_manager.h" +#include "utils/logger.h" +#include "utils/rwlock.h" #include "utils/threads/async_runner.h" -#include "policy/policy_settings.h" +#include "utils/threads/thread.h" +#include "utils/threads/thread_delegate.h" namespace Json { class Value; @@ -77,6 +79,8 @@ class PolicyHandler : public PolicyHandlerInterface, PolicyHandler(const policy::PolicySettings& get_settings, application_manager::ApplicationManager& application_manager); virtual ~PolicyHandler(); + PolicyEncryptionFlagGetterInterfaceSPtr PolicyEncryptionFlagGetter() + const OVERRIDE; bool LoadPolicyLibrary() OVERRIDE; bool PolicyEnabled() const OVERRIDE; bool InitPolicyTable() OVERRIDE; @@ -87,24 +91,31 @@ class PolicyHandler : public PolicyHandlerInterface, bool ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) OVERRIDE; bool UnloadPolicyLibrary() OVERRIDE; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const HMILevel& default_hmi) OVERRIDE; - virtual void OnPermissionsUpdated(const std::string& policy_app_id, + virtual void OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) OVERRIDE; #ifdef EXTERNAL_PROPRIETARY_MODE void OnSnapshotCreated(const BinaryMessage& pt_string, const std::vector<int>& retry_delay_seconds, uint32_t timeout_exchange) OVERRIDE; + + PTURetryHandler& ptu_retry_handler() const OVERRIDE; #else // EXTERNAL_PROPRIETARY_MODE - void OnSnapshotCreated(const BinaryMessage& pt_string) OVERRIDE; + void OnSnapshotCreated(const BinaryMessage& pt_string, + const PTUIterationType iteration_type) OVERRIDE; #endif // EXTERNAL_PROPRIETARY_MODE virtual bool GetPriority(const std::string& policy_app_id, std::string* priority) const OVERRIDE; virtual void CheckPermissions( const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result) OVERRIDE; @@ -113,12 +124,16 @@ class PolicyHandler : public PolicyHandlerInterface, virtual DeviceConsent GetUserConsentForDevice( const std::string& device_id) const OVERRIDE; + Json::Value GetPolicyTableData() const OVERRIDE; + /** * @brief Sets HMI default type for specified application + * @param device_handle device identifier * @param application_id ID application * @param app_types list of HMI types */ - void SetDefaultHmiTypes(const std::string& application_id, + void SetDefaultHmiTypes(const transport_manager::DeviceHandle& device_handle, + const std::string& application_id, const smart_objects::SmartObject* app_types) OVERRIDE; /** @@ -168,6 +183,9 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& policy_app_id, const std::string& hmi_level) OVERRIDE; +#ifndef EXTERNAL_PROPRIETARY_MODE + void OnPTUTimeOut() OVERRIDE; +#endif /** * Gets all allowed module types * @param app_id unique identifier of application @@ -177,7 +195,8 @@ class PolicyHandler : public PolicyHandlerInterface, bool GetModuleTypes(const std::string& policy_app_id, std::vector<std::string>* modules) const OVERRIDE; - bool GetDefaultHmi(const std::string& policy_app_id, + bool GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const OVERRIDE; bool GetInitialAppData(const std::string& application_id, StringArray* nicknames = NULL, @@ -204,6 +223,9 @@ class PolicyHandler : public PolicyHandlerInterface, uint32_t TimeoutExchangeMSec() const OVERRIDE; void OnExceededTimeout() OVERRIDE; void OnSystemReady() OVERRIDE; + const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE; + const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; void PTUpdatedAt(Counters counter, int value) OVERRIDE; void add_listener(PolicyHandlerObserver* listener) OVERRIDE; void remove_listener(PolicyHandlerObserver* listener) OVERRIDE; @@ -247,7 +269,8 @@ class PolicyHandler : public PolicyHandlerInterface, */ void OnIgnitionCycleOver() OVERRIDE; - void OnPendingPermissionChange(const std::string& policy_app_id) OVERRIDE; + void OnPendingPermissionChange(const std::string& device_id, + const std::string& policy_app_id) OVERRIDE; /** * Initializes PT exchange at user request @@ -334,9 +357,11 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Update currently used device id in policies manager for given * application + * @param device_handle device identifier * @param policy_app_id Application id */ std::string OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) OVERRIDE; /** @@ -441,9 +466,12 @@ class PolicyHandler : public PolicyHandlerInterface, std::string& cloud_transport_type, std::string& hybrid_app_preference) const OVERRIDE; + void OnAuthTokenUpdated(const std::string& policy_app_id, + const std::string& auth_token) OVERRIDE; + /** - * @brief Callback for when a SetCloudAppProperties message is received from a - * mobile app + * @brief Callback for when a SetCloudAppProperties message is received + * from a mobile app * @param message The SetCloudAppProperties message */ void OnSetCloudAppProperties( @@ -478,7 +506,7 @@ class PolicyHandler : public PolicyHandlerInterface, * @brief Check if an app can send unknown rpc requests to an app service * provider * @param policy_app_id Unique application id - */ + */ bool UnknownRPCPassthroughAllowed( const std::string& policy_app_id) const OVERRIDE; @@ -487,11 +515,11 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void OnCertificateUpdated( const std::string& certificate_data) OVERRIDE; + #ifdef EXTERNAL_PROPRIETARY_MODE void OnCertificateDecrypted(bool is_succeeded) OVERRIDE; + void ProcessCertDecryptFailed(); #endif // EXTERNAL_PROPRIETARY_MODE - void OnAuthTokenUpdated(const std::string& policy_app_id, - const std::string& auth_token); virtual bool CanUpdate() OVERRIDE; @@ -500,6 +528,7 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void SendOnAppPermissionsChanged( const AppPermissions& permissions, + const std::string& device_id, const std::string& policy_app_id) const OVERRIDE; virtual void OnPTExchangeNeeded() OVERRIDE; @@ -509,11 +538,13 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Allows to add new or update existed application during * registration process + * @param device_id device identifier * @param application_id The policy aplication id. * @param hmi_types list of hmi types * @return function that will notify update manager about new application */ StatusNotifier AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE; @@ -557,17 +588,21 @@ class PolicyHandler : public PolicyHandlerInterface, * succesfully registered on mobile device. * It will send OnAppPermissionSend notification and will try to start PTU. * + * @param device_id device identifier * @param application_id registered application. */ - void OnAppRegisteredOnMobile(const std::string& application_id) OVERRIDE; + void OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) OVERRIDE; /** * @brief Checks if certain request type is allowed for application + * @param device_handle device identifier * @param policy_app_id Unique applicaion id * @param type Request type * @return true, if allowed, otherwise - false */ bool IsRequestTypeAllowed( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id, mobile_apis::RequestType::eType type) const OVERRIDE; @@ -599,10 +634,12 @@ class PolicyHandler : public PolicyHandlerInterface, /** * @brief Gets application request types + * @param device_id device identifier * @param policy_app_id Unique application id * @return request types */ const std::vector<std::string> GetAppRequestTypes( + const transport_manager::DeviceHandle& device_id, const std::string& policy_app_id) const OVERRIDE; /** @@ -613,12 +650,6 @@ class PolicyHandler : public PolicyHandlerInterface, const std::vector<std::string> GetAppRequestSubTypes( const std::string& policy_app_id) const OVERRIDE; - /** - * @brief Gets vehicle information - * @return Structure with vehicle information - */ - const VehicleInfo GetVehicleInfo() const OVERRIDE; - #ifdef EXTERNAL_PROPRIETARY_MODE /** * @brief Gets meta information @@ -652,6 +683,10 @@ class PolicyHandler : public PolicyHandlerInterface, virtual void OnPTUFinished(const bool ptu_result) OVERRIDE; + virtual void OnPTInited() OVERRIDE; + + void StopRetrySequence() OVERRIDE; + /** * @brief OnDeviceSwitching Notifies policy manager on device switch event so * policy permissions should be processed accordingly @@ -661,6 +696,19 @@ class PolicyHandler : public PolicyHandlerInterface, void OnDeviceSwitching(const std::string& device_id_from, const std::string& device_id_to) FINAL; + // VehicleDataItemProvider interface : + /** + * @brief Gets vehicle data items + * @return Structure with vehicle data items + */ + const std::vector<rpc::policy_table_interface_base::VehicleDataItem> + GetVehicleDataItems() const OVERRIDE; + + std::vector<rpc::policy_table_interface_base::VehicleDataItem> + GetRemovedVehicleDataItems() const OVERRIDE; + + void OnLockScreenDismissalStateChanged() FINAL; + protected: /** * Starts next retry exchange policy table @@ -720,7 +768,7 @@ class PolicyHandler : public PolicyHandlerInterface, void UpdateHMILevel(application_manager::ApplicationSharedPtr app, mobile_apis::HMILevel::eType level); std::vector<std::string> GetDevicesIds( - const std::string& policy_app_id) OVERRIDE; + const std::string& policy_app_id) const OVERRIDE; /** * @brief Sets days after epoch on successful policy update @@ -811,16 +859,14 @@ class PolicyHandler : public PolicyHandlerInterface, static const std::string kLibrary; /** - * @brief Collects currently registered applications ids linked to their - * device id - * @param out_links Collection of device_id-to-app_id links - */ + * @brief Collects currently registered applications ids linked to their + * device id + * @param out_links Collection of device_id-to-app_id links + */ void GetRegisteredLinks(std::map<std::string, std::string>& out_links) const; - private: mutable sync_primitives::RWLock policy_manager_lock_; std::shared_ptr<PolicyManager> policy_manager_; - void* dl_handle_; std::shared_ptr<PolicyEventObserver> event_observer_; uint32_t last_activated_app_id_; diff --git a/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h b/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h index 6913f5038e..7e83aefe81 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/regular/delegates/app_permission_delegate.h @@ -33,18 +33,18 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_DELEGATES_APP_PERMISSION_DELEGATE_H_ +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "policy/policy_types.h" #include "application_manager/policies/policy_handler_interface.h" +#include "policy/policy_types.h" namespace policy { /** -*@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent -*in async way. -*/ + *@brief The AppPermissionDelegate class allows to call OnAppPermissionConsent + *in async way. + */ class AppPermissionDelegate : public threads::ThreadDelegate { public: /** diff --git a/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h b/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h index 3dc9ad925c..74d88fac69 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h +++ b/src/components/application_manager/include/application_manager/policies/regular/delegates/statistics_delegate.h @@ -35,10 +35,10 @@ #include <string> +#include "application_manager/usage_statistics.h" +#include "utils/conditional_variable.h" #include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" -#include "utils/conditional_variable.h" -#include "application_manager/usage_statistics.h" namespace policy { diff --git a/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h b/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h index 68e7511b43..fdfed698c4 100644 --- a/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h +++ b/src/components/application_manager/include/application_manager/policies/regular/policy_handler_observer.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_POLICY_HANDLER_OBSERVER_H_ -#include <vector> -#include <string> #include <map> +#include <string> +#include <vector> namespace policy { @@ -53,6 +53,8 @@ class PolicyHandlerObserver { virtual void OnPTUFinished(const bool ptu_result) {} + virtual void OnPTUTimeoutExceeded() {} + virtual ~PolicyHandlerObserver() {} }; } // namespace policy diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller.h index ea8d95a92a..8a3c90061e 100644 --- a/src/components/application_manager/include/application_manager/request_controller.h +++ b/src/components/application_manager/include/application_manager/request_controller.h @@ -34,21 +34,21 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_CONTROLLER_H_ #include <climits> -#include <vector> #include <list> +#include <vector> #include "utils/lock.h" -#include "utils/threads/thread.h" #include "utils/conditional_variable.h" +#include "utils/threads/thread.h" #include "utils/threads/thread_delegate.h" #include "utils/timer.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" -#include "application_manager/request_info.h" #include "application_manager/request_controller_settings.h" +#include "application_manager/request_info.h" #include "application_manager/request_tracker.h" namespace application_manager { @@ -56,14 +56,14 @@ namespace application_manager { namespace request_controller { /** -* @brief RequestController class is used to control currently active mobile -* requests. -*/ + * @brief RequestController class is used to control currently active mobile + * requests. + */ class RequestController { public: /** - * @brief Result code for addRequest - */ + * @brief Result code for addRequest + */ enum TResult { SUCCESS = 0, TOO_MANY_REQUESTS, @@ -73,8 +73,8 @@ class RequestController { }; /** - * @brief Thread pool state - */ + * @brief Thread pool state + */ enum TPoolState { UNDEFINED = 0, STARTED, @@ -84,121 +84,121 @@ class RequestController { // Methods /** - * @brief Class constructor - * - */ + * @brief Class constructor + * + */ RequestController(const RequestControlerSettings& settings); /** - * @brief Class destructor - * - */ + * @brief Class destructor + * + */ virtual ~RequestController(); /** - * @brief Initialize thread pool - * - */ + * @brief Initialize thread pool + * + */ void InitializeThreadpool(); /** - * @brief Destroy thread pool - * - */ + * @brief Destroy thread pool + * + */ void DestroyThreadpool(); /** - * @brief Check if max request amount wasn't exceed and adds request to queue. - * - * @param request Active mobile request - * @param hmi_level Current application hmi_level - * - * @return Result code - * - */ + * @brief Check if max request amount wasn't exceed and adds request to queue. + * + * @param request Active mobile request + * @param hmi_level Current application hmi_level + * + * @return Result code + * + */ TResult addMobileRequest(const RequestPtr request, const mobile_apis::HMILevel::eType& hmi_level); /** - * @brief Store HMI request until response or timeout won't remove it - * - * @param request Active hmi request - * @return Result code - * - */ + * @brief Store HMI request until response or timeout won't remove it + * + * @param request Active hmi request + * @return Result code + * + */ TResult addHMIRequest(const RequestPtr request); /** - * @ Add notification to collection - * - * @param ptr Reference to shared pointer that point on hmi notification - */ + * @ Add notification to collection + * + * @param ptr Reference to shared pointer that point on hmi notification + */ void addNotification(const RequestPtr ptr); /** - * @brief Removes request from queue - * - * @param correlation_id Active request correlation ID, - * @param connection_key Active request connection key (0 for HMI requersts) - * @param function_id Active request function id - * @param force_terminate if true, request controller will terminate - * even if not allowed by request - */ + * @brief Removes request from queue + * + * @param correlation_id Active request correlation ID, + * @param connection_key Active request connection key (0 for HMI requersts) + * @param function_id Active request function id + * @param force_terminate if true, request controller will terminate + * even if not allowed by request + */ void TerminateRequest(const uint32_t correlation_id, const uint32_t connection_key, const int32_t function_id, bool force_terminate = false); /** - * @brief Removes request from queue - * - * @param mobile_correlation_id Active mobile request correlation ID - * - */ + * @brief Removes request from queue + * + * @param mobile_correlation_id Active mobile request correlation ID + * + */ void OnMobileResponse(const uint32_t mobile_correlation_id, const uint32_t connection_key, const int32_t function_id); /** - * @brief Removes request from queue - * - * @param mobile_correlation_id Active mobile request correlation ID - * - */ + * @brief Removes request from queue + * + * @param mobile_correlation_id Active mobile request correlation ID + * + */ void OnHMIResponse(const uint32_t correlation_id, const int32_t function_id); /** - * @ Add notification to collection - * - * @param ptr Reference to shared pointer that point on hmi notification - */ + * @ Add notification to collection + * + * @param ptr Reference to shared pointer that point on hmi notification + */ void removeNotification(const commands::Command* notification); /** - * @brief Removes all requests from queue for specified application - * - * @param app_id Mobile application ID (app_id) - * - */ + * @brief Removes all requests from queue for specified application + * + * @param app_id Mobile application ID (app_id) + * + */ void terminateAppRequests(const uint32_t& app_id); /** - * @brief Terminates all requests from HMI - */ + * @brief Terminates all requests from HMI + */ void terminateAllHMIRequests(); /** - * @brief Terminates all requests from Mobile - */ + * @brief Terminates all requests from Mobile + */ void terminateAllMobileRequests(); /** - * @brief Updates request timeout - * - * @param app_id Connection key of application - * @param mobile_correlation_id Correlation ID of the mobile request - * @param new_timeout_value New timeout to be set in milliseconds - */ + * @brief Updates request timeout + * + * @param app_id Connection key of application + * @param mobile_correlation_id Correlation ID of the mobile request + * @param new_timeout_value New timeout to be set in milliseconds + */ void updateRequestTimeout(const uint32_t& app_id, const uint32_t& mobile_correlation_id, const uint32_t& new_timeout); @@ -217,13 +217,13 @@ class RequestController { protected: /** - * @brief Timer callback which handles all request timeouts - */ + * @brief Timer callback which handles all request timeouts + */ void TimeoutThread(); /** - * @brief Signal timer condition variable - */ + * @brief Signal timer condition variable + */ void NotifyTimer(); void terminateWaitingForExecutionAppRequests(const uint32_t& app_id); @@ -285,8 +285,8 @@ class RequestController { RequestTracker request_tracker_; /** - * @brief Set of HMI notifications with timeout. - */ + * @brief Set of HMI notifications with timeout. + */ std::list<RequestPtr> notification_list_; /** 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 be28bad63c..6900a50926 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -29,9 +29,9 @@ * 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. -*/ + * 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_REQUEST_INFO_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_INFO_H_ @@ -127,7 +127,7 @@ struct RequestInfo { } uint64_t hash(); static uint64_t GenerateHash(uint32_t var1, uint32_t var2); - static uint32_t HmiConnectoinKey; + static uint32_t HmiConnectionKey; protected: RequestPtr request_; @@ -268,9 +268,9 @@ class RequestInfoSet { }; /** -* @brief Structure used in std algorithms to determine amount of request -* during time scale -*/ + * @brief Structure used in std algorithms to determine amount of request + * during time scale + */ struct TimeScale { TimeScale(const date_time::TimeDuration& start, const date_time::TimeDuration& end, diff --git a/src/components/application_manager/include/application_manager/request_tracker.h b/src/components/application_manager/include/application_manager/request_tracker.h index b351e716a7..72d04abf4a 100644 --- a/src/components/application_manager/include/application_manager/request_tracker.h +++ b/src/components/application_manager/include/application_manager/request_tracker.h @@ -1,39 +1,39 @@ /* - * 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) + * 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_REQUEST_TRACKER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_REQUEST_TRACKER_H_ -#include <string> #include <map> +#include <string> #include <vector> #include "application_manager/request_controller_settings.h" #include "interfaces/MOBILE_API.h" diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h index f9a60c862b..11b1bcf926 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h @@ -42,7 +42,7 @@ class ApplicationManager; class Application; typedef std::shared_ptr<Application> ApplicationSharedPtr; typedef std::shared_ptr<const Application> ApplicationConstSharedPtr; -} +} // namespace application_manager namespace app_mngr = application_manager; namespace resumption { @@ -81,6 +81,13 @@ class ResumeCtrl { application_manager::ApplicationSharedPtr application) = 0; /** + * @brief Restore widgets HMI level on the resumption response from HMI + * @param response_message smart_object with HMI message + */ + virtual void RestoreWidgetsHMIState( + const smart_objects::SmartObject& response_message) = 0; + + /** * @brief Set application HMI Level as stored in policy * @param application is application witch HMI Level is need to setup * @return true if success, otherwise return false @@ -103,6 +110,16 @@ class ResumeCtrl { bool check_policy = true) = 0; /** + * @brief RestoreAppWidgets add widgets for the application + * @param application application which will be resumed + * @param saved_app application specific section from backup file + * @return true if widgets resumed successfully otherwise - false + */ + virtual void RestoreAppWidgets( + application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) = 0; + + /** * @brief Remove application from list of saved applications * @param application is application which need to be removed * @return return true, if success, otherwise return false @@ -233,7 +250,7 @@ class ResumeCtrl { * @param application - application to restore hmi level * and audio streaming state */ - virtual void StartAppHmiStateResumption( + virtual bool StartAppHmiStateResumption( application_manager::ApplicationSharedPtr application) = 0; /** @@ -282,6 +299,9 @@ class ResumeCtrl { virtual int32_t GetSavedAppHmiLevel(const std::string& app_id, const std::string& device_id) const = 0; + virtual void StartWaitingForDisplayCapabilitiesUpdate( + app_mngr::ApplicationSharedPtr application) = 0; + virtual time_t LaunchTime() const = 0; #ifdef BUILD_TESTS diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h index e749118140..5e6fb58671 100644 --- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h +++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h @@ -36,18 +36,18 @@ #include "application_manager/resumption/resume_ctrl.h" #include <stdint.h> -#include <vector> +#include <list> #include <map> #include <set> -#include <list> +#include <vector> +#include "application_manager/application.h" +#include "application_manager/event_engine/event_observer.h" +#include "application_manager/resumption/resumption_data.h" #include "interfaces/HMI_API.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" -#include "application_manager/event_engine/event_observer.h" #include "smart_objects/smart_object.h" -#include "application_manager/application.h" -#include "application_manager/resumption/resumption_data.h" #include "utils/timer.h" namespace resumption { @@ -95,6 +95,9 @@ class ResumeCtrlImpl : public ResumeCtrl, */ bool RestoreAppHMIState(app_mngr::ApplicationSharedPtr application) OVERRIDE; + void RestoreWidgetsHMIState( + const smart_objects::SmartObject& response_message) OVERRIDE; + /** * @brief Set application HMI Level as stored in policy * @param application is application witch HMI Level is need to setup @@ -117,6 +120,14 @@ class ResumeCtrlImpl : public ResumeCtrl, bool check_policy = true) OVERRIDE; /** + * @brief RestoreAppWidgets add widgets for the application + * @param application application which will be resumed + * @param saved_app application specific section from backup file + */ + void RestoreAppWidgets(application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) OVERRIDE; + + /** * @brief Remove application from list of saved applications * @param application is application which need to be removed * @return return true, if success, otherwise return false @@ -250,8 +261,9 @@ class ResumeCtrlImpl : public ResumeCtrl, * @brief Resume HMI Level and audio streaming state if needed * @param application - application to restore hmi level * and audio streaming state + * @return true if success otherwise false */ - void StartAppHmiStateResumption( + bool StartAppHmiStateResumption( app_mngr::ApplicationSharedPtr application) OVERRIDE; /** @@ -296,6 +308,9 @@ class ResumeCtrlImpl : public ResumeCtrl, int32_t GetSavedAppHmiLevel(const std::string& app_id, const std::string& device_id) const OVERRIDE; + void StartWaitingForDisplayCapabilitiesUpdate( + app_mngr::ApplicationSharedPtr application) OVERRIDE; + /** * @brief geter for launch_time_ * @return value of launch_time_ @@ -322,10 +337,10 @@ class ResumeCtrlImpl : public ResumeCtrl, #endif // BUILD_TESTS private: /** - * @brief Returns Low Voltage signal timestamp - * @return Low Voltage event timestamp if event LOW VOLTAGE event occures - * otherwise 0 - */ + * @brief Returns Low Voltage signal timestamp + * @return Low Voltage event timestamp if event LOW VOLTAGE event occures + * otherwise 0 + */ time_t LowVoltageTime() const; /** @@ -592,6 +607,16 @@ class ResumeCtrlImpl : public ResumeCtrl, app_mngr::ApplicationConstSharedPtr application) const; /** + * @brief Constructs and sends system capability mobile notification + * + * @param app to send display capabilities updated + * @param display_capabilities SO containing notification data + */ + void ProcessSystemCapabilityUpdated( + app_mngr::Application& app, + const smart_objects::SmartObject& display_capabilities); + + /** *@brief Mapping applications to time_stamps * wait for timer to resume HMI Level * @@ -609,6 +634,13 @@ class ResumeCtrlImpl : public ResumeCtrl, time_t wake_up_time_; std::shared_ptr<ResumptionData> resumption_storage_; application_manager::ApplicationManager& application_manager_; + /** + *@brief Mapping correlation id to request + *wait for on event response from HMI to resume HMI Level + */ + typedef std::map<int32_t, smart_objects::SmartObjectSPtr> + WaitingResponseToRequest; + WaitingResponseToRequest requests_msg_; }; } // namespace resumption diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index c2634173a5..d1dada345c 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -1,5 +1,5 @@ -/* - * Copyright (c) 2015, Ford Motor Company +/* + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_DATA_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_DATA_H_ -#include "smart_objects/smart_object.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" +#include "smart_objects/smart_object.h" #include "utils/macro.h" namespace application_manager { @@ -256,6 +256,14 @@ class ResumptionData { app_mngr::ApplicationConstSharedPtr application) const; /** + * @brief Retrieves of windows info from list of available window + * @param application contains list of available windows + * @return windows info from list of available window + */ + smart_objects::SmartObject GetApplicationWidgetsInfo( + app_mngr::ApplicationConstSharedPtr application) const; + + /** * @brief checks pointer that it is not equal NULL * @param ptr - contains pointer which need to check * @return smartObject from pointer @@ -264,6 +272,21 @@ class ResumptionData { const smart_objects::SmartObject* ptr) const; /** + * @brief creates smart object containing window info + * @param window_id window id + * @param window_type window type + * @param window_name window name + * @param window_optional_params_map collection containing optional params for + * creating window + * @return smart object with window data + */ + smart_objects::SmartObject CreateWindowInfoSO( + const application_manager::WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const application_manager::WindowParamsMap& window_optional_params_map) + const; + + /** * @brief Creates smart array from received data * @param first - iterator points to beginning of the data * @param last - iterator points to ending of the data diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h index e1dc9e6c5d..b1e94ab331 100644 --- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h @@ -35,18 +35,18 @@ #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" -#include "application_manager/rpc_handler.h" -#include "application_manager/rpc_service.h" #include "application_manager/mobile_message_handler.h" #include "application_manager/policies/policy_handler_observer.h" +#include "application_manager/rpc_handler.h" +#include "application_manager/rpc_service.h" -#include "protocol_handler/protocol_observer.h" #include "hmi_message_handler/hmi_message_observer.h" #include "hmi_message_handler/hmi_message_sender.h" +#include "protocol_handler/protocol_observer.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" #ifdef TELEMETRY_MONITOR @@ -56,8 +56,8 @@ #include "interfaces/v4_protocol_v1_2_no_extra.h" #include "interfaces/v4_protocol_v1_2_no_extra_schema.h" -#include "utils/threads/message_loop_thread.h" #include "utils/semantic_version.h" +#include "utils/threads/message_loop_thread.h" namespace application_manager { namespace rpc_handler { @@ -87,13 +87,15 @@ typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile> > FromMobileQueue; typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi> > FromHmiQueue; -} +} // namespace impl class RPCHandlerImpl : public RPCHandler, public impl::FromMobileQueue::Handler, public impl::FromHmiQueue::Handler { public: - RPCHandlerImpl(ApplicationManager& app_manager); + RPCHandlerImpl(ApplicationManager& app_manager, + hmi_apis::HMI_API& hmi_so_factory, + mobile_apis::MOBILE_API& mobile_so_factory); ~RPCHandlerImpl(); // CALLED ON messages_from_mobile_ thread! @@ -177,8 +179,8 @@ class RPCHandlerImpl : public RPCHandler, // Thread that pumps messages coming from HMI. impl::FromHmiQueue messages_from_hmi_; - hmi_apis::HMI_API hmi_so_factory_; - mobile_apis::MOBILE_API mobile_so_factory_; + hmi_apis::HMI_API& hmi_so_factory_; + mobile_apis::MOBILE_API& mobile_so_factory_; #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; #endif // TELEMETRY_MONITOR diff --git a/src/components/application_manager/include/application_manager/rpc_protection_manager.h b/src/components/application_manager/include/application_manager/rpc_protection_manager.h new file mode 100644 index 0000000000..34188da4e9 --- /dev/null +++ b/src/components/application_manager/include/application_manager/rpc_protection_manager.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ + +#include <cstdint> +#include <memory> + +#include "application_manager/application.h" +#include "application_manager/policies/policy_handler_observer.h" +#include "smart_objects/smart_object.h" + +namespace ns_smart_device_link { +namespace ns_smart_objects { +class SmartObject; +} // namespace ns_smart_objects +} // namespace ns_smart_device_link +namespace smart_objects = ns_smart_device_link::ns_smart_objects; + +namespace application_manager { +class Application; +} // namespace application_manager + +namespace application_manager { +/** + * @brief RPCProtectionManager interface + * This entity exists to get info from policy table regarding encryption on + * application and function group level, as well as make decisions whether + * certain RPC should be encrypted or not. + * It mediates communication between PRCService and + * PolicyEncryptionFlagGetterInterface which is implemented by PolicyManager, + * providing adequate level of abstraction. + */ +class RPCProtectionManager : public policy::PolicyHandlerObserver { + public: + /* + * @brief virtual destructor RPCProtectionManager + */ + virtual ~RPCProtectionManager() {} + + /* + * @brief checks whether given rpc requires encryption by policy + * @param function_id function id + * @param app ref to Application + * @param is_rpc_service_secure the flag the secure service started + * @return true if function need encryption for current app, else false + */ + virtual bool CheckPolicyEncryptionFlag( + const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure) const = 0; + /* + * @brief check whether given rpc is saved to internal cache and needs to be + * encrypted before sending to mobile + * @param app_id application id + * @param correlation_id correlation id + * @return true if the message with correlation id correlation_id needed e + * ncryption else false + */ + virtual bool IsInEncryptionNeededCache( + const uint32_t app_id, const uint32_t conrrelation_id) const = 0; + + /* + * @brief Adds app id and correlation id of a message to internal cache + * @param app_id application if + * @param correlation_id correlation id + */ + virtual void AddToEncryptionNeededCache(const uint32_t app_id, + const uint32_t correlation_id) = 0; + + /* + * @brief Removes app id and correlation id of a message from internal cache + * @param app_id application if + * @param correlation_id correlation id + */ + virtual void RemoveFromEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) = 0; +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h b/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h new file mode 100644 index 0000000000..b971ace480 --- /dev/null +++ b/src/components/application_manager/include/application_manager/rpc_protection_manager_impl.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ + +#include <map> +#include <set> +#include "application_manager/policies/policy_handler.h" +#include "application_manager/rpc_protection_manager.h" + +namespace application_manager { +/* + * @brief RPCProtectionManager implementation + */ +class RPCProtectionManagerImpl : public RPCProtectionManager { + public: + typedef std::pair<uint32_t, uint32_t> AppIdCorrIdPair; + typedef std::set<std::string> FunctionNames; + typedef std::map<std::string, FunctionNames> AppEncryptedRpcMap; + + RPCProtectionManagerImpl(policy::PolicyHandlerInterface& policy_handler); + + ~RPCProtectionManagerImpl() OVERRIDE {} + + bool CheckPolicyEncryptionFlag( + const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure) const OVERRIDE; + + bool IsInEncryptionNeededCache(const uint32_t app_id, + const uint32_t conrrelation_id) const OVERRIDE; + + void AddToEncryptionNeededCache(const uint32_t app_id, + const uint32_t correlation_id) OVERRIDE; + + void RemoveFromEncryptionNeededCache(const uint32_t app_id, + const uint32_t correlation_id) OVERRIDE; + + // PolicyHandlerObserver interface + void OnPTUFinished(const bool ptu_result) OVERRIDE; + + void OnPTInited() OVERRIDE; + + private: + /* + * @brief check whether given rpc is an exception + * @param function_id function id + * @return true if function_id is an exception (rpc that can be sent before + * app is registered, hence before secure rpc service is established) + */ + bool IsExceptionRPC(const uint32_t function_id) const; + + /* + * @brief retreives list of rpcs that require encryption by policy + * @param policy_app_id policy application name + * @return container with function names that require encryption by policy + */ + FunctionNames GetEncryptedRPCsForApp(const std::string& policy_app_id); + + /* + * @brief checks whether given function name is in saved encrypted rpc list + * @param policy_app_id policy application name + * @param function_name policy function name + * @return true if function_name for this policy_app_id is saved, otherwise - + * false + */ + bool IsEncryptionRequiredByPolicy(const std::string& policy_app_id, + const std::string& function_name) const; + + /* + * @brief saves rpcs that have encryption_required flag in policy table to + * internal container + */ + void SaveEncryptedRPC(); + + policy::PolicyHandlerInterface& policy_handler_; + + AppEncryptedRpcMap encrypted_rpcs_; + sync_primitives::Lock encrypted_rpcs_lock_; + + std::set<AppIdCorrIdPair> encryption_needed_cache_; + sync_primitives::Lock message_needed_encryption_lock_; +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_PROTOCOL_HANDLER_RPC_PROTECTION_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/rpc_service_impl.h b/src/components/application_manager/include/application_manager/rpc_service_impl.h index 98aad1a90e..3e3d83a519 100644 --- a/src/components/application_manager/include/application_manager/rpc_service_impl.h +++ b/src/components/application_manager/include/application_manager/rpc_service_impl.h @@ -34,24 +34,25 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RPC_SERVICE_IMPL_H #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" -#include "application_manager/request_controller.h" +#include "application_manager/command_holder_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/usage_statistics.h" #include "application_manager/mobile_message_handler.h" -#include "application_manager/command_holder_impl.h" +#include "application_manager/request_controller.h" +#include "application_manager/rpc_protection_manager.h" +#include "application_manager/rpc_service.h" +#include "application_manager/usage_statistics.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" #include "interfaces/HMI_API_schema.h" #include "interfaces/MOBILE_API_schema.h" #include "interfaces/v4_protocol_v1_2_no_extra.h" #include "interfaces/v4_protocol_v1_2_no_extra_schema.h" -#include "utils/threads/message_loop_thread.h" #include "utils/logger.h" +#include "utils/threads/message_loop_thread.h" namespace application_manager { namespace rpc_service { @@ -85,7 +86,15 @@ typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToMobile> > ToMobileQueue; typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToHmi> > ToHmiQueue; -} +} // namespace impl + +typedef std::shared_ptr<RPCProtectionManager> RPCProtectionManagerSPtr; + +enum class EncryptionFlagCheckResult { + kSuccess_Protected, + kSuccess_NotProtected, + kError_EncryptionNeeded +}; class RPCServiceImpl : public RPCService, public impl::ToMobileQueue::Handler, @@ -103,9 +112,14 @@ class RPCServiceImpl : public RPCService, request_controller::RequestController& request_ctrl, protocol_handler::ProtocolHandler* protocol_handler, hmi_message_handler::HMIMessageHandler* hmi_handler, - CommandHolder& commands_holder); + CommandHolder& commands_holder, + RPCProtectionManagerSPtr rpc_protection_manager, + hmi_apis::HMI_API& hmi_so_factory_, + mobile_apis::MOBILE_API& mobile_so_factory_); ~RPCServiceImpl(); + void Stop() OVERRIDE; + bool ManageMobileCommand(const commands::MessageSharedPtr message, commands::Command::CommandSource source) OVERRIDE; bool ManageHMICommand(const commands::MessageSharedPtr message, @@ -122,17 +136,31 @@ class RPCServiceImpl : public RPCService, void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE; bool IsAppServiceRPC(int32_t function_id, - commands::Command::CommandSource source); + commands::Command::CommandSource source) OVERRIDE; void set_protocol_handler( protocol_handler::ProtocolHandler* handler) OVERRIDE; void set_hmi_message_handler( hmi_message_handler::HMIMessageHandler* handler) OVERRIDE; + void UpdateMobileRPCParams( + const mobile_apis::FunctionID::eType& function_id, + const mobile_apis::messageType::eType& message_type, + const std::map<std::string, SMember>& members) OVERRIDE; + void UpdateHMIRPCParams( + const hmi_apis::FunctionID::eType& function_id, + const hmi_apis::messageType::eType& message_type, + const std::map<std::string, SMember>& members) OVERRIDE; + private: bool ConvertSOtoMessage(const smart_objects::SmartObject& message, Message& output, const bool allow_unknown_parameters = false); + + EncryptionFlagCheckResult IsEncryptionRequired( + const smart_objects::SmartObject& message, + ApplicationSharedPtr app, + const bool is_rpc_service_secure) const; hmi_apis::HMI_API& hmi_so_factory(); mobile_apis::MOBILE_API& mobile_so_factory(); void CheckSourceForUnsupportedRequest( @@ -143,14 +171,15 @@ class RPCServiceImpl : public RPCService, request_controller::RequestController& request_ctrl_; protocol_handler::ProtocolHandler* protocol_handler_; hmi_message_handler::HMIMessageHandler* hmi_handler_; + RPCProtectionManagerSPtr rpc_protection_manager_; CommandHolder& commands_holder_; // Thread that pumps messages being passed to mobile side. impl::ToMobileQueue messages_to_mobile_; // Thread that pumps messages being passed to HMI. impl::ToHmiQueue messages_to_hmi_; - hmi_apis::HMI_API hmi_so_factory_; - mobile_apis::MOBILE_API mobile_so_factory_; + hmi_apis::HMI_API& hmi_so_factory_; + mobile_apis::MOBILE_API& mobile_so_factory_; }; } // namespace rpc_service } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index 5d04207200..19dd6fbe3b 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 @@ -1,5 +1,5 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2019, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,6 +38,8 @@ namespace application_manager { namespace strings { extern const char* params; +extern const char* require_encryption; +extern const char* protection; extern const char* message_type; extern const char* correlation_id; extern const char* function_id; @@ -53,6 +55,7 @@ extern const char* info; extern const char* app_id; extern const char* full_app_id; extern const char* bundle_id; +extern const char* window_id; extern const char* app_info; extern const char* app_launch; extern const char* app_launch_list; @@ -92,6 +95,7 @@ extern const char* main_field_1; extern const char* main_field_2; extern const char* main_field_3; extern const char* main_field_4; +extern const char* template_title; extern const char* metadata_tags; extern const char* eta; extern const char* time_to_destination; @@ -110,10 +114,13 @@ extern const char* menu_icon; extern const char* keyboard_properties; extern const char* vr_commands; extern const char* position; +extern const char* user_location; extern const char* num_ticks; extern const char* slider_footer; extern const char* menu_id; extern const char* menu_name; +extern const char* menu_layout; +extern const char* menu_layouts_available; extern const char* interaction_choice_set_id; extern const char* interaction_choice_set_id_list; extern const char* choice_set; @@ -129,7 +136,10 @@ extern const char* initial_prompt; extern const char* initial_text; extern const char* duration; extern const char* progress_indicator; +extern const char* func_id; +extern const char* cancel_id; extern const char* alert_type; +extern const char* alert_icon; extern const char* play_tone; extern const char* soft_buttons; extern const char* soft_button_id; @@ -166,9 +176,17 @@ extern const char* activate_app_hmi_level; extern const char* audio_streaming_state; extern const char* video_streaming_state; extern const char* system_context; +extern const char* window_name; +extern const char* window_type; +extern const char* window_type_supported; +extern const char* maximum_number_of_windows; +extern const char* window_capabilities; +extern const char* associated_service_type; +extern const char* duplicate_updates_from_window_id; extern const char* speech_capabilities; extern const char* vr_capabilities; extern const char* audio_pass_thru_capabilities; +extern const char* audio_pass_thru_capabilities_list; extern const char* pcm_stream_capabilities; extern const char* audio_pass_thru_icon; extern const char* way_points; @@ -179,6 +197,7 @@ extern const char* navigation_capability; extern const char* phone_capability; extern const char* video_streaming_capability; extern const char* rc_capability; +extern const char* seat_location_capability; extern const char* app_services_capabilities; extern const char* day_color_scheme; extern const char* night_color_scheme; @@ -189,6 +208,8 @@ extern const char* red; extern const char* green; extern const char* blue; extern const char* display_layout; +extern const char* template_configuration; +extern const char* template_layout; extern const char* icon_resumed; extern const char* nicknames; extern const char* enabled; @@ -198,6 +219,11 @@ extern const char* hybrid_app_preference; extern const char* is_cloud_application; extern const char* cloud_connection_status; extern const char* endpoint; +extern const char* display_capabilities; +extern const char* policy_type; +extern const char* property; +extern const char* displays; +extern const char* seat_location; // PutFile extern const char* sync_file_name; @@ -216,6 +242,7 @@ extern const char* is_template; extern const char* image; extern const char* type; extern const char* system_file; +extern const char* is_system_file; extern const char* offset; extern const char* length; extern const char* secondary_image; @@ -254,6 +281,7 @@ extern const char* key_press_mode; // duplicate names from hmi_request extern const char* limited_character_list; extern const char* auto_complete_text; +extern const char* auto_complete_list; extern const char* navigation_text; // vehicle info @@ -285,6 +313,7 @@ extern const char* e_call_info; extern const char* airbag_status; extern const char* emergency_event; extern const char* cluster_mode_status; +extern const char* cluster_modes; extern const char* my_key; extern const char* help_prompt; extern const char* scroll_message_body; @@ -304,6 +333,7 @@ extern const char* sdl_version; extern const char* system_software_version; extern const char* priority; extern const char* engine_oil_life; +extern const char* oem_custom_data_type; // app services extern const char* app_service_manifest; @@ -322,6 +352,7 @@ extern const char* service_active; extern const char* app_service_id; extern const char* service_data; extern const char* media_service_data; +extern const char* media_image; extern const char* weather_service_data; extern const char* location; extern const char* current_forecast; @@ -343,6 +374,10 @@ extern const char* activate; extern const char* set_as_default; extern const char* origin_app; +// sis data +extern const char* station_short_name; +extern const char* station_location; + // resuming extern const char* application_commands; extern const char* application_submenus; @@ -363,11 +398,16 @@ extern const char* ign_off_count; extern const char* global_ign_on_counter; +extern const char* suspend_count; + extern const char* connection_info; extern const char* is_download_complete; +extern const char* shifted; +extern const char* altitude; extern const char* longitude_degrees; extern const char* latitude_degrees; + extern const char* address; extern const char* country_name; extern const char* country_code; @@ -396,6 +436,8 @@ extern const char* delivery_mode; extern const char* audio_streaming_indicator; +extern const char* windows_info; + // keys for default parameters loaded from hmi_capabilities.json: extern const char* const keyboard_properties_default; extern const char* const language_default; @@ -408,7 +450,6 @@ extern const char* const language_supported; extern const char* const keyboard_layout_supported; extern const char* const keypress_mode_supported; extern const char* const limited_characters_list_supported; -extern const char* const auto_complete_text_supported; extern const char* const send_location_enabled; extern const char* const get_way_points_enabled; extern const char* const entity_type; @@ -429,6 +470,9 @@ 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 diagonal_screen_size; +extern const char* const pixel_per_inch; +extern const char* const scale; extern const char* const haptic_rect_data; extern const char* const rect; extern const char* const x; @@ -465,12 +509,14 @@ extern const char* instance_follow_redirect; extern const char* charset; extern const char* content_lenght; extern const char* GET; -} // http_request +} // namespace http_request namespace mobile_notification { extern const char* state; extern const char* syncp_timeout; extern const char* syncp_url; +extern const char* lock_screen_dismissal_enabled; +extern const char* lock_screen_dismissal_warning; } // namespace mobile_notification namespace hmi_levels { @@ -517,7 +563,7 @@ extern const char* keyboard_properties; extern const char* method_name; extern const char* keyboard_layout; extern const char* limited_character_list; -extern const char* auto_complete_text; +extern const char* auto_complete_list; extern const char* file; extern const char* file_name; extern const char* retry; @@ -578,6 +624,9 @@ extern const char* policyfile; extern const char* is_active; extern const char* is_deactivated; extern const char* event_name; +extern const char* service_type; +extern const char* service_event; +extern const char* reason; } // namespace hmi_notification diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 8270e9b807..000569e450 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -35,15 +35,15 @@ #include <list> #include <map> -#include "application_manager/hmi_state.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" -#include "event_engine/event_observer.h" -#include "application_manager/state_controller.h" +#include "application_manager/hmi_state.h" #include "application_manager/message_helper.h" +#include "application_manager/state_controller.h" +#include "event_engine/event_observer.h" #include "interfaces/MOBILE_API.h" -#include "utils/lock.h" #include "utils/helpers.h" +#include "utils/lock.h" namespace application_manager { @@ -52,155 +52,101 @@ class StateControllerImpl : public event_engine::EventObserver, public: explicit StateControllerImpl(ApplicationManager& app_mngr); - /** - * @brief SetRegularState setup regular hmi state, that will appear if - * no specific events are active - * @param app appication to setup regular State - * @param state state of new regular state - */ - - virtual void SetRegularState(ApplicationSharedPtr app, - HmiStatePtr state, - const bool SendActivateApp); - - /** - * @brief SetRegularState Change regular hmi level and audio state - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param audio_state of new regular state - * @paran video_state of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state, + const bool SendActivateApp) OVERRIDE; - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, - const bool SendActivateApp); + const bool SendActivateApp) OVERRIDE; - /** - * @brief SetRegularState Change regular hmi level - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI - */ - virtual void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level, - const bool SendActivateApp); - - /** - * @brief SetRegularState Change regular hmi level, audio state and system - * context - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param audio_state of new regular state - * @param video_state of new regular state - * @param system_context of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::HMILevel::eType hmi_level, + const bool SendActivateApp) OVERRIDE; - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, - const bool SendActivateApp); + const bool SendActivateApp) OVERRIDE; - /** - * @brief SetRegularState Sets regular state with new hmi level - * to application - * @param app appication to setup regular state - * @param hmi_level new hmi level for application - */ - virtual void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level); + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::HMILevel::eType hmi_level) OVERRIDE; - /** - * @brief SetRegularState Change regular audio state - * @param app appication to setup regular State - * @param audio_state of new regular state - * @param video_state of new regular state - */ - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::AudioStreamingState::eType audio_state, - const mobile_apis::VideoStreamingState::eType video_state); + const mobile_apis::VideoStreamingState::eType video_state) OVERRIDE; - /** - * @brief SetRegularState Change regular system context - * @param app appication to setup regular State - * @param system_context of new regular state - */ - virtual void SetRegularState( + void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::SystemContext::eType system_context); + const WindowID window_id, + const mobile_apis::SystemContext::eType system_context) OVERRIDE; - /** - * @brief SetRegularState Sets new regular state to application - * @param app appication to setup regular state - * @param state new hmi state for application - */ - virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state); + void SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state) OVERRIDE; - // EventObserver interface - void on_event(const event_engine::Event& event); - void on_event(const event_engine::MobileEvent& event); + void OnApplicationRegistered( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType default_level) OVERRIDE; - /** - * @brief Sets default application state and apply currently active HMI states - * on application registration - * @param app application to apply states - * @param default_level default HMI level - */ - virtual void OnApplicationRegistered( + void OnAppWindowAdded( ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType default_level); + const WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType default_level) OVERRIDE; - /** - * @brief OnVideoStreamingStarted process video streaming started - * @param app projection or navigation application starting streaming - */ - virtual void OnVideoStreamingStarted(ApplicationConstSharedPtr app); + void OnVideoStreamingStarted(ApplicationConstSharedPtr app) OVERRIDE; - /** - * @brief OnVideoStreamingStopped process video streaming stopped - * @param app projection or navigation application stopping streaming - */ - virtual void OnVideoStreamingStopped(ApplicationConstSharedPtr app); + void OnVideoStreamingStopped(ApplicationConstSharedPtr app) OVERRIDE; - /** - * @brief OnStateChanged send HMIStatusNotification if needed - * @param app application - * @param old_state state before change - * @param new_state state after change - */ - virtual void OnStateChanged(ApplicationSharedPtr app, - HmiStatePtr old_state, - HmiStatePtr new_state); + void OnStateChanged(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr old_state, + HmiStatePtr new_state) OVERRIDE; - /** - * @brief Checks activity of Deactivate HMI state. - * @return Returns TRUE if deactivate HMI state is active, otherwise returns - * FALSE. - */ - virtual bool IsStateActive(HmiState::StateID state_id) const; + bool IsStateActive(HmiState::StateID state_id) const OVERRIDE; + + // EventObserver interface + void on_event(const event_engine::Event& event) OVERRIDE; + void on_event(const event_engine::MobileEvent& event) OVERRIDE; + + void ActivateDefaultWindow(ApplicationSharedPtr app) OVERRIDE; + void ExitDefaultWindow(ApplicationSharedPtr app) OVERRIDE; private: - int64_t SendBCActivateApp(ApplicationConstSharedPtr app, - hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority); + int64_t RequestHMIStateChange(ApplicationConstSharedPtr app, + hmi_apis::Common_HMILevel::eType level, + bool send_policy_priority); /** * @brief The HmiLevelConflictResolver struct * Move other application to HmiStates if applied moved to FULL or LIMITED */ struct HmiLevelConflictResolver { const ApplicationSharedPtr applied_; + const WindowID window_id_; const HmiStatePtr state_; StateControllerImpl* state_ctrl_; HmiLevelConflictResolver(const ApplicationSharedPtr app, + const WindowID window_id, const HmiStatePtr state, StateControllerImpl* state_ctrl) - : applied_(app), state_(state), state_ctrl_(state_ctrl) {} + : applied_(app) + , window_id_(window_id) + , state_(state) + , state_ctrl_(state_ctrl) {} void operator()(ApplicationSharedPtr to_resolve); }; @@ -298,14 +244,19 @@ class StateControllerImpl : public event_engine::EventObserver, template <HmiState::StateID ID> void HMIStateStarted(ApplicationSharedPtr app) { DCHECK_OR_RETURN_VOID(app); - HmiStatePtr old_hmi_state = app->CurrentHmiState(); - HmiStatePtr new_hmi_state = CreateHmiState(app, ID); - DCHECK_OR_RETURN_VOID(new_hmi_state); - DCHECK_OR_RETURN_VOID(new_hmi_state->state_id() != - HmiState::STATE_ID_REGULAR); - new_hmi_state->set_parent(old_hmi_state); - app->AddHMIState(new_hmi_state); - OnStateChanged(app, old_hmi_state, new_hmi_state); + const WindowIds window_ids = app->GetWindowIds(); + + for (auto window_id : window_ids) { + HmiStatePtr old_hmi_state = app->CurrentHmiState(window_id); + HmiStatePtr new_hmi_state = CreateHmiState(app, ID); + DCHECK_OR_RETURN_VOID(new_hmi_state); + DCHECK_OR_RETURN_VOID(new_hmi_state->state_id() != + HmiState::STATE_ID_REGULAR); + new_hmi_state->set_parent(old_hmi_state); + new_hmi_state->set_window_type(old_hmi_state->window_type()); + app->AddHMIState(window_id, new_hmi_state); + OnStateChanged(app, window_id, old_hmi_state, new_hmi_state); + } } /** @@ -326,7 +277,7 @@ class StateControllerImpl : public event_engine::EventObserver, * depends on application type * @param app Application to deactivate */ - void DeactivateApp(ApplicationSharedPtr app); + void DeactivateApp(ApplicationSharedPtr app, const WindowID window_id); /** * Function to remove temporary HmiState for application @@ -334,54 +285,78 @@ class StateControllerImpl : public event_engine::EventObserver, template <HmiState::StateID ID> void HMIStateStopped(ApplicationSharedPtr app) { DCHECK_OR_RETURN_VOID(app); - HmiStatePtr cur = app->CurrentHmiState(); - HmiStatePtr old_hmi_state = - CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(old_hmi_state); - old_hmi_state->set_hmi_level(cur->hmi_level()); - old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state()); - old_hmi_state->set_video_streaming_state(cur->video_streaming_state()); - old_hmi_state->set_system_context(cur->system_context()); - app->RemoveHMIState(ID); - HmiStatePtr new_hmi_state = app->CurrentHmiState(); - OnStateChanged(app, old_hmi_state, new_hmi_state); + const WindowIds window_ids = app->GetWindowIds(); + + for (auto window_id : window_ids) { + HmiStatePtr cur = app->CurrentHmiState(window_id); + HmiStatePtr old_hmi_state = + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(old_hmi_state); + old_hmi_state->set_hmi_level(cur->hmi_level()); + old_hmi_state->set_window_type(cur->window_type()); + old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state()); + old_hmi_state->set_video_streaming_state(cur->video_streaming_state()); + old_hmi_state->set_system_context(cur->system_context()); + app->RemoveHMIState(window_id, ID); + HmiStatePtr new_hmi_state = app->CurrentHmiState(window_id); + OnStateChanged(app, window_id, old_hmi_state, new_hmi_state); + } } /** * @brief ApplyRegularState setup regular hmi state, that will appear if no * specific events are active, without sending ActivateApp * @param app appication to setup default State + * @param window_id id of applicaion's window to apply HMI state * @param state state of new defailt state */ - void ApplyRegularState(ApplicationSharedPtr app, HmiStatePtr state); + void ApplyRegularState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state); + + /** + * @brief UpdateAppWindowsStreamingState updates all application windows + * audio/video streaming state according to a new HMI state of the main window + * @param app pointer to affected application + * @param state pointer to state with the new streaming state of the main + * window + */ + void UpdateAppWindowsStreamingState(ApplicationSharedPtr app, + HmiStatePtr state); /** * @brief SetupRegularHmiState set regular HMI State without * resolving conflicts and ActivateApp request * @param app application + * @param window_id id of applicaion's window to apply HMI state * @param state hmi_state to setup */ - void SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state); + void SetupRegularHmiState(ApplicationSharedPtr app, + const WindowID window_id, + HmiStatePtr state); /** * @brief SetupRegularHmiState set regular HMI State without * resolving conflicts and ActivateApp request * @param app application + * @param window_id id of applicaion's window to apply HMI state * @param hmi_level of new regular state * @param audio_state of new regular state * @param video_state of new regular state */ void SetupRegularHmiState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state); /** - * @brief OnActivateAppResponse calback for activate app response + * @brief OnHMIResponse callback for activate app or close application + * response * @param message Smart Object */ - void OnActivateAppResponse(const smart_objects::SmartObject& message); + void OnHMIResponse(const smart_objects::SmartObject& message); /** * @brief OnAppDeactivated callback for OnAppDeactivated notification @@ -449,9 +424,9 @@ class StateControllerImpl : public event_engine::EventObserver, typedef std::list<HmiState::StateID> StateIDList; StateIDList active_states_; mutable sync_primitives::Lock active_states_lock_; - std::map<uint32_t, HmiStatePtr> waiting_for_activate_; + std::map<uint32_t, HmiStatePtr> waiting_for_response_; ApplicationManager& app_mngr_; }; -} +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ diff --git a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h index 05565861f6..a8ba796a1b 100644 --- a/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h +++ b/src/components/application_manager/include/application_manager/system_time/system_time_handler_impl.h @@ -36,11 +36,11 @@ #include <time.h> #include <vector> +#include "application_manager/application_manager.h" +#include "application_manager/event_engine/event_observer.h" #include "utils/lock.h" #include "utils/macro.h" #include "utils/system_time_handler.h" -#include "application_manager/application_manager.h" -#include "application_manager/event_engine/event_observer.h" namespace application_manager { @@ -130,6 +130,12 @@ class SystemTimeHandlerImpl : public utils::SystemTimeHandler, void ProcessSystemTimeReadyNotification(); /** + * @brief ResetPendingSystemTimeRequests resets waiting for system time + * requests flag + */ + void ResetPendingSystemTimeRequests() OVERRIDE; + + /** * @brief Checks if UTC time is ready to provided by HMI * and can be requested by GetSystemTime request * @return True if HMI is ready to provide UTC time diff --git a/src/components/application_manager/include/application_manager/telemetry_observer.h b/src/components/application_manager/include/application_manager/telemetry_observer.h index 49f15165db..afd5397db9 100644 --- a/src/components/application_manager/include/application_manager/telemetry_observer.h +++ b/src/components/application_manager/include/application_manager/telemetry_observer.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TELEMETRY_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TELEMETRY_OBSERVER_H_ -#include "smart_objects/smart_object.h" #include "application_manager/smart_object_keys.h" #include "json/json.h" +#include "smart_objects/smart_object.h" #include "utils/date_time.h" @@ -53,5 +53,5 @@ class AMTelemetryObserver { virtual void OnMessage(MessageMetricSharedPtr) = 0; virtual ~AMTelemetryObserver() {} }; -} // application_manager +} // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_TELEMETRY_OBSERVER_H_ diff --git a/src/components/application_manager/include/application_manager/usage_statistics.h b/src/components/application_manager/include/application_manager/usage_statistics.h index 6d0b5cd6bd..ebd8e4729b 100644 --- a/src/components/application_manager/include/application_manager/usage_statistics.h +++ b/src/components/application_manager/include/application_manager/usage_statistics.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_USAGE_STATISTICS_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_USAGE_STATISTICS_H_ -#include <string> #include <memory> -#include "policy/usage_statistics/counter.h" +#include <string> #include "policy/usage_statistics/app_stopwatch.h" +#include "policy/usage_statistics/counter.h" #include "utils/macro.h" #include "interfaces/MOBILE_API.h" diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt index 1e23aac8ee..ef215cdd5a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/CMakeLists.txt @@ -53,22 +53,25 @@ collect_sources(COMMANDS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/commands") set(LIBRARIES HMI_API MOBILE_API + MessageHelper ApplicationManager + Resumption v4_protocol_v1_2_no_extra SmartObjects Utils - sdl_rpc_plugin + sdl_rpc_plugin_static ) if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("app_service_rpc_plugin" SHARED ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${COMMANDS_SOURCES}) -target_link_libraries("app_service_rpc_plugin" ${LIBRARIES}) +add_library("app_service_rpc_plugin_static" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) +target_link_libraries("app_service_rpc_plugin_static" ${LIBRARIES}) + +add_library("app_service_rpc_plugin" SHARED "src/app_service_rpc_plugin.cc") +target_link_libraries("app_service_rpc_plugin" app_service_rpc_plugin_static) -add_library("AppServiceRpcPluginStaticLib" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) -target_link_libraries("AppServiceRpcPluginStaticLib" ${LIBRARIES}) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h index 9be93f5c9e..b04edbe2f4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_app_extension.h @@ -126,6 +126,6 @@ class AppServiceAppExtension : public app_mngr::AppExtension { AppServiceRpcPlugin& plugin_; app_mngr::Application& app_; }; -} +} // namespace app_service_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h index c42b64f559..fd96bf0fb6 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_hmi_command_factory.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_HMI_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace app_service_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h index bd1e10f267..a6300dbb3d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_mobile_command_factory.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_APP_SERVICE_RPC_MOBILE_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace app_service_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h index c9cb98cdfb..1765c1e7fa 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/app_service_rpc_plugin.h @@ -47,7 +47,8 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, @@ -69,5 +70,6 @@ class AppServiceRpcPlugin : public plugins::RPCPlugin { } // namespace app_service_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_PLUGIN_INCLUDE_APP_SERVICE_PLUGIN_APP_SERVICE_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h index 531d1816e9..d9eb7528e4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_get_app_service_data_request_from_hmi.h @@ -92,6 +92,8 @@ class ASGetAppServiceDataRequestFromHMI application_manager::ApplicationSharedPtr app); void GetNavigationImagePaths(smart_objects::SmartObject& data, application_manager::ApplicationSharedPtr app); + void GetMediaImagePaths(smart_objects::SmartObject& data, + application_manager::ApplicationSharedPtr app); bool ValidateResponse(smart_objects::SmartObject& message_params); DISALLOW_COPY_AND_ASSIGN(ASGetAppServiceDataRequestFromHMI); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h new file mode 100644 index 0000000000..fdeadfa7c0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_REQUEST_H_ + +#include "application_manager/commands/request_from_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASUnpublishAppServiceRequest command class + **/ +class ASUnpublishAppServiceRequest : public app_mngr::commands::RequestFromHMI { + public: + /** + * @brief ASUnpublishAppServiceRequest class constructor + * + * @param message Incoming SmartObject message + **/ + ASUnpublishAppServiceRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASUnpublishAppServiceRequest class destructor + **/ + virtual ~ASUnpublishAppServiceRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASUnpublishAppServiceRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h new file mode 100644 index 0000000000..51edd2dadb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h @@ -0,0 +1,78 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ASUnpublishAppServiceResponse command class + **/ +class ASUnpublishAppServiceResponse : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief ASUnpublishAppServiceResponse class constructor + * + * @param message Incoming SmartObject message + **/ + ASUnpublishAppServiceResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief ASUnpublishAppServiceResponse class destructor + **/ + virtual ~ASUnpublishAppServiceResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(ASUnpublishAppServiceResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_HMI_AS_UNPUBLISH_APP_SERVICE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h index cff7c8e5b8..2dcd5ec251 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h @@ -70,6 +70,8 @@ class OnASAppServiceDataNotification virtual void Run(); private: + void GetMediaImagePaths(smart_objects::SmartObject& data, + application_manager::ApplicationSharedPtr app); void GetWeatherImagePaths(smart_objects::SmartObject& data, application_manager::ApplicationSharedPtr app); void GetNavigationImagePaths(smart_objects::SmartObject& data, diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h index 7c80ec5e03..6971354806 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/get_app_service_data_request.h @@ -68,6 +68,11 @@ class GetAppServiceDataRequest : public app_mngr::commands::CommandRequestImpl { virtual void Run(); /** + * @brief Init sets hash update mode for request + **/ + bool Init() FINAL; + + /** * @brief Interface method that is called whenever new event received * * @param event The received event diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h new file mode 100644 index 0000000000..4a883b92ee --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UnpublishAppServiceRequest command class + **/ +class UnpublishAppServiceRequest + : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief UnpublishAppServiceRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UnpublishAppServiceRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UnpublishAppServiceRequest class destructor + **/ + virtual ~UnpublishAppServiceRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnpublishAppServiceRequest); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h new file mode 100644 index 0000000000..512e39eea0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/include/app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace app_service_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UnpublishAppServiceResponse command class + **/ +class UnpublishAppServiceResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief UnpublishAppServiceResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UnpublishAppServiceResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UnpublishAppServiceResponse class destructor + **/ + virtual ~UnpublishAppServiceResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnpublishAppServiceResponse); +}; + +} // namespace commands + +} // namespace app_service_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_APP_SERVICE_RPC_PLUGIN_INCLUDE_APP_SERVICE_RPC_PLUGIN_COMMANDS_MOBILE_UNPUBLISH_APP_SERVICE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc index 6d8b0c08cc..87f947d250 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_app_extension.cc @@ -103,7 +103,7 @@ void AppServiceAppExtension::ProcessResumption( const smart_objects::SmartObject& subscriptions_app_services = resumption_data[app_service_info]; for (size_t i = 0; i < subscriptions_app_services.length(); ++i) { - std::string service_type = resumption_data[i].asString(); + std::string service_type = subscriptions_app_services[i].asString(); SubscribeToAppService(service_type); } } @@ -119,4 +119,4 @@ AppServiceAppExtension& AppServiceAppExtension::ExtractASExtension( DCHECK(vi_app_extension); return *vi_app_extension; } -} +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc index f0a0698bb7..8ce4d10b6e 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_command_factory.cc @@ -74,4 +74,4 @@ bool AppServiceCommandFactory::IsAbleToProcess( ? hmi_command_factory_->IsAbleToProcess(function_id, source) : mobile_command_factory_->IsAbleToProcess(function_id, source); } -} // namespace service_plugin +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc index 7cfbdd22d0..3090ea8ced 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_hmi_command_factory.cc @@ -50,6 +50,8 @@ #include "app_service_rpc_plugin/commands/hmi/as_perform_app_service_interaction_response_to_hmi.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_request.h" #include "app_service_rpc_plugin/commands/hmi/as_publish_app_service_response.h" +#include "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h" +#include "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification.h" #include "app_service_rpc_plugin/commands/hmi/on_as_app_service_data_notification_from_hmi.h" @@ -106,9 +108,9 @@ bool AppServiceHmiCommandFactory::IsAbleToProcess( LOG4CXX_DEBUG(logger_, "HMI App Service Plugin IsAbleToProcess: " << function_id); UNUSED(source); - return buildCommandCreator(function_id, - hmi_apis::messageType::INVALID_ENUM, - source).CanBeCreated(); + return buildCommandCreator( + function_id, hmi_apis::messageType::INVALID_ENUM, source) + .CanBeCreated(); } app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( @@ -126,6 +128,11 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::ASPublishAppServiceRequest>() : factory.GetCreator<commands::ASPublishAppServiceResponse>(); + case hmi_apis::FunctionID::AppService_UnpublishAppService: + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::ASUnpublishAppServiceRequest>() + : factory + .GetCreator<commands::ASUnpublishAppServiceResponse>(); case hmi_apis::FunctionID::AppService_OnAppServiceData: return app_mngr::commands::Command::CommandSource::SOURCE_HMI == source ? factory.GetCreator< @@ -188,4 +195,4 @@ app_mngr::CommandCreator& AppServiceHmiCommandFactory::buildCommandCreator( } return factory.GetCreator<app_mngr::InvalidCommand>(); } -} +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc index e8db20bdea..5c44fb5fae 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_mobile_command_factory.cc @@ -47,6 +47,8 @@ #include "app_service_rpc_plugin/commands/mobile/perform_app_service_interaction_response_from_mobile.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_request.h" #include "app_service_rpc_plugin/commands/mobile/publish_app_service_response.h" +#include "app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h" +#include "app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h" CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -97,9 +99,9 @@ bool AppServiceMobileCommandFactory::IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource source) const { UNUSED(source); - return buildCommandCreator(function_id, - mobile_apis::messageType::INVALID_ENUM, - source).CanBeCreated(); + return buildCommandCreator( + function_id, mobile_apis::messageType::INVALID_ENUM, source) + .CanBeCreated(); } app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( @@ -120,6 +122,16 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( return factory.GetCreator<commands::PublishAppServiceResponse>(); } break; + case mobile_apis::FunctionID::UnpublishAppServiceID: + if (app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source && + mobile_apis::messageType::response != message_type) { + return factory.GetCreator<commands::UnpublishAppServiceRequest>(); + } else if (app_mngr::commands::Command::CommandSource::SOURCE_SDL == + source && + mobile_apis::messageType::request != message_type) { + return factory.GetCreator<commands::UnpublishAppServiceResponse>(); + } + break; case mobile_apis::FunctionID::OnAppServiceDataID: return app_mngr::commands::Command::CommandSource::SOURCE_MOBILE == source ? factory.GetCreator< @@ -162,4 +174,4 @@ app_mngr::CommandCreator& AppServiceMobileCommandFactory::buildCommandCreator( } return factory.GetCreator<app_mngr::InvalidCommand>(); } -} // namespace vehicle_info_plugin +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index b96e5c199d..0e739522d9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -30,12 +30,12 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/message_helper.h" -#include "application_manager/smart_object_keys.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "app_service_rpc_plugin/app_service_app_extension.h" #include "app_service_rpc_plugin/app_service_command_factory.h" -#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/message_helper.h" #include "application_manager/plugin_manager/plugin_keys.h" +#include "application_manager/smart_object_keys.h" namespace app_service_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "AppServiceRpcPlugin") @@ -49,7 +49,9 @@ bool AppServiceRpcPlugin::Init( application_manager::ApplicationManager& app_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + UNUSED(last_state); application_manager_ = &app_manager; command_factory_.reset(new app_service_rpc_plugin::AppServiceCommandFactory( app_manager, rpc_service, hmi_capabilities, policy_handler)); @@ -93,6 +95,14 @@ void AppServiceRpcPlugin::DeleteSubscriptions( } // namespace app_service_rpc_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new app_service_rpc_plugin::AppServiceRpcPlugin(); } + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(app_service_rpc_plugin::logger_); +} diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc index 2da8834b96..e03c0ad15a 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_get_app_service_data_request_from_hmi.cc @@ -161,6 +161,14 @@ void ASGetAppServiceDataRequestFromHMI::GetNavigationImagePaths( } } +void ASGetAppServiceDataRequestFromHMI::GetMediaImagePaths( + smart_objects::SmartObject& data, ApplicationSharedPtr app) { + if (data.keyExists(strings::media_image)) { + MessageHelper::VerifyImage( + data[strings::media_image], app, application_manager_); + } +} + bool ASGetAppServiceDataRequestFromHMI::ValidateResponse( smart_objects::SmartObject& message_params) { if (!message_params.keyExists(strings::service_data)) { @@ -215,6 +223,11 @@ bool ASGetAppServiceDataRequestFromHMI::ValidateResponse( GetNavigationImagePaths(service_data[strings::navigation_service_data], app); } + + if (service_type_value == mobile_apis::AppServiceType::MEDIA && + service_data.keyExists(strings::media_service_data)) { + GetMediaImagePaths(service_data[strings::media_service_data], app); + } } return true; } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc new file mode 100644 index 0000000000..30905b5fa2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_request.cc @@ -0,0 +1,97 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + 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 "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_request.h" +#include "application_manager/app_service_manager.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASUnpublishAppServiceRequest::ASUnpublishAppServiceRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASUnpublishAppServiceRequest::~ASUnpublishAppServiceRequest() {} + +void ASUnpublishAppServiceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::string service_id = + (*message_)[strings::msg_params][strings::service_id].asString(); + + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + if (!service || service->mobile_service) { + SendErrorResponse( + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_UnpublishAppService, + hmi_apis::Common_Result::INVALID_ID, + "Invalid Service ID", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + bool ret = application_manager_.GetAppServiceManager().UnpublishAppService( + service_id); + + if (!ret) { + SendErrorResponse( + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_UnpublishAppService, + hmi_apis::Common_Result::REJECTED, + "The app service with that requested service ID does not exist", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + SendResponse(true, + (*message_)[strings::params][strings::correlation_id].asUInt(), + hmi_apis::FunctionID::AppService_UnpublishAppService, + hmi_apis::Common_Result::SUCCESS, + NULL, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_response.cc new file mode 100644 index 0000000000..0c8b479da8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/as_unpublish_app_service_response.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + 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 "app_service_rpc_plugin/commands/hmi/as_unpublish_app_service_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +ASUnpublishAppServiceResponse::ASUnpublishAppServiceResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ASUnpublishAppServiceResponse::~ASUnpublishAppServiceResponse() {} + +void ASUnpublishAppServiceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToHMI(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc index e90de23837..db1716ecb8 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification.cc @@ -55,6 +55,14 @@ OnASAppServiceDataNotification::OnASAppServiceDataNotification( OnASAppServiceDataNotification::~OnASAppServiceDataNotification() {} +void OnASAppServiceDataNotification::GetMediaImagePaths( + smart_objects::SmartObject& data, ApplicationSharedPtr app) { + if (data.keyExists(strings::media_image)) { + MessageHelper::VerifyImage( + data[strings::media_image], app, application_manager_); + } +} + void OnASAppServiceDataNotification::GetWeatherImagePaths( smart_objects::SmartObject& data, ApplicationSharedPtr app) { if (data[strings::location].keyExists(strings::location_image)) { @@ -186,6 +194,11 @@ bool OnASAppServiceDataNotification::ValidateParams( GetNavigationImagePaths(service_data[strings::navigation_service_data], app); } + + if (service_type_value == mobile_apis::AppServiceType::MEDIA && + service_data.keyExists(strings::media_service_data)) { + GetMediaImagePaths(service_data[strings::media_service_data], app); + } } return true; } diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc index 575aa5ca28..1c73fc73f4 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/hmi/on_as_app_service_data_notification_from_hmi.cc @@ -59,7 +59,8 @@ void OnASAppServiceDataNotificationFromHMI::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id].asString(); + [strings::service_id] + .asString(); AppService* service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); if (!service) { @@ -76,7 +77,8 @@ void OnASAppServiceDataNotificationFromHMI::Run() { std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type].asString(); + [strings::service_type] + .asString(); std::string published_service_type = service->record[strings::service_manifest][strings::service_type] .asString(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc index 7c2e62abe2..e3bf40308d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/get_app_service_data_request.cc @@ -65,6 +65,11 @@ void GetAppServiceDataRequest::Run() { true); } +bool GetAppServiceDataRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + void GetAppServiceDataRequest::HandleSubscribe() { std::string service_type = (*message_)[strings::msg_params][strings::service_type].asString(); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc index fd3891e0e8..1ffe99462d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification.cc @@ -66,15 +66,18 @@ void OnAppServiceDataNotification::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id].asString(); + [strings::service_id] + .asString(); auto service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); if (!service) { LOG4CXX_ERROR(logger_, "Service sending OnAppServiceData is not published"); return; - } else if (!service->record[strings::service_manifest] - [strings::allow_app_consumers].asBool()) { + } else if (!service + ->record[strings::service_manifest] + [strings::allow_app_consumers] + .asBool()) { LOG4CXX_ERROR(logger_, "Service does not allow for app consumers, skipping mobile " "OnAppServiceData notification"); @@ -83,7 +86,8 @@ void OnAppServiceDataNotification::Run() { std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type].asString(); + [strings::service_type] + .asString(); auto subscribed_to_app_service_predicate = [service_type](const ApplicationSharedPtr app) { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index 2e92bd19bb..5caacc9801 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -64,7 +64,8 @@ void OnAppServiceDataNotificationFromMobile::Run() { uint32_t app_connection_key = connection_key(); std::string service_type = (*message_)[strings::msg_params][strings::service_data] - [strings::service_type].asString(); + [strings::service_type] + .asString(); ApplicationSharedPtr app = application_manager_.application(app_connection_key); @@ -81,7 +82,8 @@ void OnAppServiceDataNotificationFromMobile::Run() { std::string service_id = (*message_)[strings::msg_params][strings::service_data] - [strings::service_id].asString(); + [strings::service_id] + .asString(); AppService* service = application_manager_.GetAppServiceManager().FindServiceByID(service_id); if (!service) { diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index 86819b44ad..53d1bf82fa 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -75,19 +75,22 @@ void PublishAppServiceRequest::Run() { strings::service_name)) { requested_service_name = (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_name].asString(); + [strings::service_name] + .asString(); } std::string requested_service_type = (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::service_type].asString(); + [strings::service_type] + .asString(); smart_objects::SmartArray* requested_handled_rpcs = NULL; if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( strings::handled_rpcs)) { requested_handled_rpcs = (*message_)[strings::msg_params][strings::app_service_manifest] - [strings::handled_rpcs].asArray(); + [strings::handled_rpcs] + .asArray(); } bool result = @@ -117,12 +120,6 @@ void PublishAppServiceRequest::Run() { return; } - if (app->IsFullscreen()) { - // Service should be activated if app is in the foreground - application_manager_.GetAppServiceManager().ActivateAppService( - service_record[strings::service_id].asString()); - } - response_params[strings::app_service_record] = service_record; SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc new file mode 100644 index 0000000000..2cb43bce07 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_request.cc @@ -0,0 +1,90 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + 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 "app_service_rpc_plugin/commands/mobile/unpublish_app_service_request.h" + +#include "application_manager/app_service_manager.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +UnpublishAppServiceRequest::UnpublishAppServiceRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +UnpublishAppServiceRequest::~UnpublishAppServiceRequest() {} + +void UnpublishAppServiceRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + std::string service_id = + (*message_)[strings::msg_params][strings::service_id].asString(); + + auto service = + application_manager_.GetAppServiceManager().FindServiceByID(service_id); + + if (!service || service->connection_key != connection_key()) { + SendResponse(false, + mobile_apis::Result::INVALID_ID, + "No app service with the requested service ID was published " + "by this application"); + return; + } + + bool ret = application_manager_.GetAppServiceManager().UnpublishAppService( + service_id); + + if (!ret) { + SendResponse( + false, + mobile_apis::Result::INVALID_ID, + "The app service with that requested service ID does not exist"); + return; + } + + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, NULL); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_response.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_response.cc new file mode 100644 index 0000000000..22450ecc4c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/unpublish_app_service_response.cc @@ -0,0 +1,62 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + 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 "app_service_rpc_plugin/commands/mobile/unpublish_app_service_response.h" +#include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" +#include "interfaces/MOBILE_API.h" + +namespace app_service_rpc_plugin { +using namespace application_manager; +namespace commands { + +UnpublishAppServiceResponse::UnpublishAppServiceResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +UnpublishAppServiceResponse::~UnpublishAppServiceResponse() {} + +void UnpublishAppServiceResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace app_service_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt index 0b56ddb7e9..1670ba5c22 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/CMakeLists.txt @@ -25,16 +25,10 @@ file(GLOB SOURCES set(LIBRARIES gmock - Utils - SmartObjects - HMI_API - MOBILE_API - connectionHandler - app_service_rpc_plugin - sdl_rpc_plugin - jsoncpp - Policy - Resumption + sdl_rpc_plugin_static + app_service_rpc_plugin_static ) create_cotired_test("app_services_commands_test" "${SOURCES}" "${LIBRARIES}" ) + +add_subdirectory("app_service_plugin") diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/CMakeLists.txt new file mode 100644 index 0000000000..9abe251204 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright (c) 2019, Ford Motor Company, Livio +# 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 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. +# +# 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) + + +set(APP_SERVICE_DIR "${COMPONENTS_DIR}/application_manager/rpc_plugins/app_service_rpc_plugin") +set(APP_SERVICE_SRC_DIR "${APP_SERVICE_DIR}/src") +set(APP_SERVICE_INCLUDE_DIR "${APP_SERVICE_DIR}/include/app_service_rpc_plugin") +set(APP_SERVICE_TEST_DIR "${APP_SERVICE_DIR}/test") + +include_directories( + ${GMOCK_INCLUDE_DIRECTORY} + ${APP_SERVICE_INCLUDE_DIR} +) + +set(SOURCES ${APP_SERVICE_TEST_DIR}/app_service_plugin/app_service_app_extension_test.cc + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc +) + +set(LIBRARIES + gmock + sdl_rpc_plugin_static + app_service_rpc_plugin_static +) + +create_test("app_service_plugin_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/app_service_app_extension_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/app_service_app_extension_test.cc new file mode 100644 index 0000000000..785cdd5200 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/app_service_plugin/app_service_app_extension_test.cc @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "app_service_rpc_plugin/app_service_app_extension.h" +#include <memory> +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/mock_application.h" +#include "gtest/gtest.h" + +namespace { +const std::string kAppServiceType1 = "AppServiceType1"; +const std::string kAppServiceType2 = "AppServiceType2"; +const std::string kResumptionDataKey = "kResumptionDataKey"; +const std::string kAppServiceInfoKey = "appService"; +} // namespace + +namespace test { +namespace components { +namespace app_service_plugin_test { + +using test::components::application_manager_test::MockApplication; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::ReturnRef; +using ::testing::SaveArg; + +using namespace app_service_rpc_plugin; +namespace strings = application_manager::strings; +namespace plugins = application_manager::plugin_manager; + +class AppServiceAppExtensionTest : public ::testing::Test { + public: + AppServiceAppExtensionTest() : mock_app_(new NiceMock<MockApplication>()) {} + + protected: + void SetUp() OVERRIDE { + app_service_app_extension_.reset( + new AppServiceAppExtension(app_service_plugin_, *mock_app_)); + } + + void TearDown() OVERRIDE { + app_service_app_extension_.reset(); + } + + app_service_rpc_plugin::AppServiceRpcPlugin app_service_plugin_; + std::unique_ptr<MockApplication> mock_app_; + std::unique_ptr<AppServiceAppExtension> app_service_app_extension_; +}; + +TEST_F(AppServiceAppExtensionTest, SubscribeToAppService_SUCCESS) { + EXPECT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + const auto& subs = app_service_app_extension_->Subscriptions(); + EXPECT_EQ(1u, subs.size()); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); +} + +TEST_F(AppServiceAppExtensionTest, + SubscribeToAppService_SubscribeOneAppServiceType_Twice_FAIL) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + + EXPECT_FALSE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + const auto& subs = app_service_app_extension_->Subscriptions(); + EXPECT_EQ(1u, subs.size()); +} + +TEST_F( + AppServiceAppExtensionTest, + UnsubscribeFromAppService_AppServiceType1Unsubscribed_AppServiceType2Remains_SUCCESS) { + // Subscribe + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType2)); + auto subs = app_service_app_extension_->Subscriptions(); + ASSERT_EQ(2u, subs.size()); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType2)); + + // Unsubscribe + EXPECT_TRUE( + app_service_app_extension_->UnsubscribeFromAppService(kAppServiceType1)); + EXPECT_FALSE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType2)); + subs = app_service_app_extension_->Subscriptions(); + EXPECT_EQ(1u, subs.size()); +} + +TEST_F(AppServiceAppExtensionTest, + UnsubscribeFromAppService_UnsubscribeNotSubscribedAppServiceType_FAIL) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_EQ(1u, app_service_app_extension_->Subscriptions().size()); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + + EXPECT_FALSE( + app_service_app_extension_->UnsubscribeFromAppService(kAppServiceType2)); + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + EXPECT_EQ(1u, app_service_app_extension_->Subscriptions().size()); +} + +TEST_F(AppServiceAppExtensionTest, + UnsubscribeFromAppService_UnsubscribeAll_SUCCESS) { + auto app_service_types = {kAppServiceType1, kAppServiceType2}; + + for (const auto& app_service_type : app_service_types) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(app_service_type)); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(app_service_type)); + } + ASSERT_EQ(2u, app_service_app_extension_->Subscriptions().size()); + + app_service_app_extension_->UnsubscribeFromAppService(); + + for (const auto& app_service_type : app_service_types) { + EXPECT_FALSE( + app_service_app_extension_->IsSubscribedToAppService(app_service_type)); + } + EXPECT_EQ(0u, app_service_app_extension_->Subscriptions().size()); +} + +TEST_F(AppServiceAppExtensionTest, SaveResumptionData_SUCCESS) { + ASSERT_TRUE( + app_service_app_extension_->SubscribeToAppService(kAppServiceType1)); + ASSERT_EQ(1u, app_service_app_extension_->Subscriptions().size()); + ASSERT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(kAppServiceType1)); + + smart_objects::SmartObject resumption_data; + resumption_data[kResumptionDataKey] = "some resumption data"; + + app_service_app_extension_->SaveResumptionData(resumption_data); + + EXPECT_TRUE(resumption_data.keyExists(kResumptionDataKey)); + EXPECT_TRUE(resumption_data.keyExists(kAppServiceInfoKey)); + EXPECT_EQ(kAppServiceType1, + resumption_data[kAppServiceInfoKey][0].asString()); +} + +TEST_F(AppServiceAppExtensionTest, ProcessResumption_SUCCESS) { + app_service_app_extension_->UnsubscribeFromAppService(); + ASSERT_EQ(0u, app_service_app_extension_->Subscriptions().size()); + + smart_objects::SmartObject app_service_data = + smart_objects::SmartObject(smart_objects::SmartType_Array); + app_service_data.asArray()->push_back( + smart_objects::SmartObject(kAppServiceType1)); + app_service_data.asArray()->push_back( + smart_objects::SmartObject(kAppServiceType2)); + + smart_objects::SmartObject resumption_data; + resumption_data[kAppServiceInfoKey] = app_service_data; + + app_service_app_extension_->ProcessResumption(resumption_data); + + for (const auto& app_service_type : {kAppServiceType1, kAppServiceType2}) { + EXPECT_TRUE( + app_service_app_extension_->IsSubscribedToAppService(app_service_type)); + } + EXPECT_EQ(2u, app_service_app_extension_->Subscriptions().size()); +} + +} // namespace app_service_plugin_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index 8ef87b6de9..4236ac23f9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -53,6 +53,8 @@ #include "hmi/as_perform_app_service_interaction_response_to_hmi.h" #include "hmi/as_publish_app_service_request.h" #include "hmi/as_publish_app_service_response.h" +#include "hmi/as_unpublish_app_service_request.h" +#include "hmi/as_unpublish_app_service_response.h" #include "hmi/on_as_app_service_data_notification.h" #include "hmi/on_as_app_service_data_notification_from_hmi.h" @@ -72,16 +74,16 @@ namespace dummy_hmi_commands_test { namespace commands = app_service_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; +using ::application_manager::ApplicationSharedPtr; using application_manager::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; template <class Command> class HMICommandsTest : public components::commands_test::CommandRequestTest< @@ -132,6 +134,8 @@ typedef Types<commands::ASAppServiceActivationRequest, commands::ASPerformAppServiceInteractionResponseToHMI, commands::ASPublishAppServiceRequest, commands::ASPublishAppServiceResponse, + commands::ASUnpublishAppServiceRequest, + commands::ASUnpublishAppServiceResponse, commands::OnASAppServiceDataNotification, commands::OnASAppServiceDataNotificationFromHMI> HMICommandsListFirst; diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 3c8a780128..69bff3ad76 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -49,11 +49,13 @@ #include "mobile/perform_app_service_interaction_response_from_mobile.h" #include "mobile/publish_app_service_request.h" #include "mobile/publish_app_service_response.h" +#include "mobile/unpublish_app_service_request.h" +#include "mobile/unpublish_app_service_response.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" +#include "test/application_manager/mock_application_manager_settings.h" namespace am = application_manager; @@ -64,16 +66,16 @@ namespace mobile_commands_test { namespace dummy_mobile_commands_test { namespace commands = app_service_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; using am::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; namespace { const std::string kEmptyString_ = ""; @@ -118,7 +120,10 @@ typedef Types<commands::GetAppServiceDataRequest, commands::PerformAppServiceInteractionResponse, commands::PerformAppServiceInteractionResponseFromMobile, commands::PublishAppServiceRequest, - commands::PublishAppServiceResponse> MobileCommandsListFirst; + commands::PublishAppServiceResponse, + commands::UnpublishAppServiceRequest, + commands::UnpublishAppServiceResponse> + MobileCommandsListFirst; TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst); diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc index 47358ef631..3e88d4eaf3 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/test/commands/mobile/on_app_service_data_notification_test.cc @@ -30,41 +30,41 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_app_service_manager.h" -#include "application_manager/commands/commands_test.h" #include "app_service_rpc_plugin/commands/mobile/on_app_service_data_notification.h" -#include "app_service_rpc_plugin/app_service_rpc_plugin.h" #include "app_service_rpc_plugin/app_service_app_extension.h" +#include "app_service_rpc_plugin/app_service_rpc_plugin.h" +#include "application_manager/application.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_app_service_manager.h" +#include "application_manager/mock_application.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/commands/command_impl.h" #include "resumption/last_state_impl.h" namespace am = application_manager; -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::ReturnNull; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::Mock; using am::ApplicationSet; using am::commands::MessageSharedPtr; +using app_service_rpc_plugin::commands::OnAppServiceDataNotification; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::application_manager_test::MockAppServiceManager; using test::components::commands_test::CommandsTest; using test::components::commands_test::CommandsTestMocks; -using app_service_rpc_plugin::commands::OnAppServiceDataNotification; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnNull; +using ::testing::ReturnRef; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; const int kModuleId = 153u; -} +} // namespace namespace app_service_plugin_test { using namespace app_service_rpc_plugin; @@ -214,4 +214,4 @@ TEST_F(OnAppServiceDataNotificationTest, Run_NoSubscribedApps) { Mock::VerifyAndClearExpectations(&app_mngr_); } -} // namespace rc_rpc_plugin_test +} // namespace app_service_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt index 00de927b6e..8129e1240d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/CMakeLists.txt @@ -50,7 +50,10 @@ collect_sources(COMMANDS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/commands") set(LIBRARIES HMI_API MOBILE_API + MessageHelper ApplicationManager + ProtocolHandler + connectionHandler v4_protocol_v1_2_no_extra SmartObjects Utils @@ -60,11 +63,12 @@ if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("rc_rpc_plugin" SHARED ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${COMMANDS_SOURCES}) -target_link_libraries("rc_rpc_plugin" ${LIBRARIES}) +add_library("rc_rpc_plugin_static" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) +target_link_libraries("rc_rpc_plugin_static" ${LIBRARIES}) + +add_library("rc_rpc_plugin" SHARED "src/rc_rpc_plugin.cc") +target_link_libraries("rc_rpc_plugin" rc_rpc_plugin_static) -add_library("RCRpcPluginStaticLib" ${PLUGIN_SOURCES} ${MOBILE_COMMANDS} ${HMI_COMMANDS}) -target_link_libraries("RCRpcPluginStaticLib" ${LIBRARIES}) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h index 3bc34be8d1..08082d98bb 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h @@ -35,8 +35,8 @@ #include "application_manager/commands/request_to_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h index 939d5fa468..5ed2236d9c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/response_from_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h index 97df5e8390..9a6cf9e290 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h @@ -1,42 +1,42 @@ /* -* Copyright (c) 2018, Ford Motor Company -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following -* disclaimer in the documentation and/or other materials provided with the -* distribution. -* -* Neither the name of the Ford Motor Company nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h index 46232987a5..677e3ad1f0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/response_from_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h index a88a39aa7a..a75020956c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h @@ -35,8 +35,8 @@ #include "application_manager/commands/request_to_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h index c9e5d39d1d..059164dc9f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/response_from_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h index aeb0a06d22..2a15f3816a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h @@ -35,8 +35,8 @@ #include "application_manager/commands/notification_from_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h index 7aa1aa3dba..82e0a8c13b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h @@ -69,6 +69,7 @@ class RCOnRemoteControlSettingsNotification private: ResourceAllocationManager& resource_allocation_manager_; InteriorDataManager& interior_data_manager_; + RCConsentManager& rc_consent_manager_; /** * @brief Disalows RC functionality for all RC apps * All registered apps will be unsubsribed from OnInteriorVehicleData diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h new file mode 100644 index 0000000000..64b11c3d7b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H + +#include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class RCSetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief RCSetGlobalPropertiesRequest class constructor + * + * @param message Command message as smart pointer to SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + RCSetGlobalPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params); + /** + * @brief Execute command + */ + void Run() OVERRIDE; + + ~RCSetGlobalPropertiesRequest(); +}; +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h new file mode 100644 index 0000000000..2e1494364c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h @@ -0,0 +1,68 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H + +#include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +class RCSetGlobalPropertiesResponse + : public application_manager::commands::ResponseFromHMI { + public: + /** + * @brief RCSetGlobalPropertiesResponse class constructor + * + * @param message Command message as smart pointer to SmartObject + * @param params Structure that contains references to + * parameters used in remote сontrol commands + */ + RCSetGlobalPropertiesResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + /** + * @brief Execute command + */ + void Run() OVERRIDE; + + ~RCSetGlobalPropertiesResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h index 69b48bfecf..aeba2f1440 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h @@ -35,8 +35,8 @@ #include "application_manager/commands/request_to_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h index 8a63503220..8369941c30 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/response_from_hmi.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h index d6ecfd0128..3946d80508 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h @@ -64,9 +64,11 @@ class ButtonPressRequest : public RCCommandRequest { /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; /** * @brief SetResourceState changes state of resource @@ -82,12 +84,18 @@ class ButtonPressRequest : public RCCommandRequest { */ void on_event(const app_mngr::event_engine::Event& event) FINAL; - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; /** * @brief ButtonPressRequest class destructor */ ~ButtonPressRequest(); + + private: + const mobile_apis::ButtonName::eType GetButtonId() const; + std::string GetButtonName() const; }; } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h index 0f3964494e..69122c19f3 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h new file mode 100644 index 0000000000..c41169d027 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H + +#include <string> + +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class GetInteriorVehicleDataConsentRequest + : public rc_rpc_plugin::commands::RCCommandRequest { + public: + /** + * @brief GetInteriorVehicleDataConsentRequest constructor + * @param message smart pointer with SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + GetInteriorVehicleDataConsentRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + /** + * @brief Execute command + */ + void Execute() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + std::string ModuleType() const FINAL; + + /** + * @brief For this RPC this method isn't correct, because SDL receives array + * of module_ids instead of only one module_id. This method returns empty + * string. + */ + std::string ModuleId() const FINAL; + + ~GetInteriorVehicleDataConsentRequest(); + + private: + /** + * @brief Saves ModuleId consents (saved before moduleids + received moduleId + * consents + date_of_consent) to file. + * + * @param msg_params Message params from response message as SmartObject. + */ + bool SaveModuleIdConsents(std::string& info_out, + const smart_objects::SmartObject& msg_params); + + /** + * @brief Gets calculated vehicle data consent and puts it into provided smart + * object + * @param out_response output smart object + * @return true in case all required consent information was provided in + * output smart object, otherwise returns false + */ + bool GetCalculatedVehicleDataConsent( + smart_objects::SmartObject& out_response) const; + + /** + * @brief Checks whether the user_location is covered by the module's + * serviceArea + * @param module_uid module key(module_type + module_id) + * @return true if the user_location is covered by the module's serviceArea or + * the user is the driver (or if seatLocationCapabilities don't exists) + * otherwise false + */ + bool IsUserLocationValid(const ModuleUid& module_uid) const; + + /** + * @brief Checks whether user should have access to module using the specific + * accessMode's rules + * @param module_uid module key(moudle_type + module_id) + * @param access_mode current HMI accessMode + * @return consent enum value + */ + rc_rpc_types::ModuleConsent GetModuleConsentByAccessMode( + const ModuleUid& module_uid, + const hmi_apis::Common_RCAccessMode::eType access_mode) const; + + smart_objects::SmartObject hmi_request_consents_; +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h new file mode 100644 index 0000000000..c163b02a80 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H + +#include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { + +namespace commands { + +class GetInteriorVehicleDataConsentResponse + : public application_manager::commands::CommandResponseImpl { + public: + /** + * @brief GetInteriorVehicleDataConsentResponse constructor + * + * @param message smart pointer with SmartObject + * @param params structure which contains references for next + * entities: ApplicationManager, RPCService, HMICapabilities, + * PolicyHandlerInterface, ResourceAllocationManager, InteriorDataCache, + * InteriorDataManager. + */ + GetInteriorVehicleDataConsentResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Run() OVERRIDE; + + ~GetInteriorVehicleDataConsentResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index 01588cc6b7..7be37f0756 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_ -#include "rc_rpc_plugin/commands/rc_command_request.h" #include <string> +#include "rc_rpc_plugin/commands/rc_command_request.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; @@ -63,8 +63,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { ~GetInteriorVehicleDataRequest(); private: - std::vector<application_manager::ApplicationSharedPtr> - AppsSubscribedToModuleType(const std::string& module_type); + std::vector<application_manager::ApplicationSharedPtr> AppsSubscribedToModule( + const ModuleUid& module); /** * @brief Check if app wants to proceed with already setup subscription @@ -76,9 +76,9 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { bool HasRequestExcessiveSubscription(); /** - * @brief Handle subscription to vehicle data - * @param hmi_response json message with response from HMI - */ + * @brief Handle subscription to vehicle data + * @param hmi_response json message with response from HMI + */ void ProccessSubscription(const smart_objects::SmartObject& hmi_response); /** @@ -87,7 +87,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { */ void RemoveExcessiveSubscription(); - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + std::string ModuleId() const FINAL; bool excessive_subscription_occured_; bool ProcessCapabilities(); void ProcessResponseToMobileFromCache(app_mngr::ApplicationSharedPtr app); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h index bf8208edc2..58dac85633 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/command_response_impl.h" #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h index 931e79366c..4663b4b371 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h @@ -35,9 +35,9 @@ #include <string> #include "application_manager/commands/command_notification_impl.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" -#include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/commands/rc_command_request.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -53,13 +53,16 @@ class OnInteriorVehicleDataNotification void Run() OVERRIDE; - std::string ModuleType(); + std::string ModuleType() const; + + std::string ModuleId() const; ~OnInteriorVehicleDataNotification(); private: InteriorDataCache& interior_data_cache_; - void AddDataToCache(const std::string& module_type); + RCCapabilitiesManager& rc_capabilities_manager_; + void AddDataToCache(const ModuleUid& module); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h new file mode 100644 index 0000000000..316dc29a1d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H + +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class ReleaseInteriorVehicleDataModuleRequest + : public rc_rpc_plugin::commands::RCCommandRequest { + public: + /** + * @brief ReleaseInteriorVehicleDataModule constructor + * @param message smart pointer with SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + ReleaseInteriorVehicleDataModuleRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Execute() FINAL; + + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; + + ~ReleaseInteriorVehicleDataModuleRequest(); + + private: + bool ProcessCapabilities(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h new file mode 100644 index 0000000000..42e0775a83 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H + +#include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class ReleaseInteriorVehicleDataModuleResponse + : public application_manager::commands::CommandResponseImpl { + public: + /** + * @brief ReleaseInteriorVehicleDataModuleResponse constructor + * + * @param message smart pointer with SmartObject + * @param params structure which contains references for next + * entities: ApplicationManager, RPCService, HMICapabilities, + * PolicyHandlerInterface, ResourceAllocationManager, InteriorDataCache, + * InteriorDataManager. + */ + ReleaseInteriorVehicleDataModuleResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Run() OVERRIDE; + + ~ReleaseInteriorVehicleDataModuleResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h index 128c668ee9..bb152a52f8 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h @@ -40,10 +40,6 @@ namespace app_mngr = application_manager; namespace commands { -enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; - -typedef std::pair<std::string, capabilitiesStatus> ModuleCapability; - class SetInteriorVehicleDataRequest : public RCCommandRequest { public: SetInteriorVehicleDataRequest( @@ -66,9 +62,11 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; /** * @brief SetResourceState changes state of resource @@ -85,28 +83,14 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { void on_event(const app_mngr::event_engine::Event& event) FINAL; /** - * @brief Method that check if READ_ONLY parameters present - * @param request_params params from received message, - * @param module_data_capabilities info for notification to mobile - * @return true if present , false - otherwise - */ - bool AreReadOnlyParamsPresent(const smart_objects::SmartObject& module_data, - ModuleCapability& module_data_capabilities); - - /** - * @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 smart_objects::SmartObject& module_data); - - /** * @brief Method that cuts-off READ_ONLY parameters * @param module_data params to handle */ void CutOffReadOnlyParams(smart_objects::SmartObject& module_data); - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; /** * @brief SetInteriorVehicleDataRequest class destructor @@ -115,14 +99,6 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { private: /** - * @brief ControlData - * @param module_data received params - * @return value of module data depending on module type - */ - const smart_objects::SmartObject& ControlData( - const smart_objects::SmartObject& module_data); - - /** * @brief CheckAudioSource check that if app wants to change * the audio source from MOBILE_APP to other types of audio * source without keepContext parameter or with keepContext=false diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h index 1ab5ccc6bc..f54418fc08 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h @@ -34,9 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" -#include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/commands/rc_command_request.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h index 8e7ed9c667..3b46b7ea30 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h @@ -39,7 +39,7 @@ namespace rpc_service { class RPCService; } class HMICapabilities; -} +} // namespace application_manager namespace policy { class PolicyHandlerInterface; @@ -50,6 +50,8 @@ namespace rc_rpc_plugin { class ResourceAllocationManager; class InteriorDataCache; class InteriorDataManager; +class RCCapabilitiesManager; +class RCConsentManager; struct RCCommandParams { application_manager::ApplicationManager& application_manager_; @@ -59,6 +61,8 @@ struct RCCommandParams { rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager_; rc_rpc_plugin::InteriorDataCache& interior_data_cache_; rc_rpc_plugin::InteriorDataManager& interior_data_manager_; + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager_; + rc_rpc_plugin::RCConsentManager& rc_consent_manager_; }; -} +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h index ce95617b6c..6bca1017e0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h @@ -33,11 +33,13 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_ -#include "rc_rpc_plugin/resource_allocation_manager.h" -#include "rc_rpc_plugin/rc_app_extension.h" #include "application_manager/commands/command_request_impl.h" -#include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/rc_consent_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; @@ -76,6 +78,8 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { ResourceAllocationManager& resource_allocation_manager_; InteriorDataCache& interior_data_cache_; InteriorDataManager& interior_data_manager_; + RCCapabilitiesManager& rc_capabilities_manager_; + RCConsentManager& rc_consent_manager_; /** * @brief AcquireResource try to allocate resource for application * In case if allocation of resource is not required, return ALLOWED by @@ -94,10 +98,13 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { * This is default implementation which has to be redefined for RPCs which * need to manage the resources * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - virtual bool IsResourceFree(const std::string& module_type) const { + virtual bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const { UNUSED(module_type); + UNUSED(module_id); return true; } /** @@ -136,7 +143,24 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { disallowed_info_ = info; } - virtual std::string ModuleType() = 0; + virtual std::string ModuleType() const = 0; + + /** + * @brief Extracts ModuleId from command message. Each inherited class should + * implement its own functionality + * + * @return ModuleId as string. + */ + virtual std::string ModuleId() const = 0; + + /** + * @brief IsModuleIdProvided checks if moduleId parameter + * is provided in the hmi response + * @param hmi_response response from hmi + * @return true if provided, otherwise - false + */ + + bool IsModuleIdProvided(const smart_objects::SmartObject& hmi_response) const; private: /** @@ -158,15 +182,44 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { /** * @brief SendGetUserConsent sends consent request to HMI * @param module_type Resource name + * @param module_ids Array of module IDs of the module type that needed user + * consent for acquiring their resources */ - void SendGetUserConsent(const std::string& module_type); + void SendGetUserConsent(const std::string& module_type, + const smart_objects::SmartObject& module_ids); + void ProcessAccessResponse(const app_mngr::event_engine::Event& event); + + /** + * @brief Precesses consents result which has been received from HMI + * If module resource consented, resource state will be switched to state BUSY + * and called method Execute. Otherwise will be sent response to Mobile with + * result code REJECTED. + * @param is_allowed consent result + * @param module_type Module type + * @param module_id Module ID + * @param app_id Application, which has asked for module resource consent. + */ + void ProcessConsentResult(const bool is_allowed, + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id); + /** + * @brief Processes ASK_DRIVE Mode. Tries to retrieve module consents from + * LastState. If consent is absent in LastState, will send + * GetInteriorVehicleDataConsent to HMI. Otherwise will start to process + * consent result. + * @param module_type Module type + * @param module_id Module ID + */ + void ProcessAskDriverMode(const std::string& module_type, + const std::string& module_id); bool IsInterfaceAvailable( const app_mngr::HmiInterfaces::InterfaceID interface) const; std::string disallowed_info_; }; -} -} +} // namespace commands +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h index bb45247fae..dad37edd1b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h @@ -37,8 +37,15 @@ namespace rc_rpc_plugin { /** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair<std::string, std::string> ModuleUid; + +/** * @brief The InteriorDataCache interface for caching data class - * Provide ability to cache module data by module type name and clear cache + * Provide ability to cache module data by module type name and module id + * and clear cache */ class InteriorDataCache { public: @@ -49,38 +56,41 @@ class InteriorDataCache { /** * @brief Add module data to cache - * @param module_type module type name + * @param module module type + module id * @param module_data data to be cached */ - virtual void Add(const std::string& module_type, + virtual void Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) = 0; /** * @brief Retrieve Get cached data - * @param module_type data type to get from cache + * @param module data type to get from cache * @return smart object with cached data, or nulll smart object */ virtual smart_objects::SmartObject Retrieve( + const ModuleUid& module) const = 0; + + virtual std::vector<ModuleUid> GetCachedModulesByType( const std::string& module_type) const = 0; /** * @brief Contains check if data exists in cache - * @param module_type module type name to check in cache + * @param module module name + module id to check in cache * @return true if cached, false otherwize */ - virtual bool Contains(const std::string& module_type) const = 0; + virtual bool Contains(const ModuleUid& module) const = 0; /** * @brief Remove cached data - * @param module_type data type to remove from cache + * @param module data type to remove from cache */ - virtual void Remove(const std::string& module_type) = 0; + virtual void Remove(const ModuleUid& module) = 0; /** * @brief Clear clear all cached data */ virtual void Clear() = 0; }; -} // rc_rpc_plugin +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h index f2971e3d72..d21b0e4162 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h @@ -35,9 +35,9 @@ #include <map> -#include "utils/macro.h" -#include "utils/lock.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "utils/lock.h" +#include "utils/macro.h" namespace rc_rpc_plugin { class InteriorDataCacheImpl : public InteriorDataCache { @@ -46,19 +46,22 @@ class InteriorDataCacheImpl : public InteriorDataCache { ~InteriorDataCacheImpl(); - void Add(const std::string& module_type, + void Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) OVERRIDE; - smart_objects::SmartObject Retrieve( + smart_objects::SmartObject Retrieve(const ModuleUid& module) const OVERRIDE; + + std::vector<ModuleUid> GetCachedModulesByType( const std::string& module_type) const OVERRIDE; - bool Contains(const std::string& module_type) const OVERRIDE; - void Remove(const std::string& module_type) OVERRIDE; + + bool Contains(const ModuleUid& module) const OVERRIDE; + void Remove(const ModuleUid& module) OVERRIDE; void Clear() OVERRIDE; private: - std::map<std::string, smart_objects::SmartObject> cached_data_; + std::map<ModuleUid, smart_objects::SmartObject> cached_data_; mutable sync_primitives::Lock cached_data_lock_; }; -} // rc_rpc_plugin +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h index f28c388055..c1fe30fa4d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h @@ -41,8 +41,15 @@ namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair<std::string, std::string> ModuleUid; + class InteriorDataManager { public: + virtual ~InteriorDataManager() {} /** * @brief OnPolicyEvent Processes policy related events * @param event Policy event @@ -50,10 +57,10 @@ class InteriorDataManager { virtual void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) = 0; /** - * @brief OnApplicationEvent Notifies modules on certain application events - * @param event Event - * @param application Pointer to application struct - */ + * @brief OnApplicationEvent Notifies modules on certain application events + * @param event Event + * @param application Pointer to application struct + */ virtual void OnApplicationEvent( plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) = 0; @@ -67,18 +74,19 @@ class InteriorDataManager { /** * @brief StoreRequestToHMITime save information and time stamp of * current interior data subscriptions + * @param module Module resource (module_type + module_id) */ - virtual void StoreRequestToHMITime(const std::string& module_type) = 0; + virtual void StoreRequestToHMITime(const ModuleUid& module) = 0; /** - * @brief CheckRequestsToHMIFrequency check that rate limits are not allowed of - * bounce during current time frame. - * calculate amount of requests per module type in time frame and checks if it - * bigger then allowed by ini file - * @param module_type moduletype to calculate frequency on - * @return true if amount of requests was not exceeded, otherwise return false. - */ - virtual bool CheckRequestsToHMIFrequency(const std::string& module_type) = 0; + * @brief CheckRequestsToHMIFrequency check that rate limits are not allowed + * of bounce during current time frame. calculate amount of requests per + * module in time frame and checks if it bigger then allowed by ini file + * @param module module to calculate frequency on + * @return true if amount of requests was not exceeded, otherwise return + * false. + */ + virtual bool CheckRequestsToHMIFrequency(const ModuleUid& module) = 0; }; } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h index 9b16a2c4da..791016cdcd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h @@ -40,7 +40,7 @@ class ApplicationManager; namespace rpc_service { class RPCService; } -} +} // namespace application_manager namespace rc_rpc_plugin { class InteriorDataCache; @@ -61,9 +61,9 @@ class InteriorDataManagerImpl : public InteriorDataManager { void OnDisablingRC() OVERRIDE; - void StoreRequestToHMITime(const std::string& module_type) OVERRIDE; + void StoreRequestToHMITime(const ModuleUid& module) OVERRIDE; - bool CheckRequestsToHMIFrequency(const std::string& module_type) OVERRIDE; + bool CheckRequestsToHMIFrequency(const ModuleUid& module) OVERRIDE; private: /** @@ -83,18 +83,21 @@ class InteriorDataManagerImpl : public InteriorDataManager { application_manager::Application& app); /** - * @brief UnsubscribeFromInteriorVehicleData remove module_type from cache and + * @brief UnsubscribeFromInteriorVehicleData remove module from cache and * send RC.GetInteriorVehicleData(subscribe=false) to HMI - * @param module_type module type that need to be unsubscribed + * @param module module that needs to be unsubscribed */ - void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + void UnsubscribeFromInteriorVehicleData(const ModuleUid& module); + + void UnsubscribeFromInteriorVehicleDataOfType(const std::string& module_type); void ClearOldRequestsToHMIHistory(); /** * @brief AppsModules mapping from applications to list of modules */ typedef std::map<application_manager::ApplicationSharedPtr, - std::vector<std::string> > AppsModules; + std::vector<ModuleUid> > + AppsModules; /** * @brief AppsSubscribedModules get mapping of application to list of @@ -103,11 +106,16 @@ class InteriorDataManagerImpl : public InteriorDataManager { */ AppsModules AppsSubscribedModules(); + typedef std::map<application_manager::ApplicationSharedPtr, + std::vector<std::string> > + AppsModuleTypes; + AppsModuleTypes AppsSubscribedModuleTypes(); + /** * @brief RequestsToHMIHistory mapping from module type to vector of time * stamps */ - typedef std::map<std::string, std::deque<date_time::TimeDuration> > + typedef std::map<ModuleUid, std::deque<date_time::TimeDuration> > RequestsToHMIHistory; RequestsToHMIHistory requests_to_hmi_history_; mutable sync_primitives::Lock requests_to_hmi_history_lock_; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h index e36968fc4b..33271e64fd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h @@ -33,13 +33,110 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ -#include <string> -#include <set> #include <memory> -#include "utils/macro.h" +#include <set> +#include <string> #include "application_manager/app_extension.h" +#include "utils/macro.h" namespace rc_rpc_plugin { + +typedef std::pair<std::string, std::string> ModuleUid; + +struct Grid { + int32_t col_; + int32_t row_; + int32_t level_; + int32_t colspan_; + int32_t rowspan_; + int32_t levelspan_; + + Grid() + : col_(0), row_(0), level_(0), colspan_(0), rowspan_(0), levelspan_(0) {} + + Grid(int32_t col, + int32_t row, + int32_t level, + int32_t colspan, + int32_t rowspan, + int32_t levelspan) + : col_(col) + , row_(row) + , level_(level) + , colspan_(colspan) + , rowspan_(rowspan) + , levelspan_(levelspan) {} + + Grid& operator=(const Grid& grid) { + col_ = grid.col_; + row_ = grid.row_; + level_ = grid.level_; + colspan_ = grid.colspan_; + rowspan_ = grid.rowspan_; + levelspan_ = grid.levelspan_; + + return *this; + } + + bool operator==(const Grid& grid) const { + return col_ == grid.col_ && row_ == grid.row_ && level_ == grid.level_ && + colspan_ == grid.colspan_ && rowspan_ == grid.rowspan_ && + levelspan_ == grid.levelspan_; + } + + /** + * @brief LevelIntersectionExists checks if the grids have an + * intersection by levels. + * @param grid with which to check intersection + * @return true if intersection exists, otherwise - false + */ + bool LevelIntersectionExists(const Grid& grid) const { + const int32_t top_level = (level_ + levelspan_) - 1; + const int32_t grid_top_level = (grid.level_ + grid.levelspan_) - 1; + + const int32_t min_level = std::max(level_, grid.level_); + const int32_t max_level = std::min(top_level, grid_top_level); + if ((max_level - min_level) < 0) { + return false; + } + return true; + } + + /** + * @brief IntersectionExists checks if the grids have an + * intersection. Grid can be represented by its bottom-left + * and top-right coordinates like a rectangle. First, the + * coordinates of the intersection are calculated, then checked + * that the rectangle which is formed by the intersections of two + * grids has non-zero width and height. + * @param grid with which to check intersection + * @return true if intersection exists, otherwise - false + */ + bool IntersectionExists(const Grid& grid) const { + if (!LevelIntersectionExists(grid)) { + return false; + } + + const int32_t right_top_col = (col_ + colspan_) - 1; + const int32_t right_top_row = (row_ + rowspan_) - 1; + const int32_t grid_right_top_col = (grid.col_ + grid.colspan_) - 1; + const int32_t grid_right_top_row = (grid.row_ + grid.rowspan_) - 1; + + const int32_t left = std::max(col_, grid.col_); + const int32_t bottom = std::max(row_, grid.row_); + const int32_t right = std::min(right_top_col, grid_right_top_col); + const int32_t top = std::min(right_top_row, grid_right_top_row); + + const int32_t width = right - left; + const int32_t height = top - bottom; + + if ((width < 0) || (height < 0)) { + return false; + } + return true; + } +}; + class RCAppExtension : public application_manager::AppExtension { public: explicit RCAppExtension(application_manager::AppExtensionUID uid); @@ -49,13 +146,15 @@ class RCAppExtension : public application_manager::AppExtension { * @brief Subscribe to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - void SubscribeToInteriorVehicleData(const std::string& module_type); + void SubscribeToInteriorVehicleData(const ModuleUid& module); /** * @brief Unsubscribe from OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + void UnsubscribeFromInteriorVehicleData(const ModuleUid& module); + + void UnsubscribeFromInteriorVehicleDataOfType(const std::string& module_type); /** * @brief UnsubscribeFromInteriorVehicleData removes all subscriptions for @@ -67,16 +166,40 @@ class RCAppExtension : public application_manager::AppExtension { * @brief Check if application subscribed to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - bool IsSubscibedToInteriorVehicleData(const std::string& module_type); + bool IsSubscribedToInteriorVehicleData(const ModuleUid& module); + + bool IsSubscribedToInteriorVehicleDataOfType(const std::string& module_type); /** * @brief get list of subscriptions of application * @return list of subscriptions of application */ - std::set<std::string> InteriorVehicleDataSubscriptions() const; + std::set<ModuleUid> InteriorVehicleDataSubscriptions() const; + + /** + * @brief GetUserLocation + * @return grid of user location + */ + Grid GetUserLocation() const; + + /** + * @brief SetUserLocation sets user location + * from object to the grid + * @param user_location smart object for user_location + */ + void SetUserLocation( + const ns_smart_device_link::ns_smart_objects::SmartObject& user_location); + + /** + * @brief SetUserLocation sets user location from grid + * @param grid grid of user_location + */ + void SetUserLocation(const Grid& grid); private: - std::set<std::string> subscribed_interior_vehicle_data_; + std::set<ModuleUid> subscribed_interior_vehicle_data_; + + Grid user_location_; // AppExtension interface public: diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h new file mode 100644 index 0000000000..36fd8bbbf9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h @@ -0,0 +1,184 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" + +namespace rc_rpc_plugin { + +enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; +typedef std::pair<std::string, capabilitiesStatus> ModuleTypeCapability; + +class RCCapabilitiesManager { + public: + /** + * @brief CheckIfButtonExistInRCCaps checks if the + * specified button exists in rc_capabilities + * @param button button name + * @return true if present, otherwise - false + */ + virtual bool CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const = 0; + + /** + * @brief CheckButtonName checks if the button + * corresponds to the module_type + * @param module_type resource name + * @param button_name button name + * @return true if they match, otherwise - false + */ + virtual bool CheckButtonName(const std::string& module_type, + const std::string& button_name) const = 0; + + /** + * @brief CheckIfModuleExistsInCapabilities checks + * if the specified module exists in rc_capabilities + * @param module moduleType + moduleId + * @return true if exists, otherwise - false + */ + virtual bool CheckIfModuleExistsInCapabilities( + const ModuleUid& module) const = 0; + + /** + * @brief GetModuleDataCapabilities checks whether rc module data + * capabilities are presented + * @param module_data smart object of module_data + * @param module_id module id + * @return pair of state and capability status - ModuleCapability + */ + virtual ModuleTypeCapability GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const = 0; + + /** + * @brief ControlData retrieves control data + * for specified module type + * @param module_data smart object of module_data + * @param module_type resource name + * @return smart object of control data + */ + virtual const smart_objects::SmartObject& ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const = 0; + + /** + * @brief AreReadOnlyParamsPresent checks if there are + * any read only params in the module data + * @param module_data smart object of module_data + * @param module_type resource name + * @param module_data_capabilities smart object of capabilities + * @return true if read only params exist, otherwise - false + */ + virtual bool AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const = 0; + + /** + * @brief AreAllParamsReadOnly checks that all params from module + * data are read only + * @param module_data smart object of module_data + * @param module_type resource name + * @return true if all params are read only, otherwise - false + */ + virtual bool AreAllParamsReadOnly( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const = 0; + + /** + * @brief GetDefaultModuleIdFromCapabilities returns the moduleId + * from the first item published by xyz-ControlCapabilities + * @param module_type resource name + * @return default module id from HMI capabilities + */ + virtual const std::string GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const = 0; + + /** + * @brief GetResources get list of ModuleUids(moduleType + moduleId) + * of all known resources + * @return vector contains all known moduleUids + */ + virtual const std::vector<ModuleUid> GetResources() const = 0; + + /** + * @brief GetModuleServiceArea retrieves service area of module, + * if module serviceArea is missed in capabilities, serviceArea is + * assumed to be the same as location, if location + * is missed in capabilities, it is assumed that serviceArea covers + * the whole area of vehicle + * @param module module type + module id + * @return Grid of module service area + */ + virtual Grid GetModuleServiceArea(const ModuleUid& module) const = 0; + + /** + * @brief IsMultipleAccessAllowed checks if multiple access allowed + * for requested module + * @param module module type + module id + * @return true if allowed, otherwise - false + */ + virtual bool IsMultipleAccessAllowed(const ModuleUid& module) const = 0; + + /** + * @brief GetDriverLocationFromSeatLocationCapability retrieves the driver's + * location from seat location capabilities + * @return Grid of driver's location + */ + virtual const Grid GetDriverLocationFromSeatLocationCapability() const = 0; + + /** + * @brief IsSeatLocationCapabilityProvided checks whether all necessary + * parameters are provided in seat location capabilities + * @return true if provided, otherwise - false + */ + virtual bool IsSeatLocationCapabilityProvided() const = 0; + + /** + * @brief GetModuleIdForSeatLocation returns the moduleId if request from + * mobile contains the id parameter and doesn't contain the moduleId + * parameter. If the vehicle support at least one seat control, seat control + * capability includes at least two items. SupportedSeat id shall be converted + * to the moduleId according to capabilities: 1st item from capabilities for + * driver’s seat. 2nd item for front passenger’s seat. + * @param id supported seat id + */ + virtual const std::string GetModuleIdForSeatLocation( + mobile_apis::SupportedSeat::eType id) const = 0; + + virtual ~RCCapabilitiesManager() {} +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h new file mode 100644 index 0000000000..844647940f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h @@ -0,0 +1,200 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_H_ +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" + +namespace rc_rpc_plugin { +class RCCapabilitiesManagerImpl : public RCCapabilitiesManager { + public: + RCCapabilitiesManagerImpl( + application_manager::HMICapabilities& hmi_capabilities); + + bool CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const FINAL; + + bool CheckButtonName(const std::string& module_type, + const std::string& button_name) const FINAL; + + bool CheckIfModuleExistsInCapabilities(const ModuleUid& module) const FINAL; + + ModuleTypeCapability GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const FINAL; + + const smart_objects::SmartObject& ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const FINAL; + + bool AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const FINAL; + + bool AreAllParamsReadOnly(const smart_objects::SmartObject& module_data, + const std::string& module_type) const FINAL; + + const std::string GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const FINAL; + + const std::vector<ModuleUid> GetResources() const FINAL; + + Grid GetModuleServiceArea(const ModuleUid& module) const FINAL; + + bool IsMultipleAccessAllowed(const ModuleUid& module) const FINAL; + + const Grid GetDriverLocationFromSeatLocationCapability() const FINAL; + + bool IsSeatLocationCapabilityProvided() const FINAL; + + const std::string GetModuleIdForSeatLocation( + mobile_apis::SupportedSeat::eType id) const FINAL; + + private: + const std::map<std::string, std::string> GetLightCapabilitiesMapping() const; + + const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() + const; + + /** + * @brief Check whether the exists light data related to correspondent + * capabilities + * @param capabilities smart object of capabilities + * @param control_data smart object of control_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const; + + /** + * @brief Check whether the parameter exist in capabilities + * @param capabilities smart object of capabilities + * @param mapping - map of module data and capabilities + * @param request_parameter - string + * @param switched_off_result - ref of mobile_apis::Result + * @return success if the parameter exists in capabilities, + * otherwise - missedParam + */ + capabilitiesStatus GetItemCapability( + const smart_objects::SmartObject& capabilities, + const std::map<std::string, std::string>& mapping, + const std::string& request_parameter, + const mobile_apis::Result::eType& switched_off_result) const; + + /** + * @brief Check whether the capabilities for light are allowed + * @param capabilities smart object of capabilities + * @param control_data smart object of control_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const; + + /** + * @brief Check whether the light name exists in capabilities + * @param capabilities_status smart object of capabilities_status + * @param light_data smart object of light_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetLightNameCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) const; + + ModuleTypeCapability GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) const; + + bool CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) const; + + bool CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) const; + + smart_objects::SmartObject GetCapabilitiesByModuleIdFromArray( + const smart_objects::SmartObject& module_data_capabilities, + const std::string& module_id) const; + + const bool CheckModuleIdWithCapabilities( + const smart_objects::SmartObject& rc_capabilities, + const ModuleUid& module) const; + + const bool CheckModuleIdWithCapabilitiesArrays( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const; + + const bool CheckModuleIdWithCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const; + + const std::string GetDefaultModuleIdFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const; + + const std::string GetDefaultModuleIdFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const; + + const std::vector<std::string> GetCapabilitiesList() const; + + const std::function<std::string(const std::string& control_cap)> + GetCapabilitiesToModuleTypeMapping() const; + + void GetResourcesFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& capabitity_key, + std::vector<ModuleUid>& out_resources) const; + + void GetResourcesFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector<ModuleUid>& out_resources) const; + + Grid GetModuleServiceAreaFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const; + + Grid GetModuleLocationFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const; + + bool IsMultipleAccessAllowedInControlCaps( + const smart_objects::SmartObject& control_capabilities) const; + + Grid GetWholeVehicleArea() const; + + application_manager::HMICapabilities& hmi_capabilities_; +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h index a9cf0e2a21..aa01b608b4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h @@ -34,15 +34,14 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ #include <memory> -#include "application_manager/command_factory.h" #include "application_manager/application_manager.h" #include "application_manager/command_factory.h" -#include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" -#include "rc_rpc_plugin/interior_data_cache.h" +#include "application_manager/rpc_service.h" #include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -64,10 +63,10 @@ class RCCommandFactory : public application_manager::CommandFactory { app_mngr::commands::Command::CommandSource source) OVERRIDE; /** - * @param int32_t command id - * @param CommandSource source - * @return return true if command can be create, else return false - **/ + * @param int32_t command id + * @param CommandSource source + * @return return true if command can be create, else return false + **/ virtual bool IsAbleToProcess( const int32_t, const application_manager::commands::Command::CommandSource) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h new file mode 100644 index 0000000000..cde7928a14 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H + +#include <string> + +#include "rc_rpc_types.h" + +namespace ns_smart_device_link { +namespace ns_smart_objects { +class SmartObject; +} // namespace ns_smart_objects +} // namespace ns_smart_device_link + +namespace rc_rpc_plugin { + +class RCConsentManager { + public: + /** + * @brief Saves consents (is_consented + date_of_consent) for module resources + * (module_type + module_id) for specified application + * @param policy_app_id Application id which module consents should be saved + * @param mac_address Device mac address + * @param module_consents - Module resources consents + */ + virtual void SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) = 0; + + /** + * @brief Retrieves saved consent for specified module resource (module_type + * + module_id) + * @param app_id Application which related to specified module resource + * @param mac_address Device mac address + * @param module_id Module resource (module_type + module_id) + * @return Module consent state + */ + virtual rc_rpc_plugin::rc_rpc_types::ModuleConsent GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) const = 0; + + /** + * @brief Remove modules consents from LastState if they exist + */ + virtual void RemoveAllConsents() = 0; + + /** + * @brief Remove all expired module consents from LastState + * if they exist + */ + virtual void RemoveExpiredConsents() = 0; + + virtual ~RCConsentManager() {} +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h new file mode 100644 index 0000000000..b3c6a0b129 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_IMPL_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_IMPL_H + +#include "rc_consent_manager.h" +#include "resumption/last_state.h" +#include "utils/lock.h" + +namespace Json { +class Value; +} // namespace Json + +namespace rc_rpc_plugin { + +class RCConsentManagerImpl : public RCConsentManager { + public: + RCConsentManagerImpl( + resumption::LastState& last_state, + application_manager::ApplicationManager& application_manager, + const uint32_t period_of_consent_expired); + + void SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) OVERRIDE; + + rc_rpc_types::ModuleConsent GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) const OVERRIDE; + + void RemoveExpiredConsents() OVERRIDE; + + void RemoveAllConsents() OVERRIDE; + + ~RCConsentManagerImpl() OVERRIDE; + + private: + /** + * @brief Saves module consents for specified application + * @param app_module_consents Application consents for which new + * consents should be added or existing ones should be overwritten + * @param consent_to_save module consents which should be saved + */ + void SaveAppModuleConsent( + Json::Value& app_module_consents, + const rc_rpc_types::ModuleIdConsent& consent_to_save); + + /** + * @brief Checks if module consent is expired + * @param module_consent Module consent + * @return ModuleConsentState + */ + rc_rpc_types::ModuleConsentState CheckModuleConsentState( + const Json::Value& module_consent) const; + + /** + * @brief Removes devices expired consents + * @param device Device section in AppConsensts section of LastState in Json + */ + void RemoveDeviceExpiredConsents(Json::Value& device); + + /** + * @brief Remove expired module consents which are related to specified + * application + * @param app_consents Application consents + */ + void RemoveAppExpiredConsents(Json::Value& app_consents); + + /** + * @brief Remove expired module consents which are related to specified + * module type + * @param module_consents Module consents wich should be checked for expired + * consents + */ + void RemoveModuleExpiredConsents(Json::Value& module_consents); + + /** + * @brief Get Remote Control section of LastState. + * In case the section is absent, will be appended a new empty section. + * @return Remote Control section of LastState in Json + */ + Json::Value& GetRemoteControlDataOrAppend() const; + + /** + * @brief Gets Device applications section for specified device mac adress + * In case the section is absent, will be appended a new empty section. + * @param mac_aress Device MAC adress + * @return Device applications section of LastState in Json + */ + Json::Value& GetDeviceApplicationsOrAppend( + const std::string& mac_address) const; + + /** + * @brief Get AppConsentsList section of LastState for specified application. + * In case the consent list is absent, will be appended a new empty section. + * @param policy_app_id Application policy ID + * @param mac_address Device MAC address + * @return AppConsentsList of LastState in Json + */ + Json::Value& GetAppConsentsListOrAppend(const std::string& policy_app_id, + const std::string& mac_address) const; + + /** + * @brief Get Application consents section of Remote Control section of + * LastState with all consents for all applications. In case if this section + * is absent, will be created a new empty section + * @return AppConsents section of RemoteControl section of LastState in Jason + */ + Json::Value& GetAppsConsentsOrAppend() const; + + /** + * @brief Get all module resource consents for specified application and + * module type. In case if section with specified module type consents is + * absent, will be created a new empty section + * @param policy_app_id Application id which contains specified module type + * @param mac_adress MAC address of mobile device that needs user consent for + * acquiring resource + * @param module_type Module type with consents + */ + Json::Value& GetModuleTypeConsentsOrAppend( + const std::string& policy_app_id, + const std::string& mac_address, + const std::string& module_type) const; + + private: + application_manager::ApplicationManager& app_manager_; + resumption::LastState& last_state_; + const uint32_t period_of_consent_expired_; + mutable sync_primitives::Lock dictionary_control_lock_; + mutable sync_primitives::Lock remote_control_lock_; + mutable sync_primitives::Lock device_applications_lock_; + mutable sync_primitives::Lock applications_lock_; + mutable sync_primitives::Lock app_consents_lock_; + mutable sync_primitives::Lock module_consents_lock_; +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_IMPL_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h index cf3c6cd5e4..eed860fc7f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h @@ -37,6 +37,7 @@ #include <string> #include "application_manager/application.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_rpc_types.h" namespace rc_rpc_plugin { class RCRPCPlugin; @@ -49,26 +50,26 @@ class RCRPCPlugin; class RCHelpers { public: /** - * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to - * actual module data filed name - * @return module mapping from enum naming to filed name - */ + * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to + * actual module data filed name + * @return module mapping from enum naming to filed name + */ static const std::function<std::string(const std::string& module_type)> GetModuleTypeToDataMapping(); /** - * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to - * actual module capabilities key - * @return module mapping from enum naming to capabilities key - */ + * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to + * actual module capabilities key + * @return module mapping from enum naming to capabilities key + */ static const std::function<std::string(const std::string& module_type)> GetModuleTypeToCapabilitiesMapping(); /** - * @brief GetModulesList get list of all known modules - * @return vector contains all known modules + * @brief GetModuleTypesList get list of all known module types + * @return vector contains all known module types */ - static const std::vector<std::string> GetModulesList(); + static const std::vector<std::string> GetModuleTypesList(); /** * @brief GetRCExtension extract RC extension from application @@ -80,17 +81,95 @@ class RCHelpers { application_manager::Application& app); static smart_objects::SmartObjectSPtr CreateUnsubscribeRequestToHMI( - const std::string& module_type, const uint32_t correlation_id); + const ModuleUid& module, const uint32_t correlation_id); + + static std::vector<application_manager::ApplicationSharedPtr> + AppsSubscribedToModule(application_manager::ApplicationManager& app_mngr, + const ModuleUid& module); static std::vector<application_manager::ApplicationSharedPtr> AppsSubscribedToModuleType(application_manager::ApplicationManager& app_mngr, const std::string& module_type); typedef std::map<application_manager::ApplicationSharedPtr, - std::vector<std::string> > AppsModules; - static AppsModules GetApplicationsAllowedModules( + std::vector<std::string> > + AppsModuleTypes; + + static AppsModuleTypes GetApplicationsAllowedModuleTypes( application_manager::ApplicationManager& app_mngr); + + typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap; + + static const std::vector<std::string> buttons_climate(); + + static const std::vector<std::string> buttons_radio(); + + static const ButtonsMap buttons_map(); + + static std::vector<std::string> GetModuleReadOnlyParams( + const std::string& module_type); + + /** + * @brief Combines module ids and alloweds for these ids and fills vector with + * ModuleConsents + * @param module_type Module type as string + * @param module_ids Modules ids which needed consents from driver + * @param allowed Consents for modules + */ + static rc_rpc_types::ModuleIdConsentVector FillModuleConsents( + const std::string& module_type, + const std::vector<std::string>& module_ids, + const std::vector<bool> allowed); + + /** + * @brief Retrieves module ids from SmartObject. + * @param moduleIds Smartobject which contains collection of module ids + * @return Collection of module ids + */ + static std::vector<std::string> RetrieveModuleIds( + const smart_objects::SmartObject& moduleIds); + + /** + * @brief Retrieves module ids consents from SmartObject. + * @param moduleIds Smartobject which contains collection of module ids + * consents + * @return Collection of module ids consents. + */ + static std::vector<bool> RetrieveModuleConsents( + const smart_objects::SmartObject& consents); + + /** + * @brief RemoveRedundantGPSDataFromVIDataMsg removes redundant GPS data + * params from interior vehicle data response message if one contains radio + * station location data + * @param msg_params Params of the interior vehicle data response message + */ + static void RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params); + + /** + * @brief MergeModuleData all keys and values from first parameter and + * update and append keys and values from the second + * @param data1 - initial data + * @param data2 - updated data + * @return updated data1 with data2 keys and values + */ + static smart_objects::SmartObject MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); + + /** + * @brief MergeArray merge two arrays if their elements contain an `id` + * parameter + * @param data1 - initial data + * @param data2 - updated data + * @return updated data1 with any values in data2 if the arrays can be merged, + * otherwise data2 + */ + static smart_objects::SmartObject MergeArray( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); }; -} // rc_rpc_plugin +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index 18014e6270..5ee2e0725c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -46,10 +46,43 @@ const char khmiSettingsControlCapabilities[] = "hmiSettingsControlCapabilities"; const char kseatControlCapabilities[] = "seatControlCapabilities"; // RemoteControlCapabilities constants -const char kRadioControlData[] = "radioControlData"; -const char kClimateControlData[] = "climateControlData"; +const char kServiceArea[] = "serviceArea"; +const char kLocation[] = "location"; +const char kCol[] = "col"; +const char kRow[] = "row"; +const char kLevel[] = "level"; +const char kColspan[] = "colspan"; +const char kRowspan[] = "rowspan"; +const char kLevelspan[] = "levelspan"; + +// SeatLocationCapability constants +const char kCols[] = "columns"; +const char kRows[] = "rows"; +const char kLevels[] = "levels"; +const char kSeats[] = "seats"; +const char kGrid[] = "grid"; +// SeatLocationCapability constants + +const char kAllowMultipleAccess[] = "allowMultipleAccess"; + const char kSupportedLights[] = "supportedLights"; +// ClimateControlCapabilities +const char kFanSpeedAvailable[] = "fanSpeedAvailable"; +const char kCurrentTemperatureAvailable[] = "currentTemperatureAvailable"; +const char kDesiredTemperatureAvailable[] = "desiredTemperatureAvailable"; +const char kAcEnableAvailable[] = "acEnableAvailable"; +const char kCirculateAirEnableAvailable[] = "circulateAirEnableAvailable"; +const char kAutoModeEnableAvailable[] = "autoModeEnableAvailable"; +const char kDefrostZoneAvailable[] = "defrostZoneAvailable"; +const char kDualModeEnableAvailable[] = "dualModeEnableAvailable"; +const char kAcMaxEnableAvailable[] = "acMaxEnableAvailable"; +const char kVentilationModeAvailable[] = "ventilationModeAvailable"; +const char kHeatedSteeringWheelAvailable[] = "heatedSteeringWheelAvailable"; +const char kHeatedWindshieldAvailable[] = "heatedWindshieldAvailable"; +const char kHeatedMirrorsAvailable[] = "heatedMirrorsAvailable"; +const char kHeatedRearWindowAvailable[] = "heatedRearWindowAvailable"; + // LightControlCapabilities const char kName[] = "name"; const char kStatusAvailable[] = "statusAvailable"; @@ -57,8 +90,51 @@ const char kDensityAvailable[] = "densityAvailable"; const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; // RadioControlCapabilities +const char kRadioBandAvailable[] = "radioBandAvailable"; +const char kRadioFrequencyAvailable[] = "radioFrequencyAvailable"; +const char kRdsDataAvailable[] = "rdsDataAvailable"; +const char kAvailableHDsAvailable[] = "availableHDsAvailable"; +const char kHdRadioEnableAvailable[] = "hdRadioEnableAvailable"; +const char kSignalStrengthAvailable[] = "signalStrengthAvailable"; +const char kSignalChangeThresholdAvailable[] = "signalChangeThresholdAvailable"; +const char kRadioEnableAvailable[] = "radioEnableAvailable"; +const char kStateAvailable[] = "stateAvailable"; +const char kSisDataAvailable[] = "sisDataAvailable"; + const char kSiriusxmRadioAvailable[] = "siriusxmRadioAvailable"; -} // strings + +// SeatControlCapabilities +const char kHeatingEnabledAvailable[] = "heatingEnabledAvailable"; +const char kCoolingEnabledAvailable[] = "coolingEnabledAvailable"; +const char kHeatingLevelAvailable[] = "heatingLevelAvailable"; +const char kCoolingLevelAvailable[] = "coolingLevelAvailable"; +const char kHorizontalPositionAvailable[] = "horizontalPositionAvailable"; +const char kVerticalPositionAvailable[] = "verticalPositionAvailable"; +const char kFrontVerticalPositionAvailable[] = "frontVerticalPositionAvailable"; +const char kBackVerticalPositionAvailable[] = "backVerticalPositionAvailable"; +const char kBackTiltAngleAvailable[] = "backTiltAngleAvailable"; +const char kHeadSupportHorizontalPositionAvailable[] = + "headSupportHorizontalPositionAvailable"; +const char kHeadSupportVerticalPositionAvailable[] = + "headSupportVerticalPositionAvailable"; +const char kMassageEnabledAvailable[] = "massageEnabledAvailable"; +const char kMassageModeAvailable[] = "massageModeAvailable"; +const char kMassageCushionFirmnessAvailable[] = + "massageCushionFirmnessAvailable"; +const char kMemoryAvailable[] = "memoryAvailable"; + +// AudioControlCapabilities +const char kSourceAvailable[] = "sourceAvailable"; +const char kKeepContextAvailable[] = "keepContextAvailable"; +const char kVolumeAvailable[] = "volumeAvailable"; +const char kEqualizerAvailable[] = "equalizerAvailable"; + +// HmiSettingsCapabilities +const char kDistanceUnitAvailable[] = "distanceUnitAvailable"; +const char kTemperatureUnitAvailable[] = "temperatureUnitAvailable"; +const char kDisplayModeUnitAvailable[] = "displayModeUnitAvailable"; + +} // namespace strings namespace result_codes { const char kSuccess[] = "SUCCESS"; @@ -84,7 +160,7 @@ const char kWrongLanguage[] = "WRONG_LANGUAGE"; const char kGenericError[] = "GENERIC_ERROR"; const char kUserDisallowed[] = "USER_DISALLOWED"; const char kReadOnly[] = "READ_ONLY"; -} // result_codes +} // namespace result_codes namespace json_keys { const char kParams[] = "params"; @@ -100,12 +176,26 @@ const char kMessage[] = "message"; const char kData[] = "data"; const char kAppId[] = "appID"; const char kCode[] = "code"; -} // json_keys +} // namespace json_keys namespace message_params { const char kName[] = "name"; const char kId[] = "id"; +// RCConsentManager, ResumptionCtrl, GetInteriorVehicleDataConsent request +const char kModuleId[] = "moduleId"; +const char kModuleInfo[] = "moduleInfo"; +const char kAppConsents[] = "appConsents"; +const char kAppConsentList[] = "appConsentsList"; +const char kConsent[] = "consent"; +const char kConsentDate[] = "consentDate"; +const char kModuleConsents[] = "moduleConsents"; +const char kAppId[] = "appId"; +const char kModuleIds[] = "moduleIds"; +const char kMacAddress[] = "macAddress"; +const char kApplications[] = "applications"; +// RCConsentManager, ResumptionCtrl, GetInteriorVehicleDataConsent request + // SetInteriorVehicleData request const char kModuleData[] = "moduleData"; // SetInteriorVehicleData request @@ -152,6 +242,8 @@ const char kBand[] = "band"; const char kRdsData[] = "rdsData"; const char kHdRadioEnable[] = "hdRadioEnable"; const char kAvailableHDs[] = "availableHDs"; +const char kAvailableHdChannels[] = "availableHdChannels"; +const char kAvailableHdChannelsAvailable[] = "availableHdChannelsAvailable"; const char kHdChannel[] = "hdChannel"; const char kSignalStrength[] = "signalStrength"; const char kSignalChangeThreshold[] = "signalChangeThreshold"; @@ -176,8 +268,27 @@ const char kHeatedSteeringWheelEnable[] = "heatedSteeringWheelEnable"; const char kHeatedWindshieldEnable[] = "heatedWindshieldEnable"; const char kHeatedRearWindowEnable[] = "heatedRearWindowEnable"; const char kHeatedMirrorsEnable[] = "heatedMirrorsEnable"; +const char kClimateEnable[] = "climateEnable"; +const char kClimateEnableAvailable[] = "climateEnableAvailable"; // ClimateControlData struct +// SeatControlData +const char kHeatingEnabled[] = "heatingEnabled"; +const char kCoolingEnabled[] = "coolingEnabled"; +const char kHeatingLevele[] = "heatingLevel"; +const char kCoolingLevel[] = "coolingLevel"; +const char kHorizontalPosition[] = "horizontalPosition"; +const char kVerticalPosition[] = "verticalPosition"; +const char kFrontVerticalPosition[] = "frontVerticalPosition"; +const char kBackVerticalPosition[] = "backVerticalPosition"; +const char kBackTiltAngle[] = "backTiltAngle"; +const char kHeadSupportHorizontalPosition[] = "headSupportHorizontalPosition"; +const char kHeadSupportVerticalPosition[] = "headSupportVerticalPosition"; +const char kMassageEnabled[] = "massageEnabled"; +const char kMassageMode[] = "massageMode"; +const char kMassageCushionFirmness[] = "massageCushionFirmness"; +const char kMemory[] = "memory"; + // LightControlData const char kLightState[] = "lightState"; const char kLightStatus[] = "status"; @@ -186,10 +297,15 @@ const char kLightColor[] = "color"; // AudioControlData const char kSource[] = "source"; +const char kVolume[] = "volume"; const char kKeepContext[] = "keepContext"; const char kEqualizerSettings[] = "equalizerSettings"; const char kChannelName[] = "channelName"; +// HmiSettingsControlData +const char kDistanceUnit[] = "distanceUnit"; +const char kDisplayMode[] = "displayMode"; + // ModuleData struct const char kRadioControlData[] = "radioControlData"; const char kClimateControlData[] = "climateControlData"; @@ -203,6 +319,15 @@ const char kHMIAppID[] = "appID"; const char kHmiLevel[] = "hmiLevel"; const char kSysContext[] = "systemContext"; const char kAudioState[] = "audioStreamingState"; + +// Grid struct +const char kCol[] = "col"; +const char kRow[] = "row"; +const char kLevel[] = "level"; +const char kColspan[] = "colspan"; +const char kRowspan[] = "rowspan"; +const char kLevelspan[] = "levelspan"; + } // namespace message_params namespace enums_value { @@ -274,6 +399,6 @@ const char kAskDriver[] = "ASK_DRIVER"; } // namespace enums_value -} // namespace remote_control +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index ae88ed9cc0..1225feb67f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -35,11 +35,17 @@ #include <memory> -#include "application_manager/plugin_manager/rpc_plugin.h" #include "application_manager/command_factory.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" +#include "application_manager/plugin_manager/rpc_plugin.h" #include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/interior_data_manager.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/rc_consent_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" + +namespace resumption { +class LastState; +} namespace rc_rpc_plugin { namespace plugins = application_manager::plugin_manager; @@ -48,22 +54,23 @@ namespace app_mngr = application_manager; class RCRPCPlugin : public plugins::RPCPlugin { public: /** - * @brief Command initialization function - * @param app_manager ApplicationManager - * @param rpc_service RPCService - * @param hmi_capabilities HMICapabilities - * @param policy_handler PolicyHandlerInterface - * @return true in case initialization was succesful, false otherwise. - **/ + * @brief Command initialization function + * @param app_manager ApplicationManager + * @param rpc_service RPCService + * @param hmi_capabilities HMICapabilities + * @param policy_handler PolicyHandlerInterface + * @return true in case initialization was succesful, false otherwise. + **/ bool Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; /** - * @param int32_t command id - * @param CommandSource source - * @return return true if command can be create, else return false - **/ + * @param int32_t command id + * @param CommandSource source + * @return return true if command can be create, else return false + **/ bool IsAbleToProcess( const int32_t function_id, const app_mngr::commands::Command::CommandSource message_source) OVERRIDE; @@ -85,10 +92,10 @@ class RCRPCPlugin : public plugins::RPCPlugin { */ void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) OVERRIDE; /** - * @brief OnApplicationEvent Notifies modules on certain application events - * @param event Event - * @param application Pointer to application struct - */ + * @brief OnApplicationEvent Notifies modules on certain application events + * @param event Event + * @param application Pointer to application struct + */ void OnApplicationEvent(plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) OVERRIDE; @@ -101,13 +108,16 @@ class RCRPCPlugin : public plugins::RPCPlugin { private: application_manager::rpc_service::RPCService* rpc_service_; application_manager::ApplicationManager* app_mngr_; + std::unique_ptr<rc_rpc_plugin::RCConsentManager> rc_consent_manager_; std::unique_ptr<application_manager::CommandFactory> command_factory_; std::unique_ptr<ResourceAllocationManager> resource_allocation_manager_; std::unique_ptr<InteriorDataCache> interior_data_cache_; std::unique_ptr<InteriorDataManager> interior_data_manager_; + std::unique_ptr<RCCapabilitiesManager> rc_capabilities_manager_; }; } // namespace rc_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h new file mode 100644 index 0000000000..3698728aa6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_H + +#include <ctime> +#include <string> +#include <utility> +#include <vector> + +namespace resumption { +class LastState; +} // namespace resumption + +namespace application_manager { +class ApplicationManager; +} // namespace application_manager + +namespace rc_rpc_plugin { +namespace rc_rpc_types { +/** + * @brief Module resource (module_type(first) + module_id(second)) + */ +typedef std::pair<std::string, std::string> ModuleUid; + +/** + * @brief Module consent enum. + */ +enum class ModuleConsent { + NOT_EXISTS = 0, /**< Consent is absent for specified module resource */ + CONSENTED, /**< Module resource is consented */ + NOT_CONSENTED /**< Module resource isn't consented */ +}; + +enum class ModuleConsentState { + NOT_EXISTS = 0, /**< Consent is absent for specified module resource */ + EXPIRED, /**< Module resource is expired */ + ACTIVE /**< Module resource isn't expired */ +}; + +/** + * @brief Module consent + * @param module_id - Module resource for consent + * @param consent - Is module resource consented by driver + * @param date_of_consent - Date, when module resource has been consented (in + * seconds [UNIX time]) + */ +struct ModuleIdConsent { + ModuleUid module_id; + ModuleConsent consent; + std::time_t date_of_consent; +}; + +/** + * @brief ModuleIdConsent collection + */ +typedef std::vector<ModuleIdConsent> ModuleIdConsentVector; +} // namespace rc_rpc_types +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h index 67598b667b..ee0bd11885 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h @@ -35,8 +35,8 @@ #include <string> #include "utils/macro.h" -#include "interfaces/HMI_API.h" #include "application_manager/plugin_manager/rpc_plugin.h" +#include "interfaces/HMI_API.h" #include "rc_rpc_plugin/rc_app_extension.h" namespace rc_rpc_plugin { @@ -66,58 +66,87 @@ namespace NotificationTrigger { * MODULE_ALLOCATION module allocation/deallocation event */ enum eType { APP_REGISTRATION = 0, MODULE_ALLOCATION, RC_STATE_CHANGING }; -} +} // namespace NotificationTrigger + +/** + * Defines result of releasing specified module type resource. + */ +namespace ResourceReleasedState { +/** + * NOT_ALLOCATED Module's resource is not allocated + * IS_ALLOCATED Module's resource is already allocated by + * different application + * IS_RELEASED Module's resource is released. + */ +enum eType { NOT_ALLOCATED = 0, IS_ALLOCATED, IS_RELEASED }; +} // namespace ResourceReleasedState + +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair<std::string, std::string> ModuleUid; /** * @brief Resources defines list of resources */ -typedef std::vector<std::string> Resources; +typedef std::vector<ModuleUid> Resources; class ResourceAllocationManager { public: /** * @brief AcquireResource acquires resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource * @return ALLOWED if resource acquired \ * IN_USE if resource already acquired * ASK_DRIVER if driver confirmation is required */ virtual AcquireResult::eType AcquireResource(const std::string& module_type, + const std::string& module_id, 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 module_id uuid of a resource * @param app_id Application aquired resource before * @param state State to set for resource */ virtual void SetResourceState(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) = 0; /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id uuid of a resource * @return True if free, otherwise - false */ - virtual bool IsResourceFree(const std::string& module_type) const = 0; + virtual bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const = 0; /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource */ virtual void ForceAcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** * @brief OnDriverDisallowed callback for rejecting acquiring resource * @param module_type resource type + * @param module_id uuid of a resource * @param app_id application id */ virtual void OnDriverDisallowed(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** @@ -171,6 +200,42 @@ class ResourceAllocationManager { virtual void set_rc_enabled(const bool value) = 0; + /** + * @brief ReleaseResource Releases resource acquired by application + * @param module_type Module name + * @param module_id uuid of a module + * @param application_id Application id + */ + virtual ResourceReleasedState::eType ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) = 0; + + /** + * @brief SetResourceAquired mark resourse as aquired and process logic of + * changing state of aquired resources + * @param module_type resource name + * @param module_id uuid of a resource + * @param app applicastion that aquire resource + */ + virtual void SetResourceAcquired(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) = 0; + + /** + * @brief Checks if specific resource is already aquired by specific + * application + * @param moduleUid Module resurce (module type + module ID) + * @param app_id Application ID which try to aquire resource + * @return true In case when resource is already aquired by specific + * application + * @return false In case when isn't aquired by specific + * application + */ + virtual bool IsResourceAlreadyAcquiredByApp( + const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id) const = 0; + virtual ~ResourceAllocationManager() {} }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h index b359ee4d29..0fd5449912 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h @@ -32,11 +32,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "application_manager/application_impl.h" #include "rc_rpc_plugin/rc_app_extension.h" -#include "utils/macro.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/lock.h" +#include "utils/macro.h" namespace rc_rpc_plugin { @@ -46,43 +47,52 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { public: ResourceAllocationManagerImpl( application_manager::ApplicationManager& app_mngr, - application_manager::rpc_service::RPCService& rpc_service); + application_manager::rpc_service::RPCService& rpc_service, + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager); ~ResourceAllocationManagerImpl(); /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resourc * @return result of acauiring resources */ AcquireResult::eType AcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) OVERRIDE FINAL; /** * @brief ForceAcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource */ void ForceAcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) FINAL; /** - * @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 - */ + * @brief SetResourceState changes resource state. Resource must be acquired + * beforehand. + * @param module_type Resource to change its state + * @param module_id uuid of a resource + * @param app_id Application aquired resource before + * @param state State to set for resource + */ void SetResourceState(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) FINAL; /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id uuid of a resource * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; void SetAccessMode( const hmi_apis::Common_RCAccessMode::eType access_mode) FINAL; @@ -90,6 +100,7 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { hmi_apis::Common_RCAccessMode::eType GetAccessMode() const FINAL; void OnDriverDisallowed(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) FINAL; /** @@ -118,6 +129,18 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void set_rc_enabled(const bool value) FINAL; + ResourceReleasedState::eType ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) FINAL; + + void SetResourceAcquired(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) FINAL; + + bool IsResourceAlreadyAcquiredByApp(const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id) const FINAL; + private: typedef std::vector<application_manager::ApplicationSharedPtr> Apps; @@ -137,20 +160,23 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { * @brief IsModuleTypeRejected check if current resource was rejected by * driver for current application * @param module_type resource to check + * @param module_id uuid of a resource * @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 std::string& module_id, const uint32_t app_id); /** - * @brief ReleaseResource Releases resource acquired by application + * @brief ReleaseModuleType Releases all resources related to + * the corresponding module type 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); + void ReleaseModuleType(const std::string& module_type, + const uint32_t application_id); /** * @brief GetAcquiredResources Provides resources acquired by particular @@ -161,6 +187,15 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { Resources GetAcquiredResources(const uint32_t application_id) const; /** + * @brief GetAcquiredModuleTypes Provides module types acquired by particular + * application currently + * @param application_id Application id + * @return List of acquired module types by specific application + */ + std::set<std::string> GetAcquiredModuleTypes( + 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 @@ -175,33 +210,38 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void RemoveAppsSubscriptions(const Apps& apps); /** - * @brief SetResourceAquired mark resourse as aquired and process logic of + * @brief SetResourceFree mark resourse as free and process logic of * changing state of aquired resources * @param module_type resource name + * @param module_id uuid of a resource * @param app applicastion that aquire resource */ - void SetResourceAquired(const std::string& module_type, - const uint32_t app_id); + ResourceReleasedState::eType SetResourceFree(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id); /** - * @brief SetResourceFree mark resourse as free and process logic of - * changing state of aquired resources - * @param module_type resource name - * @param app applicastion that aquire resource + * @brief CheckLocation checks if the user's grid is equal to or is within the + * service area of the module, or user location is driver's seat + * @param module module type + module id + * @return true if the user's grid equals to or is within module service + * area or user location is driver's seat, otherwise - false */ - void SetResourceFree(const std::string& module_type, const uint32_t app_id); + bool IsUserLocationValid(ModuleUid& module, + application_manager::ApplicationSharedPtr app); /** * @brief AllocatedResources contains link between resource and application * owning that resource */ - typedef std::map<std::string, uint32_t> AllocatedResources; + + typedef std::map<ModuleUid, 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; + typedef std::map<ModuleUid, ResourceState::eType> ResourcesState; ResourcesState resources_state_; mutable sync_primitives::Lock resources_state_lock_; @@ -210,15 +250,16 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { * driver for application * application_id : [vector of rejected resources] */ - typedef std::map<uint32_t, std::vector<std::string> > RejectedResources; + typedef std::map<uint32_t, std::vector<ModuleUid> > RejectedResources; RejectedResources rejected_resources_for_application_; mutable sync_primitives::Lock rejected_resources_for_application_lock_; hmi_apis::Common_RCAccessMode::eType current_access_mode_; application_manager::ApplicationManager& app_mngr_; application_manager::rpc_service::RPCService& rpc_service_; + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager_; bool is_rc_enabled_; }; -} // rc_rpc_plugin +} // namespace rc_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc index e56f9088bc..a366aa65fa 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc @@ -31,8 +31,8 @@ */ #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h" -#include "rc_rpc_plugin/rc_module_constants.h" #include "application_manager/event_engine/event.h" +#include "rc_rpc_plugin/rc_module_constants.h" namespace rc_rpc_plugin { namespace commands { @@ -53,8 +53,9 @@ void RCGetInteriorVehicleDataResponse::Run() { app_mngr::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); - smart_objects::SmartObject& module_data = (*message_) - [application_manager::strings::msg_params][message_params::kModuleData]; + smart_objects::SmartObject& module_data = + (*message_)[application_manager::strings::msg_params] + [message_params::kModuleData]; if (module_data.keyExists(message_params::kAudioControlData)) { smart_objects::SmartObject& audio_control_data = module_data[message_params::kAudioControlData]; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc index 0117003f11..c6cf1b0d5a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h" +#include "rc_rpc_plugin/rc_module_constants.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,8 +54,9 @@ void RCOnInteriorVehicleDataNotification::Run() { (*message_)[app_mngr::strings::params][app_mngr::strings::function_id] = static_cast<int>(mobile_apis::FunctionID::eType::OnInteriorVehicleDataID); - smart_objects::SmartObject& module_data = (*message_) - [application_manager::strings::msg_params][message_params::kModuleData]; + smart_objects::SmartObject& module_data = + (*message_)[application_manager::strings::msg_params] + [message_params::kModuleData]; if (module_data.keyExists(rc_rpc_plugin::message_params::kAudioControlData)) { smart_objects::SmartObject& audio_control_data = module_data[message_params::kAudioControlData]; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 91cb6cb7ee..45b0d13582 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -31,10 +31,10 @@ */ #include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/interior_data_manager.h" -#include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -59,7 +59,8 @@ RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification( params.hmi_capabilities_, params.policy_handler_) , resource_allocation_manager_(params.resource_allocation_manager_) - , interior_data_manager_(params.interior_data_manager_) {} + , interior_data_manager_(params.interior_data_manager_) + , rc_consent_manager_(params.rc_consent_manager_) {} RCOnRemoteControlSettingsNotification:: ~RCOnRemoteControlSettingsNotification() {} @@ -115,7 +116,8 @@ void RCOnRemoteControlSettingsNotification::Run() { message_params::kAccessMode)) { access_mode = static_cast<hmi_apis::Common_RCAccessMode::eType>( (*message_)[app_mngr::strings::msg_params] - [message_params::kAccessMode].asUInt()); + [message_params::kAccessMode] + .asUInt()); LOG4CXX_DEBUG( logger_, "Setting up access mode : " << AccessModeToString(access_mode)); @@ -131,6 +133,7 @@ void RCOnRemoteControlSettingsNotification::Run() { DisallowRCFunctionality(); resource_allocation_manager_.ResetAllAllocations(); resource_allocation_manager_.set_rc_enabled(false); + rc_consent_manager_.RemoveAllConsents(); } } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_request.cc new file mode 100644 index 0000000000..2f203afc2d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_request.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +RCSetGlobalPropertiesRequest::RCSetGlobalPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : app_mngr::commands::RequestToHMI(message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void RCSetGlobalPropertiesRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +RCSetGlobalPropertiesRequest::~RCSetGlobalPropertiesRequest() {} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_response.cc new file mode 100644 index 0000000000..c31314ec21 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_global_properties_response.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h" + +namespace rc_rpc_plugin { +namespace commands { + +RCSetGlobalPropertiesResponse::RCSetGlobalPropertiesResponse( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void RCSetGlobalPropertiesResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::event_engine::Event event( + hmi_apis::FunctionID::RC_SetGlobalProperties); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +RCSetGlobalPropertiesResponse::~RCSetGlobalPropertiesResponse() {} +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc index 5ce047071c..3adc48dfbf 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc @@ -31,12 +31,13 @@ */ #include "rc_rpc_plugin/commands/mobile/button_press_request.h" +#include "interfaces/MOBILE_API.h" +#include "json/json.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "smart_objects/enum_schema_item.h" -#include "utils/macro.h" -#include "json/json.h" #include "utils/helpers.h" -#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" namespace rc_rpc_plugin { namespace commands { @@ -46,8 +47,6 @@ using namespace message_params; CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") -typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap; - ButtonPressRequest::ButtonPressRequest( const app_mngr::commands::MessageSharedPtr& message, const RCCommandParams& params) @@ -55,146 +54,44 @@ ButtonPressRequest::ButtonPressRequest( 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]; - auto 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; +std::string ButtonPressRequest::GetButtonName() const { + mobile_apis::ButtonName::eType button_name = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[app_mngr::strings::msg_params] + [message_params::kButtonName] + .asUInt()); + const char* str; + const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< + mobile_apis::ButtonName::eType>::EnumToCString(button_name, &str); + return ok ? str : "unknown"; } -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; - } +const mobile_apis::ButtonName::eType ButtonPressRequest::GetButtonId() const { + const auto button_name = GetButtonName(); + static RCHelpers::ButtonsMap btn_map = RCHelpers::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]; } - return true; + return button_id; } void ButtonPressRequest::Execute() { LOG4CXX_AUTO_TRACE(logger_); - - const char* button_name; - ns_smart_device_link::ns_smart_objects:: - EnumConversionHelper<mobile_apis::ButtonName::eType>::EnumToCString( - static_cast<mobile_apis::ButtonName::eType>( - (*message_)[app_mngr::strings::msg_params] - [message_params::kButtonName].asUInt()), - &button_name); - const std::string module_type = ModuleType(); - 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 = - hmi_capabilities_.rc_capability(); 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); + rc_capabilities_manager_.CheckButtonName(module_type, GetButtonName()); + + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + const bool is_module_exists = + rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module); + + const bool button_valid_by_caps = + is_module_exists && + rc_capabilities_manager_.CheckIfButtonExistInRCCaps(GetButtonId()); app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -202,7 +99,9 @@ void ButtonPressRequest::Execute() { (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = app->app_id(); - if (button_name_matches_module_type && button_id_exist_in_caps) { + if (button_name_matches_module_type && button_valid_by_caps) { + (*message_)[app_mngr::strings::msg_params][message_params::kModuleId] = + module_id; SendHMIRequest(hmi_apis::FunctionID::Buttons_ButtonPress, &(*message_)[app_mngr::strings::msg_params], true); @@ -213,11 +112,12 @@ void ButtonPressRequest::Execute() { mobile_apis::Result::INVALID_DATA, "Request module type and button name mismatch!"); } else { - LOG4CXX_WARN(logger_, "Requested button is not exists in capabilities!"); + LOG4CXX_WARN(logger_, + "Requested button or module does not exist in capabilities!"); SetResourceState(module_type, ResourceState::FREE); SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE, - "Requested button is not exists in capabilities!"); + "Requested button or module does not exist in capabilities!"); } } @@ -227,13 +127,15 @@ AcquireResult::eType ButtonPressRequest::AcquireResource( const std::string module_type = ModuleType(); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - return resource_allocation_manager_.AcquireResource(module_type, - app->app_id()); + + return resource_allocation_manager_.AcquireResource( + module_type, ModuleId(), app->app_id()); } -bool ButtonPressRequest::IsResourceFree(const std::string& module_type) const { +bool ButtonPressRequest::IsResourceFree(const std::string& module_type, + const std::string& module_id) const { LOG4CXX_AUTO_TRACE(logger_); - return resource_allocation_manager_.IsResourceFree(module_type); + return resource_allocation_manager_.IsResourceFree(module_type, module_id); } void ButtonPressRequest::SetResourceState(const std::string& module_type, @@ -241,8 +143,9 @@ void ButtonPressRequest::SetResourceState(const std::string& module_type, LOG4CXX_AUTO_TRACE(logger_); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); + resource_allocation_manager_.SetResourceState( - module_type, app->app_id(), state); + module_type, ModuleId(), app->app_id(), state); } void ButtonPressRequest::on_event(const app_mngr::event_engine::Event& event) { @@ -269,22 +172,64 @@ void ButtonPressRequest::on_event(const app_mngr::event_engine::Event& event) { result = false; result_code = mobile_apis::Result::GENERIC_ERROR; } + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + + const rc_rpc_types::ModuleUid resource{module_type, module_id}; + auto app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, ""); + return; + } + + const auto app_id = app->app_id(); + + bool is_resource_acquired = false; + + if (result && !resource_allocation_manager_.IsResourceAlreadyAcquiredByApp( + resource, app_id)) { + resource_allocation_manager_.SetResourceAcquired( + module_type, module_id, app_id); + + is_resource_acquired = true; + } + std::string response_info; GetInfo(message, response_info); - SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(result, result_code, response_info.c_str()); + + if (is_resource_acquired) { + resource_allocation_manager_.SendOnRCStatusNotifications( + NotificationTrigger::MODULE_ALLOCATION, + std::shared_ptr<application_manager::Application>()); + } } -std::string ButtonPressRequest::ModuleType() { - mobile_apis::ModuleType::eType module_type = static_cast< - mobile_apis::ModuleType::eType>( - (*message_)[app_mngr::strings::msg_params][message_params::kModuleType] - .asUInt()); +std::string ButtonPressRequest::ModuleType() const { + mobile_apis::ModuleType::eType module_type = + static_cast<mobile_apis::ModuleType::eType>( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); const char* str; const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); return ok ? str : "unknown"; } +std::string ButtonPressRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kModuleId)) { + return msg_params[message_params::kModuleId].asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc new file mode 100644 index 0000000000..fd661afd5f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_request.cc @@ -0,0 +1,472 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <algorithm> +#include <ctime> +#include <numeric> +#include <vector> + +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_types.h" +#include "smart_objects/enum_schema_item.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; +namespace commands { + +GetInteriorVehicleDataConsentRequest::GetInteriorVehicleDataConsentRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : RCCommandRequest(message, params) {} + +void GetInteriorVehicleDataConsentRequest::Execute() { + LOG4CXX_AUTO_TRACE(logger_); + + auto& msg_params = (*message_)[app_mngr::strings::msg_params]; + + const bool module_ids_exists = + msg_params.keyExists(message_params::kModuleIds); + if (!module_ids_exists) { + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "ModuleIds collection is absent in request message"); + return; + } + + if (msg_params[message_params::kModuleIds].empty()) { + LOG4CXX_DEBUG(logger_, + "ModuleIds collection is empty. Will be add default " + "module_id from capabilities"); + + const auto module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities( + ModuleType()); + + msg_params[message_params::kModuleIds][0] = module_id; + } + + const std::string module_type = ModuleType(); + for (const auto module_id : + *(msg_params[message_params::kModuleIds].asArray())) { + const ModuleUid module(module_type, module_id.asString()); + if (!rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN(logger_, + "Accessing not supported module: " << module_type << " " + << module_id.asString()); + SetResourceState(module_type, ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module data"); + return; + } + } + + smart_objects::SmartObject response_params; + if (GetCalculatedVehicleDataConsent(response_params)) { + LOG4CXX_DEBUG( + logger_, + "No need to send request to HMI. Sending cached consents to mobile"); + SendResponse(true, mobile_apis::Result::SUCCESS, nullptr, &response_params); + return; + } + + (*message_)[application_manager::strings::msg_params] + [application_manager::strings::app_id] = connection_key(); + + hmi_request_consents_ = + smart_objects::SmartObject(response_params[message_params::kAllowed]); + + LOG4CXX_DEBUG( + logger_, "Filtering out module ids with successfully calculated consent"); + + smart_objects::SmartObject hmi_msg_params(msg_params); + auto module_ids_for_consent = + hmi_msg_params[message_params::kModuleIds].asArray(); + module_ids_for_consent->clear(); + + auto module_ids = msg_params[message_params::kModuleIds].asArray(); + for (uint32_t i = 0; i < module_ids->size(); i++) { + // Only add modules whose consent is unknown(needs to be sent to the hmi) + bool is_consent_undefined = + (*hmi_request_consents_.asArray())[i].getType() == + smart_objects::SmartType::SmartType_Null; + if (is_consent_undefined) { + module_ids_for_consent->push_back((*module_ids)[i]); + } + } + + LOG4CXX_DEBUG(logger_, + "Forwarding request to HMI with moduleIds for modules with " + "unknown consent"); + SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent, + (&hmi_msg_params), + true); +} + +void GetInteriorVehicleDataConsentRequest::on_event( + const app_mngr::event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (event.id() != hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent) { + LOG4CXX_ERROR(logger_, "Received wrong event. FunctionID: " << event.id()); + return; + } + + auto temp_response = event.smart_object(); + + auto result_code = + GetMobileResultCode(static_cast<hmi_apis::Common_Result::eType>( + temp_response[app_mngr::strings::params][app_mngr::hmi_response::code] + .asUInt())); + + const bool success_result = + helpers::Compare<mobile_apis::Result::eType, helpers::EQ, helpers::ONE>( + result_code, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS); + + if (!success_result) { + std::string info; + GetInfo(temp_response, info); + SendResponse(false, result_code, info.c_str(), nullptr); + return; + } + + if (!temp_response[app_mngr::strings::msg_params].keyExists( + message_params::kAllowed) || + temp_response[app_mngr::strings::msg_params][message_params::kAllowed] + .empty()) { + std::string info_out = + "Collection of consents is absent in HMI response or empty"; + LOG4CXX_ERROR(logger_, info_out); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, info_out.c_str()); + return; + } + + uint32_t number_of_expected_response_consents = std::accumulate( + hmi_request_consents_.asArray()->begin(), + hmi_request_consents_.asArray()->end(), + uint32_t(0), + [](uint32_t num_consents, smart_objects::SmartObject& consent) { + // Only module ids with valid location consents were sent to the hmi + bool is_consent_undefined = + consent.getType() == smart_objects::SmartType::SmartType_Null; + return (is_consent_undefined) ? num_consents + 1 : num_consents; + }); + + const auto response_consents = + temp_response[app_mngr::strings::msg_params][message_params::kAllowed] + .asArray(); + + if (number_of_expected_response_consents != response_consents->size()) { + std::string info_out = + "HMI response has incorrect number of consents expected: " + + std::to_string(number_of_expected_response_consents) + + ", actual: " + std::to_string(response_consents->size()); + LOG4CXX_ERROR(logger_, info_out); + SendResponse(false, mobile_apis::Result::GENERIC_ERROR, info_out.c_str()); + return; + } + + LOG4CXX_DEBUG(logger_, + "Adding back filtered out module ids for response to mobile"); + uint32_t response_consents_counter = 0; + for (auto& consent : *(hmi_request_consents_.asArray())) { + // Only modify consent for moduleIds allowed by location constraints + bool is_consent_undefined = + consent.getType() == smart_objects::SmartType::SmartType_Null; + if (is_consent_undefined) { + consent = (*response_consents)[response_consents_counter]; + response_consents_counter++; + } + } + + temp_response[app_mngr::strings::msg_params][message_params::kAllowed] = + hmi_request_consents_; + + const auto hmi_response = temp_response; + std::string response_info; + const bool result_of_saving = SaveModuleIdConsents( + response_info, hmi_response[app_mngr::strings::msg_params]); + + if (!result_of_saving) { + LOG4CXX_DEBUG(logger_, "Consent saving failed"); + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, response_info.c_str()); + return; + } + + smart_objects::SmartObject response_params = + hmi_response[app_mngr::strings::msg_params]; + std::string info; + GetInfo(hmi_response, info); + SendResponse(success_result, result_code, info.c_str(), &response_params); +} + +std::string GetInteriorVehicleDataConsentRequest::ModuleType() const { + mobile_apis::ModuleType::eType module_type = + static_cast<mobile_apis::ModuleType::eType>( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); + + const char* str; + const bool ok = smart_objects::EnumConversionHelper< + mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); + return ok ? str : "unknown"; +} + +std::string GetInteriorVehicleDataConsentRequest::ModuleId() const { + return std::string(); +} + +GetInteriorVehicleDataConsentRequest::~GetInteriorVehicleDataConsentRequest() {} + +bool GetInteriorVehicleDataConsentRequest::IsUserLocationValid( + const ModuleUid& module_uid) const { + LOG4CXX_AUTO_TRACE(logger_); + + if (!rc_capabilities_manager_.IsSeatLocationCapabilityProvided()) { + return true; + } + const auto app_ptr = application_manager_.application(connection_key()); + const auto extension = RCHelpers::GetRCExtension(*app_ptr); + const auto module_service_area = + rc_capabilities_manager_.GetModuleServiceArea(module_uid); + const auto user_location = extension->GetUserLocation(); + const auto driver = + rc_capabilities_manager_.GetDriverLocationFromSeatLocationCapability(); + const bool is_driver = (user_location == driver); + if (is_driver || user_location.IntersectionExists(module_service_area)) { + return true; + } + return false; +} + +rc_rpc_types::ModuleConsent +GetInteriorVehicleDataConsentRequest::GetModuleConsentByAccessMode( + const ModuleUid& module_uid, + const hmi_apis::Common_RCAccessMode::eType access_mode) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto get_auto_allow_consent = [](const ModuleUid& module_uid) { + return rc_rpc_types::ModuleConsent::CONSENTED; + }; + + auto get_auto_deny_consent = [this](const ModuleUid& module_uid) { + auto app = application_manager_.application(connection_key()); + const uint32_t app_id = app->app_id(); + const bool is_resource_available = + (resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app_id) == + AcquireResult::ALLOWED); + return (is_resource_available) ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + }; + + auto get_ask_driver_consent = [this](const ModuleUid& module_uid) { + auto app = application_manager_.application(connection_key()); + const std::string policy_app_id = app->policy_app_id(); + const std::string mac_address = app->mac_address(); + + auto consent = rc_consent_manager_.GetModuleConsent( + policy_app_id, mac_address, module_uid); + + if (rc_rpc_types::ModuleConsent::NOT_EXISTS == consent) { + auto acquire_result = resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app->app_id()); + const bool is_resource_available = + (acquire_result == AcquireResult::ALLOWED); + const bool is_resource_rejected = + (acquire_result == AcquireResult::REJECTED); + + if (!is_resource_available && !is_resource_rejected) { + return rc_rpc_types::ModuleConsent::NOT_EXISTS; + } + + return (is_resource_available) + ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + } + + const bool is_consent_allowed = + (rc_rpc_types::ModuleConsent::CONSENTED == consent); + return (is_consent_allowed) ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + }; + + switch (access_mode) { + case hmi_apis::Common_RCAccessMode::AUTO_ALLOW: { + LOG4CXX_DEBUG(logger_, + "Calculating consent for module(" + << module_uid.first << ", " << module_uid.second + << ") in accessMode: AUTO_ALLOW"); + return get_auto_allow_consent(module_uid); + } + case hmi_apis::Common_RCAccessMode::AUTO_DENY: { + LOG4CXX_DEBUG(logger_, + "Calculating consent for module(" + << module_uid.first << ", " << module_uid.second + << ") in accessMode: AUTO_DENY"); + return get_auto_deny_consent(module_uid); + } + case hmi_apis::Common_RCAccessMode::ASK_DRIVER: { + LOG4CXX_DEBUG(logger_, + "Calculating consent for module(" + << module_uid.first << ", " << module_uid.second + << ") in accessMode: ASK_DRIVER"); + return get_ask_driver_consent(module_uid); + } + default: { + LOG4CXX_DEBUG(logger_, + "Unknown accessMode specified. Denying consent for module(" + << module_uid.first << ", " << module_uid.second + << ")"); + return rc_rpc_types::ModuleConsent::NOT_CONSENTED; + } + } +} + +bool GetInteriorVehicleDataConsentRequest::GetCalculatedVehicleDataConsent( + smart_objects::SmartObject& out_response) const { + LOG4CXX_AUTO_TRACE(logger_); + + out_response = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Map); + out_response[message_params::kAllowed] = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Array); + + auto modules_consent_array = out_response[message_params::kAllowed].asArray(); + const auto module_ids = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleIds] + .asArray(); + const std::string module_type = ModuleType(); + bool can_handle_internally = true; + + auto get_disallowed_multiple_access_consent = + [this](const ModuleUid& module_uid) { + auto app = application_manager_.application(connection_key()); + const uint32_t app_id = app->app_id(); + const bool is_resource_available = + (resource_allocation_manager_.AcquireResource( + module_uid.first, module_uid.second, app_id) == + AcquireResult::ALLOWED); + return (is_resource_available) + ? rc_rpc_types::ModuleConsent::CONSENTED + : rc_rpc_types::ModuleConsent::NOT_CONSENTED; + }; + + for (const auto module_id : *(module_ids)) { + const ModuleUid module_uid(module_type, module_id.asString()); + // Check if the user_location is covered by the module's serviceArea + if (!IsUserLocationValid(module_uid)) { + LOG4CXX_DEBUG(logger_, + "User is outside the serviceArea for module(" + << module_uid.first << ", " << module_uid.second + << "). Denying consent"); + modules_consent_array->push_back(smart_objects::SmartObject(false)); + continue; + } + + rc_rpc_types::ModuleConsent module_consent; + + const bool is_multiple_access_allowed = + rc_capabilities_manager_.IsMultipleAccessAllowed(module_uid); + if (!is_multiple_access_allowed) { + LOG4CXX_DEBUG(logger_, + "multipleAccess disallowed for module(" + << module_uid.first << ", " << module_uid.second + << ")"); + module_consent = get_disallowed_multiple_access_consent(module_uid); + modules_consent_array->push_back(smart_objects::SmartObject( + module_consent == rc_rpc_types::ModuleConsent::CONSENTED)); + continue; + } + + const auto access_mode = resource_allocation_manager_.GetAccessMode(); + + module_consent = GetModuleConsentByAccessMode(module_uid, access_mode); + if (module_consent == rc_rpc_types::ModuleConsent::NOT_EXISTS) { + LOG4CXX_DEBUG(logger_, + "Unable to calculate consent for module(" + << module_uid.first << ", " << module_uid.second + << "), should send moduleId to HMI for consent"); + modules_consent_array->push_back(smart_objects::SmartObject()); + can_handle_internally = false; + continue; + } + modules_consent_array->push_back(smart_objects::SmartObject( + module_consent == rc_rpc_types::ModuleConsent::CONSENTED)); + } + return can_handle_internally; +} + +bool GetInteriorVehicleDataConsentRequest::SaveModuleIdConsents( + std::string& info_out, const smart_objects::SmartObject& msg_params) { + LOG4CXX_AUTO_TRACE(logger_); + + const auto& allowed = msg_params[message_params::kAllowed]; + const auto& moduleIds = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleIds]; + + if (allowed.length() != moduleIds.length()) { + info_out = + "The received module_id collection from mobile and received consent " + "collection from HMI are not equal by size."; + LOG4CXX_ERROR(logger_, info_out); + return false; + } + std::string module_type = ModuleType(); + auto module_ids = RCHelpers::RetrieveModuleIds(moduleIds); + auto module_allowed = RCHelpers::RetrieveModuleConsents(allowed); + + auto module_consents = + RCHelpers::FillModuleConsents(module_type, module_ids, module_allowed); + + auto application = application_manager_.application(connection_key()); + if (!application) { + LOG4CXX_ERROR(logger_, + "Application with connection key:" << connection_key() + << " isn't registered"); + return false; + } + std::string policy_app_id = application->policy_app_id(); + const auto mac_address = application->mac_address(); + rc_consent_manager_.SaveModuleConsents( + policy_app_id, mac_address, module_consents); + return true; +} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_response.cc new file mode 100644 index 0000000000..3e197fbdea --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_consent_response.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h" + +namespace rc_rpc_plugin { +namespace commands { + +GetInteriorVehicleDataConsentResponse::GetInteriorVehicleDataConsentResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void GetInteriorVehicleDataConsentResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.GetRPCService().SendMessageToMobile(message_); +} + +GetInteriorVehicleDataConsentResponse:: + ~GetInteriorVehicleDataConsentResponse() {} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 4d12b4f375..10f6303ac9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -31,12 +31,12 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/rc_module_constants.h" +#include "interfaces/MOBILE_API.h" #include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" -#include "interfaces/MOBILE_API.h" namespace rc_rpc_plugin { namespace commands { @@ -50,36 +50,21 @@ GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, const RCCommandParams& params) : RCCommandRequest(message, params) - , excessive_subscription_occured_(false) {} -bool CheckIfModuleTypeExistInCapabilities( - const smart_objects::SmartObject& rc_capabilities, - const std::string& module_type) { - LOG4CXX_AUTO_TRACE(logger_); - const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); - const auto& module_list = RCHelpers::GetModulesList(); - bool is_module_type_valid = false; - for (const auto& module : module_list) { - if (module == module_type) { - if (rc_capabilities.keyExists(mapping(module))) { - is_module_type_valid = true; - break; - } - } - } - return is_module_type_valid; -} - bool GetInteriorVehicleDataRequest::ProcessCapabilities() { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); if (rc_capabilities && - !CheckIfModuleTypeExistInCapabilities(*rc_capabilities, module_type)) { - LOG4CXX_WARN(logger_, "Accessing not supported module data"); + !rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN( + logger_, + "Accessing not supported module: " << module_type << " " << module_id); SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE, @@ -109,6 +94,7 @@ void GetInteriorVehicleDataRequest::FilterDisabledModuleData( module_data[message_params::kHdRadioEnable].asBool() == false) { module_data.erase(message_params::kHdChannel); module_data.erase(message_params::kAvailableHDs); + module_data.erase(message_params::kAvailableHdChannels); module_data.erase(message_params::kSisData); } } @@ -117,14 +103,20 @@ void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( app_mngr::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); - auto data = interior_data_cache_.Retrieve(ModuleType()); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + auto data = interior_data_cache_.Retrieve(module); FilterDisabledModuleData(data); auto response_msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - response_msg_params[message_params::kModuleData][data_mapping(ModuleType())] = + response_msg_params[message_params::kModuleData][data_mapping(module_type)] = data; response_msg_params[message_params::kModuleData] - [message_params::kModuleType] = ModuleType(); + [message_params::kModuleType] = module_type; + + response_msg_params[message_params::kModuleData][message_params::kModuleId] = + module_id; const auto& request_msg_params = (*message_)[app_mngr::strings::msg_params]; LOG4CXX_DEBUG(logger_, @@ -136,7 +128,7 @@ void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( if (request_msg_params[message_params::kSubscribe].asBool()) { auto extension = RCHelpers::GetRCExtension(*app); DCHECK(extension); - extension->SubscribeToInteriorVehicleData(ModuleType()); + extension->SubscribeToInteriorVehicleData(module); } } SendResponse( @@ -144,13 +136,16 @@ void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( if (AppShouldBeUnsubscribed()) { auto extension = RCHelpers::GetRCExtension(*app); DCHECK(extension); - extension->UnsubscribeFromInteriorVehicleData(ModuleType()); + extension->UnsubscribeFromInteriorVehicleData(module); } } bool GetInteriorVehicleDataRequest::CheckRateLimits() { LOG4CXX_AUTO_TRACE(logger_); - return interior_data_manager_.CheckRequestsToHMIFrequency(ModuleType()); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + return interior_data_manager_.CheckRequestsToHMIFrequency(module); } bool GetInteriorVehicleDataRequest::AppShouldBeUnsubscribed() { @@ -166,13 +161,16 @@ bool GetInteriorVehicleDataRequest::TheLastAppShouldBeUnsubscribed( app_mngr::ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); if (AppShouldBeUnsubscribed()) { + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); const auto subscribed_to_module_type = - RCHelpers::AppsSubscribedToModuleType(application_manager_, - ModuleType()); + RCHelpers::AppsSubscribedToModule(application_manager_, module); if (subscribed_to_module_type.size() == 1 && subscribed_to_module_type.front() == app) { LOG4CXX_DEBUG(logger_, - "The last application unsubscribes from " << ModuleType()); + "The last application unsubscribes from " + << module_type << " " << module_id); return true; } } @@ -188,9 +186,12 @@ void GetInteriorVehicleDataRequest::Execute() { app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); if (TheLastAppShouldBeUnsubscribed(app) || - !interior_data_cache_.Contains(ModuleType())) { + !interior_data_cache_.Contains(module)) { if (HasRequestExcessiveSubscription()) { excessive_subscription_occured_ = true; is_subscribed = @@ -203,7 +204,9 @@ void GetInteriorVehicleDataRequest::Execute() { SendResponse(false, mobile_apis::Result::REJECTED); return; } - interior_data_manager_.StoreRequestToHMITime(ModuleType()); + interior_data_manager_.StoreRequestToHMITime(module); + (*message_)[app_mngr::strings::msg_params][message_params::kModuleId] = + ModuleId(); SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); @@ -241,20 +244,32 @@ void GetInteriorVehicleDataRequest::on_event( } if (result) { + if (!IsModuleIdProvided(hmi_response)) { + LOG4CXX_WARN(logger_, + "conditional mandatory parameter " + << message_params::kModuleId + << " missed in hmi response"); + result = false; + result_code = mobile_apis::Result::GENERIC_ERROR; + } app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); DCHECK_OR_RETURN_VOID(app); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (TheLastAppShouldBeUnsubscribed(app)) { - interior_data_cache_.Remove(ModuleType()); + interior_data_cache_.Remove(module); } ProccessSubscription(hmi_response); if (is_subscribed) { const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); const auto module_data = hmi_response[app_mngr::strings::msg_params] - [message_params::kModuleData][data_mapping(ModuleType())]; - interior_data_cache_.Add(ModuleType(), module_data); + [message_params::kModuleData][data_mapping(module_type)]; + interior_data_cache_.Add(module, module_data); } } else { hmi_response[app_mngr::strings::msg_params].erase( @@ -297,10 +312,18 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( static_cast<mobile_apis::ModuleType::eType>( hmi_response[app_mngr::strings::msg_params] [message_params::kModuleData] - [message_params::kModuleType].asUInt()), + [message_params::kModuleType] + .asUInt()), &module_type); + + const std::string module_id = + hmi_response[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleId] + .asString(); + const ModuleUid module(module_type, module_id); + if (excessive_subscription_occured_) { - is_subscribed = extension->IsSubscibedToInteriorVehicleData(module_type); + is_subscribed = extension->IsSubscribedToInteriorVehicleData(module); temp_hmi_response[app_mngr::strings::msg_params] [message_params::kIsSubscribed] = is_subscribed; return; @@ -315,7 +338,7 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( << message_params::kIsSubscribed << " missed in hmi response"); - is_subscribed = extension->IsSubscibedToInteriorVehicleData(module_type); + is_subscribed = extension->IsSubscribedToInteriorVehicleData(module); temp_hmi_response[app_mngr::strings::msg_params] [message_params::kIsSubscribed] = is_subscribed; return; @@ -346,16 +369,21 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( LOG4CXX_TRACE(logger_, "response_subscribe = " << response_subscribe); if (request_subscribe == response_subscribe) { const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (response_subscribe) { LOG4CXX_DEBUG(logger_, "SubscribeToInteriorVehicleData " << app->app_id() << " " - << module_type); - extension->SubscribeToInteriorVehicleData(module_type); + << module_type << " " + << module_id); + extension->SubscribeToInteriorVehicleData(module); } else { LOG4CXX_DEBUG(logger_, "UnsubscribeFromInteriorVehicleData " - << app->app_id() << " " << module_type); - extension->UnsubscribeFromInteriorVehicleData(module_type); + << app->app_id() << " " << module_type << " " + << module_id); + extension->UnsubscribeFromInteriorVehicleData(module); } } } @@ -371,8 +399,12 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() { application_manager_.application(CommandRequestImpl::connection_key()); const auto extension = RCHelpers::GetRCExtension(*app); + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + const bool is_app_already_subscribed = - extension->IsSubscibedToInteriorVehicleData(ModuleType()); + extension->IsSubscribedToInteriorVehicleData(module); const bool app_wants_to_subscribe = (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] .asBool(); @@ -389,16 +421,29 @@ void GetInteriorVehicleDataRequest::RemoveExcessiveSubscription() { (*message_)[app_mngr::strings::msg_params].erase(message_params::kSubscribe); } -std::string GetInteriorVehicleDataRequest::ModuleType() { - mobile_apis::ModuleType::eType module_type = static_cast< - mobile_apis::ModuleType::eType>( - (*message_)[app_mngr::strings::msg_params][message_params::kModuleType] - .asUInt()); +std::string GetInteriorVehicleDataRequest::ModuleType() const { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::ModuleType::eType module_type = + static_cast<mobile_apis::ModuleType::eType>( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); const char* str; const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); return ok ? str : "unknown"; } +std::string GetInteriorVehicleDataRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kModuleId)) { + return msg_params[message_params::kModuleId].asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc index a7572f1d62..b1fa8d6ea0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc @@ -31,6 +31,7 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -49,6 +50,9 @@ GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {} void GetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); + + RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + (*message_)[app_mngr::strings::msg_params]); application_manager_.GetRPCService().SendMessageToMobile(message_); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index 37890b7979..91ecbe77eb 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -31,9 +31,9 @@ */ #include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" @@ -50,31 +50,37 @@ OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification( params.rpc_service_, params.hmi_capabilities_, params.policy_handler_) - , interior_data_cache_(params.interior_data_cache_) {} + , interior_data_cache_(params.interior_data_cache_) + , rc_capabilities_manager_(params.rc_capabilities_manager_) {} OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {} void OnInteriorVehicleDataNotification::AddDataToCache( - const std::string& module_type) { + const ModuleUid& module) { const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); const auto module_data = (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] - [data_mapping(module_type)]; - interior_data_cache_.Add(module_type, module_data); + [data_mapping(module.first)]; + interior_data_cache_.Add(module, module_data); } void OnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + auto apps_subscribed = - RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type); + RCHelpers::AppsSubscribedToModule(application_manager_, module); if (!apps_subscribed.empty()) { - AddDataToCache(module_type); + AddDataToCache(module); } typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); + RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + (*message_)[app_mngr::strings::msg_params]); for (AppPtrs::iterator it = apps.begin(); it != apps.end(); ++it) { DCHECK(*it); application_manager::Application& app = **it; @@ -82,17 +88,36 @@ void OnInteriorVehicleDataNotification::Run() { const auto extension = RCHelpers::GetRCExtension(app); DCHECK(extension); LOG4CXX_TRACE(logger_, - "Check subscription for " - << app.app_id() << "and module type " << module_type); - if (extension->IsSubscibedToInteriorVehicleData(module_type)) { + "Check subscription for " << app.app_id() + << "and module type " << module_type + << " " << module_id); + + if (extension->IsSubscribedToInteriorVehicleData(module)) { (*message_)[app_mngr::strings::params] [app_mngr::strings::connection_key] = app.app_id(); + + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleId] = module_id; + SendNotification(); } } } -std::string OnInteriorVehicleDataNotification::ModuleType() { +std::string OnInteriorVehicleDataNotification::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params[message_params::kModuleData].keyExists( + message_params::kModuleId)) { + return msg_params[message_params::kModuleData][message_params::kModuleId] + .asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + +std::string OnInteriorVehicleDataNotification::ModuleType() const { mobile_apis::ModuleType::eType module_type = static_cast<mobile_apis::ModuleType::eType>( (*message_)[app_mngr::strings::msg_params] diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc new file mode 100644 index 0000000000..e30d7869bd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <string> + +#include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "smart_objects/enum_schema_item.h" + +namespace rc_rpc_plugin { +using namespace application_manager; +namespace commands { + +namespace { +struct ResponseParams { + std::string response_info; + std::string module_type; + std::string module_id; + mobile_apis::Result::eType result_code; + uint32_t app_id; + bool success_result; +}; + +void PrepareResponseResult( + ResponseParams& response_params_out, + rc_rpc_plugin::ResourceReleasedState::eType& released_result) { + std::stringstream ss; + auto info_inserter = [&ss, response_params_out](std::string info) { + ss << "Module [" << response_params_out.module_type << ":" + << response_params_out.module_id << "] " << info; + }; + switch (released_result) { + case rc_rpc_plugin::ResourceReleasedState::eType::IS_RELEASED: { + response_params_out.success_result = true; + response_params_out.result_code = mobile_apis::Result::eType::SUCCESS; + info_inserter("is released successfully."); + break; + } + case rc_rpc_plugin::ResourceReleasedState::eType::IS_ALLOCATED: { + response_params_out.success_result = false; + response_params_out.result_code = mobile_apis::Result::eType::REJECTED; + info_inserter("is allocated to a different application."); + break; + } + case rc_rpc_plugin::ResourceReleasedState::eType::NOT_ALLOCATED: { + response_params_out.success_result = false; + response_params_out.result_code = mobile_apis::Result::eType::IGNORED; + info_inserter("is not allocated to any application."); + break; + } + } + response_params_out.response_info = ss.str(); +} +} // namespace + +ReleaseInteriorVehicleDataModuleRequest:: + ReleaseInteriorVehicleDataModuleRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : RCCommandRequest(message, params) {} + +bool ReleaseInteriorVehicleDataModuleRequest::ProcessCapabilities() { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject* rc_capabilities = + hmi_capabilities_.rc_capability(); + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (rc_capabilities && + !rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN( + logger_, + "Accessing not supported module: " << module_type << " " << module_id); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module"); + return false; + } + return true; +} + +void ReleaseInteriorVehicleDataModuleRequest::Execute() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!ProcessCapabilities()) { + return; + } + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + + 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; + } + + const uint32_t app_id = app->app_id(); + + ResourceReleasedState::eType released_result = + resource_allocation_manager_.ReleaseResource( + module_type, module_id, app_id); + + bool success_result = true; + mobile_apis::Result::eType result_code = mobile_apis::Result::eType::SUCCESS; + std::string response_info; + ResponseParams response_params{response_info, + ModuleType(), + module_id, + result_code, + app_id, + success_result}; + PrepareResponseResult(response_params, released_result); + + if (response_params.success_result) { + resource_allocation_manager_.SendOnRCStatusNotifications( + NotificationTrigger::MODULE_ALLOCATION, app); + } + + LOG4CXX_DEBUG(logger_, + "Resource for module: " + << ModuleType() << " with id: " << module_id + << " was released with result " << std::boolalpha + << response_params.success_result + << " and result_code: " << response_params.result_code); + + SendResponse(response_params.success_result, + response_params.result_code, + response_params.response_info.c_str()); +} + +std::string ReleaseInteriorVehicleDataModuleRequest::ModuleType() const { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::ModuleType::eType module_type = + static_cast<mobile_apis::ModuleType::eType>( + (*message_)[app_mngr::strings::msg_params] + [message_params::kModuleType] + .asUInt()); + + const char* str; + const bool ok = ns_smart_device_link::ns_smart_objects::EnumConversionHelper< + mobile_apis::ModuleType::eType>::EnumToCString(module_type, &str); + return ok ? str : "unknown"; +} + +std::string ReleaseInteriorVehicleDataModuleRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kModuleId)) { + return msg_params[message_params::kModuleId].asString(); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + +ReleaseInteriorVehicleDataModuleRequest:: + ~ReleaseInteriorVehicleDataModuleRequest() {} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_response.cc new file mode 100644 index 0000000000..fae792f143 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_response.cc @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h" + +namespace rc_rpc_plugin { +namespace commands { + +ReleaseInteriorVehicleDataModuleResponse:: + ReleaseInteriorVehicleDataModuleResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} + +void ReleaseInteriorVehicleDataModuleResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.GetRPCService().SendMessageToMobile(message_); +} + +ReleaseInteriorVehicleDataModuleResponse:: + ~ReleaseInteriorVehicleDataModuleResponse() {} + +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index edc45670ce..c3e5e807d7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -31,116 +31,20 @@ */ #include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" +#include "interfaces/MOBILE_API.h" +#include "json/json.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_helpers.h" #include "smart_objects/enum_schema_item.h" -#include "utils/macro.h" -#include "json/json.h" #include "utils/helpers.h" -#include "interfaces/MOBILE_API.h" +#include "utils/macro.h" namespace rc_rpc_plugin { 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); - module_ro_params.push_back(kSisData); - } else if (enums_value::kLight == module_type) { - module_ro_params.push_back(kLightStatus); - } - - return module_ro_params; -} - -const std::map<std::string, std::string> GetLightCapabilitiesMapping() { - std::map<std::string, std::string> mapping = { - {message_params::kId, strings::kName}, - {message_params::kLightStatus, strings::kStatusAvailable}, - {message_params::kLightDensity, strings::kDensityAvailable}, - {message_params::kLightColor, strings::kRGBColorSpaceAvailable}}; - return mapping; -} - -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"; - mapping["heatedSteeringWheelEnable"] = "heatedSteeringWheelAvailable"; - mapping["heatedWindshieldEnable"] = "heatedWindshieldAvailable"; - mapping["heatedMirrorsEnable"] = "heatedMirrorsAvailable"; - mapping["heatedRearWindowEnable"] = "heatedRearWindowAvailable"; - - // radio - mapping["band"] = "radioBandAvailable"; - mapping["frequencyInteger"] = "radioFrequencyAvailable"; - mapping["frequencyFraction"] = "radioFrequencyAvailable"; - mapping["rdsData"] = "rdsDataAvailable"; - mapping["availableHDs"] = "availableHDsAvailable"; - mapping["hdChannel"] = "availableHDsAvailable"; - mapping["hdRadioEnable"] = "hdRadioEnableAvailable"; - mapping["signalStrength"] = "signalStrengthAvailable"; - mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable"; - mapping["radioEnable"] = "radioEnableAvailable"; - mapping["state"] = "stateAvailable"; - mapping["sisData"] = "sisDataAvailable"; - - // seat - mapping["heatingEnabled"] = "heatingEnabledAvailable"; - mapping["coolingEnabled"] = "coolingEnabledAvailable"; - mapping["heatingLevel"] = "heatingLevelAvailable"; - mapping["coolingLevel"] = "coolingLevelAvailable"; - mapping["horizontalPosition"] = "horizontalPositionAvailable"; - mapping["verticalPosition"] = "verticalPositionAvailable"; - mapping["frontVerticalPosition"] = "frontVerticalPositionAvailable"; - mapping["backVerticalPosition"] = "backVerticalPositionAvailable"; - mapping["backTiltAngle"] = "backTiltAngleAvailable"; - mapping["headSupportHorizontalPosition"] = - "headSupportHorizontalPositionAvailable"; - mapping["headSupportVerticalPosition"] = - "headSupportVerticalPositionAvailable"; - mapping["massageEnabled"] = "massageEnabledAvailable"; - mapping["massageMode"] = "massageModeAvailable"; - mapping["massageCushionFirmness"] = "massageCushionFirmnessAvailable"; - mapping["memory"] = "memoryAvailable"; - - // audio - mapping["source"] = "sourceAvailable"; - mapping["keepContext"] = "keepContextAvailable"; - mapping["volume"] = "volumeAvailable"; - mapping["equalizerSettings"] = "equalizerAvailable"; - - // hmi settings - mapping["distanceUnit"] = "distanceUnitAvailable"; - mapping["temperatureUnit"] = "temperatureUnitAvailable"; - mapping["displayMode"] = "displayModeUnitAvailable"; - - return mapping; -} -} // namespace - CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( @@ -150,250 +54,6 @@ SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest( SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {} -const std::string LightName(const smart_objects::SmartObject& light_name) { - const char* name; - const bool ok = ns_smart_device_link::ns_smart_objects:: - EnumConversionHelper<mobile_apis::LightName::eType>::EnumToCString( - static_cast<mobile_apis::LightName::eType>(light_name.asUInt()), - &name); - return ok ? name : "unknown"; -} - -/** - * @brief Check whether the parameter exist in capabilities - * @param smart object of capabilities - * @param mapping - map of module data and capabilities - * @param request_parameter - string - * @param switched_off_result - ref of mobile_apis::Result - * @return success if parameter exist in capabilities missedParam otherwise - */ -capabilitiesStatus GetItemCapability( - const smart_objects::SmartObject& capabilities, - const std::map<std::string, std::string>& mapping, - const std::string& request_parameter, - const mobile_apis::Result::eType& switched_off_result) { - const auto it = mapping.find(request_parameter); - - if (it == mapping.end()) { - LOG4CXX_DEBUG(logger_, - "Parameter " << request_parameter - << " doesn't exist in capabilities."); - return capabilitiesStatus::missedParam; - } - - const std::string& caps_key = it->second; - - LOG4CXX_DEBUG(logger_, - "Checking request parameter " - << request_parameter - << " with capabilities. Appropriate key is " << caps_key); - - if (!capabilities.keyExists(caps_key)) { - LOG4CXX_DEBUG(logger_, - "Capability " << caps_key - << " is missed in RemoteControl capabilities"); - return capabilitiesStatus::missedParam; - } - - if (!capabilities[caps_key].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is switched off in RemoteControl capabilities"); - capabilitiesStatus status = capabilitiesStatus::missedParam; - if (mobile_apis::Result::READ_ONLY == switched_off_result) { - status = capabilitiesStatus::readOnly; - } - return status; - } - - return capabilitiesStatus::success; -} - -/** - * @brief Check whether the cpabilities for light allowed - * @param smart object of capabilities - * @param smart object of control_data - * @return pair of state and capability status - ModuleCapability - */ -ModuleCapability GetLightDataCapabilities( - const smart_objects::SmartObject& capabilities, - const smart_objects::SmartObject& control_data) { - LOG4CXX_AUTO_TRACE(logger_); - std::map<std::string, std::string> mapping = GetLightCapabilitiesMapping(); - - for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { - const std::string& request_parameter = it->first; - - if (message_params::kId == request_parameter) { - continue; - } - - const capabilitiesStatus status_item_capability = - GetItemCapability(capabilities, - mapping, - request_parameter, - mobile_apis::Result::READ_ONLY); - - if (capabilitiesStatus::success != status_item_capability) { - return std::make_pair(message_params::kLightState, - status_item_capability); - } - } - - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @brief Check whether the light name exists in capabilities - * @param smart object of capabilities_status - * @param smart object of light_data - * @return pair of state and capability status - ModuleCapability - */ -ModuleCapability GetLightNameCapabilities( - const smart_objects::SmartObject& capabilities_status, - const smart_objects::SmartObject& light_data) { - LOG4CXX_AUTO_TRACE(logger_); - auto it = capabilities_status.asArray()->begin(); - for (; it != capabilities_status.asArray()->end(); ++it) { - const smart_objects::SmartObject& so = *it; - const int64_t current_id = so[message_params::kName].asInt(); - if (current_id == light_data[message_params::kId].asInt()) { - return GetLightDataCapabilities(so, light_data); - } - } - LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); - return std::make_pair(message_params::kLightState, - capabilitiesStatus::missedLightName); -} - -ModuleCapability GetRadioBandByCapabilities( - const smart_objects::SmartObject& capabilities_status, - const smart_objects::SmartObject& request_parameter) { - mobile_apis::RadioBand::eType radio_band = - static_cast<mobile_apis::RadioBand::eType>(request_parameter.asUInt()); - if (mobile_apis::RadioBand::XM == radio_band) { - if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) { - LOG4CXX_DEBUG(logger_, - "Capability " - << strings::kSiriusxmRadioAvailable - << " is missed in RemoteControl capabilities"); - return std::make_pair(strings::kSiriusxmRadioAvailable, - capabilitiesStatus::missedParam); - } - if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << strings::kSiriusxmRadioAvailable - << " is switched off in RemoteControl capabilities"); - return std::make_pair(strings::kSiriusxmRadioAvailable, - capabilitiesStatus::missedParam); - } - } - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @brief Check whether the exists light data related to correspondent - * capabilities - * @param smart object of capabilities - * @param smart object of control_data - * @return pair of state and capability status - ModuleCapability - */ -ModuleCapability GetControlDataCapabilities( - const smart_objects::SmartObject& capabilities, - const smart_objects::SmartObject& control_data) { - LOG4CXX_AUTO_TRACE(logger_); - std::map<std::string, std::string> mapping = - GetModuleDataToCapabilitiesMapping(); - - for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { - const std::string& request_parameter = it->first; - if (message_params::kId == request_parameter) { - continue; - } - if (message_params::kLightState == request_parameter) { - auto light_data = control_data[request_parameter].asArray()->begin(); - ModuleCapability light_capability = - std::make_pair("", capabilitiesStatus::success); - - for (; light_data != control_data[request_parameter].asArray()->end(); - ++light_data) { - light_capability = GetLightNameCapabilities( - capabilities[strings::kSupportedLights], *light_data); - - if (capabilitiesStatus::success != light_capability.second) { - return light_capability; - } - } - - return light_capability; - } - if (message_params::kBand == request_parameter) { - ModuleCapability radio_capability = GetRadioBandByCapabilities( - capabilities, control_data[request_parameter]); - if (capabilitiesStatus::success != radio_capability.second) { - return radio_capability; - } - } - - const capabilitiesStatus status_item_capability = - GetItemCapability(capabilities, - mapping, - request_parameter, - mobile_apis::Result::UNSUPPORTED_RESOURCE); - - if (capabilitiesStatus::success != status_item_capability) { - return std::make_pair("", status_item_capability); - } - } - - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @brief Check whether rc module data capabilities are presented - * @param smart object of rc_capabilities - * @param smart object of module_data - * @return pair of state and capability status - ModuleCapability - */ -ModuleCapability GetModuleDataCapabilities( - const smart_objects::SmartObject& rc_capabilities, - const smart_objects::SmartObject& module_data) { - LOG4CXX_AUTO_TRACE(logger_); - - const auto& all_module_types = RCHelpers::GetModulesList(); - const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); - const auto& get_capabilities_key = - RCHelpers::GetModuleTypeToCapabilitiesMapping(); - ModuleCapability module_data_capabilities = - std::make_pair("", capabilitiesStatus::missedParam); - - for (const auto& module_type : all_module_types) { - const auto module_data_key = get_module_data_key(module_type); - const auto capabilities_key = get_capabilities_key(module_type); - if (module_data.keyExists(module_data_key)) { - if (!rc_capabilities.keyExists(capabilities_key)) { - LOG4CXX_DEBUG(logger_, module_data_key << " capabilities not present"); - return module_data_capabilities; - } - const smart_objects::SmartObject& caps = - rc_capabilities[capabilities_key]; - - if (message_params::kHmiSettingsControlData == module_data_key || - message_params::kLightControlData == module_data_key) { - module_data_capabilities = - GetControlDataCapabilities(caps, module_data[module_data_key]); - } else { - module_data_capabilities = - GetControlDataCapabilities(caps[0], module_data[module_data_key]); - } - } - } - - return module_data_capabilities; -} - /** * @brief Clears unrelated module data parameters * @param module type in request @@ -403,7 +63,7 @@ ModuleCapability GetModuleDataCapabilities( bool ClearUnrelatedModuleData(const std::string& module_type, smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& all_module_types = RCHelpers::GetModuleTypesList(); const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); bool module_type_and_data_match = false; for (const auto& type : all_module_types) { @@ -419,7 +79,7 @@ bool ClearUnrelatedModuleData(const std::string& module_type, } mobile_apis::Result::eType PrepareResultCodeAndInfo( - const ModuleCapability module_data_capabilities, std::string& info) { + const ModuleTypeCapability module_data_capabilities, std::string& info) { mobile_apis::Result::eType result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; if (message_params::kLightState == module_data_capabilities.first) { @@ -455,25 +115,35 @@ void SetInteriorVehicleDataRequest::Execute() { const std::string module_type = ModuleType(); if (ClearUnrelatedModuleData(module_type, module_data)) { - const smart_objects::SmartObject* rc_capabilities = - hmi_capabilities_.rc_capability(); - ModuleCapability module_data_capabilities; + const std::string module_id = ModuleId(); + const ModuleUid module(module_type, module_id); + if (!rc_capabilities_manager_.CheckIfModuleExistsInCapabilities(module)) { + LOG4CXX_WARN(logger_, + "Accessing not supported module: " << module_type << " " + << module_id); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module data"); + return; + } - if (rc_capabilities) { - module_data_capabilities = - GetModuleDataCapabilities(*rc_capabilities, module_data); + ModuleTypeCapability module_data_capabilities; + module_data_capabilities = + rc_capabilities_manager_.GetModuleDataCapabilities(module_data, + module_id); - if (capabilitiesStatus::success != module_data_capabilities.second) { - SetResourceState(ModuleType(), ResourceState::FREE); - std::string info; - mobile_apis::Result::eType result = - PrepareResultCodeAndInfo(module_data_capabilities, info); - SendResponse(false, result, info.c_str()); - return; - } + if (capabilitiesStatus::success != module_data_capabilities.second) { + SetResourceState(ModuleType(), ResourceState::FREE); + std::string info; + mobile_apis::Result::eType result = + PrepareResultCodeAndInfo(module_data_capabilities, info); + SendResponse(false, result, info.c_str()); + return; } - if (AreAllParamsReadOnly(module_data)) { + if (rc_capabilities_manager_.AreAllParamsReadOnly(module_data, + module_type)) { LOG4CXX_WARN(logger_, "All request params in module type are READ ONLY!"); SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(false, @@ -484,7 +154,8 @@ void SetInteriorVehicleDataRequest::Execute() { module_data_capabilities = std::make_pair("", capabilitiesStatus::success); - if (AreReadOnlyParamsPresent(module_data, module_data_capabilities)) { + if (rc_capabilities_manager_.AreReadOnlyParamsPresent( + module_data, module_type, module_data_capabilities)) { LOG4CXX_DEBUG(logger_, "Request module type has READ ONLY parameters"); if (enums_value::kLight == module_data_capabilities.first && @@ -525,17 +196,20 @@ void SetInteriorVehicleDataRequest::Execute() { return; } else if (module_data[message_params::kAudioControlData].keyExists( message_params::kKeepContext)) { - app->set_keep_context( - module_data[message_params::kAudioControlData] - [message_params::kKeepContext].asBool()); + app->set_keep_context(module_data[message_params::kAudioControlData] + [message_params::kKeepContext] + .asBool()); } } + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kModuleId] = module_id; SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); } else { LOG4CXX_WARN(logger_, "Request module type & data mismatch!"); + SetResourceState(ModuleType(), ResourceState::FREE); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Request module type & data mismatch!"); @@ -564,13 +238,45 @@ void SetInteriorVehicleDataRequest::on_event( mobile_apis::Result::WARNINGS); smart_objects::SmartObject response_params; + bool is_resource_acquired = false; + if (result) { + if (!IsModuleIdProvided(hmi_response)) { + LOG4CXX_WARN(logger_, + "conditional mandatory parameter " + << message_params::kModuleId + << " missed in hmi response"); + result = false; + result_code = mobile_apis::Result::GENERIC_ERROR; + } response_params = hmi_response[app_mngr::strings::msg_params]; if (enums_value::kAudio == ModuleType()) { CheckAudioSource(( *message_)[app_mngr::strings::msg_params][message_params::kModuleData] [message_params::kAudioControlData]); } + + const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); + + const rc_rpc_types::ModuleUid resource{module_type, module_id}; + auto app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, ""); + return; + } + + const auto app_id = app->app_id(); + + if (!resource_allocation_manager_.IsResourceAlreadyAcquiredByApp(resource, + app_id)) { + resource_allocation_manager_.SetResourceAcquired( + module_type, module_id, app_id); + is_resource_acquired = true; + } + } else { app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -580,21 +286,12 @@ void SetInteriorVehicleDataRequest::on_event( GetInfo(hmi_response, info); SendResponse( result, result_code, info.c_str(), result ? &response_params : nullptr); -} - -const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( - const smart_objects::SmartObject& module_data) { - const std::string module_type = ModuleType(); - const auto& all_module_types = RCHelpers::GetModulesList(); - const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); - for (const auto& type : all_module_types) { - if (type == module_type) { - return module_data[data_mapping(type)]; - } + if (is_resource_acquired) { + resource_allocation_manager_.SendOnRCStatusNotifications( + NotificationTrigger::MODULE_ALLOCATION, + std::shared_ptr<application_manager::Application>()); } - NOTREACHED(); - return module_data[0]; } void SetInteriorVehicleDataRequest::CheckAudioSource( @@ -606,131 +303,12 @@ void SetInteriorVehicleDataRequest::CheckAudioSource( } } -bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( - const smart_objects::SmartObject& module_data) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& module_type_params = - ControlData(module_data); - auto it = module_type_params.map_begin(); - std::vector<std::string> ro_params = GetModuleReadOnlyParams(ModuleType()); - for (; it != module_type_params.map_end(); ++it) { - if (!helpers::in_range(ro_params, it->first)) { - return false; - } - } - - LOG4CXX_DEBUG(logger_, "All params are ReadOnly"); - return true; -} - -bool CheckReadOnlyParamsForAudio( - const smart_objects::SmartObject& module_type_params) { - if (module_type_params.keyExists(message_params::kEqualizerSettings)) { - const auto& equalizer_settings = - module_type_params[message_params::kEqualizerSettings]; - auto it = equalizer_settings.asArray()->begin(); - - for (; it != equalizer_settings.asArray()->end(); ++it) { - if (it->keyExists(message_params::kChannelName)) { - LOG4CXX_DEBUG(logger_, - "READ ONLY parameter. ChannelName = " - << (*it)[message_params::kChannelName].asString()); - return true; - } - } - } - - return false; -} - -bool CheckReadOnlyParamsForLight( - const smart_objects::SmartObject& module_type_params) { - if (module_type_params.keyExists(message_params::kLightState)) { - const auto& light_state = module_type_params[message_params::kLightState]; - auto it = light_state.asArray()->begin(); - - for (; it != light_state.asArray()->end(); ++it) { - if (it->keyExists(message_params::kLightStatus)) { - const mobile_apis::LightStatus::eType light_status = - static_cast<mobile_apis::LightStatus::eType>( - (*it)[message_params::kLightStatus].asUInt()); - - if (helpers::Compare<mobile_apis::LightStatus::eType, - helpers::EQ, - helpers::ONE>(light_status, - mobile_apis::LightStatus::RAMP_UP, - mobile_apis::LightStatus::RAMP_DOWN, - mobile_apis::LightStatus::UNKNOWN, - mobile_apis::LightStatus::INVALID)) { - LOG4CXX_DEBUG(logger_, - "READ ONLY parameter. Status = " - << (*it)[message_params::kLightStatus].asInt()); - return true; - } - } - } - } - - return false; -} - -bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent( - const smart_objects::SmartObject& module_data, - ModuleCapability& module_data_capabilities) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& module_type_params = - ControlData(module_data); - const std::string module_type = ModuleType(); - - if (enums_value::kAudio == module_type) { - return CheckReadOnlyParamsForAudio(module_type_params); - } - - if (enums_value::kLight == module_type) { - const bool result = CheckReadOnlyParamsForLight(module_type_params); - - if (result) { - module_data_capabilities = - std::make_pair(module_type, capabilitiesStatus::readOnly); - } - - return result; - } - - const std::vector<std::string> ro_params = - GetModuleReadOnlyParams(module_type); - auto it = module_type_params.map_begin(); - - for (; it != module_type_params.map_end(); ++it) { - if (helpers::in_range(ro_params, it->first)) { - return true; - } - } - - return false; -} - void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& module_type_params = - ControlData(module_data); const std::string module_type = ModuleType(); - std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type); - - for (auto& it : ro_params) { - if (module_type_params.keyExists(it)) { - if (enums_value::kClimate == module_type) { - module_data[message_params::kClimateControlData].erase(it); - } else if (enums_value::kRadio == module_type) { - module_data[message_params::kRadioControlData].erase(it); - } else { - continue; - } - - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); - } - } + const auto& module_type_params = + rc_capabilities_manager_.ControlDataForType(module_data, module_type); if (enums_value::kAudio == module_type) { auto& equalizer_settings = module_data[message_params::kAudioControlData] @@ -745,9 +323,20 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( } } } + + std::vector<std::string> ro_params = + RCHelpers::GetModuleReadOnlyParams(module_type); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + for (const auto& param : ro_params) { + if (module_type_params.keyExists(param)) { + module_data[data_mapping(module_type)].erase(param); + LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << param); + } + } } -std::string SetInteriorVehicleDataRequest::ModuleType() { +std::string SetInteriorVehicleDataRequest::ModuleType() const { + LOG4CXX_AUTO_TRACE(logger_); mobile_apis::ModuleType::eType module_type = static_cast<mobile_apis::ModuleType::eType>( (*message_)[app_mngr::strings::msg_params] @@ -759,19 +348,40 @@ std::string SetInteriorVehicleDataRequest::ModuleType() { return ok ? str : "unknown"; } +std::string SetInteriorVehicleDataRequest::ModuleId() const { + LOG4CXX_AUTO_TRACE(logger_); + auto msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params[message_params::kModuleData].keyExists( + message_params::kModuleId)) { + return msg_params[message_params::kModuleData][message_params::kModuleId] + .asString(); + } + if (enums_value::kSeat == ModuleType()) { + const auto id = static_cast<mobile_apis::SupportedSeat::eType>( + msg_params[message_params::kModuleData] + [message_params::kSeatControlData][message_params::kId] + .asUInt()); + return rc_capabilities_manager_.GetModuleIdForSeatLocation(id); + } + const std::string module_id = + rc_capabilities_manager_.GetDefaultModuleIdFromCapabilities(ModuleType()); + return module_id; +} + AcquireResult::eType SetInteriorVehicleDataRequest::AcquireResource( const app_mngr::commands::MessageSharedPtr& message) { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - return resource_allocation_manager_.AcquireResource(module_type, - app->app_id()); + + return resource_allocation_manager_.AcquireResource( + module_type, ModuleId(), app->app_id()); } bool SetInteriorVehicleDataRequest::IsResourceFree( - const std::string& module_type) const { - return resource_allocation_manager_.IsResourceFree(module_type); + const std::string& module_type, const std::string& module_id) const { + return resource_allocation_manager_.IsResourceFree(module_type, module_id); } void SetInteriorVehicleDataRequest::SetResourceState( @@ -780,7 +390,7 @@ void SetInteriorVehicleDataRequest::SetResourceState( app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); resource_allocation_manager_.SetResourceState( - module_type, app->app_id(), state); + module_type, ModuleId(), app->app_id(), state); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index c24529d720..885c5ac0dd 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -31,11 +31,15 @@ */ #include "rc_rpc_plugin/commands/rc_command_request.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "application_manager/message_helper.h" +#include <sstream> #include "application_manager/hmi_interfaces.h" -#include "smart_objects/enum_schema_item.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "smart_objects/enum_schema_item.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") @@ -55,7 +59,9 @@ RCCommandRequest::RCCommandRequest( , auto_allowed_(false) , resource_allocation_manager_(params.resource_allocation_manager_) , interior_data_cache_(params.interior_data_cache_) - , interior_data_manager_(params.interior_data_manager_) {} + , interior_data_manager_(params.interior_data_manager_) + , rc_capabilities_manager_(params.rc_capabilities_manager_) + , rc_consent_manager_(params.rc_consent_manager_) {} RCCommandRequest::~RCCommandRequest() {} @@ -100,6 +106,14 @@ rc_rpc_plugin::TypeAccess RCCommandRequest::CheckModule( : rc_rpc_plugin::TypeAccess::kDisallowed; } +bool RCCommandRequest::IsModuleIdProvided( + const smart_objects::SmartObject& hmi_response) const { + LOG4CXX_AUTO_TRACE(logger_); + return hmi_response[app_mngr::strings::msg_params] + [message_params::kModuleData] + .keyExists(message_params::kModuleId); +} + void RCCommandRequest::SendDisallowed(rc_rpc_plugin::TypeAccess access) { LOG4CXX_AUTO_TRACE(logger_); std::string info; @@ -143,6 +157,15 @@ void RCCommandRequest::Run() { "Remote control is disabled by user"); return; } + auto rc_capabilities = hmi_capabilities_.rc_capability(); + if (!rc_capabilities || rc_capabilities->empty()) { + LOG4CXX_WARN(logger_, "Accessing not supported module: " << ModuleType()); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Accessing not supported module"); + return; + } if (CheckDriverConsent()) { if (AcquireResources()) { @@ -157,8 +180,9 @@ void RCCommandRequest::Run() { bool RCCommandRequest::AcquireResources() { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); - if (!IsResourceFree(module_type)) { + if (!IsResourceFree(module_type, module_id)) { LOG4CXX_WARN(logger_, "Resource is busy."); SendResponse(false, mobile_apis::Result::IN_USE, ""); return false; @@ -175,7 +199,7 @@ bool RCCommandRequest::AcquireResources() { return false; } case AcquireResult::ASK_DRIVER: { - SendGetUserConsent(module_type); + ProcessAskDriverMode(module_type, module_id); return false; } case AcquireResult::REJECTED: { @@ -203,6 +227,7 @@ void RCCommandRequest::ProcessAccessResponse( app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); const std::string module_type = ModuleType(); + const std::string module_id = ModuleId(); if (!app) { LOG4CXX_ERROR(logger_, "NULL pointer."); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED, ""); @@ -227,23 +252,18 @@ void RCCommandRequest::ProcessAccessResponse( if (message[app_mngr::strings::msg_params].keyExists( message_params::kAllowed)) { is_allowed = - message[app_mngr::strings::msg_params][message_params::kAllowed] + message[app_mngr::strings::msg_params][message_params::kAllowed][0] .asBool(); } - if (is_allowed) { - resource_allocation_manager_.ForceAcquireResource(module_type, - app->app_id()); - SetResourceState(module_type, ResourceState::BUSY); - Execute(); // run child's logic - } else { - resource_allocation_manager_.OnDriverDisallowed(module_type, - app->app_id()); - SendResponse( - false, - mobile_apis::Result::REJECTED, - "The resource is in use and the driver disallows this remote " - "control RPC"); - } + std::string policy_app_id = app->policy_app_id(); + const auto mac_address = app->mac_address(); + std::vector<std::string> module_ids{module_id}; + std::vector<bool> module_allowed{is_allowed}; + auto module_consents = + RCHelpers::FillModuleConsents(module_type, module_ids, module_allowed); + rc_consent_manager_.SaveModuleConsents( + policy_app_id, mac_address, module_consents); + ProcessConsentResult(is_allowed, module_type, module_id, app->app_id()); } else { std::string response_info; GetInfo(message, response_info); @@ -251,7 +271,56 @@ void RCCommandRequest::ProcessAccessResponse( } } -void RCCommandRequest::SendGetUserConsent(const std::string& module_type) { +void RCCommandRequest::ProcessConsentResult(const bool is_allowed, + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + if (is_allowed) { + SetResourceState(module_type, ResourceState::BUSY); + Execute(); // run child's logic + } else { + resource_allocation_manager_.OnDriverDisallowed( + module_type, module_id, app_id); + + std::stringstream ss; + ss << "The resource [" << module_type << ":" << module_id + << "] is in use and the driver disallows this remote " + "control RPC"; + SendResponse(false, mobile_apis::Result::REJECTED, ss.str().c_str()); + } +} + +void RCCommandRequest::ProcessAskDriverMode(const std::string& module_type, + const std::string& module_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto app = + application_manager_.application(CommandRequestImpl::connection_key()); + const std::string policy_app_id = app->policy_app_id(); + const std::string mac_address = app->mac_address(); + + auto consent = rc_consent_manager_.GetModuleConsent( + policy_app_id, mac_address, {module_type, module_id}); + switch (consent) { + case rc_rpc_types::ModuleConsent::NOT_EXISTS: { + smart_objects::SmartObject module_ids( + smart_objects::SmartType::SmartType_Array); + module_ids[0] = module_id; + SendGetUserConsent(module_type, module_ids); + break; + } + case rc_rpc_types::ModuleConsent::NOT_CONSENTED: + case rc_rpc_types::ModuleConsent::CONSENTED: { + const bool is_allowed = rc_rpc_types::ModuleConsent::CONSENTED == consent; + ProcessConsentResult(is_allowed, module_type, module_id, app->app_id()); + break; + } + }; +} + +void RCCommandRequest::SendGetUserConsent( + const std::string& module_type, + const smart_objects::SmartObject& module_ids) { LOG4CXX_AUTO_TRACE(logger_); app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); @@ -260,9 +329,11 @@ void RCCommandRequest::SendGetUserConsent(const std::string& module_type) { smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[app_mngr::strings::app_id] = app->app_id(); msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleIds] = module_ids; + SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent, &msg_params, true); } -} -} +} // namespace commands +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc index 780aab537b..3e50818210 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc @@ -30,11 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/interior_data_cache_impl.h" +#include <chrono> #include <iostream> #include <thread> -#include <chrono> -#include "rc_rpc_plugin/interior_data_cache_impl.h" #include "application_manager/smart_object_keys.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/date_time.h" #include "utils/logger.h" @@ -46,139 +47,72 @@ InteriorDataCacheImpl::InteriorDataCacheImpl() {} InteriorDataCacheImpl::~InteriorDataCacheImpl() {} -/** - * @brief MergeModuleData all keys and values from first parameter and - * update and append keys and values from the second - * @param data1 - initial data - * @param data2 - updated data - * @return updated data1 with data2 keys and values - */ -smart_objects::SmartObject MergeModuleData( - const smart_objects::SmartObject& data1, - const smart_objects::SmartObject& data2); - -/** - * @brief MergeArray merge two arrays if their elements contain an `id` - * parameter - * @param data1 - initial data - * @param data2 - updated data - * @return updated data1 with any values in data2 if the arrays can be merged, - * otherwise data2 - */ -smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, - const smart_objects::SmartObject& data2); - -smart_objects::SmartObject MergeModuleData( - const smart_objects::SmartObject& data1, - const smart_objects::SmartObject& data2) { - smart_objects::SmartObject result = data1; - auto it = data2.map_begin(); - for (; it != data2.map_end(); ++it) { - const std::string& key = it->first; - smart_objects::SmartObject& value = it->second; - if (!result.keyExists(key) || value.getType() != result[key].getType()) { - result[key] = value; - continue; - } - - // Merge maps and arrays with `id` param included, replace other types - if (value.getType() == smart_objects::SmartType::SmartType_Map) { - value = MergeModuleData(result[key], value); - } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { - value = MergeArray(result[key], value); - } - result[key] = value; - } - return result; -} - -smart_objects::SmartObject MergeArray(const smart_objects::SmartObject& data1, - const smart_objects::SmartObject& data2) { - // Merge data only in the case where each value in the array is an Object with - // an ID included, otherwise replace - bool array_contains_objects = - !data2.empty() && - data2.getElement(0).getType() != smart_objects::SmartType::SmartType_Map; - bool can_merge_arrays = - array_contains_objects && - data2.getElement(0).keyExists(application_manager::strings::id); - if (!can_merge_arrays) { - return data2; - } - - smart_objects::SmartObject result = data1; - smart_objects::SmartArray* result_array = result.asArray(); - smart_objects::SmartArray* data_array = data2.asArray(); - auto data_it = data_array->begin(); - auto find_by_id = - [](smart_objects::SmartArray* array, const smart_objects::SmartObject& id) - -> smart_objects::SmartArray::iterator { - auto it = std::find_if( - array->begin(), - array->end(), - [&id](smart_objects::SmartObject& obj) -> bool { - return obj[application_manager::strings::id] == id; - }); - return it; - }; - - for (; data_it != data_array->end(); ++data_it) { - const smart_objects::SmartObject element_id = - (*data_it)[application_manager::strings::id]; - auto result_it = find_by_id(result_array, element_id); - - if (result_it != result_array->end()) { - *result_it = MergeModuleData(*result_it, *data_it); - } else { - result_array->push_back(*data_it); - } - } - return result; -} - -void InteriorDataCacheImpl::Add(const std::string& module_type, +void InteriorDataCacheImpl::Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) { - LOG4CXX_TRACE(logger_, "module_type : " << module_type); + LOG4CXX_TRACE( + logger_, + "module_type : " << module.first << " module_id : " << module.second); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); if (cached_data_.end() == it) { - cached_data_[module_type] = module_data; + cached_data_[module] = module_data; return; } - cached_data_[module_type] = MergeModuleData(it->second, module_data); + cached_data_[module] = RCHelpers::MergeModuleData(it->second, module_data); } smart_objects::SmartObject InteriorDataCacheImpl::Retrieve( - const std::string& module_type) const { + const ModuleUid& module) const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); if (it == cached_data_.end()) { LOG4CXX_WARN(logger_, - "Module type " << module_type << " was not found in cache"); + "Module with type: " << module.first + << " and id: " << module.second + << " was not found in cache"); return smart_objects::SmartObject(smart_objects::SmartType_Null); } - LOG4CXX_TRACE(logger_, "module_type : " << module_type); + LOG4CXX_TRACE( + logger_, + "module_type : " << module.first << " module_id : " << module.second); return it->second; } -bool InteriorDataCacheImpl::Contains(const std::string& module_type) const { +std::vector<ModuleUid> InteriorDataCacheImpl::GetCachedModulesByType( + const std::string& module_type) const { + std::vector<ModuleUid> modules; + for (auto& item : cached_data_) { + auto& module = item.first; + if (module_type == module.first) { + modules.push_back(module); + } + } + return modules; +} + +bool InteriorDataCacheImpl::Contains(const ModuleUid& module) const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); const bool contains = it != cached_data_.end(); LOG4CXX_TRACE(logger_, - "module_type : " << module_type << " " + "module_type : " << module.first + << " module_id : " << module.second << " " << (contains ? "true" : "false")); return contains; } -void InteriorDataCacheImpl::Remove(const std::string& module_type) { - LOG4CXX_TRACE(logger_, "module_type : " << module_type); +void InteriorDataCacheImpl::Remove(const ModuleUid& module) { + LOG4CXX_TRACE( + logger_, + "module_type : " << module.first << " module_id : " << module.second); sync_primitives::AutoLock autolock(cached_data_lock_); - auto it = cached_data_.find(module_type); + auto it = cached_data_.find(module); if (cached_data_.end() == it) { - LOG4CXX_TRACE(logger_, "Not existing module_type : " << module_type); + LOG4CXX_TRACE( + logger_, + "Not existing module : " << module.first << " " << module.second); return; } cached_data_.erase(it); @@ -189,4 +123,4 @@ void InteriorDataCacheImpl::Clear() { sync_primitives::AutoLock autolock(cached_data_lock_); cached_data_.clear(); } -} +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc index 0c42f6e3de..50568de63a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc @@ -1,8 +1,8 @@ #include "rc_rpc_plugin/interior_data_manager_impl.h" -#include "rc_rpc_plugin/rc_helpers.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" namespace rc_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); @@ -33,7 +33,7 @@ void InteriorDataManagerImpl::OnApplicationEvent( void InteriorDataManagerImpl::OnDisablingRC() { LOG4CXX_AUTO_TRACE(logger_); auto existing_subscription = AppsSubscribedModules(); - std::set<std::string> subscribed_modules; + std::set<ModuleUid> subscribed_modules; for (auto& pair : existing_subscription) { auto& app = pair.first; auto rc_extension = RCHelpers::GetRCExtension(*app); @@ -43,36 +43,37 @@ void InteriorDataManagerImpl::OnDisablingRC() { } } for (auto& module : subscribed_modules) { - LOG4CXX_TRACE(logger_, "unsubscribe " << module); + LOG4CXX_TRACE(logger_, + "unsubscribe from module type: " << module.first + << " id: " << module.second); UnsubscribeFromInteriorVehicleData(module); } } -void InteriorDataManagerImpl::StoreRequestToHMITime( - const std::string& module_type) { +void InteriorDataManagerImpl::StoreRequestToHMITime(const ModuleUid& module) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_); - requests_to_hmi_history_[module_type].push_back(date_time::getCurrentTime()); + requests_to_hmi_history_[module].push_back(date_time::getCurrentTime()); } bool InteriorDataManagerImpl::CheckRequestsToHMIFrequency( - const std::string& module_type) { + const ModuleUid& module) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_); ClearOldRequestsToHMIHistory(); - const auto& history = requests_to_hmi_history_[module_type]; + const auto& history = requests_to_hmi_history_[module]; const auto limit = app_mngr_.get_settings().get_interior_vehicle_data_frequency().first; return history.size() < limit; } void InteriorDataManagerImpl::UpdateHMISubscriptionsOnPolicyUpdated() { - auto apps_allowed_modules = - RCHelpers::GetApplicationsAllowedModules(app_mngr_); - auto apps_subscribed_modules = AppsSubscribedModules(); - InteriorDataManagerImpl::AppsModules apps_disallowed_modules; - for (auto& pair : apps_subscribed_modules) { - auto& allowed = apps_allowed_modules[pair.first]; + auto apps_allowed_module_types = + RCHelpers::GetApplicationsAllowedModuleTypes(app_mngr_); + auto apps_subscribed_module_types = AppsSubscribedModuleTypes(); + InteriorDataManagerImpl::AppsModuleTypes apps_disallowed_modules; + for (auto& pair : apps_subscribed_module_types) { + auto& allowed = apps_allowed_module_types[pair.first]; auto& subscribed = pair.second; std::vector<std::string> disallowed_modules; std::set_difference(subscribed.begin(), @@ -80,18 +81,25 @@ void InteriorDataManagerImpl::UpdateHMISubscriptionsOnPolicyUpdated() { allowed.begin(), allowed.end(), std::back_inserter(disallowed_modules)); + + std::sort(disallowed_modules.begin(), disallowed_modules.end()); + + auto unique_result = + std::unique(disallowed_modules.begin(), disallowed_modules.end()); + + disallowed_modules.erase(unique_result, disallowed_modules.end()); apps_disallowed_modules[pair.first] = disallowed_modules; } for (auto& pair : apps_disallowed_modules) { auto& app = pair.first; auto rc_extension = RCHelpers::GetRCExtension(*app); - for (const auto& module : pair.second) { - rc_extension->UnsubscribeFromInteriorVehicleData(module); + for (const auto& module_type : pair.second) { + rc_extension->UnsubscribeFromInteriorVehicleDataOfType(module_type); auto apps_subscribed = - RCHelpers::AppsSubscribedToModuleType(app_mngr_, module); + RCHelpers::AppsSubscribedToModuleType(app_mngr_, module_type); if (apps_subscribed.empty()) { - UnsubscribeFromInteriorVehicleData(module); + UnsubscribeFromInteriorVehicleDataOfType(module_type); } } } @@ -104,8 +112,7 @@ void InteriorDataManagerImpl::UpdateHMISubscriptionsOnAppUnregistered( auto subscribed_data = rc_extension->InteriorVehicleDataSubscriptions(); rc_extension->UnsubscribeFromInteriorVehicleData(); for (auto& data : subscribed_data) { - auto apps_subscribed = - RCHelpers::AppsSubscribedToModuleType(app_mngr_, data); + auto apps_subscribed = RCHelpers::AppsSubscribedToModule(app_mngr_, data); if (apps_subscribed.empty()) { UnsubscribeFromInteriorVehicleData(data); } @@ -117,14 +124,31 @@ void InteriorDataManagerImpl::UpdateHMISubscriptionsOnAppUnregistered( } void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleData( - const std::string& module_type) { - cache_.Remove(module_type); + const ModuleUid& module) { + cache_.Remove(module); auto unsubscribe_request = RCHelpers::CreateUnsubscribeRequestToHMI( - module_type, app_mngr_.GetNextHMICorrelationID()); - LOG4CXX_DEBUG(logger_, "Send Unsubscribe from " << module_type); + module, app_mngr_.GetNextHMICorrelationID()); + LOG4CXX_DEBUG(logger_, + "Send Unsubscribe from module type: " << module.first << " id: " + << module.second); rpc_service_.ManageHMICommand(unsubscribe_request); } +void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleDataOfType( + const std::string& module_type) { + const auto& modules = cache_.GetCachedModulesByType(module_type); + + for (const auto& module : modules) { + cache_.Remove(module); + auto unsubscribe_request = RCHelpers::CreateUnsubscribeRequestToHMI( + module, app_mngr_.GetNextHMICorrelationID()); + LOG4CXX_DEBUG(logger_, + "Send Unsubscribe from module type: " + << module.first << " id: " << module.second); + rpc_service_.ManageHMICommand(unsubscribe_request); + } +} + void InteriorDataManagerImpl::ClearOldRequestsToHMIHistory() { auto limit = app_mngr_.get_settings().get_interior_vehicle_data_frequency().second; @@ -148,11 +172,30 @@ InteriorDataManagerImpl::AppsSubscribedModules() { for (auto& app_ptr : apps_list) { const auto rc_extension = RCHelpers::GetRCExtension(*app_ptr); auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions(); - result[app_ptr] = std::vector<std::string>(app_subscriptions.size()); + result[app_ptr] = std::vector<ModuleUid>(app_subscriptions.size()); std::copy(app_subscriptions.begin(), app_subscriptions.end(), result[app_ptr].begin()); } return result; } + +InteriorDataManagerImpl::AppsModuleTypes +InteriorDataManagerImpl::AppsSubscribedModuleTypes() { + auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr_); + RCHelpers::AppsModuleTypes result; + for (auto& app_ptr : apps_list) { + const auto rc_extension = RCHelpers::GetRCExtension(*app_ptr); + auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions(); + std::vector<std::string> app_module_types; + + for (auto& app_subscription : app_subscriptions) { + app_module_types.push_back(app_subscription.first); + } + + std::sort(app_module_types.begin(), app_module_types.end()); + result[app_ptr] = app_module_types; + } + return result; +} } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc index 5282da8d83..ea9c13113c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc @@ -31,29 +31,51 @@ */ #include "rc_rpc_plugin/rc_app_extension.h" +#include <algorithm> +#include "rc_rpc_plugin/rc_module_constants.h" +#include "smart_objects/smart_object.h" namespace rc_rpc_plugin { RCAppExtension::RCAppExtension(application_manager::AppExtensionUID uid) : AppExtension(uid) {} -void RCAppExtension::SubscribeToInteriorVehicleData( - const std::string& module_type) { - subscribed_interior_vehicle_data_.insert(module_type); +void RCAppExtension::SubscribeToInteriorVehicleData(const ModuleUid& module) { + subscribed_interior_vehicle_data_.insert(module); } void RCAppExtension::UnsubscribeFromInteriorVehicleData( + const ModuleUid& module) { + subscribed_interior_vehicle_data_.erase(module); +} + +void RCAppExtension::UnsubscribeFromInteriorVehicleDataOfType( const std::string& module_type) { - subscribed_interior_vehicle_data_.erase(module_type); + for (auto& item : subscribed_interior_vehicle_data_) { + if (module_type == item.first) { + subscribed_interior_vehicle_data_.erase(item); + } + } } void RCAppExtension::UnsubscribeFromInteriorVehicleData() { subscribed_interior_vehicle_data_.clear(); } -bool RCAppExtension::IsSubscibedToInteriorVehicleData( +bool RCAppExtension::IsSubscribedToInteriorVehicleDataOfType( const std::string& module_type) { - std::set<std::string>::iterator it = - subscribed_interior_vehicle_data_.find(module_type); + auto it = std::find_if(subscribed_interior_vehicle_data_.begin(), + subscribed_interior_vehicle_data_.end(), + [&module_type](ModuleUid module) -> bool { + return module_type == module.first; + }); + + return (it != subscribed_interior_vehicle_data_.end()); +} + +bool RCAppExtension::IsSubscribedToInteriorVehicleData( + const ModuleUid& module) { + std::set<ModuleUid>::iterator it = + subscribed_interior_vehicle_data_.find(module); return (it != subscribed_interior_vehicle_data_.end()); } @@ -65,9 +87,29 @@ void RCAppExtension::ProcessResumption( const ns_smart_device_link::ns_smart_objects::SmartObject& resumption_data) {} -std::set<std::string> RCAppExtension::InteriorVehicleDataSubscriptions() const { +std::set<ModuleUid> RCAppExtension::InteriorVehicleDataSubscriptions() const { return subscribed_interior_vehicle_data_; } +Grid RCAppExtension::GetUserLocation() const { + return user_location_; +} + +void RCAppExtension::SetUserLocation( + const ns_smart_device_link::ns_smart_objects::SmartObject& user_location) { + const auto grid = user_location[strings::kGrid]; + const int32_t col = grid[strings::kCol].asInt(); + const int32_t row = grid[strings::kRow].asInt(); + const int32_t level = grid[strings::kLevel].asInt(); + const int32_t colspan = grid[strings::kColspan].asInt(); + const int32_t rowspan = grid[strings::kRowspan].asInt(); + const int32_t levelspan = grid[strings::kLevelspan].asInt(); + user_location_ = Grid(col, row, level, colspan, rowspan, levelspan); +} + +void RCAppExtension::SetUserLocation(const Grid& grid) { + user_location_ = grid; +} + RCAppExtension::~RCAppExtension() {} } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc new file mode 100644 index 0000000000..dbedd0167f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc @@ -0,0 +1,925 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the 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. + + 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 "rc_rpc_plugin/rc_capabilities_manager_impl.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") + +RCCapabilitiesManagerImpl::RCCapabilitiesManagerImpl( + application_manager::HMICapabilities& hmi_capabilities) + : hmi_capabilities_(hmi_capabilities) {} + +const std::string +RCCapabilitiesManagerImpl::GetDefaultModuleIdFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + if (control_capabilities.keyExists(message_params::kModuleInfo)) { + // moduleId - mandatory param for ModuleInfo structure + const auto module_id = control_capabilities[message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + LOG4CXX_WARN(logger_, + "Use default moduleId from hmi capabilities: " + << module_id + << " for requested moduleType: " << module_type); + return module_id; + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleType " + << module_type); + return ""; +} + +const std::string +RCCapabilitiesManagerImpl::GetDefaultModuleIdFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& cap_item : *(control_capabilities.asArray())) { + if (cap_item.keyExists(message_params::kModuleInfo)) { + // moduleId - mandatory param for ModuleInfo structure + const auto module_id = + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString(); + LOG4CXX_WARN(logger_, + "Use default moduleId from hmi capabilities: " + << module_id + << " for requested moduleType: " << module_type); + return module_id; + } + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleType " + << module_type); + return ""; +} + +const std::string RCCapabilitiesManagerImpl::GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + if (!rc_capabilities.keyExists(mapping(module_type))) { + LOG4CXX_WARN( + logger_, + "There is no RC capability for requested module_type " << module_type); + return ""; + } + if (enums_value::kHmiSettings == module_type || + enums_value::kLight == module_type) { + return GetDefaultModuleIdFromCapabilitiesStructure( + rc_capabilities[mapping(module_type)], module_type); + } + return GetDefaultModuleIdFromCapabilitiesArray( + rc_capabilities[mapping(module_type)], module_type); +} + +const bool RCCapabilitiesManagerImpl::CheckModuleIdWithCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const { + LOG4CXX_AUTO_TRACE(logger_); + if (control_capabilities.keyExists(message_params::kModuleInfo) && + (module_id == control_capabilities[message_params::kModuleInfo] + [message_params::kModuleId] + .asString())) { + return true; + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleId " + << module_id); + return false; +} + +const bool RCCapabilitiesManagerImpl::CheckModuleIdWithCapabilitiesArrays( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& cap_item : *(control_capabilities.asArray())) { + if (cap_item.keyExists(message_params::kModuleInfo) && + (module_id == + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString())) { + return true; + } + } + LOG4CXX_WARN(logger_, + "There are no moduleInfo in hmi capabilities for requested " + "moduleId " + << module_id); + return false; +} + +const bool RCCapabilitiesManagerImpl::CheckModuleIdWithCapabilities( + const smart_objects::SmartObject& rc_capabilities, + const ModuleUid& module) const { + LOG4CXX_AUTO_TRACE(logger_); + if (module.second.empty()) { + return true; + } + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + if (enums_value::kHmiSettings == module.first || + enums_value::kLight == module.first) { + return CheckModuleIdWithCapabilitiesStructure( + rc_capabilities[mapping(module.first)], module.second); + } + return CheckModuleIdWithCapabilitiesArrays( + rc_capabilities[mapping(module.first)], module.second); +} + +bool RCCapabilitiesManagerImpl::CheckIfModuleExistsInCapabilities( + const ModuleUid& module) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& resource_list = GetResources(); + bool is_module_type_valid = false; + for (const auto& resource : resource_list) { + if (resource.first == module.first) { + if (rc_capabilities.keyExists(mapping(module.first)) && + CheckModuleIdWithCapabilities(rc_capabilities, module)) { + is_module_type_valid = true; + break; + } + } + } + return is_module_type_valid; +} + +const std::vector<std::string> RCCapabilitiesManagerImpl::GetCapabilitiesList() + const { + using namespace enums_value; + return {strings::kclimateControlCapabilities, + strings::kradioControlCapabilities, + strings::kseatControlCapabilities, + strings::kaudioControlCapabilities, + strings::klightControlCapabilities, + strings::khmiSettingsControlCapabilities}; +} + +const std::function<std::string(const std::string& control_cap)> +RCCapabilitiesManagerImpl::GetCapabilitiesToModuleTypeMapping() const { + auto mapping_lambda = [](const std::string& control_cap) -> std::string { + static std::map<std::string, std::string> mapping = { + {strings::kclimateControlCapabilities, enums_value::kClimate}, + {strings::kradioControlCapabilities, enums_value::kRadio}, + {strings::kseatControlCapabilities, enums_value::kSeat}, + {strings::kaudioControlCapabilities, enums_value::kAudio}, + {strings::klightControlCapabilities, enums_value::kLight}, + {strings::khmiSettingsControlCapabilities, enums_value::kHmiSettings}}; + auto it = mapping.find(control_cap); + if (mapping.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown control capability " << control_cap); + return std::string(); + } + return it->second; + }; + + return mapping_lambda; +} + +void RCCapabilitiesManagerImpl::GetResourcesFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector<ModuleUid>& out_resources) const { + const auto& mapping = GetCapabilitiesToModuleTypeMapping(); + if (control_capabilities.keyExists(message_params::kModuleInfo)) { + std::string module_id = control_capabilities[message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + out_resources.push_back(std::make_pair(mapping(capability_key), module_id)); + } else { + LOG4CXX_WARN(logger_, "There are no moduleId in " << capability_key); + out_resources.push_back(std::make_pair(mapping(capability_key), "")); + } +} + +void RCCapabilitiesManagerImpl::GetResourcesFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector<ModuleUid>& out_resources) const { + const auto& mapping = GetCapabilitiesToModuleTypeMapping(); + for (auto cap_item : *(control_capabilities.asArray())) { + if (cap_item.keyExists(message_params::kModuleInfo)) { + std::string module_id = + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString(); + out_resources.push_back( + std::make_pair(mapping(capability_key), module_id)); + } else { + LOG4CXX_WARN(logger_, + "There are no moduleId for item from " << capability_key); + out_resources.push_back(std::make_pair(mapping(capability_key), "")); + } + } +} + +const std::vector<ModuleUid> RCCapabilitiesManagerImpl::GetResources() const { + LOG4CXX_AUTO_TRACE(logger_); + std::vector<ModuleUid> resources; + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& control_caps_list = GetCapabilitiesList(); + for (const auto& capability_key : control_caps_list) { + if (rc_capabilities.keyExists(capability_key)) { + if (strings::khmiSettingsControlCapabilities == capability_key || + strings::klightControlCapabilities == capability_key) { + GetResourcesFromCapabilitiesStructure( + rc_capabilities[capability_key], capability_key, resources); + } else { + GetResourcesFromCapabilitiesArray( + rc_capabilities[capability_key], capability_key, resources); + } + } + } + return resources; +} + +const std::string RCCapabilitiesManagerImpl::GetModuleIdForSeatLocation( + const mobile_apis::SupportedSeat::eType id) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto seat_capabilities = + rc_capabilities[strings::kseatControlCapabilities]; + if (seat_capabilities.length() > 0) { + if (mobile_apis::SupportedSeat::DRIVER == id) { + return seat_capabilities[0][message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + } + if ((seat_capabilities.length() > 1) && + mobile_apis::SupportedSeat::FRONT_PASSENGER == id) { + return seat_capabilities[1][message_params::kModuleInfo] + [message_params::kModuleId] + .asString(); + } + } + LOG4CXX_DEBUG(logger_, "There are no capabitities for requested id: " << id); + return ""; +} + +bool RCCapabilitiesManagerImpl::CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const { + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + if (rc_capabilities.keyExists(strings::kbuttonCapabilities)) { + const smart_objects::SmartObject& button_caps = + rc_capabilities[strings::kbuttonCapabilities]; + for (auto& button_cap : *(button_caps.asArray())) { + int64_t current_id = button_cap[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 = + button_cap[message_params::kName].asString(); + static RCHelpers::ButtonsMap btn_map = RCHelpers::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; +} + +smart_objects::SmartObject +RCCapabilitiesManagerImpl::GetCapabilitiesByModuleIdFromArray( + const smart_objects::SmartObject& module_data_capabilities, + const std::string& module_id) const { + for (auto& cap_item : *(module_data_capabilities.asArray())) { + std::string current_id = + cap_item[message_params::kModuleInfo][message_params::kModuleId] + .asString(); + if (module_id == current_id) { + return cap_item; + } + } + LOG4CXX_WARN(logger_, + "Capabilities for moduleId " << module_id + << " do not exist in capabilities"); + return smart_objects::SmartObject(smart_objects::SmartType_Null); +} + +bool RCCapabilitiesManagerImpl::CheckButtonName( + const std::string& module_type, const std::string& button_name) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = hmi_capabilities_.rc_capability(); + if (!rc_capabilities) { + LOG4CXX_ERROR(logger_, "No remote controll capabilities available"); + return false; + } + + if (enums_value::kRadio == module_type) { + if (!helpers::in_range(RCHelpers::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(RCHelpers::buttons_climate(), button_name)) { + LOG4CXX_WARN(logger_, + "Trying to acceess radio button with module type climate"); + return false; + } + } + return true; +} + +const std::map<std::string, std::string> +RCCapabilitiesManagerImpl::GetLightCapabilitiesMapping() const { + std::map<std::string, std::string> mapping = { + {message_params::kId, strings::kName}, + {message_params::kLightStatus, strings::kStatusAvailable}, + {message_params::kLightDensity, strings::kDensityAvailable}, + {message_params::kLightColor, strings::kRGBColorSpaceAvailable}}; + return mapping; +} + +const std::map<std::string, std::string> +RCCapabilitiesManagerImpl::GetModuleDataToCapabilitiesMapping() const { + std::map<std::string, std::string> mapping; + using namespace message_params; + using namespace rc_rpc_plugin::strings; + // climate + mapping[kFanSpeed] = kFanSpeedAvailable; + mapping[kCurrentTemperature] = kCurrentTemperatureAvailable; + mapping[kDesiredTemperature] = kDesiredTemperatureAvailable; + mapping[kACEnable] = kAcEnableAvailable; + mapping[kCirculateAirEnable] = kCirculateAirEnableAvailable; + mapping[kAutoModeEnable] = kAutoModeEnableAvailable; + mapping[kDefrostZone] = kDefrostZoneAvailable; + mapping[kDualModeEnable] = kDualModeEnableAvailable; + mapping[kACMaxEnable] = kAcMaxEnableAvailable; + mapping[kVentilationMode] = kVentilationModeAvailable; + mapping[kHeatedSteeringWheelEnable] = kHeatedSteeringWheelAvailable; + mapping[kHeatedWindshieldEnable] = kHeatedWindshieldAvailable; + mapping[kHeatedMirrorsEnable] = kHeatedMirrorsAvailable; + mapping[kHeatedRearWindowEnable] = kHeatedRearWindowAvailable; + mapping[kClimateEnable] = kClimateEnableAvailable; + mapping[kClimateEnableAvailable] = kClimateEnableAvailable; + + // radio + mapping[kBand] = kRadioBandAvailable; + mapping[kFrequencyInteger] = kRadioFrequencyAvailable; + mapping[kFrequencyFraction] = kRadioFrequencyAvailable; + mapping[kRdsData] = kRdsDataAvailable; + mapping[kAvailableHDs] = kAvailableHDsAvailable; + mapping[kAvailableHdChannels] = kAvailableHdChannelsAvailable; + mapping[kHdChannel] = kAvailableHdChannelsAvailable; + mapping[kHdRadioEnable] = kHdRadioEnableAvailable; + mapping[kSignalStrength] = kSignalStrengthAvailable; + mapping[kSignalChangeThreshold] = kSignalChangeThresholdAvailable; + mapping[kRadioEnable] = kRadioEnableAvailable; + mapping[kState] = kStateAvailable; + mapping[kSisData] = kSisDataAvailable; + + // seat + mapping[kHeatingEnabled] = kHeatingEnabledAvailable; + mapping[kCoolingEnabled] = kCoolingEnabledAvailable; + mapping[kHeatingLevele] = kHeatingLevelAvailable; + mapping[kCoolingLevel] = kCoolingLevelAvailable; + mapping[kHorizontalPosition] = kHorizontalPositionAvailable; + mapping[kVerticalPosition] = kVerticalPositionAvailable; + mapping[kFrontVerticalPosition] = kFrontVerticalPositionAvailable; + mapping[kBackVerticalPosition] = kBackVerticalPositionAvailable; + mapping[kBackTiltAngle] = kBackTiltAngleAvailable; + mapping[kHeadSupportHorizontalPosition] = + kHeadSupportHorizontalPositionAvailable; + mapping[kHeadSupportVerticalPosition] = kHeadSupportVerticalPositionAvailable; + mapping[kMassageEnabled] = kMassageEnabledAvailable; + mapping[kMassageMode] = kMassageModeAvailable; + mapping[kMassageCushionFirmness] = kMassageCushionFirmnessAvailable; + mapping[kMemory] = kMemoryAvailable; + + // audio + mapping[kSource] = kSourceAvailable; + mapping[kKeepContext] = kKeepContextAvailable; + mapping[kVolume] = kVolumeAvailable; + mapping[kEqualizerSettings] = kEqualizerAvailable; + + // hmi settings + mapping[kDistanceUnit] = kDistanceUnitAvailable; + mapping[kTemperatureUnit] = kTemperatureUnitAvailable; + mapping[kDisplayMode] = kDisplayModeUnitAvailable; + + return mapping; +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const { + LOG4CXX_AUTO_TRACE(logger_); + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + + const auto& all_module_types = RCHelpers::GetModuleTypesList(); + const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); + const auto& get_capabilities_key = + RCHelpers::GetModuleTypeToCapabilitiesMapping(); + ModuleTypeCapability module_data_capabilities = + std::make_pair("", capabilitiesStatus::missedParam); + + for (const auto& module_type : all_module_types) { + const auto module_data_key = get_module_data_key(module_type); + const auto capabilities_key = get_capabilities_key(module_type); + if (module_data.keyExists(module_data_key)) { + if (!rc_capabilities.keyExists(capabilities_key)) { + LOG4CXX_DEBUG(logger_, module_data_key << " capabilities not present"); + return module_data_capabilities; + } + const auto& caps = rc_capabilities[capabilities_key]; + + if (message_params::kHmiSettingsControlData == module_data_key || + message_params::kLightControlData == module_data_key) { + module_data_capabilities = + GetControlDataCapabilities(caps, module_data[module_data_key]); + } else { + module_data_capabilities = GetControlDataCapabilities( + GetCapabilitiesByModuleIdFromArray(caps, module_id), + module_data[module_data_key]); + } + } + } + + return module_data_capabilities; +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const { + LOG4CXX_AUTO_TRACE(logger_); + std::map<std::string, std::string> mapping = + GetModuleDataToCapabilitiesMapping(); + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { + const std::string& request_parameter = it->first; + if (message_params::kId == request_parameter) { + continue; + } + if (message_params::kLightState == request_parameter) { + ModuleTypeCapability light_capability = + std::make_pair("", capabilitiesStatus::success); + + for (auto& light_data : *(control_data[request_parameter].asArray())) { + light_capability = GetLightNameCapabilities( + capabilities[strings::kSupportedLights], light_data); + + if (capabilitiesStatus::success != light_capability.second) { + return light_capability; + } + } + + return light_capability; + } + if (message_params::kBand == request_parameter) { + ModuleTypeCapability radio_capability = GetRadioBandByCapabilities( + capabilities, control_data[request_parameter]); + if (capabilitiesStatus::success != radio_capability.second) { + return radio_capability; + } + } + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + request_parameter, + mobile_apis::Result::UNSUPPORTED_RESOURCE); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair("", status_item_capability); + } + } + + return std::make_pair("", capabilitiesStatus::success); +} + +capabilitiesStatus RCCapabilitiesManagerImpl::GetItemCapability( + const smart_objects::SmartObject& capabilities, + const std::map<std::string, std::string>& mapping, + const std::string& request_parameter, + const mobile_apis::Result::eType& switched_off_result) const { + const auto it = mapping.find(request_parameter); + + if (it == mapping.end()) { + LOG4CXX_DEBUG( + logger_, + "Parameter " << request_parameter << " doesn't exist in capabilities."); + return capabilitiesStatus::missedParam; + } + + const std::string& caps_key = it->second; + + LOG4CXX_DEBUG(logger_, + "Checking request parameter " + << request_parameter + << " with capabilities. Appropriate key is " << caps_key); + + if (!capabilities.keyExists(caps_key)) { + LOG4CXX_DEBUG(logger_, + "Capability " << caps_key + << " is missed in RemoteControl capabilities"); + return capabilitiesStatus::missedParam; + } + + if (!capabilities[caps_key].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is switched off in RemoteControl capabilities"); + capabilitiesStatus status = capabilitiesStatus::missedParam; + if (mobile_apis::Result::READ_ONLY == switched_off_result) { + status = capabilitiesStatus::readOnly; + } + return status; + } + + return capabilitiesStatus::success; +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const { + LOG4CXX_AUTO_TRACE(logger_); + std::map<std::string, std::string> mapping = GetLightCapabilitiesMapping(); + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { + const std::string& request_parameter = it->first; + + if (message_params::kId == request_parameter) { + continue; + } + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + request_parameter, + mobile_apis::Result::READ_ONLY); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair(message_params::kLightState, + status_item_capability); + } + } + + return std::make_pair("", capabilitiesStatus::success); +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetLightNameCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) const { + LOG4CXX_AUTO_TRACE(logger_); + for (auto& so : *(capabilities_status.asArray())) { + const int64_t current_id = so[message_params::kName].asInt(); + if (current_id == light_data[message_params::kId].asInt()) { + return GetLightDataCapabilities(so, light_data); + } + } + LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); + return std::make_pair(message_params::kLightState, + capabilitiesStatus::missedLightName); +} + +ModuleTypeCapability RCCapabilitiesManagerImpl::GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) const { + mobile_apis::RadioBand::eType radio_band = + static_cast<mobile_apis::RadioBand::eType>(request_parameter.asUInt()); + if (mobile_apis::RadioBand::XM == radio_band) { + if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is missed in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is switched off in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + } + return std::make_pair("", capabilitiesStatus::success); +} + +const smart_objects::SmartObject& RCCapabilitiesManagerImpl::ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const { + const auto& all_module_types = RCHelpers::GetModuleTypesList(); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + for (const auto& type : all_module_types) { + if (type == module_type) { + return module_data[data_mapping(type)]; + } + } + NOTREACHED(); + return module_data[0]; +} + +bool RCCapabilitiesManagerImpl::CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) const { + if (module_type_params.keyExists(message_params::kEqualizerSettings)) { + const auto& equalizer_settings = + module_type_params[message_params::kEqualizerSettings]; + + for (auto& so : *(equalizer_settings.asArray())) { + if (so.keyExists(message_params::kChannelName)) { + LOG4CXX_DEBUG(logger_, + "READ ONLY parameter. ChannelName = " + << so[message_params::kChannelName].asString()); + return true; + } + } + } + + return false; +} + +bool RCCapabilitiesManagerImpl::CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) const { + if (module_type_params.keyExists(message_params::kLightState)) { + const auto& light_state = module_type_params[message_params::kLightState]; + + for (auto& light_data : *(light_state.asArray())) { + if (light_data.keyExists(message_params::kLightStatus)) { + const mobile_apis::LightStatus::eType light_status = + static_cast<mobile_apis::LightStatus::eType>( + light_data[message_params::kLightStatus].asUInt()); + + if (helpers::Compare<mobile_apis::LightStatus::eType, + helpers::EQ, + helpers::ONE>(light_status, + mobile_apis::LightStatus::RAMP_UP, + mobile_apis::LightStatus::RAMP_DOWN, + mobile_apis::LightStatus::UNKNOWN, + mobile_apis::LightStatus::INVALID)) { + LOG4CXX_DEBUG( + logger_, + "READ ONLY parameter. Status = " + << light_data[message_params::kLightStatus].asInt()); + return true; + } + } + } + } + + return false; +} + +bool RCCapabilitiesManagerImpl::AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& module_type_params = + ControlDataForType(module_data, module_type); + + if (enums_value::kAudio == module_type) { + return CheckReadOnlyParamsForAudio(module_type_params); + } + + if (enums_value::kLight == module_type) { + const bool result = CheckReadOnlyParamsForLight(module_type_params); + + if (result) { + module_data_capabilities = + std::make_pair(module_type, capabilitiesStatus::readOnly); + } + return result; + } + + const std::vector<std::string> ro_params = + RCHelpers::GetModuleReadOnlyParams(module_type); + auto it = module_type_params.map_begin(); + + for (; it != module_type_params.map_end(); ++it) { + if (helpers::in_range(ro_params, it->first)) { + return true; + } + } + return false; +} + +bool RCCapabilitiesManagerImpl::AreAllParamsReadOnly( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& module_type_params = + ControlDataForType(module_data, module_type); + auto it = module_type_params.map_begin(); + std::vector<std::string> ro_params = + RCHelpers::GetModuleReadOnlyParams(module_type); + for (; it != module_type_params.map_end(); ++it) { + if (!helpers::in_range(ro_params, it->first)) { + return false; + } + } + + LOG4CXX_DEBUG(logger_, "All params are ReadOnly"); + return true; +} + +bool RCCapabilitiesManagerImpl::IsSeatLocationCapabilityProvided() const { + LOG4CXX_AUTO_TRACE(logger_); + auto seat_location_capability = hmi_capabilities_.seat_location_capability(); + if (!seat_location_capability || seat_location_capability->empty()) { + LOG4CXX_DEBUG(logger_, "Seat Location capability is not provided by HMI"); + return false; + } + + if (seat_location_capability->keyExists(strings::kRows) && + seat_location_capability->keyExists(strings::kCols) && + seat_location_capability->keyExists(strings::kLevels) && + seat_location_capability->keyExists(strings::kSeats)) { + const auto* seats = (*seat_location_capability)[strings::kSeats].asArray(); + if (!seats->empty()) { + return true; + } + } + + LOG4CXX_DEBUG( + logger_, + "Seat Location capability doesn't contain all necessary parameters"); + return false; +} + +const Grid +RCCapabilitiesManagerImpl::GetDriverLocationFromSeatLocationCapability() const { + LOG4CXX_AUTO_TRACE(logger_); + Grid grid; + if (IsSeatLocationCapabilityProvided()) { + auto seat_location_capability = + hmi_capabilities_.seat_location_capability(); + const auto* seats = (*seat_location_capability)[strings::kSeats].asArray(); + const auto& driver_seat = (*seats)[0]; + if (driver_seat.keyExists(strings::kGrid)) { + const auto& driver_location = driver_seat[strings::kGrid]; + grid = Grid(driver_location[strings::kCol].asInt(), + driver_location[strings::kRow].asInt(), + driver_location[strings::kLevel].asInt(), + driver_location[strings::kColspan].asInt(), + driver_location[strings::kRowspan].asInt(), + driver_location[strings::kLevelspan].asInt()); + } else { + LOG4CXX_DEBUG(logger_, "Driver's location doesn't provided"); + } + } + return grid; +} + +Grid RCCapabilitiesManagerImpl::GetWholeVehicleArea() const { + auto seat_location_capability = + *(hmi_capabilities_.seat_location_capability()); + int32_t colspan = seat_location_capability.keyExists(strings::kCols) + ? seat_location_capability[strings::kCols].asInt() + : 0; + + int32_t rowspan = seat_location_capability.keyExists(strings::kRows) + ? seat_location_capability[strings::kRows].asInt() + : 0; + + int32_t levelspan = seat_location_capability.keyExists(strings::kLevels) + ? seat_location_capability[strings::kLevels].asInt() + : 0; + return Grid(0, 0, 0, colspan, rowspan, levelspan); +} + +Grid RCCapabilitiesManagerImpl::GetModuleLocationFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const { + if (control_capabilities[message_params::kModuleInfo].keyExists( + strings::kLocation)) { + const auto& location = + control_capabilities[message_params::kModuleInfo][strings::kLocation]; + + return Grid(location[strings::kCol].asInt(), + location[strings::kRow].asInt(), + location[strings::kLevel].asInt(), + location[strings::kColspan].asInt(), + location[strings::kRowspan].asInt(), + location[strings::kLevelspan].asInt()); + } + return GetWholeVehicleArea(); +} + +Grid RCCapabilitiesManagerImpl::GetModuleServiceAreaFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const { + if (control_capabilities.keyExists(message_params::kModuleInfo)) { + if (control_capabilities[message_params::kModuleInfo].keyExists( + strings::kServiceArea)) { + const auto& serviceArea = + control_capabilities[message_params::kModuleInfo] + [strings::kServiceArea]; + + return Grid(serviceArea[strings::kCol].asInt(), + serviceArea[strings::kRow].asInt(), + serviceArea[strings::kLevel].asInt(), + serviceArea[strings::kColspan].asInt(), + serviceArea[strings::kRowspan].asInt(), + serviceArea[strings::kLevelspan].asInt()); + } + } + return GetModuleLocationFromControlCapability(control_capabilities); +} + +Grid RCCapabilitiesManagerImpl::GetModuleServiceArea( + const ModuleUid& module) const { + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& module_type = module.first; + const auto& capabilities_key = mapping(module_type); + if (!rc_capabilities.keyExists(capabilities_key)) { + LOG4CXX_DEBUG(logger_, module_type << "control capabilities not present"); + return Grid(); + } + const auto& caps = rc_capabilities[capabilities_key]; + + if (strings::khmiSettingsControlCapabilities == capabilities_key || + strings::klightControlCapabilities == capabilities_key) { + return GetModuleServiceAreaFromControlCapability(caps); + } else { + const auto& capability_item = + GetCapabilitiesByModuleIdFromArray(caps, module.second); + return GetModuleServiceAreaFromControlCapability(capability_item); + } +} + +bool RCCapabilitiesManagerImpl::IsMultipleAccessAllowedInControlCaps( + const smart_objects::SmartObject& control_capabilities) const { + if (control_capabilities.keyExists(message_params::kModuleInfo) && + control_capabilities[message_params::kModuleInfo].keyExists( + strings::kAllowMultipleAccess)) { + return control_capabilities[message_params::kModuleInfo] + [strings::kAllowMultipleAccess] + .asBool(); + } + return true; +} + +bool RCCapabilitiesManagerImpl::IsMultipleAccessAllowed( + const ModuleUid& module) const { + auto rc_capabilities = *(hmi_capabilities_.rc_capability()); + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& module_type = module.first; + const auto& capabilities_key = mapping(module_type); + if (!rc_capabilities.keyExists(capabilities_key)) { + LOG4CXX_DEBUG(logger_, module_type << "control capabilities not present"); + return false; + } + const auto& caps = rc_capabilities[capabilities_key]; + + if (strings::khmiSettingsControlCapabilities == capabilities_key || + strings::klightControlCapabilities == capabilities_key) { + return IsMultipleAccessAllowedInControlCaps(caps); + } else { + return IsMultipleAccessAllowedInControlCaps( + GetCapabilitiesByModuleIdFromArray(caps, module.second)); + } +} + +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc index acfc75a389..4ca2cf5182 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc @@ -31,36 +31,42 @@ */ #include <iostream> -#include "rc_rpc_plugin/rc_command_factory.h" -#include "rc_rpc_plugin/commands/mobile/button_press_request.h" -#include "rc_rpc_plugin/commands/mobile/button_press_response.h" -#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" -#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" -#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" -#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h" -#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" #include "rc_rpc_plugin/commands/hmi/rc_button_press_request.h" #include "rc_rpc_plugin/commands/hmi/rc_button_press_response.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h" #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h" #include "rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h" #include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h" +#include "rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h" +#include "rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h" #include "rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h" #include "rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/commands/mobile/button_press_request.h" +#include "rc_rpc_plugin/commands/mobile/button_press_response.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h" +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h" +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_command_factory.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" -#include "rc_rpc_plugin/resource_allocation_manager.h" #include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") namespace application_manager { -using rc_rpc_plugin::ResourceAllocationManager; using rc_rpc_plugin::InteriorDataCache; using rc_rpc_plugin::RCCommandParams; +using rc_rpc_plugin::ResourceAllocationManager; template <typename RCCommandType> class RCCommandCreator : public CommandCreator { @@ -113,7 +119,7 @@ struct RCCommandCreatorFactory { } const RCCommandParams params_; }; -} +} // namespace application_manager namespace rc_rpc_plugin { using namespace application_manager; @@ -158,11 +164,13 @@ bool RCCommandFactory::IsAbleToProcess( Command::SOURCE_SDL_TO_HMI == message_source) { return get_hmi_creator_factory( static_cast<hmi_apis::FunctionID::eType>(function_id), - hmi_apis::messageType::INVALID_ENUM).CanBeCreated(); + hmi_apis::messageType::INVALID_ENUM) + .CanBeCreated(); } else { auto id = static_cast<mobile_apis::FunctionID::eType>(function_id); - return get_mobile_command_creator( - id, mobile_apis::messageType::INVALID_ENUM).CanBeCreated() || + return get_mobile_command_creator(id, + mobile_apis::messageType::INVALID_ENUM) + .CanBeCreated() || get_mobile_notification_creator(id).CanBeCreated(); } } @@ -194,6 +202,20 @@ CommandCreator& RCCommandFactory::get_mobile_command_creator( : rc_factory .GetCreator<commands::SetInteriorVehicleDataResponse>(); } + case mobile_apis::FunctionID::ReleaseInteriorVehicleDataModuleID: { + return mobile_apis::messageType::request == message_type + ? rc_factory.GetCreator< + commands::ReleaseInteriorVehicleDataModuleRequest>() + : rc_factory.GetCreator< + commands::ReleaseInteriorVehicleDataModuleResponse>(); + } + case mobile_apis::FunctionID::GetInteriorVehicleDataConsentID: { + return mobile_apis::messageType::request == message_type + ? rc_factory.GetCreator< + commands::GetInteriorVehicleDataConsentRequest>() + : rc_factory.GetCreator< + commands::GetInteriorVehicleDataConsentResponse>(); + } default: {} } return rc_factory.GetCreator<RCInvalidCommand>(); @@ -285,7 +307,14 @@ CommandCreator& RCCommandFactory::get_hmi_creator_factory( return rc_factory .GetCreator<commands::RCOnRemoteControlSettingsNotification>(); } + case hmi_apis::FunctionID::RC_SetGlobalProperties: { + return hmi_apis::messageType::request == message_type + ? rc_factory + .GetCreator<commands::RCSetGlobalPropertiesRequest>() + : rc_factory + .GetCreator<commands::RCSetGlobalPropertiesResponse>(); + } default: { return rc_factory.GetCreator<RCInvalidCommand>(); } } } -} +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc new file mode 100644 index 0000000000..acaa6ce86c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc @@ -0,0 +1,388 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include <algorithm> + +#include "application_manager/application_manager.h" +#include "application_manager/smart_object_keys.h" +#include "json/json.h" +#include "rc_rpc_plugin/rc_consent_manager_impl.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "resumption/last_state.h" +#include "smart_objects/smart_object.h" +#include "utils/date_time.h" +#include "utils/logger.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +CREATE_LOGGERPTR_GLOBAL(logger_, "RCConsentManager") + +RCConsentManagerImpl::RCConsentManagerImpl( + resumption::LastState& last_state, + application_manager::ApplicationManager& application_manager, + const uint32_t period_of_consent_expired) + : app_manager_(application_manager) + , last_state_(last_state) + , period_of_consent_expired_(period_of_consent_expired) {} + +void RCConsentManagerImpl::SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) { + LOG4CXX_AUTO_TRACE(logger_); + + for (const auto& consent : module_consents) { + std::string module_type = consent.module_id.first; + + auto& app_module_consents = + GetModuleTypeConsentsOrAppend(policy_app_id, mac_address, module_type); + SaveAppModuleConsent(app_module_consents, consent); + } +} + +rc_rpc_types::ModuleConsent RCConsentManagerImpl::GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) const { + sync_primitives::AutoLock autolock(module_consents_lock_); + + auto& module_consents = + GetModuleTypeConsentsOrAppend(app_id, mac_address, module_id.first); + if (module_consents.empty()) { + LOG4CXX_DEBUG( + logger_, + "For app: " << app_id << " module type doesn't have any consents"); + return rc_rpc_types::ModuleConsent::NOT_EXISTS; + } + + for (const auto& conset_item : module_consents) { + if (conset_item[message_params::kModuleId].asString() == module_id.second) { + return static_cast<rc_rpc_types::ModuleConsent>( + conset_item[message_params::kConsent].asUInt()); + } + } + + LOG4CXX_DEBUG(logger_, + "For app: " << app_id << " and module resource [" + << module_id.first << ":" << module_id.second + << "] consent is absent"); + + return rc_rpc_types::ModuleConsent::NOT_EXISTS; +} + +void RCConsentManagerImpl::RemoveExpiredConsents() { + LOG4CXX_AUTO_TRACE(logger_); + auto& remote_control = GetRemoteControlDataOrAppend(); + if (remote_control.empty()) { + return; + } + + auto& devices = GetAppsConsentsOrAppend(); + + sync_primitives::AutoLock autolock(device_applications_lock_); + + for (auto& device_item : devices) { + RemoveDeviceExpiredConsents(device_item); + } +} + +void RCConsentManagerImpl::RemoveAllConsents() { + auto& remote_control = GetRemoteControlDataOrAppend(); + remote_control.removeMember(message_params::kAppConsents); +} + +rc_rpc_types::ModuleConsentState RCConsentManagerImpl::CheckModuleConsentState( + const Json::Value& module_consent) const { + if (!module_consent.isMember(message_params::kConsentDate)) { + LOG4CXX_DEBUG(logger_, "Date of consent is absent"); + return rc_rpc_types::ModuleConsentState::NOT_EXISTS; + } + + const uint32_t period_for_expiring = + app_manager_.get_settings().period_for_consent_expiration(); + + const time_t consent_date = static_cast<time_t>( + module_consent[message_params::kConsentDate].asUInt()); + + const auto past_period_in_days = + date_time::calculateAmountDaysFromDate(consent_date); + + LOG4CXX_DEBUG( + logger_, + "Keeping time of consent is: " << past_period_in_days << " days"); + LOG4CXX_DEBUG(logger_, "Period for expired: " << period_for_expiring); + + return (past_period_in_days >= period_for_expiring) + ? rc_rpc_types::ModuleConsentState::EXPIRED + : rc_rpc_types::ModuleConsentState::ACTIVE; +} + +void RCConsentManagerImpl::RemoveDeviceExpiredConsents(Json::Value& device) { + sync_primitives::AutoLock autolock(applications_lock_); + + if (device.isMember(message_params::kApplications)) { + auto& applications = device[message_params::kApplications]; + + for (auto& app : applications) { + if (app.isMember(message_params::kAppConsentList)) { + RemoveAppExpiredConsents(app[message_params::kAppConsentList]); + } + } + } +} + +void RCConsentManagerImpl::RemoveAppExpiredConsents(Json::Value& app_consents) { + for (auto& module : app_consents) { + if (module.isMember(message_params::kModuleConsents)) { + auto& module_consents = module[message_params::kModuleConsents]; + RemoveModuleExpiredConsents(module_consents); + } + } +} + +void RCConsentManagerImpl::RemoveModuleExpiredConsents( + Json::Value& module_consents) { + sync_primitives::AutoLock autolock(module_consents_lock_); + Json::Value temp_consents; + + for (auto& consent : module_consents) { + const bool is_module_id_exists = + consent.isMember(message_params::kModuleId); + + const bool is_expired = rc_rpc_types::ModuleConsentState::EXPIRED == + CheckModuleConsentState(consent); + if (is_expired) { + LOG4CXX_DEBUG(logger_, + "Consent for module resource [" + << consent[message_params::kModuleId].asString() + << "] is expired and will be removed"); + } + + if (is_module_id_exists && !is_expired) { + LOG4CXX_DEBUG(logger_, + "Consent for module resource [" + << consent[message_params::kModuleId].asString() + << "] is actual."); + temp_consents.append(consent); + } + } + + module_consents.clear(); + if (!temp_consents.empty()) { + std::swap(module_consents, temp_consents); + } +} + +Json::Value& RCConsentManagerImpl::GetRemoteControlDataOrAppend() const { + Json::Value& dictionary = last_state_.get_dictionary(); + + sync_primitives::AutoLock autolock(dictionary_control_lock_); + if (!dictionary.isMember(app_mngr::strings::remote_control)) { + dictionary[app_mngr::strings::remote_control] = + Json::Value(Json::objectValue); + LOG4CXX_DEBUG(logger_, "remote_control section is missed"); + } + + Json::Value& remote_control = dictionary[app_mngr::strings::remote_control]; + + if (!remote_control.isObject()) { + LOG4CXX_ERROR(logger_, "remote_control type INVALID rewrite"); + remote_control = Json::Value(Json::objectValue); + } + return remote_control; +} + +Json::Value& RCConsentManagerImpl::GetDeviceApplicationsOrAppend( + const std::string& mac_address) const { + sync_primitives::AutoLock autolock(device_applications_lock_); + + auto& apps_consents = GetAppsConsentsOrAppend(); + + if (!apps_consents.isArray()) { + LOG4CXX_DEBUG(logger_, "applications_consents type INVALID rewrite"); + apps_consents = Json::Value(Json::arrayValue); + } + + for (auto& device_applications_item : apps_consents) { + const bool is_device_section_exists = + device_applications_item.isMember(message_params::kMacAddress); + + if (is_device_section_exists) { + auto saved_mac_adress = + device_applications_item[message_params::kMacAddress].asString(); + + if (saved_mac_adress == mac_address) { + return device_applications_item[message_params::kApplications]; + } + } + } + + auto device_applications = Json::Value(Json::objectValue); + device_applications[message_params::kMacAddress] = Json::Value(mac_address); + device_applications[message_params::kApplications] = + Json::Value(Json::arrayValue); + + apps_consents.append(device_applications); + return apps_consents[apps_consents.size() - 1][message_params::kApplications]; +} + +Json::Value& RCConsentManagerImpl::GetAppConsentsListOrAppend( + const std::string& policy_app_id, const std::string& mac_address) const { + auto& device_applications = GetDeviceApplicationsOrAppend(mac_address); + + sync_primitives::AutoLock autolock(applications_lock_); + if (!device_applications.isArray()) { + LOG4CXX_DEBUG(logger_, "applications_consents type INVALID rewrite"); + device_applications = Json::Value(Json::arrayValue); + } + + for (auto& application : device_applications) { + const bool is_app_id_section_exists = + application.isMember(message_params::kAppId); + + if (is_app_id_section_exists) { + auto saved_app_id = application[message_params::kAppId].asString(); + + if (saved_app_id == policy_app_id) { + return application[message_params::kAppConsentList]; + } + } + } + + // In case when specified application section is absent in json file, + // will be created new section and added to dictionary. + auto application = Json::Value(Json::objectValue); + application[message_params::kAppId] = Json::Value(policy_app_id); + application[message_params::kAppConsentList] = Json::Value(Json::arrayValue); + device_applications.append(application); + + // Returns last appended object + return device_applications[device_applications.size() - 1] + [message_params::kAppConsentList]; +} + +Json::Value& RCConsentManagerImpl::GetAppsConsentsOrAppend() const { + Json::Value& remote_control = GetRemoteControlDataOrAppend(); + sync_primitives::AutoLock autolock(remote_control_lock_); + + if (!remote_control.isMember(message_params::kAppConsents)) { + LOG4CXX_DEBUG(logger_, "app_consents section is missed"); + remote_control[message_params::kAppConsents] = + Json::Value(Json::arrayValue); + } + + auto& app_consents = remote_control[message_params::kAppConsents]; + if (!app_consents.isArray()) { + LOG4CXX_DEBUG(logger_, "applications_consents type INVALID rewrite"); + app_consents = Json::Value(Json::arrayValue); + } + return app_consents; +} + +Json::Value& RCConsentManagerImpl::GetModuleTypeConsentsOrAppend( + const std::string& policy_app_id, + const std::string& mac_address, + const std::string& module_type) const { + auto& app_consnets_list = + GetAppConsentsListOrAppend(policy_app_id, mac_address); + + sync_primitives::AutoLock autolock(app_consents_lock_); + for (auto& module_consents : app_consnets_list) { + const bool module_exists = + module_consents.isMember(message_params::kModuleType); + + if (module_exists && + (module_consents[message_params::kModuleType].asString() == + module_type)) { + return module_consents[message_params::kModuleConsents]; + } + } + + // In case of absent specified module_type in section of specified + // application, will be added empty section with this module type. + LOG4CXX_DEBUG( + logger_, + "Section module_type: " << module_type + << " is missed for app_id:" << policy_app_id); + auto consent_item = Json::Value(Json::objectValue); + consent_item[message_params::kModuleType] = module_type; + consent_item[message_params::kModuleConsents] = Json::Value(Json::arrayValue); + + app_consnets_list.append(consent_item); + + // Returns last (appended) object + return app_consnets_list[app_consnets_list.size() - 1] + [message_params::kModuleConsents]; +} + +RCConsentManagerImpl::~RCConsentManagerImpl() {} + +void RCConsentManagerImpl::SaveAppModuleConsent( + Json::Value& app_module_consents, + const rc_rpc_types::ModuleIdConsent& consent_to_save) { + bool is_found = false; + + sync_primitives::AutoLock autolock(app_consents_lock_); + for (auto& consent : app_module_consents) { + const bool is_module_id_exists = + consent.isMember(message_params::kModuleId); + + // In case existing consent of specified ModuelResource (module_type + + // module_id), old value will be rewritten by new value. + + if (is_module_id_exists && (consent[message_params::kModuleId].asString() == + consent_to_save.module_id.second)) { + is_found = true; + consent[message_params::kConsent] = + Json::Value(static_cast<uint32_t>(consent_to_save.consent)); + consent[message_params::kConsentDate] = Json::Value( + static_cast<Json::UInt64>(consent_to_save.date_of_consent)); + } + } + + // Otherwise, new item will be added to the "consents" collection + + if (!is_found) { + auto new_consent = Json::Value(Json::objectValue); + new_consent[message_params::kModuleId] = + Json::Value(consent_to_save.module_id.second); + new_consent[message_params::kConsent] = + Json::Value(static_cast<uint32_t>(consent_to_save.consent)); + new_consent[message_params::kConsentDate] = + Json::Value(static_cast<Json::UInt64>(consent_to_save.date_of_consent)); + + app_module_consents.append(new_consent); + } +} + +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index 0bdec55733..ca0edc90b1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -1,13 +1,131 @@ #include "rc_rpc_plugin/rc_helpers.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message.h" +#include "application_manager/smart_object_keys.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" namespace rc_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); +const std::vector<std::string> RCHelpers::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> RCHelpers::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 RCHelpers::ButtonsMap RCHelpers::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; +} + +std::vector<std::string> RCHelpers::GetModuleReadOnlyParams( + const std::string& module_type) { + using namespace message_params; + 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(kAvailableHdChannels); + module_ro_params.push_back(kSignalStrength); + module_ro_params.push_back(kSignalChangeThreshold); + module_ro_params.push_back(kState); + module_ro_params.push_back(kSisData); + } else if (enums_value::kLight == module_type) { + module_ro_params.push_back(kLightStatus); + } + + return module_ro_params; +} + +rc_rpc_types::ModuleIdConsentVector RCHelpers::FillModuleConsents( + const std::string& module_type, + const std::vector<std::string>& module_ids, + const std::vector<bool> allowed) { + using namespace rc_rpc_types; + if (module_ids.size() != allowed.size()) { + return rc_rpc_types::ModuleIdConsentVector(); + } + + rc_rpc_types::ModuleIdConsentVector module_consents; + std::time_t current_date = std::time(0); + size_t array_size = module_ids.size(); + + for (size_t i = 0; i < array_size; ++i) { + rc_rpc_types::ModuleIdConsent module_consent; + module_consent.module_id = {module_type, module_ids[i]}; + module_consent.consent = + allowed[i] ? ModuleConsent::CONSENTED : ModuleConsent::NOT_CONSENTED; + module_consent.date_of_consent = current_date; + + module_consents.push_back(module_consent); + } + return module_consents; +} + +std::vector<std::string> RCHelpers::RetrieveModuleIds( + const ns_smart_device_link::ns_smart_objects::SmartObject& moduleIds) { + std::vector<std::string> module_ids; + for (const auto& module_id : (*moduleIds.asArray())) { + module_ids.push_back(module_id.asString()); + } + return module_ids; +} + +std::vector<bool> RCHelpers::RetrieveModuleConsents( + const ns_smart_device_link::ns_smart_objects::SmartObject& consents) { + std::vector<bool> module_consents; + for (const auto& allowed_item : (*consents.asArray())) { + module_consents.push_back(allowed_item.asBool()); + } + return module_consents; +} + const std::function<std::string(const std::string& module_type)> RCHelpers::GetModuleTypeToDataMapping() { auto mapping_lambda = [](const std::string& module_type) -> std::string { @@ -50,7 +168,7 @@ RCHelpers::GetModuleTypeToCapabilitiesMapping() { return mapping_lambda; } -const std::vector<std::string> RCHelpers::GetModulesList() { +const std::vector<std::string> RCHelpers::GetModuleTypesList() { using namespace enums_value; return {kClimate, kRadio, kSeat, kAudio, kLight, kHmiSettings}; } @@ -64,7 +182,7 @@ RCAppExtensionPtr RCHelpers::GetRCExtension( } smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI( - const std::string& module_type, const uint32_t correlation_id) { + const ModuleUid& module, const uint32_t correlation_id) { using namespace smart_objects; namespace commands = application_manager::commands; namespace am_strings = application_manager::strings; @@ -82,11 +200,28 @@ smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI( params[am_strings::function_id] = hmi_apis::FunctionID::RC_GetInteriorVehicleData; msg_params[message_params::kSubscribe] = false; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module.first; + msg_params[message_params::kModuleId] = module.second; return message; } std::vector<application_manager::ApplicationSharedPtr> +RCHelpers::AppsSubscribedToModule( + application_manager::ApplicationManager& app_mngr, + const ModuleUid& module) { + std::vector<application_manager::ApplicationSharedPtr> result; + auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr); + for (auto& app : rc_apps) { + auto rc_ext = RCHelpers::GetRCExtension(*app); + DCHECK_OR_RETURN(rc_ext, result); + if (rc_ext->IsSubscribedToInteriorVehicleData(module)) { + result.push_back(app); + } + } + return result; +} + +std::vector<application_manager::ApplicationSharedPtr> RCHelpers::AppsSubscribedToModuleType( application_manager::ApplicationManager& app_mngr, const std::string& module_type) { @@ -95,17 +230,17 @@ RCHelpers::AppsSubscribedToModuleType( for (auto& app : rc_apps) { auto rc_ext = RCHelpers::GetRCExtension(*app); DCHECK_OR_RETURN(rc_ext, result); - if (rc_ext->IsSubscibedToInteriorVehicleData(module_type)) { + if (rc_ext->IsSubscribedToInteriorVehicleDataOfType(module_type)) { result.push_back(app); } } return result; } -RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( +RCHelpers::AppsModuleTypes RCHelpers::GetApplicationsAllowedModuleTypes( app_mngr::ApplicationManager& app_mngr) { auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr); - RCHelpers::AppsModules result; + RCHelpers::AppsModuleTypes result; for (auto& app_ptr : apps_list) { std::vector<std::string> allowed_modules; app_mngr.GetPolicyHandler().GetModuleTypes(app_ptr->policy_app_id(), @@ -115,4 +250,115 @@ RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( } return result; } + +void RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params) { + using namespace message_params; + using namespace application_manager::strings; + + LOG4CXX_AUTO_TRACE(logger_); + if (!msg_params.keyExists(kModuleData)) { + return; + } + auto& module_data = msg_params[kModuleData]; + if (!module_data.keyExists(kRadioControlData) || + !module_data[kRadioControlData].keyExists(kSisData) || + !module_data[kRadioControlData][kSisData].keyExists(station_location)) { + return; + } + + auto& location_data = + module_data[kRadioControlData][kSisData][station_location]; + auto new_location_data = + smart_objects::SmartObject(smart_objects::SmartType_Map); + new_location_data[latitude_degrees] = location_data[latitude_degrees]; + new_location_data[longitude_degrees] = location_data[longitude_degrees]; + if (location_data.keyExists(altitude)) { + new_location_data[altitude] = location_data[altitude]; + + location_data = new_location_data; + } +} + +smart_objects::SmartObject RCHelpers::MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + if (data1.getType() != smart_objects::SmartType::SmartType_Map || + data2.getType() != smart_objects::SmartType::SmartType_Map) { + return data2; + } + + smart_objects::SmartObject result = data1; + + for (auto it = data2.map_begin(); it != data2.map_end(); ++it) { + const std::string& key = it->first; + smart_objects::SmartObject& value = it->second; + if (!result.keyExists(key) || value.getType() != result[key].getType()) { + result[key] = value; + continue; + } + + // Merge maps and arrays with `id` param included, replace other types + if (value.getType() == smart_objects::SmartType::SmartType_Map) { + value = MergeModuleData(result[key], value); + } else if (value.getType() == smart_objects::SmartType::SmartType_Array) { + value = MergeArray(result[key], value); + } + result[key] = value; + } + return result; +} + +smart_objects::SmartObject RCHelpers::MergeArray( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + // Merge data only in the case where each value in the array is an Object with + // an ID included, otherwise replace + + if (data1.getType() != smart_objects::SmartType::SmartType_Array || + data2.getType() != smart_objects::SmartType::SmartType_Array || + data2.empty()) { + return data2; + } + + auto& data2_array = *data2.asArray(); + for (const auto& data_item : data2_array) { + if (data_item.getType() != smart_objects::SmartType_Map || + !data_item.keyExists(application_manager::strings::id)) { + return data2; + } + } + + smart_objects::SmartObject result = data1; + smart_objects::SmartArray* result_array = result.asArray(); + + auto find_by_id = [](smart_objects::SmartArray* array, + const smart_objects::SmartObject& id) + -> smart_objects::SmartArray::iterator { + return std::find_if(array->begin(), + array->end(), + [&id](const smart_objects::SmartObject& obj) -> bool { + return id == obj[application_manager::strings::id]; + }); + }; + + auto merge = [&result_array, + &find_by_id](const smart_objects::SmartObject& data) -> void { + auto element_id = data[application_manager::strings::id]; + auto result_it = find_by_id(result_array, element_id); + + if (result_array->end() != result_it) { + *result_it = RCHelpers::MergeModuleData(*result_it, data); + } else { + result_array->push_back(data); + } + }; + + for (const auto& data : data2_array) { + merge(data); + } + + return result; } + +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 3bc1106573..9005eb7fd0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -29,16 +29,18 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/plugin_manager/plugin_keys.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_command_factory.h" -#include "rc_rpc_plugin/rc_app_extension.h" -#include "rc_rpc_plugin/resource_allocation_manager_impl.h" +#include <memory> +#include "application_manager/plugin_manager/plugin_keys.h" #include "rc_rpc_plugin/interior_data_cache_impl.h" #include "rc_rpc_plugin/interior_data_manager_impl.h" +#include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_capabilities_manager_impl.h" +#include "rc_rpc_plugin/rc_command_factory.h" +#include "rc_rpc_plugin/rc_consent_manager_impl.h" #include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/resource_allocation_manager_impl.h" #include "utils/helpers.h" -#include <memory> namespace rc_rpc_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); @@ -49,23 +51,35 @@ bool RCRPCPlugin::Init( application_manager::ApplicationManager& app_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + rc_consent_manager_.reset(new rc_rpc_plugin::RCConsentManagerImpl( + last_state, + app_manager, + app_manager.get_settings().period_for_consent_expiration())); interior_data_cache_.reset(new InteriorDataCacheImpl()); interior_data_manager_.reset(new InteriorDataManagerImpl( *this, *interior_data_cache_, app_manager, rpc_service)); - - resource_allocation_manager_.reset( - new ResourceAllocationManagerImpl(app_manager, rpc_service)); + rc_capabilities_manager_.reset( + new RCCapabilitiesManagerImpl(hmi_capabilities)); + resource_allocation_manager_.reset(new ResourceAllocationManagerImpl( + app_manager, rpc_service, *(rc_capabilities_manager_.get()))); RCCommandParams params{app_manager, rpc_service, hmi_capabilities, policy_handler, *(resource_allocation_manager_.get()), *(interior_data_cache_.get()), - *(interior_data_manager_.get())}; + *(interior_data_manager_.get()), + *(rc_capabilities_manager_.get()), + *(rc_consent_manager_.get())}; command_factory_.reset(new rc_rpc_plugin::RCCommandFactory(params)); rpc_service_ = &rpc_service; app_mngr_ = &app_manager; + + // Check all saved consents and remove expired + rc_consent_manager_->RemoveExpiredConsents(); + return true; } @@ -98,8 +112,13 @@ void RCRPCPlugin::OnApplicationEvent( } switch (event) { case plugins::kApplicationRegistered: { - application->AddExtension( - std::shared_ptr<RCAppExtension>(new RCAppExtension(kRCPluginID))); + auto extension = + std::shared_ptr<RCAppExtension>(new RCAppExtension(kRCPluginID)); + application->AddExtension(extension); + const auto driver_location = + rc_capabilities_manager_ + ->GetDriverLocationFromSeatLocationCapability(); + extension->SetUserLocation(driver_location); resource_allocation_manager_->SendOnRCStatusNotifications( NotificationTrigger::APP_REGISTRATION, application); break; @@ -114,6 +133,12 @@ void RCRPCPlugin::OnApplicationEvent( interior_data_manager_->OnApplicationEvent(event, application); break; } + case plugins::kGlobalPropertiesUpdated: { + const auto user_location = application->get_user_location(); + auto extension = RCHelpers::GetRCExtension(*application); + extension->SetUserLocation(user_location); + break; + } default: break; } @@ -121,8 +146,8 @@ void RCRPCPlugin::OnApplicationEvent( RCRPCPlugin::Apps RCRPCPlugin::GetRCApplications( application_manager::ApplicationManager& app_mngr) { - using application_manager::ApplicationSharedPtr; using application_manager::ApplicationSet; + using application_manager::ApplicationSharedPtr; ApplicationSet accessor = app_mngr.applications().GetData(); std::vector<ApplicationSharedPtr> result; @@ -136,6 +161,14 @@ RCRPCPlugin::Apps RCRPCPlugin::GetRCApplications( } // namespace rc_rpc_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new rc_rpc_plugin::RCRPCPlugin(); } // namespace rc_rpc_plugin + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(rc_rpc_plugin::logger_); +} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc index ecd263b77a..97ff2b23da 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc @@ -33,14 +33,14 @@ #include "rc_rpc_plugin/resource_allocation_manager_impl.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" -#include "smart_objects/enum_schema_item.h" -#include "application_manager/message_helper.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/rc_helpers.h" #include "json/json.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" namespace rc_rpc_plugin { @@ -49,16 +49,20 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") ResourceAllocationManagerImpl::ResourceAllocationManagerImpl( application_manager::ApplicationManager& app_mngr, - application_manager::rpc_service::RPCService& rpc_service) + application_manager::rpc_service::RPCService& rpc_service, + RCCapabilitiesManager& rc_capabilities_manager) : current_access_mode_(hmi_apis::Common_RCAccessMode::AUTO_ALLOW) , app_mngr_(app_mngr) , rpc_service_(rpc_service) + , rc_capabilities_manager_(rc_capabilities_manager) , is_rc_enabled_(true) {} ResourceAllocationManagerImpl::~ResourceAllocationManagerImpl() {} AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); const application_manager::ApplicationSharedPtr acquiring_app = app_mngr_.application(app_id); @@ -67,40 +71,57 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource( return AcquireResult::IN_USE; } + ModuleUid module(module_type, module_id); + + if (rc_capabilities_manager_.IsSeatLocationCapabilityProvided() && + !IsUserLocationValid(module, acquiring_app)) { + LOG4CXX_WARN(logger_, + "Resource acquisition is not allowed " + "according to location verification."); + return AcquireResult::REJECTED; + } + sync_primitives::AutoLock lock(allocated_resources_lock_); const AllocatedResources::const_iterator allocated_it = - allocated_resources_.find(module_type); + allocated_resources_.find(module); if (allocated_resources_.end() == allocated_it) { - SetResourceAquired(module_type, app_id); LOG4CXX_DEBUG(logger_, "Resource is not acquired yet. " << "App: " << app_id << " is allowed to acquire " - << module_type); + << module_type << " " << module_id); return AcquireResult::ALLOWED; } - if (app_id == allocated_resources_[module_type]) { + if (app_id == allocated_resources_[module]) { LOG4CXX_DEBUG(logger_, "App: " << app_id << " is already acquired resource " - << module_type); + << module_type << " " << module_id); return AcquireResult::ALLOWED; } - if (IsModuleTypeRejected(module_type, app_id)) { + if (IsModuleTypeRejected(module_type, module_id, app_id)) { LOG4CXX_DEBUG(logger_, "Driver disallowed app: " << app_id << " to acquire " - << module_type); + << module_type << " " << module_id); return AcquireResult::REJECTED; } const mobile_apis::HMILevel::eType acquiring_app_hmi_level = - acquiring_app->hmi_level(); + acquiring_app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (mobile_apis::HMILevel::HMI_FULL != acquiring_app_hmi_level) { LOG4CXX_DEBUG(logger_, "Aquiring resources is not allowed in HMI level: " << acquiring_app_hmi_level << ". App: " << app_id - << " is disallowed to acquire " << module_type); + << " is disallowed to acquire " << module_type << " " + << module_id); + return AcquireResult::REJECTED; + } + + if (!rc_capabilities_manager_.IsMultipleAccessAllowed(module)) { + LOG4CXX_DEBUG(logger_, + "Multiple access for the: " << module_type << " " << module_id + << " isn't allowed"); return AcquireResult::REJECTED; } @@ -109,34 +130,57 @@ AcquireResult::eType ResourceAllocationManagerImpl::AcquireResource( LOG4CXX_DEBUG(logger_, "Current access_mode is AUTO_DENY. " << "App: " << app_id << " is disallowed to acquire " - << module_type); + << module_type << " " << module_id); 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); + << app_id << " to acquire " << module_type << " " + << module_id); 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); - - SetResourceAquired(module_type, app_id); + << module_type << " " << module_id); return AcquireResult::ALLOWED; } default: { DCHECK_OR_RETURN(false, AcquireResult::IN_USE); } } } -void ResourceAllocationManagerImpl::ReleaseResource( +bool ResourceAllocationManagerImpl::IsUserLocationValid( + ModuleUid& module, application_manager::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + const auto extension = RCHelpers::GetRCExtension(*app); + const auto user_location = extension->GetUserLocation(); + const auto module_service_area = + rc_capabilities_manager_.GetModuleServiceArea(module); + const auto driver = + rc_capabilities_manager_.GetDriverLocationFromSeatLocationCapability(); + const bool is_driver = user_location == driver; + if (is_driver || user_location.IntersectionExists(module_service_area)) { + return true; + } + LOG4CXX_DEBUG(logger_, "User location is not valid"); + return false; +} + +void ResourceAllocationManagerImpl::ReleaseModuleType( const std::string& module_type, const uint32_t application_id) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Release " << module_type << " by " << application_id); - SetResourceFree(module_type, application_id); + LOG4CXX_DEBUG(logger_, + "Release " << module_type << " " + << " by " << application_id); + Resources allocated_resources = GetAcquiredResources(application_id); + for (const auto& resource : allocated_resources) { + if (module_type == resource.first) { + SetResourceFree(module_type, resource.second, application_id); + } + } } void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { @@ -147,10 +191,10 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { 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()); + std::set<std::string> acquired_modules = + GetAcquiredModuleTypes(application_id); - Resources allowed_modules; + std::vector<std::string> allowed_modules; app_mngr_.GetPolicyHandler().GetModuleTypes((*app)->policy_app_id(), &allowed_modules); std::sort(allowed_modules.begin(), allowed_modules.end()); @@ -160,17 +204,16 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { << " , allowed modules: " << allowed_modules.size()); - Resources disallowed_modules; + std::vector<std::string> disallowed_modules; std::set_difference(acquired_modules.begin(), acquired_modules.end(), allowed_modules.begin(), allowed_modules.end(), std::back_inserter(disallowed_modules)); - auto rc_extention = RCHelpers::GetRCExtension(**app); - Resources::const_iterator module = disallowed_modules.begin(); + auto module = disallowed_modules.begin(); for (; disallowed_modules.end() != module; ++module) { - ReleaseResource(*module, application_id); + ReleaseModuleType(*module, application_id); } if (!disallowed_modules.empty()) { SendOnRCStatusNotifications( @@ -190,23 +233,24 @@ EnumType StringToEnum(const std::string& str) { void ConstructOnRCStatusNotificationParams( smart_objects::SmartObject& msg_params, - const std::map<std::string, uint32_t>& allocated_resources, - const std::vector<std::string>& supported_resources, + const std::map<ModuleUid, uint32_t>& allocated_resources, + const std::vector<ModuleUid>& supported_resources, const uint32_t app_id) { namespace strings = application_manager::strings; namespace message_params = rc_rpc_plugin::message_params; using smart_objects::SmartObject; - using smart_objects::SmartType_Map; using smart_objects::SmartType_Array; + using smart_objects::SmartType_Map; LOG4CXX_AUTO_TRACE(logger_); auto modules_inserter = [](SmartObject& result_modules) { - return [&result_modules](const std::string& module_name) { + return [&result_modules](const ModuleUid& module) { smart_objects::SmartObject module_data = SmartObject(smart_objects::SmartType_Map); auto module_type = - StringToEnum<mobile_apis::ModuleType::eType>(module_name); + StringToEnum<mobile_apis::ModuleType::eType>(module.first); module_data[message_params::kModuleType] = module_type; + module_data[message_params::kModuleId] = module.second; result_modules.asArray()->push_back(module_data); }; }; @@ -236,10 +280,11 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile( mobile_apis::FunctionID::OnRCStatusID, app->app_id()); auto& msg_params = (*msg_to_mobile)[application_manager::strings::msg_params]; if (is_rc_enabled()) { - ConstructOnRCStatusNotificationParams(msg_params, - allocated_resources_, - RCHelpers::GetModulesList(), - app->app_id()); + ConstructOnRCStatusNotificationParams( + msg_params, + allocated_resources_, + rc_capabilities_manager_.GetResources(), + app->app_id()); } else { msg_params[message_params::kAllocatedModules] = smart_objects::SmartObject(smart_objects::SmartType_Array); @@ -259,21 +304,12 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi( auto& msg_params = (*msg_to_hmi)[application_manager::strings::msg_params]; ConstructOnRCStatusNotificationParams(msg_params, allocated_resources_, - RCHelpers::GetModulesList(), + rc_capabilities_manager_.GetResources(), app->app_id()); msg_params[application_manager::strings::app_id] = app->hmi_app_id(); return msg_to_hmi; } -void ResourceAllocationManagerImpl::SetResourceAquired( - const std::string& module_type, const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); - allocated_resources_[module_type] = app_id; - SendOnRCStatusNotifications( - NotificationTrigger::MODULE_ALLOCATION, - std::shared_ptr<application_manager::Application>()); -} - void ResourceAllocationManagerImpl::SendOnRCStatusNotifications( NotificationTrigger::eType event, application_manager::ApplicationSharedPtr application) { @@ -310,25 +346,81 @@ void ResourceAllocationManagerImpl::set_rc_enabled(const bool value) { std::shared_ptr<application_manager::Application>()); } -void ResourceAllocationManagerImpl::SetResourceFree( - const std::string& module_type, const uint32_t app_id) { +ResourceReleasedState::eType ResourceAllocationManagerImpl::ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, + "Release " << module_type << " " << module_id << " by " + << application_id); + return SetResourceFree(module_type, module_id, application_id); +} + +void ResourceAllocationManagerImpl::SetResourceAcquired( + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); + allocated_resources_[module] = app_id; +} + +bool ResourceAllocationManagerImpl::IsResourceAlreadyAcquiredByApp( + const ModuleUid& moduleUid, const uint32_t app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto allocation = allocated_resources_.find(moduleUid); + + if (allocated_resources_.end() == allocation) { + LOG4CXX_DEBUG(logger_, + "Resource " << moduleUid.first + << " is not allocated for any application."); + return false; + } + + if (allocation->second != app_id) { + LOG4CXX_DEBUG(logger_, + "Resource " + << moduleUid.first + << " is already allocated by app:" << allocation->second + << ". Asquire has been asked for app:" << app_id); + return false; + } + + LOG4CXX_DEBUG(logger_, + "Resource " << moduleUid.first + << " is allocated by app:" << allocation->second); + + return true; +} + +ResourceReleasedState::eType ResourceAllocationManagerImpl::SetResourceFree( + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { + ModuleUid module(module_type, module_id); AllocatedResources::const_iterator allocation = - allocated_resources_.find(module_type); + allocated_resources_.find(module); if (allocated_resources_.end() == allocation) { LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is not allocated."); - return; + return ResourceReleasedState::NOT_ALLOCATED; } if (app_id != allocation->second) { LOG4CXX_ERROR(logger_, "Resource " << module_type << " is allocated by different application " << allocation->second); + return ResourceReleasedState::IS_ALLOCATED; } allocated_resources_.erase(allocation); - LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released."); + LOG4CXX_DEBUG( + logger_, + "Resource " << module_type << ":" << module_id << " is released."); + return ResourceReleasedState::IS_RELEASED; } -std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources( +std::vector<ModuleUid> ResourceAllocationManagerImpl::GetAcquiredResources( const uint32_t application_id) const { LOG4CXX_AUTO_TRACE(logger_); Resources allocated_resources; @@ -347,18 +439,37 @@ std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources( return allocated_resources; } +std::set<std::string> ResourceAllocationManagerImpl::GetAcquiredModuleTypes( + const uint32_t application_id) const { + LOG4CXX_AUTO_TRACE(logger_); + Resources allocated_resources = GetAcquiredResources(application_id); + std::set<std::string> acquired_module_types; + for (const auto& resource : allocated_resources) { + acquired_module_types.insert(resource.first); + } + + LOG4CXX_DEBUG(logger_, + "Application " << application_id << " acquired " + << acquired_module_types.size() + << " module type(s)."); + + return acquired_module_types; +} + void ResourceAllocationManagerImpl::SetResourceState( const std::string& module_type, + const std::string& module_id, 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); + ModuleUid module(module_type, module_id); { sync_primitives::AutoLock lock(allocated_resources_lock_); const AllocatedResources::const_iterator allocated_it = - allocated_resources_.find(module_type); + allocated_resources_.find(module); const bool acquired = allocated_resources_.end() != allocated_it; if (acquired) { @@ -374,16 +485,16 @@ void ResourceAllocationManagerImpl::SetResourceState( } sync_primitives::AutoLock lock(resources_state_lock_); - resources_state_[module_type] = state; + resources_state_[module] = state; LOG4CXX_DEBUG(logger_, "Resource " << module_type << " got state " << state); } bool ResourceAllocationManagerImpl::IsResourceFree( - const std::string& module_type) const { + const std::string& module_type, const std::string& module_id) const { LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); sync_primitives::AutoLock lock(resources_state_lock_); - const ResourcesState::const_iterator resource = - resources_state_.find(module_type); + const ResourcesState::const_iterator resource = resources_state_.find(module); if (resources_state_.end() == resource) { LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is free."); @@ -411,15 +522,20 @@ ResourceAllocationManagerImpl::GetAccessMode() const { } void ResourceAllocationManagerImpl::ForceAcquireResource( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_DEBUG(logger_, "Force " << app_id << " acquiring " << module_type); sync_primitives::AutoLock lock(allocated_resources_lock_); - SetResourceAquired(module_type, app_id); + SetResourceAcquired(module_type, module_id, app_id); } bool ResourceAllocationManagerImpl::IsModuleTypeRejected( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); sync_primitives::AutoLock lock(rejected_resources_for_application_lock_); RejectedResources::iterator it = rejected_resources_for_application_.find(app_id); @@ -428,24 +544,27 @@ bool ResourceAllocationManagerImpl::IsModuleTypeRejected( return false; } - const std::vector<std::string>& list_of_rejected_resources = + const std::vector<ModuleUid>& list_of_rejected_resources = rejected_resources_for_application_[app_id]; - return helpers::in_range(list_of_rejected_resources, module_type); + return helpers::in_range(list_of_rejected_resources, module); } void ResourceAllocationManagerImpl::OnDriverDisallowed( - const std::string& module_type, const uint32_t app_id) { + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); + ModuleUid module(module_type, module_id); sync_primitives::AutoLock lock(rejected_resources_for_application_lock_); auto 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>(); + rejected_resources_for_application_[app_id] = std::vector<ModuleUid>(); } - std::vector<std::string>& list_of_rejected_resources = + std::vector<ModuleUid>& list_of_rejected_resources = rejected_resources_for_application_[app_id]; - list_of_rejected_resources.push_back(module_type); + list_of_rejected_resources.push_back(module); } void ResourceAllocationManagerImpl::OnApplicationEvent( @@ -458,10 +577,10 @@ void ResourceAllocationManagerImpl::OnApplicationEvent( if (ApplicationEvent::kApplicationExit == event || ApplicationEvent::kApplicationUnregistered == event) { - Resources acquired_modules = GetAcquiredResources(application->app_id()); - Resources::const_iterator module = acquired_modules.begin(); + auto acquired_modules = GetAcquiredModuleTypes(application->app_id()); + auto module = acquired_modules.begin(); for (; acquired_modules.end() != module; ++module) { - ReleaseResource(*module, application->app_id()); + ReleaseModuleType(*module, application->app_id()); } if (!acquired_modules.empty()) { SendOnRCStatusNotifications( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt index c1c59d7e78..bd46bdf11f 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt @@ -37,11 +37,14 @@ include_directories ( ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/include/ ${COMPONENTS_DIR}/include/test/application_manager/ ${COMPONENTS_DIR}/rc_rpc_plugin/test/include + ${COMPONENTS_DIR}/resumption/include ) set (RC_TEST_SOURCES -${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/interior_data_cache_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/rc_consent_manager_impl_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/grid_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/rc_helpers_test.cc ) set(RC_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) @@ -52,17 +55,9 @@ file(GLOB SOURCES ) set(LIBRARIES - RCRpcPluginStaticLib - ApplicationManager - connectionHandler - SmartObjects - ProtocolHandler - MessageHelper - connectionHandler - Utils - jsoncpp + rc_rpc_plugin_static + Resumption gmock_main - dl ) if(ENABLE_LOG) @@ -75,3 +70,4 @@ endif() create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" ) create_test("rc_plugin_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") +add_subdirectory(resource_allocation_manager) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index e9d1063648..fb8de0bb9c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -30,22 +30,28 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "rc_rpc_plugin/commands/mobile/button_press_request.h" -#include "rc_rpc_plugin/rc_command_factory.h" -#include "rc_rpc_plugin/rc_app_extension.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" -#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" -#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_command_factory.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +using ::application_manager::Message; +using ::application_manager::MessageType; +using application_manager::commands::MessageSharedPtr; +using ::protocol_handler::MessagePriority; using test::components::application_manager_test::MockApplication; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; @@ -57,17 +63,13 @@ using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SaveArg; -using ::application_manager::Message; -using ::application_manager::MessageType; -using application_manager::commands::MessageSharedPtr; -using ::protocol_handler::MessagePriority; namespace { const int kModuleId = 153u; const uint32_t kConnectionKey = 1u; const uint32_t kAppId = 0u; const std::string kPolicyAppId = "Test"; -} +} // namespace namespace rc_rpc_plugin_test { @@ -82,40 +84,9 @@ class ButtonPressRequestTest , rc_app_extention_( std::make_shared<rc_rpc_plugin::RCAppExtension>(kModuleId)) {} - 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 mobile_apis; - - std::vector<ButtonName::eType> button_names = {ButtonName::AC_MAX, - ButtonName::AC, - ButtonName::RECIRCULATE, - ButtonName::FAN_UP, - ButtonName::FAN_DOWN, - ButtonName::TEMP_UP, - ButtonName::TEMP_DOWN, - ButtonName::DEFROST_MAX, - ButtonName::DEFROST, - ButtonName::DEFROST_REAR, - ButtonName::UPPER_VENT, - ButtonName::LOWER_VENT, - ButtonName::VOLUME_UP, - ButtonName::VOLUME_DOWN, - ButtonName::EJECT, - ButtonName::SOURCE, - ButtonName::SHUFFLE, - 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; + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); @@ -129,9 +100,16 @@ class ButtonPressRequestTest ON_CALL(mock_policy_handler_, CheckHMIType(kPolicyAppId, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, - nullptr)).WillByDefault(Return(true)); + nullptr)) + .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckButtonName(_, _)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfButtonExistInRCCaps(_)) + .WillByDefault(Return(true)); } MessageSharedPtr CreateBasicMessage() { @@ -155,7 +133,9 @@ class ButtonPressRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -171,33 +151,41 @@ class ButtonPressRequestTest mock_interior_data_cache_; testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager> mock_interior_data_manager_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(ButtonPressRequestTest, Execute_ButtonNameMatchesModuleType_ExpectCorrectMessageSentToHMI) { // Arrange + const std::string resource = "CLIMATE"; + const std::string resource_id = "id1"; MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + msg_params[message_params::kModuleId] = resource_id; msg_params[message_params::kButtonName] = mobile_apis::ButtonName::AC; msg_params[message_params::kButtonPressMode] = mobile_apis::ButtonPressMode::SHORT; // Expectations - const std::string resource = "CLIMATE"; ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource)) + + EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource, resource_id)) .WillOnce(Return(true)); - EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::ALLOWED)); EXPECT_CALL( mock_allocation_manager_, - SetResourceState(resource, kAppId, rc_rpc_plugin::ResourceState::BUSY)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), - _)).WillOnce(Return(true)); + SetResourceState( + resource, resource_id, kAppId, rc_rpc_plugin::ResourceState::BUSY)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), _)) + .WillOnce(Return(true)); // Act std::shared_ptr<rc_rpc_plugin::commands::ButtonPressRequest> command = @@ -211,28 +199,34 @@ TEST_F( ButtonPressRequestTest, Execute_ButtonNameDoesNotMatchModuleType_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { // Arrange + const std::string resource = "RADIO"; + const std::string resource_id = "id1"; MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + msg_params[message_params::kModuleId] = resource_id; msg_params[message_params::kButtonName] = mobile_apis::ButtonName::AC; msg_params[message_params::kButtonPressMode] = mobile_apis::ButtonPressMode::SHORT; // Expectations - const std::string resource = "RADIO"; + EXPECT_CALL(mock_rc_capabilities_manager_, CheckButtonName(_, _)) + .WillOnce(Return(false)); ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource)) + EXPECT_CALL(mock_allocation_manager_, IsResourceFree(resource, resource_id)) .WillOnce(Return(true)); - EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(resource, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::ALLOWED)); - EXPECT_CALL(mock_allocation_manager_, SetResourceState(resource, kAppId, _)) + EXPECT_CALL(mock_allocation_manager_, + SetResourceState(resource, resource_id, kAppId, _)) .Times(2); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), - _)).Times(0); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_ButtonPress), _)) + .Times(0); MessageSharedPtr command_result; EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( @@ -266,9 +260,10 @@ TEST_F(ButtonPressRequestTest, OnEvent_ExpectSuccessfullResponseSentToMobile) { hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; // Expectations - EXPECT_CALL(mock_allocation_manager_, - SetResourceState(_, kAppId, rc_rpc_plugin::ResourceState::FREE)) - .Times(2); + EXPECT_CALL( + mock_allocation_manager_, + SetResourceState(_, _, kAppId, rc_rpc_plugin::ResourceState::FREE)) + .Times(1); EXPECT_CALL( mock_rpc_service_, @@ -305,9 +300,10 @@ TEST_F(ButtonPressRequestTest, hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; // Expectations - EXPECT_CALL(mock_allocation_manager_, - SetResourceState(_, kAppId, rc_rpc_plugin::ResourceState::FREE)) - .Times(2); + EXPECT_CALL( + mock_allocation_manager_, + SetResourceState(_, _, kAppId, rc_rpc_plugin::ResourceState::FREE)) + .Times(1); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc new file mode 100644 index 0000000000..29708d05bd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_consent_request_test.cc @@ -0,0 +1,402 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <memory> +#include <string> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +using application_manager::commands::MessageSharedPtr; +using rc_rpc_plugin_test::MockInteriorDataCache; +using rc_rpc_plugin_test::MockInteriorDataManager; +using rc_rpc_plugin_test::MockRCCapabilitiesManager; +using rc_rpc_plugin_test::MockRCConsentManager; +using rc_rpc_plugin_test::MockResourceAllocationManager; +using test::components::application_manager_test::MockApplication; +using test::components::commands_test::CommandRequestTest; +using test::components::commands_test::CommandsTestMocks; + +using ::testing::_; +using ::testing::DoAll; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SaveArg; + +typedef std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataConsentRequest> + GIVDConsentPtr; + +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kAppId = 2u; +const std::string kPolicyAppId = "policy_app_id"; +const std::string kMacAddress = "device1"; +const std::string kModuleId_1 = "34045662-a9dc-4823-8435-91056d4c26cb"; +const std::string kModuleId_2 = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; +const std::string kModuleId_3 = "06cdec22-920e-4865-bf2e-9518463edc68"; +const mobile_apis::ModuleType::eType kModule_Type = + mobile_apis::ModuleType::eType::RADIO; +} // namespace + +namespace rc_rpc_plugin_test { +namespace get_interior_vehicle_data_consent_request_test { +using namespace rc_rpc_plugin; + +class GetInteriorVehicleDataConsentRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + GetInteriorVehicleDataConsentRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + TestPrecondition(); + } + + void TestPrecondition() { + message_ = CreateBasicMessage(); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(true)); + } + + void PrepareNoConsentExistInCache() { + ON_CALL(mock_allocation_manager_, GetAccessMode()) + .WillByDefault(Return(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + ON_CALL(mock_rc_consent_manger_, + GetModuleConsent(kPolicyAppId, kMacAddress, _)) + .WillByDefault(Return(rc_rpc_types::ModuleConsent::NOT_EXISTS)); + ON_CALL(mock_allocation_manager_, + AcquireResource(_, _, mock_app_->app_id())) + .WillByDefault(Return(AcquireResult::IN_USE)); + } + + void PrepareMobileMessage() { + auto& msg_params = (*message_)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = kModule_Type; + + msg_params[message_params::kModuleIds][0] = kModuleId_1; + msg_params[message_params::kModuleIds][1] = kModuleId_2; + msg_params[message_params::kModuleIds][2] = kModuleId_3; + } + + /** + * @brief CreateBasicMessage creates message for + * GetInteriorVehicleData request for app1 + * @return message shared ptr + */ + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::GetInteriorVehicleDataID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::app_id] = kAppId; + return message; + } + + template <class Command> + std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) { + InitCommand(kDefaultTimeout_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; + return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); + } + + protected: + GIVDConsentPtr command_; + MessageSharedPtr message_; + + MockAppPtr mock_app_; + NiceMock<MockResourceAllocationManager> mock_allocation_manager_; + NiceMock<MockInteriorDataCache> mock_interior_data_cache_; + NiceMock<MockInteriorDataManager> mock_interior_data_manager_; + NiceMock<MockRCCapabilitiesManager> mock_rc_capabilities_manager_; + NiceMock<MockRCConsentManager> mock_rc_consent_manger_; +}; + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + ModuleIDReturnsEmptyString_SUCCESS) { + std::string empty_str; + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + + EXPECT_EQ(empty_str, command_->ModuleId()); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + Execute_ModuleIdsIsAbsentInMessage_Response_INVALID_DATA) { + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + + auto response_to_mobile = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->Execute(); + + const bool result = + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + const auto result_code = static_cast<mobile_apis::Result::eType>( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_FALSE(result); + EXPECT_EQ(mobile_apis::Result::INVALID_DATA, result_code); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + Execute_ModuleIdsIsEmpty_AddDefaultModuleID) { + (*message_)[application_manager::strings::msg_params] + [message_params::kModuleIds] = smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Array); + (*message_)[application_manager::strings::msg_params] + [message_params::kModuleType] = kModule_Type; + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + + auto message_to_hmi = CreateMessage(); + + const std::string module_type = "RADIO"; + const std::string default_module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + ON_CALL(mock_rc_capabilities_manager_, + GetDefaultModuleIdFromCapabilities(module_type)) + .WillByDefault(Return(default_module_id)); + + PrepareNoConsentExistInCache(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_hmi), Return(true))); + + command_->Execute(); + + ASSERT_FALSE((*message_to_hmi)[application_manager::strings::msg_params] + [message_params::kModuleIds] + .empty()); + const auto sent_module_id = + (*message_to_hmi)[application_manager::strings::msg_params] + [message_params::kModuleIds][0] + .asString(); + EXPECT_EQ(sent_module_id, default_module_id); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + Execute_SDLForwardsMobileMessageToHMI_SUCCESS) { + auto message_to_hmi = CreateMessage(); + + PrepareMobileMessage(); + PrepareNoConsentExistInCache(); + + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_hmi), Return(true))); + + command_->Execute(); + + auto outgoing_msg_params = + (*message_to_hmi)[application_manager::strings::msg_params]; + + auto module_type = static_cast<mobile_apis::ModuleType::eType>( + outgoing_msg_params[message_params::kModuleType].asUInt()); + + EXPECT_EQ(kModule_Type, module_type); + EXPECT_EQ(kModuleId_1, + outgoing_msg_params[message_params::kModuleIds][0].asString()); + EXPECT_EQ(kModuleId_2, + outgoing_msg_params[message_params::kModuleIds][1].asString()); + EXPECT_EQ(kModuleId_3, + outgoing_msg_params[message_params::kModuleIds][2].asString()); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + On_Event_ConsentCollectionIsAbsentOrEmpty_Response_GENERIC_ERROR) { + PrepareMobileMessage(); + + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + + // Consent collection in HMI response is absent + auto event_message = CreateMessage(); + application_manager::event_engine::Event event_collection_is_absent( + hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent); + event_collection_is_absent.set_smart_object(*event_message); + + auto response_to_mobile = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event_collection_is_absent); + + const auto result_code_is_absent = static_cast<mobile_apis::Result::eType>( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR, result_code_is_absent); + + // Consent coolection in HMI response isn't absent but is empty + event_message = CreateMessage(); + application_manager::event_engine::MobileEvent event_collection_is_empty( + mobile_apis::FunctionID::GetInteriorVehicleDataConsentID); + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed] = smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Array); + event_collection_is_empty.set_smart_object(*event_message); + + response_to_mobile = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event_collection_is_absent); + + const auto result_code_is_empty = static_cast<mobile_apis::Result::eType>( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR, result_code_is_empty); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + On_Event_ConsentsSizeIsNotEqualModuleIdsSize_Response_GENERIC_ERROR) { + PrepareMobileMessage(); + PrepareNoConsentExistInCache(); + + // ModuleIds collection will be saved + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + command_->Execute(); + + auto event_message = CreateMessage(); + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed] = smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Array); + + // Consent collection will contain only two items in collection + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][0] = true; + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][1] = false; + + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent); + event.set_smart_object(*event_message); + + auto response_to_mobile = CreateMessage(); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event); + + const auto result_code_is_empty = static_cast<mobile_apis::Result::eType>( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::GENERIC_ERROR, result_code_is_empty); +} + +TEST_F(GetInteriorVehicleDataConsentRequestTest, + On_Event_SaveModuleConsentsToLastState_Response_SUCCESS) { + PrepareMobileMessage(); + PrepareNoConsentExistInCache(); + + // ModuleIds collection will be saved + command_ = + CreateRCCommand<commands::GetInteriorVehicleDataConsentRequest>(message_); + command_->Execute(); + + // Consent collection will have same size as moduelIds collection + auto event_message = CreateMessage(); + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][0] = true; + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][1] = false; + (*event_message)[application_manager::strings::msg_params] + [message_params::kAllowed][2] = false; + + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleDataConsent); + event.set_smart_object(*event_message); + + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + + EXPECT_CALL(mock_rc_consent_manger_, SaveModuleConsents(kPolicyAppId, _, _)); + + auto response_to_mobile = CreateMessage(); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + + command_->on_event(event); + + const auto result_code_is_empty = static_cast<mobile_apis::Result::eType>( + (*response_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + EXPECT_EQ(mobile_apis::Result::SUCCESS, result_code_is_empty); +} + +} // namespace get_interior_vehicle_data_consent_request_test +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index 4e74e74ef8..532a62df3b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,52 +31,57 @@ */ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" -#include "gtest/gtest.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/message_helper.h" #include "application_manager/mock_application.h" +#include "gtest/gtest.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_command_factory.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "application_manager/message_helper.h" -#include "rc_rpc_plugin/rc_command_factory.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/commands/command_request_test.h" -#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" -#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" -#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" -#include <thread> +#include <stdint.h> #include <chrono> +#include <thread> -using ::testing::_; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::StrictMock; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::SaveArg; +using application_manager::ApplicationSet; +using ::application_manager::ApplicationSharedPtr; using ::application_manager::Message; using ::application_manager::MessageType; -using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; -using ::application_manager::ApplicationSharedPtr; using ::protocol_handler::MessagePriority; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; -using test::components::commands_test::MockApplicationManager; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; using test::components::commands_test::HMIResultCodeIs; using test::components::commands_test::MobileResultCodeIs; +using test::components::commands_test::MockApplicationManager; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::SaveArg; +using ::testing::StrictMock; namespace { const int32_t kConnectionKey = 5u; const uint32_t kAppId = 0u; const uint32_t kAppId2 = 1u; const int kModuleId = 153u; -const auto module_type = mobile_apis::ModuleType::RADIO; +const auto module_eType = mobile_apis::ModuleType::RADIO; +const auto module_type = "RADIO"; +const auto module_id = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; const int32_t time_frame_of_allowed_requests = 1; const uint32_t max_request_in_time_frame = 5u; -} +} // namespace namespace rc_rpc_plugin_test { @@ -90,7 +95,8 @@ class GetInteriorVehicleDataRequestTest , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) , rc_app_extention2_(std::make_shared<RCAppExtension>(kModuleId)) , apps_lock_(std::make_shared<sync_primitives::Lock>()) - , apps_da_(apps_, apps_lock_) { + , apps_da_(apps_, apps_lock_) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) { ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(*mock_app2_, app_id()).WillByDefault(Return(kAppId2)); ON_CALL(*mock_app_, is_remote_control_supported()) @@ -124,6 +130,8 @@ class GetInteriorVehicleDataRequestTest std::pair<uint32_t, int32_t> frequency; frequency.first = max_request_in_time_frame; frequency.second = time_frame_of_allowed_requests; + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, get_settings()) .WillByDefault(ReturnRef(app_mngr_settings_)); ON_CALL(app_mngr_settings_, get_interior_vehicle_data_frequency()) @@ -143,7 +151,7 @@ class GetInteriorVehicleDataRequestTest ON_CALL(app_mngr_, hmi_capabilities()) .WillByDefault(ReturnRef(mock_hmi_capabilities_)); ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(nullptr)); + .WillByDefault(Return(&rc_capabilities_)); ON_CALL(mock_policy_handler_, CheckHMIType( _, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr)) @@ -152,6 +160,8 @@ class GetInteriorVehicleDataRequestTest .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); } template <class Command> @@ -163,7 +173,9 @@ class GetInteriorVehicleDataRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -181,6 +193,10 @@ class GetInteriorVehicleDataRequestTest application_manager::ApplicationSet apps_; const std::shared_ptr<sync_primitives::Lock> apps_lock_; DataAccessor<application_manager::ApplicationSet> apps_da_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + smart_objects::SmartObject rc_capabilities_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(GetInteriorVehicleDataRequestTest, @@ -188,13 +204,15 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; - ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_id; + const ModuleUid module(module_type, module_id); + ON_CALL(mock_interior_data_cache_, Contains(module)) .WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); @@ -205,6 +223,8 @@ TEST_F(GetInteriorVehicleDataRequestTest, HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act + + ASSERT_TRUE(command->Init()); command->Run(); } @@ -213,15 +233,17 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = true; - ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + const ModuleUid module(module_type, module_id); + ON_CALL(mock_interior_data_cache_, Contains(module)) .WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); @@ -232,6 +254,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), _)) .WillOnce(Return(true)); // Act + ASSERT_TRUE(command->Init()); command->Run(); } @@ -239,21 +262,35 @@ TEST_F( GetInteriorVehicleDataRequestTest, Execute_ExpectMessageNotSentToHMI_SuccessSentToMobile_AppSubscribed_DataFromCache) { // Arrange - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + const ModuleUid module(module_type, module_id); + rc_app_extention_->SubscribeToInteriorVehicleData(module); MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; smart_objects::SmartObject radio_data; + smart_objects::SmartObject sis_data; + smart_objects::SmartObject gps_data; + + gps_data[application_manager::strings::longitude_degrees] = 1.0; + gps_data[application_manager::strings::latitude_degrees] = 1.0; + + sis_data[application_manager::strings::station_short_name] = + "dummy_short_name"; + sis_data[application_manager::strings::station_location] = gps_data; + radio_data[message_params::kBand] = enums_value::kAM; - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + radio_data[message_params::kSisData] = sis_data; + + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Retrieve(module)) .WillOnce(Return(radio_data)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); MessageSharedPtr command_result; @@ -263,6 +300,7 @@ TEST_F( .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); // Assert @@ -274,13 +312,16 @@ TEST_F( TEST_F( GetInteriorVehicleDataRequestTest, - Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscibe_ClearCache) { + Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscribe_ClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; + const ModuleUid module(module_type, module_id); MessageSharedPtr hmi_response = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& hmi_msg_params = @@ -289,9 +330,11 @@ TEST_F( hmi_apis::Common_Result::SUCCESS; hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + hmi_msg_params[message_params::kModuleData][message_params::kModuleId] = + module_id; apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); @@ -307,13 +350,13 @@ TEST_F( ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Remove(enums_value::kRadio)); + EXPECT_CALL(mock_interior_data_cache_, Remove(module)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); @@ -326,28 +369,30 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; + const ModuleUid module(module_type, module_id); apps_.insert(mock_app_); apps_.insert(mock_app2_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); - rc_app_extention2_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); + rc_app_extention2_->SubscribeToInteriorVehicleData(module); smart_objects::SmartObject radio_data; radio_data[message_params::kBand] = enums_value::kAM; ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_cache_, Retrieve(module)) .WillOnce(Return(radio_data)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); @@ -358,11 +403,12 @@ TEST_F(GetInteriorVehicleDataRequestTest, .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); // Assert - EXPECT_FALSE( - rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_FALSE(rc_app_extention_->IsSubscribedToInteriorVehicleDataOfType( + enums_value::kRadio)); EXPECT_EQ((*command_result)[application_manager::strings::msg_params] [message_params::kModuleData] [message_params::kRadioControlData], @@ -376,22 +422,22 @@ TEST_F( MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + msg_params[message_params::kModuleType] = module_eType; + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); - smart_objects::SmartObject rc_capabilities; ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(&rc_capabilities)); + .WillByDefault(Return(nullptr)); // Expectations EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); - EXPECT_CALL(mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), - _)).WillOnce((Return(true))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)) + .WillOnce((Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); } @@ -402,9 +448,8 @@ TEST_F( MessageSharedPtr mobile_message = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + msg_params[message_params::kModuleType] = module_eType; + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false)); @@ -417,6 +462,7 @@ TEST_F( .WillOnce((Return(true))); // Act + ASSERT_TRUE(command->Init()); command->Run(); } @@ -429,12 +475,14 @@ TEST_F(GetInteriorVehicleDataRequestTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[strings::msg_params]; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module_eType; MessageSharedPtr hmi_response_message = CreateBasicMessage(); auto& hmi_response_params = (*hmi_response_message)[strings::msg_params]; hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; hmi_response_params[strings::connection_key] = kConnectionKey; + hmi_response_params[message_params::kModuleData][message_params::kModuleId] = + module_id; ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) @@ -457,6 +505,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); event.set_smart_object(*hmi_response_message); + ASSERT_TRUE(command->Init()); command->Run(); command->on_event(event); } @@ -471,7 +520,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, MessageSharedPtr mobile_message = CreateBasicMessage(); auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = module_type; + msg_params[message_params::kModuleType] = module_eType; MessageSharedPtr hmi_message = CreateBasicMessage(); auto& hmi_msg_params = (*hmi_message)[strings::params]; @@ -497,19 +546,22 @@ TEST_F(GetInteriorVehicleDataRequestTest, hmi_apis::FunctionID::RC_GetInteriorVehicleData); event.set_smart_object(*hmi_message); auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); command->on_event(event); } TEST_F(GetInteriorVehicleDataRequestTest, - OnEvent_InvalidHmiResponse_DontUnsubscibeLastApp_NoClearCache) { + OnEvent_InvalidHmiResponse_DontUnsubscribeLastApp_NoClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; (*mobile_message)[application_manager::strings::msg_params] [message_params::kSubscribe] = false; - + const ModuleUid module(module_type, module_id); MessageSharedPtr hmi_response = CreateBasicMessage(); ns_smart_device_link::ns_smart_objects::SmartObject& hmi_msg_params = (*hmi_response)[application_manager::strings::params]; @@ -518,7 +570,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) .WillByDefault(Return(true)); @@ -537,10 +589,10 @@ TEST_F(GetInteriorVehicleDataRequestTest, EXPECT_CALL(mock_interior_data_cache_, Clear()).Times(0); // Act - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); @@ -548,45 +600,47 @@ TEST_F(GetInteriorVehicleDataRequestTest, command->on_event(event); // Assert - EXPECT_TRUE( - rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_TRUE(rc_app_extention_->IsSubscribedToInteriorVehicleData(module)); } TEST_F(GetInteriorVehicleDataRequestTest, Execute_ExpectRejectDuToRequestLimitation_NoCahce) { // Arrange - rc_app_extention_->UnsubscribeFromInteriorVehicleData(enums_value::kRadio); + rc_app_extention_->UnsubscribeFromInteriorVehicleDataOfType( + enums_value::kRadio); MessageSharedPtr mobile_message = CreateBasicMessage(); (*mobile_message)[application_manager::strings::msg_params] - [message_params::kModuleType] = module_type; + [message_params::kModuleType] = module_eType; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleId] = module_id; smart_objects::SmartObject radio_data; radio_data[message_params::kBand] = enums_value::kAM; - std::shared_ptr< - rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + const ModuleUid module(module_type, module_id); size_t i = 0; for (; i <= max_request_in_time_frame; ++i) { // Expectations EXPECT_CALL(mock_interior_data_manager_, - CheckRequestsToHMIFrequency(enums_value::kRadio)) + CheckRequestsToHMIFrequency(module)) .WillOnce(Return(true)); - EXPECT_CALL(mock_interior_data_manager_, - StoreRequestToHMITime(enums_value::kRadio)); - EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_manager_, StoreRequestToHMITime(module)); + EXPECT_CALL(mock_interior_data_cache_, Contains(module)) .WillRepeatedly(Return(false)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::RC_GetInteriorVehicleData), - _)).WillRepeatedly(Return(true)); + _)) + .WillRepeatedly(Return(true)); // Act + ASSERT_TRUE(command->Init()); command->Run(); } // Expectations - EXPECT_CALL(mock_interior_data_manager_, - CheckRequestsToHMIFrequency(enums_value::kRadio)) + EXPECT_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(module)) .WillOnce(Return(false)); EXPECT_CALL( mock_rpc_service_, @@ -595,6 +649,130 @@ TEST_F(GetInteriorVehicleDataRequestTest, EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); // Act + ASSERT_TRUE(command->Init()); command->Run(); } + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_ValidHmiResponse_AvailableHDChanelsIsArrayWithHDChanels) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + + const uint32_t chanel1_index = 1u; + const uint32_t chanel2_index = 2u; + const uint32_t chanel3_index = 3u; + + const uint32_t expected_array_length = 3u; + + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + + MessageSharedPtr hmi_response_message = CreateBasicMessage(); + auto& hmi_response_params = (*hmi_response_message)[strings::msg_params]; + hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + hmi_response_params[strings::connection_key] = kAppId; + + auto& msg_params = (*hmi_response_message)[strings::msg_params]; + msg_params[message_params::kModuleType] = module_type; + + auto available_hd_chanels = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + available_hd_chanels[0] = chanel1_index; + available_hd_chanels[1] = chanel2_index; + available_hd_chanels[2] = chanel3_index; + + msg_params[message_params::kModuleData][message_params::kRadioControlData] + [message_params::kAvailableHdChannels] = available_hd_chanels; + + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + MessageSharedPtr message_to_mob = CreateBasicMessage(); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mob), Return(true))); + + // Act + auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + + ASSERT_TRUE(command->Init()); + command->Run(); + + event.set_smart_object(*hmi_response_message); + command->on_event(event); + + auto& hd_chanels = + (*message_to_mob)[strings::msg_params][message_params::kModuleData] + [message_params::kRadioControlData] + [message_params::kAvailableHdChannels]; + const size_t array_length = hd_chanels.length(); + + EXPECT_EQ(expected_array_length, array_length); + + EXPECT_EQ(chanel1_index, hd_chanels[0].asUInt()); + EXPECT_EQ(chanel2_index, hd_chanels[1].asUInt()); + EXPECT_EQ(chanel3_index, hd_chanels[2].asUInt()); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_ValidHmiResponse_ClimateEnableAvailable) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + + MessageSharedPtr hmi_response_message = CreateBasicMessage(); + auto& hmi_response_params = (*hmi_response_message)[strings::msg_params]; + hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + hmi_response_params[strings::connection_key] = kAppId; + + auto& msg_params = (*hmi_response_message)[strings::msg_params]; + + auto climate_control_data = + smart_objects::SmartObject(smart_objects::SmartType_Boolean); + climate_control_data = true; + + msg_params[message_params::kModuleData][message_params::kClimateControlData] + [message_params::kClimateEnableAvailable] = climate_control_data; + + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + auto message_to_mob = CreateBasicMessage(); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mob), Return(true))); + + // Act + auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + + ASSERT_TRUE(command->Init()); + command->Run(); + + event.set_smart_object(*hmi_response_message); + command->on_event(event); + + const bool climate_enable_available = + (*message_to_mob)[strings::msg_params][message_params::kModuleData] + [message_params::kClimateControlData] + [message_params::kClimateEnableAvailable] + .asBool(); + + EXPECT_TRUE(climate_enable_available); +} + } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc index b344471254..d6771c534d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc @@ -30,36 +30,40 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" #include "application_manager/application.h" -#include "application_manager/mock_application.h" #include "application_manager/commands/commands_test.h" -#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" -#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" -#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "application_manager/mock_application.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" -using ::testing::_; -using ::testing::Return; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::Mock; using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandsTest; using test::components::commands_test::CommandsTestMocks; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; +const std::string module_type = "CLIMATE"; +const std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; const int kModuleId = 153u; -} +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -93,6 +97,8 @@ class OnInteriorVehicleDataNotificationTest (*message)[application_manager::strings::msg_params]; msg_param[message_params::kModuleData][message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + msg_param[message_params::kModuleData][message_params::kModuleId] = + module_id; return message; } @@ -105,7 +111,9 @@ class OnInteriorVehicleDataNotificationTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return ::std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -122,6 +130,9 @@ class OnInteriorVehicleDataNotificationTest application_manager::ApplicationSet apps_; const std::shared_ptr<sync_primitives::Lock> apps_lock_; DataAccessor<application_manager::ApplicationSet> apps_da_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(OnInteriorVehicleDataNotificationTest, @@ -129,11 +140,12 @@ TEST_F(OnInteriorVehicleDataNotificationTest, // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); apps_.insert(mock_app_); - rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kClimate); + const ModuleUid module(module_type, module_id); + rc_app_extention_->SubscribeToInteriorVehicleData(module); ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); // Expectations - EXPECT_CALL(mock_interior_data_cache_, Add(enums_value::kClimate, _)); + EXPECT_CALL(mock_interior_data_cache_, Add(module, _)); MessageSharedPtr message; EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) .WillOnce(SaveArg<0>(&message)); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index b95725e0b4..62b726ac60 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc @@ -32,34 +32,36 @@ #include "application_manager/application.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" #include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" #include "rc_rpc_plugin/mock/mock_interior_data_cache.h" #include "rc_rpc_plugin/mock/mock_interior_data_manager.h" -#include "gtest/gtest.h" -#include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" -using ::testing::_; -using ::testing::Return; -using ::testing::NiceMock; -using ::testing::SaveArg; -using ::testing::Mock; using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandsTest; using test::components::commands_test::CommandsTestMocks; +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; -} +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -95,7 +97,9 @@ class RCOnRemoteControlSettingsNotificationTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -107,6 +111,9 @@ class RCOnRemoteControlSettingsNotificationTest mock_interior_data_cache_; testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager> mock_interior_data_manager_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(RCOnRemoteControlSettingsNotificationTest, @@ -124,8 +131,8 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER)); // Act std::shared_ptr< - rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command = - CreateRCCommand< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> + command = CreateRCCommand< rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>( mobile_message); @@ -141,11 +148,12 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); + EXPECT_CALL(mock_rc_consent_manger_, RemoveAllConsents()); // Act std::shared_ptr< - rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> command = - CreateRCCommand< + rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification> + command = CreateRCCommand< rc_rpc_plugin::commands::RCOnRemoteControlSettingsNotification>( mobile_message); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc index 567d4b1e20..d44265a1d5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc @@ -31,59 +31,61 @@ */ #include "application_manager/application.h" -#include "application_manager/mock_application.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/rpc_service_impl.h" -#include "application_manager/mock_request_controller_settings.h" #include "application_manager/include/application_manager/command_holder_impl.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/request_controller.h" -#include "application_manager/mock_rpc_plugin_manager.h" -#include "application_manager/mock_rpc_plugin.h" +#include "application_manager/message.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_command_factory.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/message.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" -#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" -#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" -#include "rc_rpc_plugin/commands/mobile/button_press_request.h" -#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" -#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_request_controller_settings.h" +#include "application_manager/mock_rpc_plugin.h" +#include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_rpc_protection_manager.h" +#include "application_manager/request_controller.h" +#include "application_manager/rpc_service_impl.h" #include "hmi_message_handler/mock_hmi_message_handler.h" -#include "interfaces/MOBILE_API.h" #include "include/test/protocol_handler/mock_protocol_handler.h" +#include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h" +#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h" +#include "rc_rpc_plugin/commands/mobile/button_press_request.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "test/application_manager/mock_application_manager_settings.h" using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; using ::testing::SaveArg; -using ::testing::Mock; -using ::testing::NiceMock; namespace am = ::application_manager; using am::ApplicationSet; -using am::commands::MessageSharedPtr; using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::plugin_manager::MockRPCPlugin; +using am::plugin_manager::MockRPCPluginManager; using am::plugin_manager::RPCPlugin; -using ::smart_objects::SmartObject; +using rc_rpc_plugin::RCRPCPlugin; using rc_rpc_plugin::commands::ButtonPressRequest; -using rc_rpc_plugin::commands::RCGetInteriorVehicleDataConsentResponse; using rc_rpc_plugin::commands::RCGetInteriorVehicleDataConsentRequest; -using rc_rpc_plugin::RCRPCPlugin; -using test::components::commands_test::CommandsTestMocks; -using test::components::commands_test::CommandRequestTest; -using am::plugin_manager::MockRPCPluginManager; -using am::plugin_manager::MockRPCPlugin; +using rc_rpc_plugin::commands::RCGetInteriorVehicleDataConsentResponse; +using ::smart_objects::SmartObject; using test::components::application_manager_test::MockApplication; +using test::components::application_manager_test::MockCommandFactory; +using test::components::application_manager_test::MockHMICapabilities; using test::components::application_manager_test::MockRequestControlerSettings; -using test::components::protocol_handler_test::MockProtocolHandler; +using test::components::commands_test::CommandRequestTest; +using test::components::commands_test::CommandsTestMocks; using test::components::hmi_message_handler_test::MockHMIMessageHandler; -using test::components::application_manager_test::MockHMICapabilities; -using test::components::application_manager_test::MockCommandFactory; using test::components::policy_test::MockPolicyHandlerInterface; +using test::components::protocol_handler_test::MockProtocolHandler; namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -92,6 +94,9 @@ namespace { const uint32_t kConnectionKey = 2u; const uint32_t kAppId = 5u; const std::string kResource = "CLIMATE"; +const std::string kResourceId = "34045662-a9dc-4823-8435-91056d4c26cb"; +const std::string kPolicyAppId = "policy_app_id"; +const std::string kMacAddress = "device1"; const uint32_t kPluginID = RCRPCPlugin::kRCPluginID; } // namespace @@ -101,17 +106,25 @@ class RCGetInteriorVehicleDataConsentTest RCGetInteriorVehicleDataConsentTest() : mock_app_(std::make_shared<NiceMock<MockApplication> >()) , command_holder(app_mngr_) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) , request_controller(mock_request_controler) + , rpc_protection_manager_( + std::make_shared<application_manager::MockRPCProtectionManager>()) , rpc_service_(app_mngr_, request_controller, &mock_protocol_handler, &mock_hmi_handler, - command_holder) + command_holder, + rpc_protection_manager_, + hmi_so_factory_, + mobile_so_factoy_) , rc_app_extention_(std::make_shared<RCAppExtension>(kPluginID)) , mock_rpc_plugin_manager( std::make_shared<NiceMock<MockRPCPluginManager> >()) , rpc_plugin(mock_rpc_plugin) , optional_mock_rpc_plugin(mock_rpc_plugin) { + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); @@ -141,10 +154,16 @@ class RCGetInteriorVehicleDataConsentTest .WillByDefault(ReturnRef(*mock_rpc_plugin_manager)); ON_CALL(*mock_rpc_plugin_manager, FindPluginToProcess(_, _)) .WillByDefault(Return(rpc_plugin)); - ON_CALL(mock_allocation_manager_, IsResourceFree(kResource)) + ON_CALL(mock_allocation_manager_, IsResourceFree(kResource, kResourceId)) .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_protocol_handler, IsRPCServiceSecure(_)) + .WillByDefault(Return(false)); + ON_CALL(*rpc_protection_manager_, CheckPolicyEncryptionFlag(_, _, _)) + .WillByDefault(Return(false)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); } template <class Command> @@ -156,7 +175,9 @@ class RCGetInteriorVehicleDataConsentTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -169,6 +190,10 @@ class RCGetInteriorVehicleDataConsentTest [application_manager::strings::connection_key] = kConnectionKey; (*message)[application_manager::strings::params] [application_manager::strings::connection_key] = kAppId; + ns_smart_device_link::ns_smart_objects::SmartObject& msg_params = + (*message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = kResource; + msg_params[message_params::kModuleId] = kResourceId; return message; } @@ -188,12 +213,19 @@ class RCGetInteriorVehicleDataConsentTest MockRPCPlugin mock_rpc_plugin; MockCommandFactory mock_command_factory; am::request_controller::RequestController request_controller; + std::shared_ptr<application_manager::MockRPCProtectionManager> + rpc_protection_manager_; am::rpc_service::RPCServiceImpl rpc_service_; std::shared_ptr<RCAppExtension> rc_app_extention_; std::shared_ptr<am::plugin_manager::MockRPCPluginManager> mock_rpc_plugin_manager; utils::Optional<RPCPlugin> rpc_plugin; utils::Optional<MockRPCPlugin> optional_mock_rpc_plugin; + hmi_apis::HMI_API hmi_so_factory_; + mobile_apis::MOBILE_API mobile_so_factoy_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(RCGetInteriorVehicleDataConsentTest, @@ -202,8 +234,17 @@ TEST_F(RCGetInteriorVehicleDataConsentTest, auto mobile_message = CreateBasicMessage(); // Expectations - EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::ASK_DRIVER)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + + rc_rpc_types::ModuleUid moduleUid{kResource, kResourceId}; + EXPECT_CALL(mock_rc_consent_manger_, + GetModuleConsent(kPolicyAppId, _, moduleUid)) + .WillOnce(Return(rc_rpc_types::ModuleConsent::NOT_EXISTS)); + EXPECT_CALL(*optional_mock_rpc_plugin, GetCommandFactory()) .WillOnce(ReturnRef(mock_command_factory)); auto rc_consent_request = @@ -228,7 +269,7 @@ TEST_F(RCGetInteriorVehicleDataConsentTest, auto mobile_message = CreateBasicMessage(); // Expectations - EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _)) + EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillOnce(Return(rc_rpc_plugin::AcquireResult::IN_USE)); EXPECT_CALL(*optional_mock_rpc_plugin, GetCommandFactory()) diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/release_interior_vehicle_data_module_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/release_interior_vehicle_data_module_request_test.cc new file mode 100644 index 0000000000..200e458c17 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/release_interior_vehicle_data_module_request_test.cc @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <memory> +#include <string> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/mock_application.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +using application_manager::commands::MessageSharedPtr; +using rc_rpc_plugin_test::MockInteriorDataCache; +using rc_rpc_plugin_test::MockInteriorDataManager; +using rc_rpc_plugin_test::MockRCCapabilitiesManager; +using rc_rpc_plugin_test::MockRCConsentManager; +using rc_rpc_plugin_test::MockResourceAllocationManager; +using test::components::application_manager_test::MockApplication; +using test::components::commands_test::CommandRequestTest; +using test::components::commands_test::CommandsTestMocks; + +using testing::_; +using ::testing::DoAll; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; + +typedef std::shared_ptr< + rc_rpc_plugin::commands::ReleaseInteriorVehicleDataModuleRequest> + ReleaseCommandPtr; + +namespace { +std::string kPolicyAppID = "app_id"; +std::uint32_t kAppID = 2u; +std::uint32_t kConnectionKey = 1u; +std::string kModuleType = "RADIO"; +std::string kModuleID = "76149d9b-5317-4cf5-9196-b8fac690fec5"; +std::string kDefaultModuleID = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; +} // namespace + +namespace rc_rpc_plugin_test { +namespace release_interior_vehicle_data_module_request { +using namespace rc_rpc_plugin; + +class ReleaseInteriorVehicleDataModuleRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + ReleaseInteriorVehicleDataModuleRequestTest() : mock_app_(CreateMockApp()) {} + + void SetUp() OVERRIDE { + TestPreCondition(); + ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppID)); + ON_CALL(mock_rc_capabilities_manager_, + GetDefaultModuleIdFromCapabilities(kModuleType)) + .WillByDefault(Return(kDefaultModuleID)); + } + + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::ReleaseInteriorVehicleDataModuleID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kAppID; + (*message)[application_manager::strings::msg_params] + [message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + (*message)[application_manager::strings::msg_params] + [message_params::kModuleId] = kModuleID; + return message; + } + + void TestPreCondition() { + message_ = CreateBasicMessage(); + command_ = + CreateRCCommand<commands::ReleaseInteriorVehicleDataModuleRequest>( + message_); + } + + template <class Command> + std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) { + InitCommand(kDefaultTimeout_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; + return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); + } + + protected: + MessageSharedPtr message_; + ReleaseCommandPtr command_; + + MockAppPtr mock_app_; + NiceMock<MockResourceAllocationManager> mock_allocation_manager_; + MockInteriorDataCache mock_interior_data_cache_; + MockInteriorDataManager mock_interior_data_manager_; + NiceMock<MockRCCapabilitiesManager> mock_rc_capabilities_manager_; + MockRCConsentManager mock_rc_consent_manger_; +}; + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ModuleIDIsAbsnetInMessage_ReturnsDefaultFromCapabilities) { + (*message_)[application_manager::strings::msg_params].erase( + message_params::kModuleId); + + auto module_id = command_->ModuleId(); + EXPECT_EQ(kDefaultModuleID, module_id); +} + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ResourceIsNotAllocated_ResponseToMobile_UNSUCCESS_IGNORED) { + ON_CALL(mock_allocation_manager_, + ReleaseResource(kModuleType, kModuleID, kAppID)) + .WillByDefault(Return(ResourceReleasedState::eType::NOT_ALLOCATED)); + + MessageSharedPtr message_to_mobile = CreateMessage(); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + _, application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + command_->Execute(); + + const bool success = + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + auto result_code = static_cast<mobile_apis::Result::eType>( + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + + EXPECT_FALSE(success); + EXPECT_EQ(mobile_apis::Result::eType::IGNORED, result_code); +} + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ResourceIsAllocated_ResponseToMobile_UNSUCCESS_REJECTED) { + ON_CALL(mock_allocation_manager_, + ReleaseResource(kModuleType, kModuleID, kAppID)) + .WillByDefault(Return(ResourceReleasedState::eType::IS_ALLOCATED)); + MessageSharedPtr message_to_mobile = CreateMessage(); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + _, application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + command_->Execute(); + + const bool success = + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + auto result_code = static_cast<mobile_apis::Result::eType>( + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + + EXPECT_FALSE(success); + EXPECT_EQ(mobile_apis::Result::eType::REJECTED, result_code); +} + +TEST_F(ReleaseInteriorVehicleDataModuleRequestTest, + ResourceIsReleased_ResponseToMobile_SUCCESS_SUCCESS) { + ON_CALL(mock_allocation_manager_, + ReleaseResource(kModuleType, kModuleID, kAppID)) + .WillByDefault(Return(ResourceReleasedState::eType::IS_RELEASED)); + + MessageSharedPtr message_to_mobile = CreateMessage(); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + _, application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + command_->Execute(); + + const bool success = + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::success] + .asBool(); + auto result_code = static_cast<mobile_apis::Result::eType>( + (*message_to_mobile)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asUInt()); + + EXPECT_TRUE(success); + EXPECT_EQ(mobile_apis::Result::eType::SUCCESS, result_code); +} +} // namespace release_interior_vehicle_data_module_request +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index b1cb8271f5..5a822a2fe4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -30,34 +30,40 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" #include "application_manager/application.h" #include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" -#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" -#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "interfaces/MOBILE_API.h" #include "rc_rpc_plugin/mock/mock_interior_data_cache.h" #include "rc_rpc_plugin/mock/mock_interior_data_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_consent_manager.h" +#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" + +#include <stdint.h> #include "gtest/gtest.h" -#include "interfaces/MOBILE_API.h" -using ::testing::_; -using ::testing::Return; -using ::testing::NiceMock; using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::commands_test::CommandRequestTest; using test::components::commands_test::CommandsTestMocks; +using test::components::commands_test::HMIResultCodeIs; +using ::testing::_; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; namespace { const uint32_t kAppId = 0u; const int kModuleId = 153u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; -} +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; @@ -67,9 +73,12 @@ class SetInteriorVehicleDataRequestTest public: SetInteriorVehicleDataRequestTest() : mock_app_(std::make_shared<NiceMock<MockApplication> >()) - , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) {} + , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) + , rc_capabilities_(smart_objects::SmartType::SmartType_Array) {} void SetUp() OVERRIDE { + smart_objects::SmartObject control_caps((smart_objects::SmartType_Array)); + rc_capabilities_[strings::kradioControlCapabilities] = control_caps; ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); ON_CALL( @@ -82,17 +91,24 @@ class SetInteriorVehicleDataRequestTest .WillByDefault(Return(rc_app_extention_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); - ON_CALL(mock_allocation_manager_, IsResourceFree(_)) + ON_CALL(mock_allocation_manager_, IsResourceFree(_, _)) .WillByDefault(Return(true)); - ON_CALL(mock_allocation_manager_, AcquireResource(_, _)) + ON_CALL(mock_allocation_manager_, AcquireResource(_, _, _)) .WillByDefault(Return(AcquireResult::ALLOWED)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); ON_CALL(mock_policy_handler_, CheckHMIType(kPolicyAppId, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, - nullptr)).WillByDefault(Return(true)); + nullptr)) + .WillByDefault(Return(true)); + ON_CALL(mock_hmi_capabilities_, rc_capability()) + .WillByDefault(Return(&rc_capabilities_)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, CheckIfModuleExistsInCapabilities(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, GetModuleDataCapabilities(_, _)) + .WillByDefault(Return(std::make_pair("", capabilitiesStatus::success))); } MessageSharedPtr CreateBasicMessage() { @@ -116,7 +132,9 @@ class SetInteriorVehicleDataRequestTest mock_policy_handler_, mock_allocation_manager_, mock_interior_data_cache_, - mock_interior_data_manager_}; + mock_interior_data_manager_, + mock_rc_capabilities_manager_, + mock_rc_consent_manger_}; return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } @@ -129,6 +147,10 @@ class SetInteriorVehicleDataRequestTest mock_interior_data_manager_; std::shared_ptr<MockApplication> mock_app_; std::shared_ptr<RCAppExtension> rc_app_extention_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + smart_objects::SmartObject rc_capabilities_; + testing::NiceMock<MockRCConsentManager> mock_rc_consent_manger_; }; TEST_F(SetInteriorVehicleDataRequestTest, @@ -139,25 +161,25 @@ TEST_F(SetInteriorVehicleDataRequestTest, (*mobile_message)[application_manager::strings::msg_params]; msg_params[message_params::kModuleData][message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + smart_objects::SmartObject climate_control_data(smart_objects::SmartType_Map); + climate_control_data[message_params::kFanSpeed] = 10; + msg_params[message_params::kModuleData][message_params::kClimateControlData] = - smart_objects::SmartObject(smart_objects::SmartType_Map); + climate_control_data; // Expectations EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); - EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) - .WillOnce(Return(nullptr)); - EXPECT_CALL( mock_rpc_service_, - ManageMobileCommand(test::components::commands_test::MobileResultCodeIs( - mobile_apis::Result::READ_ONLY), - application_manager::commands::Command::SOURCE_SDL)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) + .WillOnce(Return(true)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> command = + auto command = CreateRCCommand<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -181,22 +203,20 @@ TEST_F( EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); - EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) - .WillOnce(Return(nullptr)); - EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_, _)); EXPECT_CALL( mock_rpc_service_, - ManageMobileCommand(test::components::commands_test::MobileResultCodeIs( - mobile_apis::Result::OUT_OF_MEMORY), - application_manager::commands::Command::SOURCE_SDL)); + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::RC_SetInteriorVehicleData), _)) + .WillOnce(Return(true)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> command = - CreateRCCommand<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( + std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( mobile_message); + ASSERT_TRUE(command->Init()); command->Run(); } @@ -224,11 +244,97 @@ TEST_F( application_manager::commands::Command::SOURCE_SDL)); // Act - std::shared_ptr< - rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> command = - CreateRCCommand<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( + std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( + mobile_message); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(SetInteriorVehicleDataRequestTest, + Execute_ValidWithSettableParams_SUCCESSSendToHMI) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + auto& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleData][message_params::kModuleType] = + mobile_apis::ModuleType::CLIMATE; + + msg_params[message_params::kModuleData][message_params::kClimateControlData] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + msg_params[message_params::kModuleData][message_params::kClimateControlData] + [message_params::kClimateEnable] = true; + + // Expectations + EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) + .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); + + MessageSharedPtr message_from_mobile = CreateBasicMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_from_mobile), Return(true))); + + std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( mobile_message); + + ASSERT_TRUE(command->Init()); command->Run(); + + auto& msg_params_from_mobile = + (*message_from_mobile)[application_manager::strings::msg_params]; + + const bool climate_enable = + msg_params_from_mobile[message_params::kModuleData] + [message_params::kClimateControlData] + [message_params::kClimateEnable] + .asBool(); + EXPECT_TRUE(climate_enable); } +TEST_F(SetInteriorVehicleDataRequestTest, + Execute_ValidWithSettableParams_SUCCESSSendToHMI_HDChannel) { + MessageSharedPtr mobile_message = CreateBasicMessage(); + auto& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleData][message_params::kModuleType] = + mobile_apis::ModuleType::RADIO; + + msg_params[message_params::kModuleData][message_params::kRadioControlData] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + const std::uint32_t hd_channel = 2u; + msg_params[message_params::kModuleData][message_params::kRadioControlData] + [message_params::kHdChannel] = hd_channel; + + // Expectations + EXPECT_CALL(mock_policy_handler_, CheckModule(kPolicyAppId, _)) + .WillOnce(Return(rc_rpc_plugin::TypeAccess::kAllowed)); + + auto message_from_mobile = CreateBasicMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_from_mobile), Return(true))); + + std::shared_ptr<rc_rpc_plugin::commands::SetInteriorVehicleDataRequest> + command = CreateRCCommand< + rc_rpc_plugin::commands::SetInteriorVehicleDataRequest>( + mobile_message); + + command->Init(); + command->Run(); + + auto& msg_params_from_mobile = + (*message_from_mobile)[application_manager::strings::msg_params]; + + const uint64_t hd_channel_from_hmi = + msg_params_from_mobile[message_params::kModuleData] + [message_params::kRadioControlData] + [message_params::kHdChannel] + .asUInt(); + + EXPECT_EQ(hd_channel, hd_channel_from_hmi); +} } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/grid_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/grid_test.cc new file mode 100644 index 0000000000..b8a0d71203 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/grid_test.cc @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gtest/gtest.h" + +#include "rc_rpc_plugin/rc_app_extension.h" + +namespace rc_rpc_plugin_test { +namespace grid_test { +using namespace rc_rpc_plugin; + +TEST(Grid, IsLevelIntersectionExists) { + Grid grid_level0{1, 1, 0, 1, 1, 1}; + Grid grid_level1{1, 1, 1, 1, 1, 1}; + EXPECT_FALSE(grid_level0.LevelIntersectionExists(grid_level1)); + + Grid grid_level1_v2{1, 2, 1, 1, 2, 1}; + EXPECT_TRUE(grid_level1.LevelIntersectionExists(grid_level1_v2)); +} + +TEST(Grid, TwoSameGrisAreEqual) { + Grid grid2{1, 1, 0, 1, 1, 1}; + Grid grid1{1, 1, 0, 1, 1, 1}; + + EXPECT_EQ(grid1, grid2); +} + +TEST(Grid, IsIntersectionExists) { + Grid grid_1{0, 1, 2, 1, 1, 1}; + Grid grid_2{0, 0, 1, 0, 0, 1}; + + // There is intersection but levels missmatch + EXPECT_FALSE(grid_1.IntersectionExists(grid_2)); + + Grid grid_3{1, 0, 2, 0, 0, 0}; + // There isn't intersection but level match + EXPECT_FALSE(grid_1.IntersectionExists(grid_3)); + + Grid grid_4{0, 1, 2, 1, 1, 1}; + EXPECT_TRUE(grid_1.IntersectionExists(grid_4)); +} +} // namespace grid_test +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h index 45465f96b0..025cef2165 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h @@ -42,10 +42,14 @@ namespace rc_rpc_plugin_test { class MockInteriorDataCache : public rc_rpc_plugin::InteriorDataCache { public: MOCK_METHOD2(Add, - void(const std::string&, const smart_objects::SmartObject&)); - MOCK_CONST_METHOD1(Retrieve, smart_objects::SmartObject(const std::string&)); - MOCK_CONST_METHOD1(Contains, bool(const std::string&)); - MOCK_METHOD1(Remove, void(const std::string&)); + void(const rc_rpc_plugin::ModuleUid&, + const smart_objects::SmartObject&)); + MOCK_CONST_METHOD1( + Retrieve, smart_objects::SmartObject(const rc_rpc_plugin::ModuleUid&)); + MOCK_CONST_METHOD1(GetCachedModulesByType, + std::vector<rc_rpc_plugin::ModuleUid>(const std::string&)); + MOCK_CONST_METHOD1(Contains, bool(const rc_rpc_plugin::ModuleUid&)); + MOCK_METHOD1(Remove, void(const rc_rpc_plugin::ModuleUid&)); MOCK_METHOD0(Clear, void()); }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h index fc19c6a889..231ac2ae36 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h @@ -46,8 +46,9 @@ class MockInteriorDataManager : public rc_rpc_plugin::InteriorDataManager { void(application_manager::plugin_manager::ApplicationEvent, application_manager::ApplicationSharedPtr)); MOCK_METHOD0(OnDisablingRC, void()); - MOCK_METHOD1(StoreRequestToHMITime, void(const std::string&)); - MOCK_METHOD1(CheckRequestsToHMIFrequency, bool(const std::string&)); + MOCK_METHOD1(StoreRequestToHMITime, void(const rc_rpc_plugin::ModuleUid&)); + MOCK_METHOD1(CheckRequestsToHMIFrequency, + bool(const rc_rpc_plugin::ModuleUid&)); }; } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_capabilities_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_capabilities_manager.h new file mode 100644 index 0000000000..6f1593dcbb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_capabilities_manager.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_CAPABILITIES_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_CAPABILITIES_MANAGER_H_ +#include "gmock/gmock.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" + +namespace rc_rpc_plugin_test { +class MockRCCapabilitiesManager : public rc_rpc_plugin::RCCapabilitiesManager { + public: + MOCK_CONST_METHOD2(CheckButtonName, + bool(const std::string& module_type, + const std::string& button_name)); + + MOCK_CONST_METHOD1(CheckIfModuleExistsInCapabilities, + bool(const rc_rpc_plugin::ModuleUid& module_type)); + + MOCK_CONST_METHOD2(GetModuleDataCapabilities, + rc_rpc_plugin::ModuleTypeCapability( + const smart_objects::SmartObject& module_data, + const std::string& module_id)); + + MOCK_CONST_METHOD2(ControlDataForType, + const smart_objects::SmartObject&( + const smart_objects::SmartObject& module_data, + const std::string& module_type)); + + MOCK_CONST_METHOD3( + AreReadOnlyParamsPresent, + bool(const smart_objects::SmartObject& module_data, + const std::string& module_type, + rc_rpc_plugin::ModuleTypeCapability& module_data_capabilities)); + + MOCK_CONST_METHOD2(AreAllParamsReadOnly, + bool(const smart_objects::SmartObject& module_data, + const std::string& module_type)); + + MOCK_CONST_METHOD1(GetDefaultModuleIdFromCapabilities, + const std::string(const std::string& module_type)); + + MOCK_CONST_METHOD1(CheckIfButtonExistInRCCaps, + bool(const mobile_apis::ButtonName::eType button)); + + MOCK_CONST_METHOD0(GetResources, + const std::vector<rc_rpc_plugin::ModuleUid>()); + + MOCK_CONST_METHOD1(GetModuleServiceArea, + rc_rpc_plugin::Grid(const rc_rpc_plugin::ModuleUid&)); + + MOCK_CONST_METHOD1(IsMultipleAccessAllowed, + bool(const rc_rpc_plugin::ModuleUid&)); + + MOCK_CONST_METHOD0(GetDriverLocationFromSeatLocationCapability, + const rc_rpc_plugin::Grid()); + + MOCK_CONST_METHOD0(IsSeatLocationCapabilityProvided, bool()); + + MOCK_CONST_METHOD1( + GetModuleIdForSeatLocation, + const std::string(const mobile_apis::SupportedSeat::eType id)); +}; +} // namespace rc_rpc_plugin_test +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_СAPABILITIES_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_consent_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_consent_manager.h new file mode 100644 index 0000000000..147da9ed55 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_consent_manager.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RC_CONSENT_MANAGER_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RC_CONSENT_MANAGER_H + +#include <string> + +#include "gmock/gmock.h" +#include "rc_rpc_plugin/rc_consent_manager.h" + +namespace rc_rpc_plugin_test { + +class MockRCConsentManager : public rc_rpc_plugin::RCConsentManager { + public: + MOCK_METHOD3(SaveModuleConsents, + void(const std::string&, + const std::string&, + const rc_rpc_plugin::rc_rpc_types::ModuleIdConsentVector&)); + MOCK_CONST_METHOD3(GetModuleConsent, + rc_rpc_plugin::rc_rpc_types::ModuleConsent( + const std::string&, + const std::string&, + const rc_rpc_plugin::rc_rpc_types::ModuleUid&)); + MOCK_METHOD0(RemoveExpiredConsents, void()); + MOCK_METHOD0(RemoveAllConsents, void()); +}; + +} // namespace rc_rpc_plugin_test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_PLUGIN_MANAGER_MOCK_RC_CONSENT_MANAGER_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_helpers.h new file mode 100644 index 0000000000..c73472d2a8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_rc_helpers.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RC_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_HELPERS_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RC_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_HELPERS_H + +#include <functional> +#include <map> +#include <string> +#include "gmock/gmock.h" + +#include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/rc_helpers.h" + +namespace rc_rpc_plugin { + +class MockRCHelpers { + public: + MOCK_METHOD0(GetModuleTypeToDataMapping, + std::function<std::string(const std::string&)>()); + MOCK_METHOD0(GetModuleTypeToCapabilitiesMapping, + std::function<std::string(const std::string&)>()); + MOCK_METHOD0(GetModuleTypesList, const std::vector<std::string>()); + MOCK_METHOD1( + GetRCExtension, + rc_rpc_plugin::RCAppExtensionPtr(application_manager::Application&)); + MOCK_METHOD2(CreateUnsubscribeRequestToHMI, + smart_objects::SmartObjectSPtr(const rc_rpc_plugin::ModuleUid&, + const uint32_t)); + MOCK_METHOD2(AppsSubscribedToModule, + std::vector<application_manager::ApplicationSharedPtr>( + application_manager::ApplicationManager&, + const rc_rpc_plugin::ModuleUid&)); + MOCK_METHOD2(AppsSubscribedToModuleType, + std::vector<application_manager::ApplicationSharedPtr>( + application_manager::ApplicationManager&, + const std::string&)); + MOCK_METHOD1(GetApplicationsAllowedModuleTypes, + rc_rpc_plugin::RCHelpers::AppsModuleTypes( + application_manager::ApplicationManager&)); + MOCK_METHOD0(buttons_climate, const std::vector<std::string>()); + MOCK_METHOD0(buttons_radio, const std::vector<std::string>()); + MOCK_METHOD0(buttons_map, const rc_rpc_plugin::RCHelpers::ButtonsMap()); + MOCK_METHOD1(GetModuleReadOnlyParams, + std::vector<std::string>(const std::string&)); + MOCK_METHOD3( + FillModuleConsents, + rc_rpc_types::ModuleIdConsentVector(const std::string&, + const std::vector<std::string>&, + const std::vector<bool>)); + MOCK_METHOD1(RetrieveModuleIds, + std::vector<std::string>(const smart_objects::SmartObject&)); + MOCK_METHOD1(RetrieveModuleConsents, + std::vector<bool>(const smart_objects::SmartObject& consents)); + MOCK_METHOD1(RemoveRedundantGPSDataFromIVDataMsg, + void(smart_objects::SmartObject& msg_params)); + MOCK_METHOD2( + MergeModuleData, + smart_objects::SmartObject(const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2)); + + static MockRCHelpers* rc_helpers_mock(); +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RC_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RC_HELPERS_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h index 72ace1432a..fca6c9c77e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h @@ -33,21 +33,27 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ -#include "gmock/gmock.h" #include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h" +#include "gmock/gmock.h" namespace rc_rpc_plugin_test { class MockResourceAllocationManager : public rc_rpc_plugin::ResourceAllocationManager { public: - MOCK_METHOD2(AcquireResource, - rc_rpc_plugin::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_METHOD3( + AcquireResource, + rc_rpc_plugin::AcquireResult::eType(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); + MOCK_METHOD3(ForceAcquireResource, + void(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); + MOCK_METHOD3(OnDriverDisallowed, + void(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); MOCK_METHOD2(OnApplicationEvent, void(application_manager::plugin_manager::ApplicationEvent event, application_manager::ApplicationSharedPtr application)); @@ -56,17 +62,32 @@ class MockResourceAllocationManager MOCK_METHOD1(SetAccessMode, void(const hmi_apis::Common_RCAccessMode::eType access_mode)); MOCK_CONST_METHOD0(GetAccessMode, hmi_apis::Common_RCAccessMode::eType()); - MOCK_METHOD3(SetResourceState, + MOCK_METHOD4(SetResourceState, void(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const rc_rpc_plugin::ResourceState::eType state)); - MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type)); + MOCK_CONST_METHOD2(IsResourceFree, + bool(const std::string& module_type, + const std::string& module_id)); MOCK_METHOD0(ResetAllAllocations, void()); MOCK_METHOD2(SendOnRCStatusNotifications, void(rc_rpc_plugin::NotificationTrigger::eType, application_manager::ApplicationSharedPtr application)); MOCK_CONST_METHOD0(is_rc_enabled, bool()); MOCK_METHOD1(set_rc_enabled, void(const bool value)); + MOCK_METHOD3(ReleaseResource, + rc_rpc_plugin::ResourceReleasedState::eType( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id)); + MOCK_METHOD3(SetResourceAcquired, + void(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id)); + MOCK_CONST_METHOD2(IsResourceAlreadyAcquiredByApp, + bool(const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id)); }; } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc index e6922a4c83..40a6bdf41d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc @@ -29,6 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/smart_object_keys.h" #include "gtest/gtest.h" #include "rc_rpc_plugin/interior_data_cache_impl.h" @@ -38,41 +39,49 @@ class InteriorDataCacheTest : public ::testing::Test {}; namespace { const uint32_t time_frame_alowed_requests = 1; +const std::string kValueKey = "value"; +const std::string kArray = "array"; } // namespace TEST_F(InteriorDataCacheTest, InteriorDataCacheDoesNotContainRandomDataInitialy) { rc_rpc_plugin::InteriorDataCacheImpl cache; std::string module_type_key = "random_module_type"; - EXPECT_FALSE(cache.Contains(module_type_key)); - auto retrieved_data = cache.Retrieve(module_type_key); + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); + EXPECT_FALSE(cache.Contains(module)); + auto retrieved_data = cache.Retrieve(module); EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data.getType()); } TEST_F(InteriorDataCacheTest, CheckThatCacheContansDataAfterAdding) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key = "random_module_type"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); smart_objects::SmartObject data; data["key"] = "value"; - cache.Add(module_type_key, data); - EXPECT_TRUE(cache.Contains(module_type_key)); - auto retrieved_data = cache.Retrieve(module_type_key); + cache.Add(module, data); + EXPECT_TRUE(cache.Contains(module)); + auto retrieved_data = cache.Retrieve(module); EXPECT_EQ(data, retrieved_data); } TEST_F(InteriorDataCacheTest, DataDoesNotExistAfterClear) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key = "random_module_type"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); smart_objects::SmartObject data; data["key"] = "value"; - cache.Add(module_type_key, data); - EXPECT_TRUE(cache.Contains(module_type_key)); - auto Retrieved_data = cache.Retrieve(module_type_key); + cache.Add(module, data); + EXPECT_TRUE(cache.Contains(module)); + auto Retrieved_data = cache.Retrieve(module); EXPECT_EQ(Retrieved_data, data); cache.Clear(); - auto Retrieved_data_after_clear = cache.Retrieve(module_type_key); + auto Retrieved_data_after_clear = cache.Retrieve(module); EXPECT_EQ(smart_objects::SmartType_Null, Retrieved_data_after_clear.getType()); } @@ -81,19 +90,23 @@ TEST_F(InteriorDataCacheTest, MultipleDataCached) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key1 = "random_module_type"; + std::string module_id1 = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module1(module_type_key1, module_id1); smart_objects::SmartObject data1; data1["key"] = "value1"; - cache.Add(module_type_key1, data1); - EXPECT_TRUE(cache.Contains(module_type_key1)); - auto retrieved_data1 = cache.Retrieve(module_type_key1); + cache.Add(module1, data1); + EXPECT_TRUE(cache.Contains(module1)); + auto retrieved_data1 = cache.Retrieve(module1); EXPECT_EQ(data1, retrieved_data1); std::string module_type_key2 = "random_module_type2"; + std::string module_id2 = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + rc_rpc_plugin::ModuleUid module2(module_type_key2, module_id2); smart_objects::SmartObject data2; data2["key"] = "value2"; - cache.Add(module_type_key2, data2); - EXPECT_TRUE(cache.Contains(module_type_key2)); - auto retrieved_data2 = cache.Retrieve(module_type_key2); + cache.Add(module2, data2); + EXPECT_TRUE(cache.Contains(module2)); + auto retrieved_data2 = cache.Retrieve(module2); EXPECT_EQ(retrieved_data2, data2); ASSERT_TRUE(data1 != data2); @@ -105,30 +118,36 @@ TEST_F(InteriorDataCacheTest, RemoveFromChacheSuccessful) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type = "random_module_type"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type, module_id); smart_objects::SmartObject data; data["key"] = "value1"; - cache.Add(module_type, data); - EXPECT_TRUE(cache.Contains(module_type)); - auto retrieved_data1 = cache.Retrieve(module_type); + cache.Add(module, data); + EXPECT_TRUE(cache.Contains(module)); + auto retrieved_data1 = cache.Retrieve(module); EXPECT_EQ(data, retrieved_data1); - cache.Remove(module_type); - EXPECT_FALSE(cache.Contains(module_type)); - auto retreived = cache.Retrieve(module_type); + cache.Remove(module); + EXPECT_FALSE(cache.Contains(module)); + auto retreived = cache.Retrieve(module); EXPECT_EQ(smart_objects::SmartType_Null, retreived.getType()); } TEST_F(InteriorDataCacheTest, RemoveNotExistingNoSideEffects) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key = "random_module_type"; + std::string module_id = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); smart_objects::SmartObject data; data["key"] = "value"; - cache.Add(module_type_key, data); - cache.Remove("some other module_type"); + cache.Add(module, data); + rc_rpc_plugin::ModuleUid other_module("some other module_type", + "some other module id"); + cache.Remove(other_module); - EXPECT_TRUE(cache.Contains(module_type_key)); - auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_TRUE(cache.Contains(module)); + auto retrieved_data = cache.Retrieve(module); EXPECT_EQ(data, retrieved_data); } @@ -136,25 +155,72 @@ TEST_F(InteriorDataCacheTest, Exist2ModuleTypesRemoveOneAnotherOneLeft) { rc_rpc_plugin::InteriorDataCacheImpl cache; const std::string module_type_key1 = "random_module_type"; + std::string module_id1 = "34045662-a9dc-4823-8435-91056d4c26cb"; + rc_rpc_plugin::ModuleUid module1(module_type_key1, module_id1); smart_objects::SmartObject data1; data1["key"] = "value1"; - cache.Add(module_type_key1, data1); + cache.Add(module1, data1); std::string module_type_key2 = "random_module_type2"; + std::string module_id2 = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + rc_rpc_plugin::ModuleUid module2(module_type_key2, module_id2); smart_objects::SmartObject data2; data2["key"] = "value2"; - cache.Add(module_type_key2, data2); + cache.Add(module2, data2); ASSERT_TRUE(data1 != data2); - cache.Remove(module_type_key1); - EXPECT_FALSE(cache.Contains(module_type_key1)); - EXPECT_TRUE(cache.Contains(module_type_key2)); + cache.Remove(module1); + EXPECT_FALSE(cache.Contains(module1)); + EXPECT_TRUE(cache.Contains(module2)); - auto retrieved_data1 = cache.Retrieve(module_type_key1); + auto retrieved_data1 = cache.Retrieve(module1); EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data1.getType()); - auto retrieved_data2 = cache.Retrieve(module_type_key2); + auto retrieved_data2 = cache.Retrieve(module2); EXPECT_EQ(data2, retrieved_data2); } -} // rc_rpc_plugin_test +TEST_F(InteriorDataCacheTest, CheckCacheDataMerge) { + using namespace smart_objects; + const std::string module_type_key = "random_module_type"; + const std::string module_id = "random_module_id"; + rc_rpc_plugin::ModuleUid module(module_type_key, module_id); + + auto gen_smart_object = [](const std::string& id, + const std::string& value) -> SmartObject { + SmartObject result(SmartType_Map); + result[application_manager::strings::id] = id; + result[kValueKey] = value; + return result; + }; + + SmartObject data1; + SmartObject data1_array(SmartType_Array); + (*data1_array.asArray()) = SmartArray{gen_smart_object("id1", "value1"), + gen_smart_object("id2", "value2")}; + data1[kArray] = data1_array; + + SmartObject data2(SmartType_Map); + SmartObject data2_array(SmartType_Array); + (*data2_array.asArray()) = SmartArray{gen_smart_object("id1", "value3"), + gen_smart_object("id3", "value4")}; + data2[kArray] = data2_array; + + SmartObject expected_data(SmartType_Map); + SmartObject expected_array(SmartType_Array); + (*expected_array.asArray()) = SmartArray{gen_smart_object("id1", "value3"), + gen_smart_object("id2", "value2"), + gen_smart_object("id3", "value4")}; + expected_data[kArray] = expected_array; + + rc_rpc_plugin::InteriorDataCacheImpl cache; + cache.Add(module, data1); + cache.Add(module, data2); + + const auto retrieved_data = cache.Retrieve(module); + + EXPECT_TRUE(cache.Contains(module)); + EXPECT_EQ(expected_data, retrieved_data); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc new file mode 100644 index 0000000000..3e60591c6b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "rc_rpc_plugin/mock/mock_rc_helpers.h" + +namespace rc_rpc_plugin { + +smart_objects::SmartObject RCHelpers::MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2) { + return MockRCHelpers::rc_helpers_mock()->MergeModuleData(data1, data2); +} + +const std::function<std::string(const std::string&)> +rc_rpc_plugin::RCHelpers::GetModuleTypeToDataMapping() { + return MockRCHelpers::rc_helpers_mock()->GetModuleTypeToDataMapping(); +} + +const std::function<std::string(const std::string&)> +rc_rpc_plugin::RCHelpers::GetModuleTypeToCapabilitiesMapping() { + return MockRCHelpers::rc_helpers_mock()->GetModuleTypeToCapabilitiesMapping(); +} + +const std::vector<std::string> rc_rpc_plugin::RCHelpers::GetModuleTypesList() { + return MockRCHelpers::rc_helpers_mock()->GetModuleTypesList(); +} + +rc_rpc_plugin::RCAppExtensionPtr rc_rpc_plugin::RCHelpers::GetRCExtension( + application_manager::Application& app) { + return MockRCHelpers::rc_helpers_mock()->GetRCExtension(app); +} + +smart_objects::SmartObjectSPtr +rc_rpc_plugin::RCHelpers::CreateUnsubscribeRequestToHMI( + const ModuleUid& module, const uint32_t correlation_id) { + return MockRCHelpers::rc_helpers_mock()->CreateUnsubscribeRequestToHMI( + module, correlation_id); +} + +std::vector<application_manager::ApplicationSharedPtr> +rc_rpc_plugin::RCHelpers::AppsSubscribedToModule( + application_manager::ApplicationManager& app_mngr, + const ModuleUid& module) { + return MockRCHelpers::rc_helpers_mock()->AppsSubscribedToModule(app_mngr, + module); +} + +std::vector<application_manager::ApplicationSharedPtr> +rc_rpc_plugin::RCHelpers::AppsSubscribedToModuleType( + application_manager::ApplicationManager& app_mngr, + const std::string& module_type) { + return MockRCHelpers::rc_helpers_mock()->AppsSubscribedToModuleType( + app_mngr, module_type); +} + +rc_rpc_plugin::RCHelpers::AppsModuleTypes +rc_rpc_plugin::RCHelpers::GetApplicationsAllowedModuleTypes( + application_manager::ApplicationManager& app_mngr) { + return MockRCHelpers::rc_helpers_mock()->GetApplicationsAllowedModuleTypes( + app_mngr); +} + +const std::vector<std::string> RCHelpers::buttons_climate() { + return MockRCHelpers::rc_helpers_mock()->buttons_climate(); +} + +const std::vector<std::string> RCHelpers::buttons_radio() { + return MockRCHelpers::rc_helpers_mock()->buttons_radio(); +} + +const rc_rpc_plugin::RCHelpers::ButtonsMap RCHelpers::buttons_map() { + return MockRCHelpers::rc_helpers_mock()->buttons_map(); +} + +std::vector<std::string> RCHelpers::GetModuleReadOnlyParams( + const std::string& module_type) { + return MockRCHelpers::rc_helpers_mock()->GetModuleReadOnlyParams(module_type); +} + +rc_rpc_types::ModuleIdConsentVector RCHelpers::FillModuleConsents( + const std::string& module_type, + const std::vector<std::string>& module_ids, + const std::vector<bool> allowed) { + return MockRCHelpers::rc_helpers_mock()->FillModuleConsents( + module_type, module_ids, allowed); +} + +std::vector<std::string> RCHelpers::RetrieveModuleIds( + const smart_objects::SmartObject& moduleIds) { + return MockRCHelpers::rc_helpers_mock()->RetrieveModuleIds(moduleIds); +} + +std::vector<bool> RCHelpers::RetrieveModuleConsents( + const smart_objects::SmartObject& consents) { + return MockRCHelpers::rc_helpers_mock()->RetrieveModuleConsents(consents); +} + +void RCHelpers::RemoveRedundantGPSDataFromIVDataMsg( + smart_objects::SmartObject& msg_params) { + return MockRCHelpers::rc_helpers_mock()->RemoveRedundantGPSDataFromIVDataMsg( + msg_params); +} + +MockRCHelpers* MockRCHelpers::rc_helpers_mock() { + static ::testing::NiceMock<MockRCHelpers> mock_rc_helpers; + return &mock_rc_helpers; +} + +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_consent_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_consent_manager_impl_test.cc new file mode 100644 index 0000000000..b4d826719a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_consent_manager_impl_test.cc @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <ctime> +#include <memory> +#include <string> +#include <vector> + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "application_manager/mock_application_manager_settings.h" +#include "rc_rpc_plugin/rc_consent_manager_impl.h" +#include "resumption/last_state.h" +#include "resumption/last_state_impl.h" +#include "utils/date_time.h" +#include "utils/file_system.h" + +#include "application_manager/mock_application_manager.h" + +using test::components::application_manager_test::MockApplicationManager; +using test::components::application_manager_test:: + MockApplicationManagerSettings; + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const std::string kPolicyApp1Id = "app1_id"; +const std::string kPolicyApp2Id = "app2_id"; +const std::string kMacAddress1 = "device1"; +const std::string kMacAddress2 = "device2"; +const std::string kClimateModule = "CLIMATE"; +const std::string kRadioModule = "RADIO"; +const std::string kAppTestStorageFolder = "app_test_storage_folder"; +const std::string kAppTestInfoStorage = "app_test_info_storage"; +const uint32_t kPeriodOfConsentExpired = 30; // in days +} // namespace + +namespace rc_rpc_plugin_test { +namespace rc_consent_manager_test { +using namespace rc_rpc_plugin::rc_rpc_types; +using namespace rc_rpc_plugin; + +class RCConsentManagerImplTest : public ::testing::Test { + public: + RCConsentManagerImplTest() + : current_date_(0u) + , last_state_(new resumption::LastStateImpl(kAppTestStorageFolder, + kAppTestInfoStorage)) + , rc_consent_manager_(new rc_rpc_plugin::RCConsentManagerImpl( + *last_state_, mock_app_mngr_, kPeriodOfConsentExpired)) {} + + void SetUp() OVERRIDE { + current_date_ = std::time(0); + RemoveTemproraryTetsFiles(); + + ON_CALL(mock_app_mngr_, get_settings()) + .WillByDefault(ReturnRef(mock_app_mnrg_settings_)); + ON_CALL(mock_app_mnrg_settings_, period_for_consent_expiration()) + .WillByDefault(Return(kPeriodOfConsentExpired)); + } + + void RemoveTemproraryTetsFiles() { + // Remove exists storage file + if (file_system::FileExists(kAppTestInfoStorage)) { + file_system::DeleteFile(kAppTestInfoStorage); + } + + // Remove exists storage folder + if (file_system::DirectoryExists(kAppTestStorageFolder)) { + file_system::RemoveDirectory(kAppTestStorageFolder); + } + + last_state_->get_dictionary().clear(); + } + + protected: + time_t current_date_; + NiceMock<MockApplicationManagerSettings> mock_app_mnrg_settings_; + NiceMock<MockApplicationManager> mock_app_mngr_; + std::unique_ptr<resumption::LastState> last_state_; + std::unique_ptr<rc_rpc_plugin::RCConsentManagerImpl> rc_consent_manager_; +}; + +TEST_F(RCConsentManagerImplTest, SaveAndGetModuleConsents_SUCCESS) { + const std::string radio_moduleId = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + const std::string climate_moduleId = "34045662-a9dc-4823-8435-91056d4c26cb"; + + ModuleIdConsent radio_module_consent{ + {kRadioModule, radio_moduleId}, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent climate_module_consent{{kClimateModule, climate_moduleId}, + ModuleConsent::NOT_CONSENTED, + current_date_}; + + ModuleIdConsentVector module_consents{radio_module_consent, + climate_module_consent}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents); + last_state_->SaveStateToFileSystem(); + + auto radio_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, {kRadioModule, radio_moduleId}); + auto climate_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, {kClimateModule, climate_moduleId}); + + EXPECT_EQ(ModuleConsent::CONSENTED, radio_consent); + EXPECT_EQ(ModuleConsent::NOT_CONSENTED, climate_consent); +} + +TEST_F(RCConsentManagerImplTest, ModuleId_NOT_EXISTS) { + const std::string radio_moduleId = "eb7739ea-b263-4fe1-af9c-9311d1acac2d"; + const std::string climate_moduleId = "34045662-a9dc-4823-8435-91056d4c26cb"; + + ModuleIdConsent radio_module_consent{ + {kRadioModule, radio_moduleId}, ModuleConsent::CONSENTED, current_date_}; + ModuleIdConsent climate_module_consent{{kClimateModule, climate_moduleId}, + ModuleConsent::CONSENTED, + current_date_}; + + const std::string uknown_moduleId = "639f1b7f-1d25-4dca-a2ce-00530860adea"; + const std::string uknown_moduleType = "UNKNOWN_TYPE"; + + ModuleUid unknown_module{uknown_moduleId, uknown_moduleType}; + + ModuleIdConsentVector module_consents{radio_module_consent, + climate_module_consent}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents); + last_state_->SaveStateToFileSystem(); + + ModuleConsent consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, unknown_module); + + EXPECT_EQ(ModuleConsent::NOT_EXISTS, consent); +} + +TEST_F(RCConsentManagerImplTest, ConsentIsExpired) { + time_t expired_date_45_days = + current_date_ - (date_time::SECONDS_IN_DAY * 45); + time_t expired_date_30_days = + current_date_ - (date_time::SECONDS_IN_DAY * 30); + time_t not_expired_date_29_days = + current_date_ - (date_time::SECONDS_IN_DAY * 29); + + const std::string moduleId1 = "dbef7693-adf9-42f1-95c7-5dff314d9985"; + const std::string moduleId2 = "1536b2ac-213f-463f-8589-a11453cd3729"; + const std::string moduleId3 = "e8b8169a-9f29-4499-a60b-2d126a1beffc"; + + ModuleUid module_resource1{kRadioModule, moduleId1}; + ModuleUid module_resource2{kRadioModule, moduleId2}; + ModuleUid module_resource3{kRadioModule, moduleId3}; + + ModuleIdConsent module_consent_expired1{ + module_resource1, ModuleConsent::CONSENTED, expired_date_45_days}; + ModuleIdConsent module_consent_expired2{ + module_resource2, ModuleConsent::CONSENTED, expired_date_30_days}; + + ModuleIdConsent module_consent_not_expired{ + module_resource3, ModuleConsent::CONSENTED, not_expired_date_29_days}; + + ModuleIdConsentVector module_consents{module_consent_expired1, + module_consent_expired2, + module_consent_not_expired}; + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents); + last_state_->SaveStateToFileSystem(); + + // All consents, which consent has been saved more than 30 days, will be + // removed. + rc_consent_manager_->RemoveExpiredConsents(); + + ModuleConsent expired_consent_45_days = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource1); + EXPECT_EQ(ModuleConsent::NOT_EXISTS, expired_consent_45_days); + + ModuleConsent expired_consent_30_days = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource2); + EXPECT_EQ(ModuleConsent::NOT_EXISTS, expired_consent_30_days); + + ModuleConsent not_expired_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource3); + EXPECT_EQ(ModuleConsent::CONSENTED, not_expired_consent); +} + +TEST_F(RCConsentManagerImplTest, + SaveModuleConsents_SameAppID_DifferentDeviceID_NotReplaced) { + const std::string moduleId = "cef4eae6-e22c-4943-bdc3-60e792414c4c"; + ModuleUid module_resource{kRadioModule, moduleId}; + + ModuleIdConsent radio_module_consent_app1_deviceId1{ + module_resource, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent radio_module_consent_app1_deviceId2{ + module_resource, ModuleConsent::NOT_CONSENTED, current_date_}; + + ModuleIdConsentVector module_consents_app1{ + radio_module_consent_app1_deviceId1}; + ModuleIdConsentVector module_consents_app2{ + radio_module_consent_app1_deviceId2}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app1); + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress2, module_consents_app2); + + last_state_->SaveStateToFileSystem(); + + // Module consents for same app ids and different device_id (mac_adress) will + // haven't been replaced each other + + ModuleConsent module_consent_deviceID1 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource); + + ModuleConsent module_consent_deviceID2 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress2, module_resource); + + EXPECT_EQ(ModuleConsent::CONSENTED, module_consent_deviceID1); + + // // Module consent for app_id2 has different value as has been saved above + EXPECT_EQ(ModuleConsent::NOT_CONSENTED, module_consent_deviceID2); +} + +TEST_F(RCConsentManagerImplTest, + SaveModuleConsents_SameAppID_SameDeviceID_Replaced) { + const std::string moduleId = "194aee9e-26cb-4f48-a775-8841a658002d"; + + ModuleUid radio_module_resource_consented{kRadioModule, moduleId}; + ModuleUid radio_module_resource_not_consented{kRadioModule, moduleId}; + + ModuleIdConsent radio_module_consent_app1_deviceId1{ + radio_module_resource_consented, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent radio_module_consent_app1_deviceId2{ + radio_module_resource_not_consented, + ModuleConsent::NOT_CONSENTED, + current_date_}; + + ModuleIdConsentVector module_consents_app1{ + radio_module_consent_app1_deviceId1}; + ModuleIdConsentVector module_consents_app2{ + radio_module_consent_app1_deviceId2}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app1); + + last_state_->SaveStateToFileSystem(); + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app2); + + last_state_->SaveStateToFileSystem(); + + // Module consents for same app ids and same device_id (mac_adress) will + // have been replaced each other + + ModuleConsent module_consent = rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, radio_module_resource_not_consented); + + EXPECT_EQ(ModuleConsent::NOT_CONSENTED, module_consent); +} + +TEST_F(RCConsentManagerImplTest, RemoveAllModuleConsents_SUCCESS) { + const std::string moduleId = "1c5408f2-9766-464c-a7bf-d834b62f43fa"; + + ModuleUid module_resource{kRadioModule, moduleId}; + + ModuleIdConsent radio_module_consent_app1_deviceId1{ + module_resource, ModuleConsent::CONSENTED, current_date_}; + + ModuleIdConsent radio_module_consent_app1_deviceId2{ + module_resource, ModuleConsent::NOT_CONSENTED, current_date_}; + + ModuleIdConsentVector module_consents_app1{ + radio_module_consent_app1_deviceId1}; + ModuleIdConsentVector module_consents_app2{ + radio_module_consent_app1_deviceId2}; + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress1, module_consents_app1); + + rc_consent_manager_->SaveModuleConsents( + kPolicyApp1Id, kMacAddress2, module_consents_app2); + + last_state_->SaveStateToFileSystem(); + + rc_consent_manager_->RemoveAllConsents(); + + ModuleConsent module_consent_deviceID1 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress1, module_resource); + + ModuleConsent module_consent_deviceID2 = + rc_consent_manager_->GetModuleConsent( + kPolicyApp1Id, kMacAddress2, module_resource); + + EXPECT_EQ(ModuleConsent::NOT_EXISTS, module_consent_deviceID1); + + EXPECT_EQ(ModuleConsent::NOT_EXISTS, module_consent_deviceID2); +} + +} // namespace rc_consent_manager_test +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_helpers_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_helpers_test.cc new file mode 100644 index 0000000000..21876c4c19 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/rc_helpers_test.cc @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + +#include "rc_rpc_plugin/rc_helpers.h" +#include <map> +#include <memory> +#include <string> +#include <type_traits> +#include <vector> +#include "gtest/gtest.h" +#include "rc_rpc_plugin/rc_module_constants.h" + +namespace { +const std::string kKeyId = "id"; +const std::string kKeyStatus = "status"; +const std::string kKeyDensity = "density"; +const std::string kKeyValue = "value"; +const std::string kArray = "array"; +} // namespace + +namespace rc_rpc_plugin_test { + +using namespace rc_rpc_plugin; +using namespace smart_objects; + +class RCHelpersTest : public ::testing::Test { + public: + /** + * @brief Generates smart object with next structure: + * { + * "status": "status<n>", + * "value": "value<n>", + * "id": "id<n>" + * } + * where <n> is number specified with 'object_number' param. + * + * @param int object_number - number of object + * @param bool use_id_key - defines, whether "id" key must be added to smart + * object + * + * @return smart_objects::SmartObject - generated smart object + */ + smart_objects::SmartObject gen_smart_object(int object_number, + bool use_id_key) { + smart_objects::SmartObject result(smart_objects::SmartType_Map); + result[kKeyStatus] = kKeyStatus + std::to_string(object_number); + result[kKeyValue] = kKeyValue + std::to_string(object_number); + if (use_id_key) { + result[kKeyId] = kKeyId + std::to_string(object_number); + } + return result; + } +}; + +TEST_F(RCHelpersTest, + MergeModuleData_OneOfParamsNotSmartMap_ExpectDataReplacedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Array); + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, + MergeModuleData_FirstObjectDontContainKey_ExpectDataAppendedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Map); + + std::map<std::string, std::string> expected_keys_values = { + {"key1", "value1"}, {"key2", "value2"}}; + auto it = expected_keys_values.begin(); + + data1[it->first] = it->second; + ++it; + data2[it->first] = it->second; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + for (auto& item : expected_keys_values) { + EXPECT_TRUE(result.keyExists(item.first)); + EXPECT_EQ(result[item.first], expected_keys_values[item.first]); + } +} + +TEST_F( + RCHelpersTest, + MergeModuleData_SecondObjectContainsDifferentValueType_ExpectDataReplacedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Map); + + data1["key1"] = "value1"; + data2["key1"] = 30; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_EQ(data2["key1"], result["key1"]); +} + +TEST_F(RCHelpersTest, MergeModuleData_Recursive) { + SmartObject data1(SmartType_Map); + SmartObject data2(SmartType_Map); + + data1["key1"]["subkey1"] = "subvalue1"; + data2["key1"]["subkey2"] = 30; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_EQ(result["key1"]["subkey1"], data1["key1"]["subkey1"]); + EXPECT_EQ(result["key1"]["subkey2"], data2["key1"]["subkey2"]); +} + +TEST_F( + RCHelpersTest, + MergeModuleData_MergeObjectsThatContainArrays_ExpectDataReplacedWithNewOne) { + SmartObject data1(SmartType_Map); + SmartObject data1_array(SmartType_Array); + (*data1_array.asArray()) = + SmartArray{gen_smart_object(1, true), gen_smart_object(2, false)}; + data1[kArray] = data1_array; + + SmartObject data2(SmartType_Map); + SmartObject data2_array(SmartType_Array); + (*data2_array.asArray()) = + SmartArray{gen_smart_object(3, true), gen_smart_object(4, false)}; + data2[kArray] = data2_array; + + SmartObject expected_result(SmartType_Map); + SmartObject expected_result_array(SmartType_Array); + (*expected_result_array.asArray()) = + SmartArray{data2[kArray].getElement(0), data2[kArray].getElement(1)}; + + expected_result[kArray] = expected_result_array; + + const auto result = RCHelpers::MergeModuleData(data1, data2); + EXPECT_EQ(expected_result, result); +} + +TEST_F(RCHelpersTest, + MergeArray_OneOfParamsNotSmartArray_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + SmartObject data2(SmartType_Map); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, MergeArray_FirstArrayEmpty_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + SmartObject data2(SmartType_Array); + for (int object : {0, 1}) { + data2.asArray()->emplace(data2.asArray()->begin(), SmartObject(object)); + } + + ASSERT_EQ(0u, data1.length()); + ASSERT_EQ(2u, data2.length()); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, + MergeArray_SecondArrayEmpty_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + for (int object : {0, 1}) { + data1.asArray()->emplace(data1.asArray()->begin(), SmartObject(object)); + } + SmartObject data2(SmartType_Array); + + ASSERT_EQ(2u, data1.length()); + ASSERT_EQ(0u, data2.length()); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, MergeArray_SimpleArrays_ExpectDataReplacedWithSecond) { + SmartObject data1(SmartType_Array); + for (int object : {0, 1, 2, 3, 4, 5}) { + data1.asArray()->emplace(data1.asArray()->begin(), SmartObject(object)); + } + + SmartObject data2(SmartType_Array); + for (int object : {0, 1}) { + data2.asArray()->emplace(data2.asArray()->begin(), SmartObject(object)); + } + + ASSERT_EQ(6u, data1.length()); + ASSERT_EQ(2u, data2.length()); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_NE(result, data1); + EXPECT_EQ(result, data2); +} + +TEST_F(RCHelpersTest, + MergeArray_ObjectsHaveNotEqualIds_ExpectDataAppendedWithNewOne) { + SmartObject data1 = gen_smart_object(1, true); + SmartObject data2 = gen_smart_object(2, true); + + SmartObject array1(SmartType_Array); + array1.asArray()->push_back(data1); + SmartObject array2(SmartType_Array); + array2.asArray()->push_back(data2); + + SmartObject expected_array(SmartType_Array); + expected_array.asArray()->push_back(data1); + expected_array.asArray()->push_back(data2); + ASSERT_EQ(2u, expected_array.length()); + + const auto result = RCHelpers::MergeArray(array1, array2); + EXPECT_EQ(expected_array, result); +} + +TEST_F(RCHelpersTest, + MergeArray_SomeObjectsDontHaveIdKey_ExpectDataReplacedWithSecond) { + int object_number = 1; + + SmartObject array1(SmartType_Array); + array1.asArray()->push_back(gen_smart_object(object_number++, true)); + + SmartObject array2(SmartType_Array); + array2.asArray()->push_back(gen_smart_object(object_number++, false)); + array2.asArray()->push_back(gen_smart_object(object_number++, true)); + + const auto result = RCHelpers::MergeArray(array1, array2); + EXPECT_EQ(array2, result); +} + +TEST_F( + RCHelpersTest, + MergeArray_SomeObjectsHaveEqualIds_ExpectDataWithSameIdUpdateValueOnlyNewDataAdded) { + SmartObject temp = gen_smart_object(1, true); + + SmartObject data1(SmartType_Array); + auto& data1_array = *data1.asArray(); + + data1_array.push_back(temp); + data1_array.push_back(gen_smart_object(2, true)); + + SmartObject data2(SmartType_Array); + auto& data2_array = *data2.asArray(); + + temp[kKeyValue] = "CUSTOM VALUE"; + data2_array.push_back(temp); + data2_array.push_back(gen_smart_object(3, true)); + + SmartObject expected_result(SmartType_Array); + expected_result.asArray()->push_back(temp); + expected_result.asArray()->push_back(data1_array[1]); + expected_result.asArray()->push_back(data2_array[1]); + + const auto result = RCHelpers::MergeArray(data1, data2); + EXPECT_EQ(expected_result, result); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/CMakeLists.txt new file mode 100644 index 0000000000..4b10d34643 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/CMakeLists.txt @@ -0,0 +1,83 @@ +# Copyright (c) 2019, Ford Motor Company +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following +# disclaimer in the documentation and/or other materials provided with the +# distribution. + +# Neither the name of the 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. + +# 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}/application_manager/test/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/include/ + ${COMPONENTS_DIR}/include/test/application_manager/ + ${COMPONENTS_DIR}/rc_rpc_plugin/test/include +) + +set (RESOURCE_ALLOC_MANAGER_TEST_SOURCES +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_consent_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_capabilities_manager_impl.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/mock_rc_helpers.cc +${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc +) + +set(RC_COMMANDS_TEST_SOURCE_DIR ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/commands) +set(RC_COMMANDS_SOURCE_DIR ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/src/commands) +collect_sources(COMMANDS_SOURCES "${RC_COMMANDS_SOURCE_DIR}" "${RC_COMMANDS_TEST_SOURCE_DIR}") + +set(LIBRARIES + ApplicationManager + connectionHandler + SmartObjects + ProtocolHandler + MessageHelper + connectionHandler + Utils + Resumption + jsoncpp + gmock_main + dl +) + +if(ENABLE_LOG) + list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) + list(APPEND LIBRARIES apr-1 -L${APR_LIBS_DIRECTORY}) + list(APPEND LIBRARIES aprutil-1 -L${APR_UTIL_LIBS_DIRECTORY}) + list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY}) +endif() + +list(APPEND COMMANDS_SOURCES ${RESOURCE_ALLOC_MANAGER_TEST_SOURCES}) + +create_test("resource_allocation_manager_test" "${COMMANDS_SOURCES}" "${LIBRARIES}") + diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc index 86c58b9d46..70ed832cb1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager/resource_allocation_manager_impl_test.cc @@ -30,41 +30,47 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <algorithm> +#include <memory> #include "gtest/gtest.h" -#include "rc_rpc_plugin/resource_allocation_manager_impl.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" -#include "rc_rpc_plugin/rc_module_constants.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_rpc_service.h" #include "application_manager/policies/mock_policy_handler_interface.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" +#include "rc_rpc_plugin/mock/mock_rc_capabilities_manager.h" +#include "rc_rpc_plugin/mock/mock_rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "rc_rpc_plugin/resource_allocation_manager_impl.h" using test::components::application_manager_test::MockApplication; using test::components::application_manager_test::MockApplicationManager; using test::components::application_manager_test::MockRPCService; +using ::application_manager::ApplicationSharedPtr; +using ::application_manager::Message; +using ::application_manager::MessageType; +using ::protocol_handler::MessagePriority; +using ::rc_rpc_plugin::MockRCHelpers; using ::testing::_; +using ::testing::DoAll; +using ::testing::Eq; 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; +using ::testing::StrictMock; namespace { const bool kDeviceHandle = 1u; const std::string kModuleType1 = "CLIMATE"; const std::string kModuleType2 = "RADIO"; +const std::string kModuleId = "id1"; const int32_t kConnectionKey = 5; const int32_t kCorrelationId = 5; const uint32_t kAppId1 = 11u; @@ -72,12 +78,27 @@ const uint32_t kHMIAppId1 = 1u; const uint32_t kAppId2 = 22u; const std::string policy_app_id_1_ = "policy_id_1"; const uint32_t kSizeOfModules = 6u; -} +const application_manager::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const rc_rpc_plugin::Grid KDefaultUserLocation = {2, 0, 0, 1, 1, 1}; +const rc_rpc_plugin::Grid kDriverLocation = {0, 0, 0, 1, 1, 1}; +const rc_rpc_plugin::Grid kInvalidLocation = {0, 0, 0, 0, 0, 0}; +const std::vector<std::string> kModuleList = { + rc_rpc_plugin::enums_value::kClimate, + rc_rpc_plugin::enums_value::kRadio, + rc_rpc_plugin::enums_value::kSeat, + rc_rpc_plugin::enums_value::kAudio, + rc_rpc_plugin::enums_value::kLight, + rc_rpc_plugin::enums_value::kHmiSettings}; + +} // namespace namespace rc_rpc_plugin_test { using namespace rc_rpc_plugin; +typedef std::shared_ptr<MockRCHelpers> MockRCHelpersPtr; + class RAManagerTest : public ::testing::Test { public: RAManagerTest() @@ -86,22 +107,58 @@ class RAManagerTest : public ::testing::Test { , mock_app_1_(std::make_shared<NiceMock<MockApplication> >()) , mock_app_2_(std::make_shared<NiceMock<MockApplication> >()) , apps_lock_ptr_(std::make_shared<sync_primitives::Lock>()) - , apps_da_(apps_, apps_lock_ptr_) { + , apps_da_(apps_, apps_lock_ptr_) + , module_service_area_(0, 0, 0, 3, 2, 1) + , mock_rc_helpers_(MockRCHelpers::rc_helpers_mock()) { ON_CALL(mock_app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); auto plugin_id = rc_rpc_plugin::RCRPCPlugin::kRCPluginID; app_ext_ptr_ = std::make_shared<rc_rpc_plugin::RCAppExtension>(plugin_id); ON_CALL(*mock_app_1_, app_id()).WillByDefault(Return(kAppId1)); + PrepareResources(); + ON_CALL(mock_rc_capabilities_manager_, GetResources()) + .WillByDefault(Return(resources_)); + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(false)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(true)); + ON_CALL(mock_rc_capabilities_manager_, GetModuleServiceArea(_)) + .WillByDefault(Return(module_service_area_)); + + ON_CALL(mock_app_mngr_, application(kAppId1)) + .WillByDefault(Return(mock_app_1_)); + ON_CALL(*mock_app_1_, + QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) + .WillByDefault(Return(app_ext_ptr_)); + + ON_CALL(mock_app_mngr_, application(kAppId2)) + .WillByDefault(Return(mock_app_2_)); + ON_CALL(*mock_app_2_, + QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) + .WillByDefault(Return(app_ext_ptr_)); + OnRCStatusNotificationExpectations(); } + void SetUp() OVERRIDE { + rc_app_extension_ = std::make_shared<rc_rpc_plugin::RCAppExtension>( + static_cast<application_manager::AppExtensionUID>( + rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); + ON_CALL(mock_rc_capabilities_manager_, + GetDriverLocationFromSeatLocationCapability()) + .WillByDefault(Return(kDriverLocation)); + ON_CALL(*mock_rc_helpers_, GetRCExtension(_)) + .WillByDefault(Return(rc_app_extension_)); + } + void CheckResultWithHMILevelAndAccessMode( ResourceAllocationManagerImpl& ra_manager, mobile_apis::HMILevel::eType app_level, const rc_rpc_plugin::AcquireResult::eType expected_result, const hmi_apis::Common_RCAccessMode::eType access_mode); + void PrepareResources(); void OnRCStatusNotificationExpectations(); protected: @@ -117,6 +174,12 @@ class RAManagerTest : public ::testing::Test { application_manager::ApplicationSet apps_; std::shared_ptr<sync_primitives::Lock> apps_lock_ptr_; DataAccessor<application_manager::ApplicationSet> apps_da_; + testing::NiceMock<rc_rpc_plugin_test::MockRCCapabilitiesManager> + mock_rc_capabilities_manager_; + std::vector<ModuleUid> resources_; + Grid module_service_area_; + RCAppExtensionPtr rc_app_extension_; + MockRCHelpers* mock_rc_helpers_; }; void RAManagerTest::CheckResultWithHMILevelAndAccessMode( @@ -131,19 +194,27 @@ void RAManagerTest::CheckResultWithHMILevelAndAccessMode( ra_manager.SetAccessMode(access_mode); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()).WillOnce(Return(app_level)); + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillOnce(Return(app_level)); // Second app tries to get already acquired resource by 1st app - EXPECT_EQ(expected_result, ra_manager.AcquireResource(kModuleType1, kAppId2)); + EXPECT_EQ(expected_result, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +void RAManagerTest::PrepareResources() { + for (auto& module_type : kModuleList) { + ModuleUid module(module_type, kModuleId); + resources_.push_back(module); + } } void RAManagerTest::OnRCStatusNotificationExpectations() { - ON_CALL(mock_app_mngr_, application(kAppId1)) - .WillByDefault(Return(mock_app_1_)); - ON_CALL(*mock_app_1_, QueryInterface(rc_rpc_plugin::RCRPCPlugin::kRCPluginID)) - .WillByDefault(Return(app_ext_ptr_)); apps_.insert(mock_app_1_); ON_CALL(mock_app_mngr_, applications()).WillByDefault(Return(apps_da_)); } @@ -152,19 +223,21 @@ TEST_F(RAManagerTest, AcquireResource_NoAppRegistered_Expect_InUse) { // Arrange EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(ApplicationSharedPtr())); - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); // Act & Assert EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); } TEST_F(RAManagerTest, AcquireResource_AppRegisteredAnyHmiLevelResourceFree_Expect_Allowed) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); // Act & Assert EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); } TEST_F( @@ -173,14 +246,15 @@ TEST_F( // Arrange EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); // Same app tries to get already acquired resource EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); } TEST_F( @@ -193,7 +267,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::REJECTED; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::AUTO_ALLOW; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -208,7 +283,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::IN_USE; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::AUTO_DENY; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -223,7 +299,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::ALLOWED; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::AUTO_ALLOW; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -238,7 +315,8 @@ TEST_F( const AcquireResult::eType expected_result = AcquireResult::ASK_DRIVER; const Common_RCAccessMode::eType access_mode = Common_RCAccessMode::eType::ASK_DRIVER; - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); CheckResultWithHMILevelAndAccessMode( ra_manager, app_level, expected_result, access_mode); } @@ -246,32 +324,36 @@ TEST_F( TEST_F(RAManagerTest, AcquireResource_AcquiredModuleIsRejectedForApp2_ExpectApp2Rejected) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_1_)); EXPECT_EQ(AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); // Act - ra_manager.OnDriverDisallowed(kModuleType1, kAppId2); + ra_manager.OnDriverDisallowed(kModuleType1, kModuleId, kAppId2); // Assert EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); EXPECT_EQ(AcquireResult::REJECTED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AppExit_ReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); // Act ra_manager.OnApplicationEvent( @@ -281,19 +363,22 @@ TEST_F(RAManagerTest, AppExit_ReleaseResource) { .WillRepeatedly(Return(mock_app_2_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillRepeatedly(Return(mock_app_2_)); @@ -306,15 +391,16 @@ TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); RCAppExtensionPtr rc_extention_ptr = @@ -322,7 +408,7 @@ TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); // Act application_manager::ApplicationSharedPtr app_ptr(mock_app_1_); @@ -335,18 +421,21 @@ TEST_F(RAManagerTest, AppUnregistered_ReleaseResource) { .WillOnce(Return(mock_app_2_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillOnce(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_2_)); @@ -360,24 +449,25 @@ TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillOnce(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); } TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId1)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId1)); application_manager::ApplicationSet apps; apps.insert(mock_app_1_); @@ -400,18 +490,19 @@ TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillRepeatedly(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId2)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId2)); Mock::VerifyAndClearExpectations(&mock_app_mngr_); } TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::eType::AUTO_DENY); EXPECT_CALL(mock_app_mngr_, application(kAppId1)) @@ -437,9 +528,13 @@ TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { .WillRepeatedly(Return(policy_app_id_1_)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId1)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId1)); + ra_manager.SetResourceAcquired(kModuleType2, kModuleId, kAppId1); application_manager::ApplicationSet apps; apps.insert(mock_app_1_); @@ -449,29 +544,31 @@ TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { EXPECT_CALL(mock_app_mngr_, applications()).WillRepeatedly(Return(apps_da)); - Resources allowed_modules; + std::vector<std::string> allowed_modules; allowed_modules.push_back(kModuleType1); EXPECT_CALL(mock_policy_handler_, GetModuleTypes(policy_app_id_1_, _)) .WillOnce(DoAll(SetArgPointee<1>(allowed_modules), Return(true))); + EXPECT_CALL(mock_app_mngr_, application(kAppId2)) + .WillRepeatedly(Return(mock_app_2_)); + EXPECT_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); + // Act ra_manager.OnPolicyEvent(application_manager::plugin_manager::PolicyEvent:: kApplicationPolicyUpdated); - EXPECT_CALL(mock_app_mngr_, application(kAppId2)) - .WillRepeatedly(Return(mock_app_2_)); - EXPECT_CALL(*mock_app_2_, hmi_level()) - .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::IN_USE, - ra_manager.AcquireResource(kModuleType1, kAppId2)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType2, kAppId2)); + ra_manager.AcquireResource(kModuleType2, kModuleId, kAppId2)); Mock::VerifyAndClearExpectations(&mock_app_mngr_); } TEST_F(RAManagerTest, GetAccessMode_ExpectedSameAsHadSet) { - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::AUTO_DENY); EXPECT_EQ(hmi_apis::Common_RCAccessMode::AUTO_DENY, @@ -492,7 +589,8 @@ TEST_F(RAManagerTest, GetAccessMode_ExpectedSameAsHadSet) { TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_allowed) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); @@ -521,7 +619,8 @@ TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_allowed) { TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_disallowed) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ra_manager.set_rc_enabled(false); ON_CALL((*mock_app_1_), is_remote_control_supported()) @@ -549,7 +648,8 @@ TEST_F(RAManagerTest, OnRCStatus_AppRegistation_RC_disallowed) { TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_disabling) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); @@ -586,7 +686,8 @@ TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_disabling) { TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_enabling) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); @@ -623,14 +724,17 @@ TEST_F(RAManagerTest, OnRCStatus_RCStateChanging_RC_enabling) { TEST_F(RAManagerTest, OnRCStatus_ModuleAllocation) { // Arrange - ResourceAllocationManagerImpl ra_manager(mock_app_mngr_, mock_rpc_service_); + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); ON_CALL((*mock_app_1_), is_remote_control_supported()) .WillByDefault(Return(true)); ON_CALL((*mock_app_1_), hmi_app_id()).WillByDefault(Return(kHMIAppId1)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, - ra_manager.AcquireResource(kModuleType1, kAppId1)); + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); application_manager::commands::MessageSharedPtr message_to_mob; EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) @@ -665,4 +769,118 @@ TEST_F(RAManagerTest, OnRCStatus_ModuleAllocation) { kHMIAppId1); } -} // namespace rc_rpc_plugin +// UL - User Location +// If User Location is invalid, in any case AcquireResult will be REJECTED +TEST_F(RAManagerTest, AcquireResource_UL_IsInvalid_REJECTED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(kInvalidLocation); + + EXPECT_EQ(AcquireResult::REJECTED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); +} + +// UL - User Location, MA - Multiple Access +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsFree_MA_False_ALLOWED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); +} + +// UL - User Location, MA - Multiple Access +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsAcquired_MA_False_REJECTED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + ON_CALL(mock_rc_capabilities_manager_, IsMultipleAccessAllowed(_)) + .WillByDefault(Return(false)); + EXPECT_EQ(AcquireResult::REJECTED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +// UL - User Location, MA - Multiple Access +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsFree_MA_True_ALLOWED) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +// UL - User Location, MA - Multiple Access, AM - Access Mode +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsAcquired_MA_True_AM_AUTO_DENY) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + + ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::AUTO_DENY); + + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_EQ(AcquireResult::IN_USE, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +TEST_F(RAManagerTest, + AcquireResource_UL_IsValid_ResourceIsAcquired_MA_True_AM_ASK_DRIVER) { + ResourceAllocationManagerImpl ra_manager( + mock_app_mngr_, mock_rpc_service_, mock_rc_capabilities_manager_); + + ON_CALL(mock_rc_capabilities_manager_, IsSeatLocationCapabilityProvided()) + .WillByDefault(Return(true)); + rc_app_extension_->SetUserLocation(KDefaultUserLocation); + + EXPECT_EQ(AcquireResult::ALLOWED, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId1)); + + ra_manager.SetResourceAcquired(kModuleType1, kModuleId, kAppId1); + + ra_manager.SetAccessMode(hmi_apis::Common_RCAccessMode::ASK_DRIVER); + + ON_CALL(*mock_app_2_, hmi_level(kDefaultWindowId)) + .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); + EXPECT_EQ(AcquireResult::ASK_DRIVER, + ra_manager.AcquireResource(kModuleType1, kModuleId, kAppId2)); +} + +} // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt index fdf02b57cb..fe8857b6b1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/CMakeLists.txt @@ -51,21 +51,27 @@ collect_sources(APP_EXTENSIONS "${EXTENSIONS_SOURCE_DIR}") collect_sources(RPC_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES + ApplicationManager HMI_API MOBILE_API - ApplicationManager + MessageHelper + connectionHandler v4_protocol_v1_2_no_extra SmartObjects Utils - Policy + PolicyStatic + jsoncpp ) if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("sdl_rpc_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES} ${APP_EXTENSIONS}) -target_link_libraries("sdl_rpc_plugin" ${LIBRARIES}) +add_library("sdl_rpc_plugin_static" ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${RPC_PLUGIN_SOURCES} ${APP_EXTENSIONS}) +target_link_libraries("sdl_rpc_plugin_static" ${LIBRARIES}) + +add_library("sdl_rpc_plugin" SHARED "src/sdl_rpc_plugin.cc") +target_link_libraries("sdl_rpc_plugin" sdl_rpc_plugin_static) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h index 7b0911fef9..6d8f5e4b2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_request.h @@ -72,6 +72,6 @@ class ActivateAppRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h index f937b4f63b..93be297bf6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/activate_app_response.h @@ -72,6 +72,6 @@ class ActivateAppResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ACTIVATE_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h index 4e9e4d54d7..6e7ef63cf4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h @@ -74,6 +74,6 @@ class AddStatisticsInfoNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ADD_STATISTICS_INFO_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h index 45acb3a424..54a81f50f3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h @@ -72,6 +72,6 @@ class AllowAllAppsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h index 41d1c9e752..ffd60a61d8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h @@ -72,6 +72,6 @@ class AllowAllAppsResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_ALL_APPS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h index b3a2d88d7d..c8c0198cc8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_request.h @@ -72,6 +72,6 @@ class AllowAppRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h index 55637e1756..5f6ee670ec 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/allow_app_response.h @@ -72,6 +72,6 @@ class AllowAppResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ALLOW_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h new file mode 100644 index 0000000000..9847f567e0 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BasicCommunicationCloseApplicationRequest command class + **/ +class BasicCommunicationCloseApplicationRequest + : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief BasicCommunicationCloseApplicationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + BasicCommunicationCloseApplicationRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief BasicCommunicationCloseApplicationRequest class destructor + **/ + ~BasicCommunicationCloseApplicationRequest() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(BasicCommunicationCloseApplicationRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h new file mode 100644 index 0000000000..9576684b77 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h @@ -0,0 +1,80 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief BasicCommunicationCloseApplicationResponse command class + **/ +class BasicCommunicationCloseApplicationResponse + : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief BasicCommunicationCloseApplicationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + BasicCommunicationCloseApplicationResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief BasicCommunicationCloseApplicationResponse class destructor + **/ + ~BasicCommunicationCloseApplicationResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(BasicCommunicationCloseApplicationResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_CLOSE_APPLICATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h index 3a97ebdfb5..e90e6cd20f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h @@ -35,8 +35,8 @@ #include "application_manager/commands/response_from_hmi.h" -#include "utils/macro.h" #include "application_manager/application_manager.h" +#include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h index 2ac1be2580..82ac7b0efa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h @@ -72,6 +72,6 @@ class OnAwakeSDLNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h index a7eb820146..71eb9e4105 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h @@ -74,6 +74,6 @@ class BasicCommunicationSystemRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h index 20483a45e3..c76993cc6f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h @@ -74,6 +74,6 @@ class BasicCommunicationSystemResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BASIC_COMMUNICATION_SYSTEM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h index 5c650fb8e4..9bb3d9a6fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h @@ -73,6 +73,6 @@ class ButtonGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h index bf2f15c18a..4431ea1224 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h @@ -74,6 +74,6 @@ class ButtonGetCapabilitiesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BUTTON_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h index 635b0579f4..bfcf478930 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_request.h @@ -72,6 +72,6 @@ class ClosePopupRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h index 199b40f070..7477bda854 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/close_popup_response.h @@ -72,6 +72,6 @@ class ClosePopupResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_CLOSE_POPUP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h index a70bff2553..f59b36fe09 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h @@ -67,6 +67,6 @@ class DecryptCertificateRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h index 88b216eeea..9844ed9165 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h @@ -73,6 +73,6 @@ class DecryptCertificateResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DECRYPT_CERTIFICATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h index fa0efb90e6..bafe9c1e91 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_request.h @@ -75,6 +75,6 @@ class DialNumberRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h index 33d4788eca..9097757ab2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/dial_number_response.h @@ -76,6 +76,6 @@ class DialNumberResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h index d771167798..8d3be68539 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_request.h @@ -72,6 +72,6 @@ class GetSystemInfoRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h index 5bf5f41b73..d4f35a4e2a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ -#include "application_manager/commands/response_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -82,6 +82,6 @@ class GetSystemInfoResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_SYSTEM_INFO_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h index 34c10cedf1..46aa575eb5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h @@ -73,6 +73,6 @@ class MixingAudioSupportedRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h index 5c67666225..32dd23d352 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h @@ -74,6 +74,6 @@ class MixingAudioSupportedResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_MIXING_AUDIO_SUPPORTED_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h index 3f63ef883d..a04488df76 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h @@ -72,6 +72,6 @@ class NaviAlertManeuverRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h index 7d7c4de85e..610af3fbfc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h @@ -72,6 +72,6 @@ class NaviAlertManeuverResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_ALERT_MANEUVER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h index 80e948ad25..fa9eee485e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h @@ -63,8 +63,8 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, virtual ~AudioStartStreamRequest(); /** - * @brief onTimeOut from requrst Controller - */ + * @brief onTimeOut from requrst Controller + */ virtual void onTimeOut(); /** @@ -78,9 +78,9 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, virtual void on_event(const app_mngr::event_engine::Event& event); /** - * @brief RetryStartSession resend HMI startSession request if needed. - * If limit expired, set audio_stream_retry_number counter to 0 - */ + * @brief RetryStartSession resend HMI startSession request if needed. + * If limit expired, set audio_stream_retry_number counter to 0 + */ void RetryStartSession(); private: @@ -90,6 +90,6 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h index 926cfc36ed..0f669084cb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h @@ -71,6 +71,6 @@ class AudioStartStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_START_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h index 7c5fbbdd3d..9f3aa8c312 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h @@ -71,6 +71,6 @@ class AudioStopStreamRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h index 8eb091dd92..740efc2d19 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h @@ -71,6 +71,6 @@ class AudioStopStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_AUDIO_STOP_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h index dab5fc1022..0e2ad8b9a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h @@ -70,6 +70,6 @@ class NaviGetWayPointsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h index fb93c2c64a..9fef4f041e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h @@ -72,6 +72,6 @@ class NaviGetWayPointsResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_GET_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h index 404ddc9f00..17d4eb483f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h @@ -78,6 +78,6 @@ class NaviIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h index 7f94312d04..5dcbdd46df 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h @@ -72,6 +72,6 @@ class NaviIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h index 7bdf0e4787..02068779a9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_request.h @@ -72,6 +72,6 @@ class NaviSendLocationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h index 6a65eb00a1..e322177e45 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_send_location_response.h @@ -72,6 +72,6 @@ class NaviSendLocationResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SEND_LOCATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h index a981b8ff81..437d58861c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h @@ -84,6 +84,6 @@ class NaviSetVideoConfigRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h index f5f9e7a5ee..3cf3ca17ae 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h @@ -74,6 +74,6 @@ class NaviSetVideoConfigResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SET_VIDEO_CONFIG_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h index f64bdf6ce0..efe6743d88 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h @@ -73,6 +73,6 @@ class NaviShowConstantTBTRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h index fd4da08cf0..a77d2b9dbb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h @@ -73,6 +73,6 @@ class NaviShowConstantTBTResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SHOW_CONSTANT_TBT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h index d5aae67661..afad744eb3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h @@ -47,10 +47,10 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, public app_mngr::event_engine::EventObserver { public: /** - * @brief NaviStartStreamRequest class constructor - * - * @param message Incoming SmartObject message - **/ + * @brief NaviStartStreamRequest class constructor + * + * @param message Incoming SmartObject message + **/ NaviStartStreamRequest(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -78,9 +78,9 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, virtual void onTimeOut(); /** - * @brief RetryStartSession resend HMI startSession request if needed. - * If limit expired, set video_stream_retry_number counter to 0 - */ + * @brief RetryStartSession resend HMI startSession request if needed. + * If limit expired, set video_stream_retry_number counter to 0 + */ void RetryStartSession(); private: @@ -90,6 +90,6 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h index b4770e82fe..38d9ba905c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h @@ -71,6 +71,6 @@ class NaviStartStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_START_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h index 400c61ba07..0d14d0595f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h @@ -71,6 +71,6 @@ class NaviStopStreamRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h index 39512ac2bb..10b5ef0f80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h @@ -71,6 +71,6 @@ class NaviStopStreamResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_STOP_STREAM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h index 052c3c7151..3def06ba9a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h @@ -71,6 +71,6 @@ class NaviSubscribeWayPointsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h index 73aab4633f..c424ae0857 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h @@ -74,6 +74,6 @@ class NaviSubscribeWayPointsResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h index f20386a246..be1ccbb45b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h @@ -72,6 +72,6 @@ class NaviUnsubscribeWayPointsRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h index ec4f4eb963..d4f98a871c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h @@ -74,5 +74,5 @@ class NaviUnsubscribeWayPointsResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h index db269a65d3..a80d111dae 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h @@ -72,6 +72,6 @@ class NaviUpdateTurnListRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h index 20295485a3..8f715ac33d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h @@ -73,6 +73,6 @@ class NaviUpdateTurnListResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_NAVI_UPDATE_TURN_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h index 42bf877f2d..3f9d096625 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h @@ -74,6 +74,6 @@ class OnAllowSDLFunctionalityNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_ALLOW_SDL_FUNCTIONALITY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h index cc21d699fb..f856ce966e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h @@ -74,6 +74,6 @@ class OnAppActivatedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_ACTIVATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h index 9b4a6ba5a0..6a7fd00632 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h @@ -74,6 +74,6 @@ class OnAppDeactivatedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_DEACTIVATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h index 6008a8ce51..afed4bfa39 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h @@ -74,6 +74,6 @@ class OnAppPermissionChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h index a751b25d85..1f06e38ccd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h @@ -74,6 +74,6 @@ class OnAppPermissionConsentNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_PERMISSION_CONSENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h index 3548786d1d..00c75d2c23 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h @@ -74,6 +74,6 @@ class OnAppRegisteredNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_REGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h index 097eb1eb28..791374f6f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h @@ -64,13 +64,13 @@ class OnAppUnregisteredNotification ~OnAppUnregisteredNotification() FINAL; /** - * @brief Init overrides and skips replacement of app id with hmi id since - * 1) at the moment this notification is being sent there is no application - * registered in application manager - * 2) hmi id is already used whenever this message is being constructed, so - * its already there - * @return True in any case - */ + * @brief Init overrides and skips replacement of app id with hmi id since + * 1) at the moment this notification is being sent there is no application + * registered in application manager + * 2) hmi id is already used whenever this message is being constructed, so + * its already there + * @return True in any case + */ bool Init() FINAL; /** @@ -84,6 +84,6 @@ class OnAppUnregisteredNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_APP_UNREGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h index cac306f760..8f51a822a2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h @@ -74,6 +74,6 @@ class OnAudioDataStreamingNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_AUDIO_DATA_STREAMING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h index 17f8a5b3c8..0e956e8688 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h @@ -74,6 +74,6 @@ class OnBCSystemCapabilityUpdatedNotification } // namespace commands -} // namespace app_service_rpc_plugin +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h new file mode 100644 index 0000000000..39b5c3aee3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_FROM_HMI_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_FROM_HMI_H_ + +#include "application_manager/commands/notification_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief OnBCSystemCapabilityUpdatedNotificationFromHMI command class + **/ +class OnBCSystemCapabilityUpdatedNotificationFromHMI + : public app_mngr::commands::NotificationFromHMI { + public: + /** + * @brief OnBCSystemCapabilityUpdatedNotificationFromHMI class constructor + * @param message Incoming SmartObject message from HMI + * @note all parameters described below required for base class + * @param application_manager Application manager instance to interact with + * related application + * @param rpc_service - service to handle appropriate RPC + * @param hmi_capabilities - HMI capabilities + * @param policy_handle - instance which allows interaction between + * application manager and application policies + **/ + OnBCSystemCapabilityUpdatedNotificationFromHMI( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief OnBCSystemCapabilityUpdatedNotificationFromHMI class destructor + **/ + ~OnBCSystemCapabilityUpdatedNotificationFromHMI() FINAL; + + void Run() FINAL; + + private: + enum ProcessSystemDisplayCapabilitiesResult { + SUCCESS, + FAIL, + CAPABILITIES_CACHED + }; + /** + * @brief ProcessSystemDisplayCapabilities processes provided display + * capabilities according to its structure + * @param display_capabilities display capabilities to process + * @return true if display capabilities have been processed properly, + * otherwise returns false + */ + ProcessSystemDisplayCapabilitiesResult ProcessSystemDisplayCapabilities( + const smart_objects::SmartObject& display_capabilities); + + DISALLOW_COPY_AND_ASSIGN(OnBCSystemCapabilityUpdatedNotificationFromHMI); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BC_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_FROM_HMI_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h index b83fe1bfe0..955249bd4b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_event_notification.h @@ -74,6 +74,6 @@ class OnButtonEventNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h index e996c9952c..9de86d1d9c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_press_notification.h @@ -74,6 +74,6 @@ class OnButtonPressNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h index 4ed60f9a07..0a0a8c3c5d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h @@ -78,6 +78,6 @@ class OnButtonSubscriptionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_BUTTON_SUBSCRIPTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h index 99c165c12f..7fe0b2a8c3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h @@ -74,6 +74,6 @@ class OnDeviceChosenNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_CHOSEN_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h index 7701e2a601..df1efb4d30 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h @@ -74,6 +74,6 @@ class OnDeviceStateChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DEVICE_STATE_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h index 51fb49c6bc..df8dd3d401 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h @@ -80,6 +80,6 @@ class OnDriverDistractionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h index cff0a0e617..4fcde5f7d0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h @@ -74,6 +74,6 @@ class OnEventChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EVENT_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h index 116932d87a..dbbbe925fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h @@ -79,6 +79,6 @@ class OnExitAllApplicationsNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_ALL_APPLICATIONS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h index 11c397bfe7..403642f64d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h @@ -74,6 +74,6 @@ class OnExitApplicationNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_EXIT_APPLICATION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h index 38c5dcf535..7658017364 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h @@ -72,6 +72,6 @@ class OnFileRemovedNotification : public app_mngr::commands::NotificationToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FILE_REMOVED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h index 672ded9dcf..bf3a9d530e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_find_applications.h @@ -72,6 +72,6 @@ class OnFindApplications : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_FIND_APPLICATIONS_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h index 85b7ed356e..d215b3d07d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnIgnitionCycleOverNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_IGNITION_CYCLE_OVER_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h index 075dc2cb5c..a07af99df1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnNaviTBTClientStateNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_TBT_CLIENT_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h index 3efde9c8c1..74058e246c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,5 +75,5 @@ class OnNaviWayPointChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_NAVI_WAY_POINT_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h index 331e352795..ede78dd362 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_policy_update.h @@ -66,6 +66,6 @@ class OnPolicyUpdate : public app_mngr::commands::NotificationFromHMI { DISALLOW_COPY_AND_ASSIGN(OnPolicyUpdate); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h index 503013ff58..e64edd51bc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_put_file_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ -#include "application_manager/commands/notification_to_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnPutFileNotification : public app_mngr::commands::NotificationToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_PUT_FILE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h index c4adc20090..f540abbf4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ready_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnReadyNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_READY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h index c1e1b01a18..1ffe038a82 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_received_policy_update.h @@ -43,10 +43,10 @@ namespace commands { class OnReceivedPolicyUpdate : public app_mngr::commands::NotificationFromHMI { public: /** - * @brief OnReceivedPolicyUpdate class constructor - * - * @param message Incoming SmartObject message - **/ + * @brief OnReceivedPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ OnReceivedPolicyUpdate(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -69,6 +69,6 @@ class OnReceivedPolicyUpdate : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECEIVED_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h index c5755a364c..68cc5ca487 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_record_start_notification.h @@ -74,6 +74,6 @@ class OnRecordStartdNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RECORD_START_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h index ef2b5a34eb..63ea659747 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ -#include "application_manager/commands/notification_to_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnResumeAudioSourceNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_RESUME_AUDIO_SOURCE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h index 34fe41de81..a40872b578 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h @@ -72,6 +72,6 @@ class OnSDLCloseNotification : public app_mngr::commands::NotificationToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CLOSE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h index 9fe736a595..00bc6c9a05 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h @@ -74,6 +74,6 @@ class OnSDLConsentNeededNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_CONSENT_NEEDED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h index 96f63845e1..6ae9aee1f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h @@ -74,6 +74,6 @@ class OnSDLPersistenceCompleteNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SDL_PERSISTENCE_COMPLETE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_service_update_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_service_update_notification.h new file mode 100644 index 0000000000..bfa9b6e6ae --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_service_update_notification.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SERVICE_UPDATE_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SERVICE_UPDATE_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +namespace hmi { + +/** + * @brief OnServiceUpdateNotification command class + **/ +class OnServiceUpdateNotification + : public app_mngr::commands::NotificationToHMI { + public: + /** + * @brief OnServiceUpdateNotification class constructor + * @param application_manager ref to application manager + * @param rpc_service ref to rpc service + * @param hmi_capabilities ref to HMI capabilities + * @param policy_handle ref to policy handler + **/ + OnServiceUpdateNotification( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief OnServiceUpdateNotification class destructor + **/ + virtual ~OnServiceUpdateNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnServiceUpdateNotification); +}; + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SERVICE_UPDATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h index da049b1dc4..38bb1db03e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h @@ -72,6 +72,6 @@ class OnStartDeviceDiscovery : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_START_DEVICE_DISCOVERY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h index 7c61fac041..7a6e8b871a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_status_update_notification.h @@ -74,6 +74,6 @@ class OnStatusUpdateNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_STATUS_UPDATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h index d4c940bac7..a239203053 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_context_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -76,6 +76,6 @@ class OnSystemContextNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_CONTEXT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h index 76325b078f..3993eefd8b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_error_notification.h @@ -73,6 +73,6 @@ class OnSystemErrorNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_ERROR_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h index 1e4046b83b..a5ab636464 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h @@ -74,6 +74,6 @@ class OnSystemInfoChangedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_INFO_CHANGED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h index 1e1e1818b8..6f9f63b517 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_request_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnSystemRequestNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_REQUEST_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h index 7cd8410d8e..799af1e134 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_SYSTEM_TIME_READY_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h index 33c7d98b6f..0462925f71 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h @@ -74,6 +74,6 @@ class OnTTSLanguageChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h index 70050a667e..c8bd159064 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h @@ -78,6 +78,6 @@ class OnTTSResetTimeoutNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h index 93dac3f292..315acf3a5f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h @@ -73,6 +73,6 @@ class OnTTSStartedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STARTED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h index 362e96f4be..0dafd61c58 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h @@ -73,6 +73,6 @@ class OnTTSStoppedNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_TTS_STOPPED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h index 0cc4e9e772..f468ce5b0a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h @@ -72,6 +72,6 @@ class OnUICommandNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h index c487894770..31b7eef3a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -79,6 +79,6 @@ class OnUIKeyBoardInputNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_KEYBOARD_INPUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h index f30b8573aa..2495aa2b96 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h @@ -74,6 +74,6 @@ class OnUILanguageChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h index bbdf4d04ef..1c87f82349 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h @@ -78,6 +78,6 @@ class OnUIResetTimeoutNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_RESET_TIMEOUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h index 5c7dd0128b..26c25f437a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -79,6 +79,6 @@ class OnUITouchEventNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UI_TOUCH_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h index 2942c36053..d638629b3a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_update_device_list.h @@ -72,6 +72,6 @@ class OnUpdateDeviceList : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_UPDATE_DEVICE_LIST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h index ed0b1572ff..c848233497 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_acc_pedal_position_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIAccPedalPositionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ACC_PEDAL_POSITION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h index cc81160ccb..0cb3e04f4e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_belt_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIBeltStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BELT_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h index 2b46b69f55..6ab920204d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_body_information_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIBodyInformationNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_BODY_INFORMATION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h index 05da9a775d..b3afeb82b3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_device_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIDeviceStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DEVICE_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h index 6640d7953a..a1885c5e29 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_driver_braking_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIDriverBrakingNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_DRIVER_BRAKING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h index f8c0526f8c..feb6cc6060 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_engine_torque_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIEngineTorqueNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ENGINE_TORQUE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h index 900aecd845..734420aaee 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_external_temperature_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIExternalTemperatureNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_EXTERNAL_TEMPERATURE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h index 7374de9ad9..a5588901f7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -74,6 +74,6 @@ class OnVIFuelLevelNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h index a705fcbd04..5ed661cdbf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_fuel_level_state_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIFuelLevelStateNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_FUEL_LEVEL_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h index 984e1e4c0b..70ee5f6c00 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_gps_data_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIGpsDataNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_GPS_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h index 1dfda8a9e0..5ef1e3ed92 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_head_lamp_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIHeadLampStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_HEAD_LAMP_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h index fd8743907c..7bb7756fc5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_instant_fuel_consumption_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIInstantFuelConsumptionNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_INSTANT_FUEL_CONSUMPTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h index 25ace2821d..cdebc99768 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_my_key_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIMyKeyNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_MY_KEY_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h index ad141e733c..1da26dd316 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_odometer_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -74,6 +74,6 @@ class OnVIOdometerNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_ODOMETER_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h index 95fb873957..7d03c62633 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_prndl_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIPrndlNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_PRNDL_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h index d4b121a96f..60a0ce0782 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_rpm_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIRpmNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_RPM_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h index 4afaafc9ff..4920fbd661 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_speed_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVISpeedNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_SPEED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h index 0d0aeadad8..cff99ecf8e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_steering_wheel_angle_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVISteeringWheelAngleNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_STEERING_WHEEL_ANGLE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h index c358ed37e9..0399780869 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_tire_pressure_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVITirePressureNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_TIRE_PRESSURE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h index 75062a51e1..60b686683f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_vin_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVIVinNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VIN_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h index de7a5dfc9e..a6e1ba9921 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vi_wiper_status_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -75,6 +75,6 @@ class OnVIWiperStatusNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_WIPER_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h index 7a7cf3cd96..6d6d4a69db 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h @@ -74,6 +74,6 @@ class OnVideoDataStreamingNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VIDEO_DATA_STREAMING_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h index 3ef21fc568..58ea2e07b5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/notification_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class OnVRCommandNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h index e6bd39d46e..f583d1e2fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h @@ -74,6 +74,6 @@ class OnVRLanguageChangeNotification } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h index abca9db91d..98ed40101b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h @@ -72,6 +72,6 @@ class OnVRStartedNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STARTED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h index 9b53214f8f..e16b440da7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h @@ -72,6 +72,6 @@ class OnVRStoppedNotification : public app_mngr::commands::NotificationFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VR_STOPPED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h index 8f94d4876a..57a90955f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h @@ -72,6 +72,6 @@ class RCGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h index dec31c9ea1..e0c305f796 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h @@ -72,6 +72,6 @@ class RCGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h index 3ba614f823..305a866659 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h @@ -89,6 +89,6 @@ class RCIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h index 93f30e795c..5f4af23527 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h @@ -72,6 +72,6 @@ class RCIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h index e97312b881..2751104486 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ -#include "application_manager/commands/request_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/request_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -109,6 +109,6 @@ class SDLActivateAppRequest : public app_mngr::commands::RequestFromHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h index 7a3f5157da..fd8b885e88 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h @@ -71,6 +71,6 @@ class SDLActivateAppResponse : public app_mngr::commands::ResponseToHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_ACTIVATE_APP_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h index 61426e0af3..acf390cfbc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h @@ -73,6 +73,6 @@ class SDLGetListOfPermissionsRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h index e2556bac3d..4fc1775c72 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h @@ -74,6 +74,6 @@ class SDLGetListOfPermissionsResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_LIST_OF_PERMISSIONS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h index 93b414c8c4..043a4369c5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,36 +30,38 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_ #include "application_manager/commands/request_from_hmi.h" -#include "policy/policy_types.h" -#include "smart_objects/smart_object.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; + namespace commands { + /** - * @brief GetUrls command class + * @brief SDLGetPolicyConfigurationDataRequest command class **/ -class GetUrls : public app_mngr::commands::RequestFromHMI { +class SDLGetPolicyConfigurationDataRequest + : public app_mngr::commands::RequestFromHMI { public: /** - * @brief GetUrls class constructor + * @brief SDLGetPolicyConfigurationDataRequest class constructor * * @param message Incoming SmartObject message **/ - GetUrls(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + SDLGetPolicyConfigurationDataRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** - * @brief GetUrls class destructor + * @brief SDLGetPolicyConfigurationDataRequest class destructor **/ - virtual ~GetUrls(); + ~SDLGetPolicyConfigurationDataRequest() OVERRIDE; /** * @brief Execute command @@ -67,30 +69,16 @@ class GetUrls : public app_mngr::commands::RequestFromHMI { void Run() OVERRIDE; private: -#ifdef PROPRIETARY_MODE - /** - * @brief Processes URLs collecting for policy service - * @param endpoints Endpoints section of policy table - */ - void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints); -#endif // PROPRIETARY_MODE + hmi_apis::Common_Result::eType PrepareResponseParams( + smart_objects::SmartObject& response_out) const; - /** - * @brief Process URLs collecting for service - * @param endpoints Endpoints section of policy table - */ - void ProcessServiceURLs(const policy::EndpointUrls& endpoints); - - /** - * @brief Sends response to HMI - * @param result Result code - */ - void SendResponseToHMI(hmi_apis::Common_Result::eType result); + smart_objects::SmartObject GetValueParam( + const Json::Value& policy_property) const; - DISALLOW_COPY_AND_ASSIGN(GetUrls); + DISALLOW_COPY_AND_ASSIGN(SDLGetPolicyConfigurationDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h new file mode 100644 index 0000000000..2c22f69281 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_ + +#include "application_manager/commands/response_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief SDLGetPolicyConfigurationDataResponse command class + **/ +class SDLGetPolicyConfigurationDataResponse + : public app_mngr::commands::ResponseToHMI { + public: + /** + * @brief SDLGetPolicyConfigurationDataResponse class constructor + * + * @param message Incoming SmartObject message + **/ + SDLGetPolicyConfigurationDataResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief SDLGetPolicyConfigurationDataResponse class destructor + **/ + virtual ~SDLGetPolicyConfigurationDataResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SDLGetPolicyConfigurationDataResponse); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_POLICY_CONFIGURATION_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h index b6376bacc6..fae0b6480d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h @@ -71,6 +71,6 @@ class SDLGetStatusUpdateRequest : public app_mngr::commands::RequestFromHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h index 4e6da22370..1c10142c99 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h @@ -72,6 +72,6 @@ class SDLGetStatusUpdateResponse : public app_mngr::commands::ResponseToHMI { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_STATUS_UPDATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h index 75902e2733..18ad1fa535 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ -#include "application_manager/commands/request_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/request_from_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -74,6 +74,6 @@ class SDLGetUserFriendlyMessageRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h index a02d6894e3..101a13b218 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h @@ -74,6 +74,6 @@ class SDLGetUserFriendlyMessageResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_GET_USER_FRIENDLY_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h index f164aed775..e330e847b0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update.h @@ -43,10 +43,10 @@ namespace commands { class SDLPolicyUpdate : public app_mngr::commands::RequestToHMI { public: /** - * @brief SDLPolicyUpdate class constructor - * - * @param message Incoming SmartObject message - **/ + * @brief SDLPolicyUpdate class constructor + * + * @param message Incoming SmartObject message + **/ SDLPolicyUpdate(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -66,6 +66,6 @@ class SDLPolicyUpdate : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h index 63f33477b6..ce7125f251 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h @@ -69,6 +69,6 @@ class SDLPolicyUpdateResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SDL_POLICY_UPDATE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h index 229ed92947..0905e90b45 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h @@ -73,6 +73,6 @@ class TTSChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h index 8462178283..1988a7ee62 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h @@ -74,6 +74,6 @@ class TTSChangeRegistratioResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h index df6cf3b4a4..d636485915 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h @@ -72,6 +72,6 @@ class TTSGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h index 7919f213a4..5c9b60e2f8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h @@ -73,6 +73,6 @@ class TTSGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h index 09345c02d7..73ef8c5234 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_request.h @@ -72,6 +72,6 @@ class TTSGetLanguageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h index e52dbf1ada..b29b3e7314 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_language_response.h @@ -72,6 +72,6 @@ class TTSGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h index c42d0257d3..a24a6446b3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h @@ -74,6 +74,6 @@ class TTSGetSupportedLanguagesRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h index cc24db22b9..25850de5f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h @@ -74,6 +74,6 @@ class TTSGetSupportedLanguagesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h index b7dffd5bde..dd360eeb4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h @@ -88,6 +88,6 @@ class TTSIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h index 268edd0eeb..881cd98179 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h @@ -72,6 +72,6 @@ class TTSIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h index f416b3a787..009ee8f0be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h @@ -73,6 +73,6 @@ class TTSSetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h index ff5622296c..d7ac422e57 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h @@ -74,6 +74,6 @@ class TTSSetGlobalPropertiesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h index 9e8915a440..efb67243fa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_request.h @@ -72,6 +72,6 @@ class TTSSpeakRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h index e4b2c8adbd..d516a9df1e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_speak_response.h @@ -72,6 +72,6 @@ class TTSSpeakResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_SPEAK_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h index 8eb6a66c95..f3ce24d928 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h @@ -72,6 +72,6 @@ class TTSStopSpeakingRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h index d433fe2280..6399193ae6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h @@ -72,6 +72,6 @@ class TTSStopSpeakingResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_TTS_STOP_SPEAKING_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h index e5d2483576..2d1e84fbec 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_request.h @@ -72,6 +72,6 @@ class UIAddCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h index 90a9666561..cf69368551 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_command_response.h @@ -72,6 +72,6 @@ class UIAddCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h index 5de5e41cd6..0cd120b3cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h @@ -72,6 +72,6 @@ class UIAddSubmenuRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h index 20f830be27..5e951600bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h @@ -72,6 +72,6 @@ class UIAddSubmenuResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ADD_SUBMENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h index 6235a51c7d..3c0423e35e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_request.h @@ -72,6 +72,6 @@ class UIAlertRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h index b43185af78..0392da0c7b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_alert_response.h @@ -72,6 +72,6 @@ class UIAlertResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_ALERT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h new file mode 100644 index 0000000000..a637f53df3 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UICancelInteractionRequest command class + **/ +class UICancelInteractionRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief UICancelInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + UICancelInteractionRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UICancelInteractionRequest class destructor + **/ + virtual ~UICancelInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UICancelInteractionRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h new file mode 100644 index 0000000000..751a2ceef8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UICancelInteractionResponse command class + **/ +class UICancelInteractionResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UICancelInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + UICancelInteractionResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UICancelInteractionResponse class destructor + **/ + virtual ~UICancelInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UICancelInteractionResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CANCEL_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h index c504c55727..44440bf49d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h @@ -73,6 +73,6 @@ class UIChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h index d7fca83d3e..e0077744a1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h @@ -73,6 +73,6 @@ class UIChangeRegistratioResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h new file mode 100644 index 0000000000..6fe8e182c4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.CreateWindow request command class + **/ +class UICreateWindowRequest : public app_mngr::commands::RequestToHMI { + public: + UICreateWindowRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + ~UICreateWindowRequest() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UICreateWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h new file mode 100644 index 0000000000..b9452fce1f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_create_window_response.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.CreateWindow response command class + **/ +class UICreateWindowResponse : public app_mngr::commands::ResponseFromHMI { + public: + UICreateWindowResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + ~UICreateWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UICreateWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_CREATE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h index ecc0b44495..4af8b91793 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h @@ -72,6 +72,6 @@ class UIDeleteCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h index f9601b7491..1eda0d362a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h @@ -72,6 +72,6 @@ class UIDeleteCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h index 3161c84b7c..9a7cd97ec7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h @@ -72,6 +72,6 @@ class UIDeleteSubmenuRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h index 7c73a53c3e..3edb8489e0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h @@ -72,6 +72,6 @@ class UIDeleteSubmenuResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_SUBMENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h new file mode 100644 index 0000000000..58b2c3989f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.DeleteWindow request command class + **/ +class UIDeleteWindowRequest : public app_mngr::commands::RequestToHMI { + public: + UIDeleteWindowRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + ~UIDeleteWindowRequest() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h new file mode 100644 index 0000000000..1500a3f9b2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UI.DeleteWindow response command class + **/ +class UIDeleteWindowResponse : public app_mngr::commands::ResponseFromHMI { + public: + UIDeleteWindowResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + ~UIDeleteWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(UIDeleteWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_DELETE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h index 8d34e1852b..90bf6f7dbc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h @@ -73,6 +73,6 @@ class UIEndAudioPassThruRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h index b1c3bfd87a..69a7959e53 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h @@ -73,6 +73,6 @@ class UIEndAudioPassThruResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_END_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h index 47782cc7a9..58d8d0f732 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h @@ -72,6 +72,6 @@ class UIGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h index 421844560d..d83d5f211b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h @@ -72,6 +72,6 @@ class UIGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h index 7c82584178..842a97a717 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_request.h @@ -72,6 +72,6 @@ class UIGetLanguageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h index 7354e87ee4..ec02b6fde9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_language_response.h @@ -72,6 +72,6 @@ class UIGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h index 7fd456b92b..42ea555358 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h @@ -73,6 +73,6 @@ class UIGetSupportedLanguagesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h index 26d8e98892..45137ba518 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h @@ -74,6 +74,6 @@ class UIGetSupportedLanguagesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h index 2e7806cd2b..18536032b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h @@ -88,6 +88,6 @@ class UIIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h index f2b4f201f3..790c0115aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h @@ -72,6 +72,6 @@ class UIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h index 6d4e870228..be7d384583 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h @@ -73,6 +73,6 @@ class UIPerformAudioPassThruRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h index e36a292573..05f2cc84fd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h @@ -74,6 +74,6 @@ class UIPerformAudioPassThruResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h index ff4540de23..15cec6c17e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h @@ -73,6 +73,6 @@ class UIPerformInteractionRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h index caf5716e18..2d13e15ad2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h @@ -74,6 +74,6 @@ class UIPerformInteractionResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h index f5acf41c8d..bc25259662 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h @@ -73,6 +73,6 @@ class UIScrollableMessageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h index e46265c0e4..f7f92600cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h @@ -73,6 +73,6 @@ class UIScrollableMessageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SCROLLABLE_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h index 4e260a99ff..56ffe40c21 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h @@ -73,6 +73,6 @@ class UISendHapticDataRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h index 1bf38939be..439c2f2682 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h @@ -73,6 +73,6 @@ class UISendHapticDataResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SEND_HAPTIC_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h index ea526df135..a7d07628e3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h @@ -72,6 +72,6 @@ class UISetAppIconRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h index af2c4fafea..3e4b338439 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h @@ -72,6 +72,6 @@ class UISetAppIconResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_APP_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h index f60f7325fd..446b77b997 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h @@ -71,6 +71,6 @@ class UiSetDisplayLayoutRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h index ce404a4049..ade6aa1c13 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h @@ -73,6 +73,6 @@ class UiSetDisplayLayoutResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_DISPLAY_LAYOUT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h index 44e8bba450..8df60a318a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h @@ -73,6 +73,6 @@ class UISetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h index a9c27a423b..a189093fc7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h @@ -74,6 +74,6 @@ class UISetGlobalPropertiesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h index 24f4d76d89..b1b196a25f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h @@ -73,6 +73,6 @@ class UISetMediaClockTimerRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h index c664bd04f9..23b6d3aefa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h @@ -74,6 +74,6 @@ class UISetMediaClockTimerResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h index 1ff38194b8..c47d73b858 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_urls_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h @@ -30,43 +30,45 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_REQUEST_H_ -#include "application_manager/commands/response_to_hmi.h" +#include "application_manager/commands/request_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; + namespace commands { -class GetUrlsResponse : public app_mngr::commands::ResponseToHMI { +/** + * @brief UIShowAppMenuRequest command class + **/ +class UIShowAppMenuRequest : public app_mngr::commands::RequestToHMI { public: /** - * @brief GetUrlsResponse class constructor - * - * @param message Incoming SmartObject message + * @brief UIShowAppMenuRequest class constructor **/ - GetUrlsResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + UIShowAppMenuRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); /** - * @brief GetUrlsResponse class destructor + * @brief UIShowAppMenuRequest class destructor **/ - virtual ~GetUrlsResponse(); + ~UIShowAppMenuRequest() OVERRIDE; /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: - DISALLOW_COPY_AND_ASSIGN(GetUrlsResponse); + DISALLOW_COPY_AND_ASSIGN(UIShowAppMenuRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_GET_URLS_RESPONSE_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h new file mode 100644 index 0000000000..c03a043e12 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_RESPONSE_H_ + +#include "application_manager/commands/response_from_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief UIShowAppMenuResponse command class + **/ +class UIShowAppMenuResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UIShowAppMenuResponse class constructor + **/ + UIShowAppMenuResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UIShowAppMenuResponse class destructor + **/ + ~UIShowAppMenuResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(UIShowAppMenuResponse); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_APP_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h index 7ba950d530..6024243481 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_request.h @@ -72,6 +72,6 @@ class UIShowRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h index f9f7a61056..4d19667153 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_show_response.h @@ -72,6 +72,6 @@ class UIShowResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SHOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h index 3de1b4e775..c41e02b44f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_request.h @@ -72,6 +72,6 @@ class UISliderRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h index 17d1f8a8ed..f4e4465568 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_slider_response.h @@ -72,6 +72,6 @@ class UISliderResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SLIDER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h index dc0166e33f..b352a3b273 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_request.h @@ -72,6 +72,6 @@ class UpdateAppListRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h index 2e3bb79233..a31621dbd5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_app_list_response.h @@ -72,6 +72,6 @@ class UpdateAppListResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_APP_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h index c4c9f11e06..db4f265a9f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h @@ -35,8 +35,8 @@ #include "application_manager/commands/request_to_hmi.h" #include "application_manager/event_engine/event_observer.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -92,6 +92,6 @@ class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h index c33518a545..5f7afed2c3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_response.h @@ -72,6 +72,6 @@ class UpdateDeviceListResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_DEVICE_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h index e30b045fcb..3e001b2582 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ -#include "application_manager/commands/request_to_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/request_to_hmi.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -73,6 +73,6 @@ class UpdateSDLRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h index f71921ea3a..a6fc917872 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_sdl_response.h @@ -72,6 +72,6 @@ class UpdateSDLResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UPDATE_SDL_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h index 0abb37adbc..b40245256e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_request.h @@ -72,6 +72,6 @@ class VRAddCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h index 5f9c99a483..dc123bc82f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_add_command_response.h @@ -72,6 +72,6 @@ class VRAddCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h index 4af28cb542..418842395d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h @@ -73,6 +73,6 @@ class VRChangeRegistrationRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h index a80df0968b..08f3dfa501 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h @@ -74,6 +74,6 @@ class VRChangeRegistrationResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h index 0ed9521ec5..2e1aa7c0d1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h @@ -72,6 +72,6 @@ class VRDeleteCommandRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h index 63efcab355..a7d45ed5ea 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h @@ -72,6 +72,6 @@ class VRDeleteCommandResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h index f8ac83af58..254d00452f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h @@ -72,6 +72,6 @@ class VRGetCapabilitiesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h index 9c9bb55b1b..781e38cda2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h @@ -72,6 +72,6 @@ class VRGetCapabilitiesResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_CAPABILITIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h index e764cbef91..441795cfb5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_request.h @@ -72,6 +72,6 @@ class VRGetLanguageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h index 470fe3ebdc..2bc08e5173 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_language_response.h @@ -72,6 +72,6 @@ class VRGetLanguageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_LANGUAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h index 8d9e9e2a61..ad87415a87 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h @@ -73,6 +73,6 @@ class VRGetSupportedLanguagesRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h index 735844cd99..16a67d6468 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h @@ -74,6 +74,6 @@ class VRGetSupportedLanguagesResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_GET_SUPPORTED_LANGUAGES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h index 0b580f6c1d..2dba80065a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h @@ -89,6 +89,6 @@ class VRIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h index 42c47f5077..f901147094 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h @@ -72,6 +72,6 @@ class VRIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h index 6f206c010f..8cbd2e346e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h @@ -73,6 +73,6 @@ class VRPerformInteractionRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h index 9e8599419f..60cb4cb80c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h @@ -74,6 +74,6 @@ class VRPerformInteractionResponse } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VR_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h index 745fb3ec18..8cac0d686d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_request.h @@ -164,6 +164,6 @@ class AddCommandRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h index fb3f172b0b..811bda2cc7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_command_response.h @@ -73,6 +73,6 @@ class AddCommandResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h index 37ba9a5990..d99c5dab38 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h @@ -88,10 +88,12 @@ class AddSubMenuRequest : public app_mngr::commands::CommandRequestImpl { */ bool CheckSubMenuName(); + bool is_menu_layout_available_ = true; + DISALLOW_COPY_AND_ASSIGN(AddSubMenuRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h index 253556f899..ba15f04cd0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h @@ -73,6 +73,6 @@ class AddSubMenuResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ADD_SUB_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h index 93f716cb65..8b7e86fb3f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h @@ -105,6 +105,6 @@ class AlertManeuverRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h index 8b21aa64eb..2f21fadb54 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h @@ -73,6 +73,6 @@ class AlertManeuverResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_MANEUVER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h index e34653daf4..dfc7b73487 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_request.h @@ -149,6 +149,6 @@ class AlertRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h index 4ae95fb979..51de24fd41 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/alert_response.h @@ -73,6 +73,6 @@ class AlertResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ALERT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h new file mode 100644 index 0000000000..0063c07512 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h @@ -0,0 +1,85 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CancelInteractionRequest command class + **/ +class CancelInteractionRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief CancelInteractionRequest class constructor + * + * @param message Incoming SmartObject message + **/ + CancelInteractionRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CancelInteractionRequest class destructor + **/ + virtual ~CancelInteractionRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief Interface method that is called whenever new event received + * + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(CancelInteractionRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h new file mode 100644 index 0000000000..3e8536e617 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CancelInteractionResponse command class + **/ +class CancelInteractionResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief CancelInteractionResponse class constructor + * + * @param message Incoming SmartObject message + **/ + CancelInteractionResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CancelInteractionResponse class destructor + **/ + virtual ~CancelInteractionResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(CancelInteractionResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CANCEL_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h index bd5c34ebd1..f9f780b84b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_request.h @@ -38,8 +38,8 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/pending.h" -#include "utils/macro.h" #include "utils/custom_string.h" +#include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -123,11 +123,12 @@ class ChangeRegistrationRequest /** * @brief Check parameters (name, vr) for * coincidence with already known parameters of registered applications - * + * @param device_id device identifier * @return SUCCESS if there is no coincidence of app.name/VR synonyms, * otherwise appropriate error code returns */ - mobile_apis::Result::eType CheckCoincidence(); + mobile_apis::Result::eType CheckCoincidence( + const connection_handler::DeviceHandle& device_id); /** * @brief Checks if requested name is allowed by policy @@ -146,11 +147,11 @@ class ChangeRegistrationRequest std::string& ResponseInfo); /** - * @brief Predicate for using with CheckCoincidence method to compare with VR - * synonym SO - * - * @return TRUE if there is coincidence of VR, otherwise FALSE - */ + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * @return TRUE if there is coincidence of VR, otherwise FALSE + */ struct CoincidencePredicateVR { CoincidencePredicateVR(const custom_str::CustomString& newItem) : newItem_(newItem) {} @@ -186,6 +187,6 @@ class ChangeRegistrationRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h index 4cb8c394c7..8c3b7f0be3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/change_registration_response.h @@ -75,6 +75,6 @@ class ChangeRegistrationResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CHANGE_REGISTRATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h new file mode 100644 index 0000000000..b965e880b4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_request.h @@ -0,0 +1,85 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CloseApplicationRequest command class + **/ +class CloseApplicationRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief CloseApplicationRequest class constructor + * + * @param message Incoming SmartObject message + **/ + CloseApplicationRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CloseApplicationRequest class destructor + **/ + ~CloseApplicationRequest() 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 app_mngr::event_engine::Event& event); + + private: + DISALLOW_COPY_AND_ASSIGN(CloseApplicationRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h new file mode 100644 index 0000000000..c7b649f4e9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/close_application_response.h @@ -0,0 +1,79 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CloseApplicationResponse command class + **/ +class CloseApplicationResponse + : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief CloseApplicationResponse class constructor + * + * @param message Incoming SmartObject message + **/ + CloseApplicationResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief CloseApplicationResponse class destructor + **/ + ~CloseApplicationResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(CloseApplicationResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CLOSE_APPLICATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h index 1ad1c07b2a..a1bc866347 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -162,11 +162,11 @@ class CreateInteractionChoiceSetRequest app_mngr::ApplicationConstSharedPtr app); /* - * @brief Predicate for using with CheckChoiceSet method to compare choice ID - *param - * - * return TRUE if there is coincidence of choice ID, otherwise FALSE - */ + * @brief Predicate for using with CheckChoiceSet method to compare choice ID + *param + * + * return TRUE if there is coincidence of choice ID, otherwise FALSE + */ struct CoincidencePredicateChoiceID { CoincidencePredicateChoiceID(const uint32_t newItem) : newItem_(newItem) {} @@ -178,11 +178,11 @@ class CreateInteractionChoiceSetRequest }; /* - * @brief Predicate for using with CheckChoiceSet method to compare menu name - *param - * - * return TRUE if there is coincidence of menu name, otherwise FALSE - */ + * @brief Predicate for using with CheckChoiceSet method to compare menu name + *param + * + * return TRUE if there is coincidence of menu name, otherwise FALSE + */ struct CoincidencePredicateMenuName { CoincidencePredicateMenuName(const std::string& newItem) : newItem_(newItem) {} @@ -195,11 +195,11 @@ class CreateInteractionChoiceSetRequest }; /* - * @brief Predicate for using with CheckChoiceSet method to compare VR commands - *param - * - * return TRUE if there is coincidence of VR commands, otherwise FALSE - */ + * @brief Predicate for using with CheckChoiceSet method to compare VR + *commands param + * + * return TRUE if there is coincidence of VR commands, otherwise FALSE + */ struct CoincidencePredicateVRCommands { CoincidencePredicateVRCommands(const smart_objects::SmartObject& newItem) : newItem_(newItem) {} @@ -219,7 +219,7 @@ class CreateInteractionChoiceSetRequest * * return Return TRUE if there are similar VR synonyms in choice set, * otherwise FALSE - */ + */ bool compareSynonyms( const ns_smart_device_link::ns_smart_objects::SmartObject& choice1, const ns_smart_device_link::ns_smart_objects::SmartObject& choice2); @@ -232,7 +232,7 @@ class CreateInteractionChoiceSetRequest * * return Return TRUE if there are similar VR synonyms in choice set, * otherwise FALSE - */ + */ static bool compareStr( const ns_smart_device_link::ns_smart_objects::SmartObject& str1, const ns_smart_device_link::ns_smart_objects::SmartObject& str2); @@ -273,6 +273,6 @@ class CreateInteractionChoiceSetRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h index 76718bc2c3..0bfc0e5cdf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h @@ -75,6 +75,6 @@ class CreateInteractionChoiceSetResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_INTERACTION_CHOICE_SET_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h new file mode 100644 index 0000000000..cfbfc460b7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_request.h @@ -0,0 +1,117 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/hmi_state.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow request command class + **/ +class CreateWindowRequest : public app_mngr::commands::CommandRequestImpl { + public: + CreateWindowRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + ~CreateWindowRequest() FINAL; + + app_mngr::WindowID window_id() const FINAL; + + void Run() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief CheckWindowName checks if provided window_name exists and allowed to + * be created + * @param app pointer to application owns affected window + * @param window_name window name to check + * @return true if window_name is valid, otherwise returns false + */ + bool CheckWindowName(app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id, + const std::string& window_name) const; + + /** + * @brief ValidateWindowCreation checks whether window can be created + * @return true if window can be created, otherwise returns false + */ + bool ValidateWindowCreation(app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id); + + /** + * @brief IsWindowForAssociatedServiceCreated check whether a window with + * current associated type has already been created + * @return true if window has been created, otherwise returns false + */ + bool IsWindowForAssociatedServiceCreated( + app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief DoesExceedMaxAllowedWindows check wheter max allowed amount of + * windows is exceeded + * @return true if amount us exceeded, otherwise returns false + */ + bool DoesExceedMaxAllowedWindows(app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief ApplyWindowInitialState apply changes related to window HMI state + * initialization + * @param app pointer to application owns affected window + */ + void ApplyWindowInitialState(app_mngr::ApplicationSharedPtr app) const; + + DISALLOW_COPY_AND_ASSIGN(CreateWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h new file mode 100644 index 0000000000..5163293a7c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_window_response.h @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow response command class + **/ +class CreateWindowResponse : public app_mngr::commands::CommandResponseImpl { + public: + CreateWindowResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + ~CreateWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(CreateWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_CREATE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h index a21b1928d0..45864ca3aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_request.h @@ -114,6 +114,6 @@ class DeleteCommandRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h index f81f119792..a91012a934 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_command_response.h @@ -73,6 +73,6 @@ class DeleteCommandResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_COMMAND_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h index 02cd0086b6..8e4d63df4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_request.h @@ -78,6 +78,6 @@ class DeleteFileRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h index fbdc70c9bc..8fbc79ba9f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_file_response.h @@ -73,6 +73,6 @@ class DeleteFileResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_FILE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h index 4dec11a67b..c1d8759962 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -90,6 +90,6 @@ class DeleteInteractionChoiceSetRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h index 0fce16ea9f..bd67f9c556 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h @@ -75,6 +75,6 @@ class DeleteInteractionChoiceSetResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_INTERACTION_CHOICE_SET_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h index c947fda78a..2f85065ee7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -104,6 +104,6 @@ class DeleteSubMenuRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h index e5b0c58a34..c569d61258 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h @@ -73,6 +73,6 @@ class DeleteSubMenuResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_SUB_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h new file mode 100644 index 0000000000..b837724d7b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_request.h @@ -0,0 +1,91 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/hmi_state.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief CreateWindow request command class + **/ +class DeleteWindowRequest : public app_mngr::commands::CommandRequestImpl { + public: + DeleteWindowRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + ~DeleteWindowRequest() FINAL; + + void Run() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + app_mngr::WindowID window_id() const FINAL; + + /** + * @brief Init sets hash update mode for request + */ + bool Init() FINAL; + + private: + /** + * @brief CheckWindowId checks if provided window_id exists and allowed to be + * deleted + * @param app pointer to application owns affected window + * @return true if window_id is valid, otherwise returns false + */ + bool CheckWindowId(app_mngr::ApplicationSharedPtr app) const; + + /** + * @brief DeleteWindow deletes data related to a request window id + * @param app pointer to applications owns affected window + */ + void DeleteWindow(app_mngr::ApplicationSharedPtr app) const; + + DISALLOW_COPY_AND_ASSIGN(DeleteWindowRequest); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h new file mode 100644 index 0000000000..279541724a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/delete_window_response.h @@ -0,0 +1,67 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief DeleteWindow response command class + **/ +class DeleteWindowResponse : public app_mngr::commands::CommandResponseImpl { + public: + DeleteWindowResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + ~DeleteWindowResponse() FINAL; + + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(DeleteWindowResponse); +}; + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DELETE_WINDOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h index 3e313602c7..750288f5e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_request.h @@ -61,13 +61,13 @@ class DialNumberRequest : public app_mngr::commands::CommandRequestImpl { ~DialNumberRequest() OVERRIDE; /** - * @brief Initialize request params + * @brief Initialize request params **/ bool Init() OVERRIDE; /** - * @brief Execute command - **/ + * @brief Execute command + **/ void Run() OVERRIDE; /** @@ -90,6 +90,6 @@ class DialNumberRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h index 6181231458..9c47537c6f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/dial_number_response.h @@ -73,6 +73,6 @@ class DialNumberResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAL_NUMBER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h index 319a20958e..1c18de3237 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h @@ -80,6 +80,6 @@ class EndAudioPassThruRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h index e2a667f272..1003d9d2d7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h @@ -74,6 +74,6 @@ class EndAudioPassThruResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_END_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h index b780daaf03..6516d3cef1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/generic_response.h @@ -72,6 +72,6 @@ class GenericResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GENERIC_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h index b8da061870..a5d1611f02 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_request.h @@ -61,7 +61,7 @@ class GetSystemCapabilityRequest DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityRequest); }; // GetSystemCapabilityRequest -} // commands -} // application_manager +} // namespace commands +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h index 9fa954c89f..61079b3ac2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_system_capability_response.h @@ -60,7 +60,7 @@ class GetSystemCapabilityResponse DISALLOW_COPY_AND_ASSIGN(GetSystemCapabilityResponse); }; // GetSystemCapabilityResponse -} // commands -} // application_manager +} // namespace commands +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_SYSTEM_CAPABILITY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h index 7197874475..ec656820e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_request.h @@ -76,6 +76,6 @@ class GetWayPointsRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h index bb480a7ac0..1b8f055e9c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/get_way_points_response.h @@ -71,6 +71,6 @@ class GetWayPointsResponse : public app_mngr::commands::CommandResponseImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h index 53d75819f8..d98fa433b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_request.h @@ -73,6 +73,6 @@ class ListFilesRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h index 1b3cdf1b02..d259b27ecf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/list_files_response.h @@ -73,6 +73,6 @@ class ListFilesResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_LIST_FILES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h index ba01d4bb28..28508d386c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h @@ -75,6 +75,6 @@ class OnAppInterfaceUnregisteredNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_INTERFACE_UNREGISTERED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h index e3410bd873..a6de6b929c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h @@ -77,6 +77,6 @@ class OnAudioPassThruNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_AUDIO_PASS_THRU_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h index 6afdc0e1cf..afde9bac92 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -87,6 +87,6 @@ class OnButtonEventNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h index fe9bc449be..57fda49be7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -86,6 +86,6 @@ class OnButtonPressNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h index 367b280e73..76ee0b4052 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_command_notification.h @@ -77,6 +77,6 @@ class OnCommandNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_COMMAND_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h index 82e6097d84..9c7fb5e91b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h @@ -79,6 +79,6 @@ class OnDriverDistractionNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_DRIVER_DISTRACTION_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h index 76c9cf34c5..b62f74e199 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h @@ -76,6 +76,6 @@ class OnHashChangeNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HASH_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h index 0e1919676b..ef040de3de 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h @@ -74,6 +74,6 @@ class OnHMIStatusNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h index 12e3b54be9..6f3ef40076 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ -#include "application_manager/commands/command_notification_from_mobile_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_notification_from_mobile_impl.h" #include "interfaces/MOBILE_API.h" #include "utils/macro.h" @@ -77,6 +77,6 @@ class OnHMIStatusNotificationFromMobile }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_HMI_STATUS_NOTIFICATION_FROM_MOBILE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h index d34815ff2f..52f6e5d487 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h @@ -78,6 +78,6 @@ class OnKeyBoardInputNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_KEYBOARD_INPUT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h index b234b93796..1bc1e94b1f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_language_change_notification.h @@ -75,6 +75,6 @@ class OnLanguageChangeNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_LANGUAGE_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h index f586a0d36c..eca3cebf31 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h @@ -75,6 +75,6 @@ class OnPermissionsChangeNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_PERMISSIONS_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h index 1f7e8468db..f29c7dcf2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ +#include <vector> #include "application_manager/commands/command_notification_impl.h" #include "policy/policy_table/enums.h" -#include <vector> namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -79,6 +79,6 @@ class OnSystemCapabilityUpdatedNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_CAPABILITY_UPDATED_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h index b369ad38f2..a0148a4abd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_system_request_notification.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ +#include <vector> #include "application_manager/commands/command_notification_impl.h" #include "policy/policy_table/enums.h" -#include <vector> namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -88,6 +88,6 @@ class OnSystemRequestNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_SYSTEM_REQUEST_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h index 39b12fea15..cbb7525092 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h @@ -75,6 +75,6 @@ class OnTBTClientStateNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TBT_CLIENT_STATE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h index 858759b793..48872d9b27 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h @@ -77,6 +77,6 @@ class OnTouchEventNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_TOUCH_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h index c379fceb02..ed7cbccf4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h @@ -71,5 +71,5 @@ class OnWayPointChangeNotification }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h index 1a4c248a02..434b6de028 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h @@ -35,8 +35,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ #include "application_manager/commands/command_request_impl.h" -#include "utils/macro.h" #include "interfaces/MOBILE_API.h" +#include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -184,6 +184,6 @@ class PerformAudioPassThruRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h index 6654762067..300ea6531f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h @@ -75,6 +75,6 @@ class PerformAudioPassThruResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_AUDIO_PASS_THRU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 2d4cbc9afc..0572679c85 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -36,8 +36,8 @@ #include <string> -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -246,6 +246,6 @@ class PerformInteractionRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h index 6bb9135dcc..113757a1ad 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_response.h @@ -75,6 +75,6 @@ class PerformInteractionResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PERFORM_INTERACTION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h index 2783280f87..b3e04f7796 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_request.h @@ -34,9 +34,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ +#include "application_manager/application_manager.h" #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" -#include "application_manager/application_manager.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -76,11 +76,11 @@ class PutFileRequest : public app_mngr::commands::CommandRequestImpl { mobile_apis::FileType::eType file_type_; bool is_persistent_file_; - void SendOnPutFileNotification(); + void SendOnPutFileNotification(bool is_system_file); DISALLOW_COPY_AND_ASSIGN(PutFileRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h index 22dbf1b5d5..348a217eba 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/put_file_response.h @@ -73,6 +73,6 @@ class PutFileResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_PUT_FILE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index 91ee8ea813..c55dcb65fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -36,8 +36,8 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/policies/policy_handler_interface.h" -#include "utils/macro.h" #include "utils/custom_string.h" +#include "utils/macro.h" namespace policy { struct DeviceInfo; @@ -126,7 +126,7 @@ class RegisterAppInterfaceRequest * * @param app application with changed HMI status * @param resumption If true, resumption-related parameters will be sent to - *the HMI + * the HMI * @param need_restore_vr If resumption is true, whether or not VR commands *should be resumed **/ @@ -154,11 +154,11 @@ class RegisterAppInterfaceRequest std::vector<app_mngr::ApplicationSharedPtr>& out_duplicate_apps); /* - * @brief Predicate for using with CheckCoincidence method to compare with VR - * synonym SO - * - * return TRUE if there is coincidence of VR, otherwise FALSE - */ + * @brief Predicate for using with CheckCoincidence method to compare with VR + * synonym SO + * + * return TRUE if there is coincidence of VR, otherwise FALSE + */ struct CoincidencePredicateVR { CoincidencePredicateVR(const custom_str::CustomString& newItem) : newItem_(newItem) {} @@ -207,17 +207,31 @@ class RegisterAppInterfaceRequest void SendSubscribeCustomButtonNotification(); /** - * @brief IsApplicationSwitched checks whether application is switched from - * another transport. If application id is found, but not in reconnection + * @brief IsApplicationSwitched checks whether application is switched + * from another transport. If application id is found, but not in reconnection * list, returns 'already registered' code. Otherwise - proceed with * switching. * @return True if application is detected as switched, otherwise false. */ bool IsApplicationSwitched(); + /** + * @brief Information about given Connection Key. + * @param key Unique key used by other components as session identifier + * @param device_id device identifier. + * @param mac_address uniq address + * @return false in case of error or true in case of success + */ + bool GetDataOnSessionKey( + const uint32_t key, + connection_handler::DeviceHandle* device_id = nullptr, + std::string* mac_address = nullptr) const; + private: std::string response_info_; mobile_apis::Result::eType result_code_; + connection_handler::DeviceHandle device_handle_; + std::string device_id_; policy::PolicyHandlerInterface& GetPolicyHandler(); DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest); @@ -225,6 +239,6 @@ class RegisterAppInterfaceRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h index d591d67794..2a6e847067 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_response.h @@ -79,6 +79,6 @@ class RegisterAppInterfaceResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_REGISTER_APP_INTERFACE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h index 6f7e330bf5..880fced6ba 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -144,6 +144,6 @@ class ResetGlobalPropertiesRequest }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h index b33ef41426..6d9b604b41 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h @@ -75,6 +75,6 @@ class ResetGlobalPropertiesResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_RESET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h index a641fa0cd4..58b7b4491a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_request.h @@ -85,6 +85,6 @@ class ScrollableMessageRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h index 8bc8a36363..e5c668b424 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/scrollable_message_response.h @@ -68,6 +68,6 @@ class ScrollableMessageResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SCROLLABLE_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h index e3ed6ef28b..2f00b58d9e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h @@ -34,8 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_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/commands/command_request_impl.h" #include "application_manager/event_engine/event.h" #include "smart_objects/smart_object.h" @@ -83,6 +83,6 @@ class SendHapticDataRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h index 53e8766241..515fe3f74d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h @@ -72,6 +72,6 @@ class SendHapticDataResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_HAPTIC_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h index 6626da4c9d..5a0dc67f35 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_request.h @@ -75,10 +75,10 @@ class SendLocationRequest : public app_mngr::commands::CommandRequestImpl { private: /** - * @brief CheckFieldsCompatibility checks if fields are compatible with each - * other. - * @return true if compatible, otherwise return false - */ + * @brief CheckFieldsCompatibility checks if fields are compatible with each + * other. + * @return true if compatible, otherwise return false + */ bool CheckFieldsCompatibility(); /** @@ -95,6 +95,6 @@ class SendLocationRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h index cb461f9a60..a2e9d1eb0a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/send_location_response.h @@ -66,6 +66,6 @@ class SendLocationResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SEND_LOCATION_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h index 1075999af9..86ca2fb126 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_request.h @@ -111,6 +111,6 @@ class SetAppIconRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h index e4ce0725dc..a9b203bec7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_app_icon_response.h @@ -73,6 +73,6 @@ class SetAppIconResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_APP_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h index 4bd800988c..2f9c0946d3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_request.h @@ -80,6 +80,6 @@ class SetDisplayLayoutRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h index 73f57fc187..7b43613ac4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_display_layout_response.h @@ -74,6 +74,6 @@ class SetDisplayLayoutResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_DISPLAY_LAYOUT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h index 674de4731a..3a32d1b671 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_request.h @@ -33,9 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ #include <string> +#include "application_manager/application.h" #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" -#include "application_manager/application.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -82,7 +82,76 @@ class SetGlobalPropertiesRequest */ bool Init() FINAL; + /** + * @brief Prepares total result for mobile according to three results: + * ui_properties_result, tts_properties_result, rc_properties_result. + * @param first ResponseInfo as first argument + * @param second ResponseInfo as secondargument + * @param third ResponseInfo as third argument + * @return total result + */ + bool PrepareResultForMobileResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) const; + + /** + * @brief Prepare result code for sending to mobile application + * @param first contains result_code from HMI response and + * interface that returns response + * @param second contains result_code from HMI response and + * interface that returns response. + * * @param third contains result_code from HMI response and + * interface that returns response. + * @return resulting code for sending to mobile application. + */ + mobile_apis::Result::eType PrepareResultCodeForResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third); + + /** + * @brief Resolves if the return code must be + * UNSUPPORTED_RESOURCE + * @param first contains result_code from HMI response and + * interface that returns response + * @param second contains result_code from HMI response and + * interface that returns response. + * * @param third contains result_code from HMI response and + * interface that returns response. + * @return True, if the communication return code must be + * UNSUPPORTED_RESOURCE, otherwise false. + */ + bool IsResultCodeUnsupported( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) const; + private: + /** + * @brief MergeInfos merge 2 infos into one string with info + * @param first_info -contains result_code from HMI response and + * interface that returns response + * @param first_str - info string that should be first in result info + * @param second_info -contains result_code from HMI response and + * interface that returns response + * @param second_str - info string that should be second in result info + * @param third_info - contains result_code from HMI response and + * interface that returns response + * @param third_str - info string that should be third in result info + * @return if first_info is not available and second_str and third_info not + * empty return second if second_info is not available and first_str and + * third_info not empty return first if third_info is not available and + * first_str and second_str not empty return first other cases return result + * MergeInfos for 2 params + */ + std::string MergeInfos(const app_mngr::commands::ResponseInfo& first_info, + const std::string& first_str, + const app_mngr::commands::ResponseInfo& second_info, + const std::string& second_str, + const app_mngr::commands::ResponseInfo& third_info, + const std::string& third_str); + // prepare UI sending data (VrHelps, Menus, Keyboard) to SmartObject static void PrepareUIRequestVRHelpData( const app_mngr::ApplicationSharedPtr app, @@ -101,6 +170,9 @@ class SetGlobalPropertiesRequest // Send UI request to HMI void SendUIRequest(const smart_objects::SmartObject& params, bool use_events); + // Send SetGlobalProperties with userLocation parameter + void SendRCRequest(const smart_objects::SmartObject& params, bool use_events); + // VRHelp shall contain sequential positions and start from 1 static bool CheckVrHelpItemsOrder(const smart_objects::SmartObject& vr_help); @@ -140,19 +212,25 @@ class SetGlobalPropertiesRequest bool is_ui_send_; bool is_tts_send_; + bool is_rc_send_; bool is_ui_received_; bool is_tts_received_; + bool is_rc_received_; hmi_apis::Common_Result::eType ui_result_; hmi_apis::Common_Result::eType tts_result_; + hmi_apis::Common_Result::eType rc_result_; std::string ui_response_info_; std::string tts_response_info_; + std::string rc_response_info_; + + bool is_menu_layout_available_ = true; DISALLOW_COPY_AND_ASSIGN(SetGlobalPropertiesRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h index 778dc9b7d7..f8d8117250 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_global_properties_response.h @@ -75,6 +75,6 @@ class SetGlobalPropertiesResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_GLOBAL_PROPERTIES_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h index ef674f1c38..adced13d73 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h @@ -81,6 +81,6 @@ class SetMediaClockRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h index 2fb3f25839..240d1be8d1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h @@ -69,6 +69,6 @@ class SetMediaClockTimerResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_MEDIA_CLOCK_TIMER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_request.h new file mode 100644 index 0000000000..c9691a808f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_request.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_REQUEST_H_ + +#include "application_manager/commands/command_request_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ShowAppMenuRequest command class + **/ +class ShowAppMenuRequest : public app_mngr::commands::CommandRequestImpl { + public: + /** + * @brief ShowAppMenuRequest class constructor + **/ + ShowAppMenuRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ShowAppMenuRequest class destructor + **/ + ~ShowAppMenuRequest() 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 app_mngr::event_engine::Event& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ShowAppMenuRequest); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_response.h new file mode 100644 index 0000000000..1e357e8a11 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_app_menu_response.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_RESPONSE_H_ + +#include "application_manager/commands/command_response_impl.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +/** + * @brief ShowAppMenuResponse command class + **/ +class ShowAppMenuResponse : public app_mngr::commands::CommandResponseImpl { + public: + /** + * @brief ShowAppMenuResponse class constructor + **/ + ShowAppMenuResponse(const app_mngr::commands::MessageSharedPtr& messasge, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ShowAppMenuResponse class destructor + **/ + ~ShowAppMenuResponse() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ShowAppMenuResponse); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_APP_MENU_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h index cadc87cef6..7694070a72 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h @@ -89,6 +89,6 @@ class ShowConstantTBTRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h index 4129a7640e..4b2136ad11 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h @@ -73,6 +73,6 @@ class ShowConstantTBTResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_CONSTANT_TBT_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h index 2277a38f11..26612609a4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_request.h @@ -90,14 +90,39 @@ class ShowRequest : public app_mngr::commands::CommandRequestImpl { int32_t field_index, smart_objects::SmartObject& msg_params); + /** + * @brief Handle the template configuration information from the + * incoming mobile json message format for specified application + * @param app - application for which configuration should be checked + * @return True if template config can be successfully applied otherwise - + * false + */ + bool CheckTemplateConfigurationForApp(application_manager::Application& app); + + /** + * @brief Applies the template configuration which was set up beforehand + * @param result - result code on which template application is dependent + * @param app - application for which configuration should be applied + */ + void ApplyTemplateConfigurationForApp(mobile_apis::Result::eType result, + application_manager::Application& app); + mobile_apis::Result::eType core_result_code_; std::string core_response_info_; + app_mngr::WindowID current_window_id_; + smart_objects::SmartObject template_config_; + bool layout_change_required_; + + // dcs - abbreviation of Day Color Scheme + bool dcs_change_required_; + // ncd - abbreviation of Night Color Scheme + bool ncs_change_required_; DISALLOW_COPY_AND_ASSIGN(ShowRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h index c78820a26e..97843c2148 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/show_response.h @@ -67,6 +67,6 @@ class ShowResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SHOW_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h index f1e06e8d8d..5dbcbb7d41 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_request.h @@ -91,6 +91,6 @@ class SliderRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h index 2a93103632..842e52f595 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/slider_response.h @@ -67,6 +67,6 @@ class SliderResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SLIDER_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h index d6d47bb869..68e35fcd1d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_request.h @@ -93,6 +93,6 @@ class SpeakRequest : public app_mngr::commands::CommandRequestImpl { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h index 30eda07810..02b7baae54 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/speak_response.h @@ -67,6 +67,6 @@ class SpeakResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SPEAK_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h index 011c0aa359..2b9887daad 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h @@ -34,8 +34,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_impl.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -98,6 +98,6 @@ class SubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h index 28e942ec17..b42ccb91e1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_response.h @@ -73,6 +73,6 @@ class SubscribeButtonResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h index 6105f08750..8b88a1c884 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h @@ -80,8 +80,8 @@ class SubscribeWayPointsRequest DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h index cd27e96d25..4039f21f8e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h @@ -71,8 +71,8 @@ class SubscribeWayPointsResponse DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsResponse); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h index c34db34506..eb2398f279 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_request.h @@ -35,8 +35,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_REQUEST_H_ #include <string> -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/event_engine/event.h" #include "smart_objects/smart_object.h" @@ -93,6 +93,6 @@ class SystemRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h index afbd557d12..5c3f69d757 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/system_response.h @@ -72,6 +72,6 @@ class SystemResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SYSTEM_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h index 172f934a15..0bc01f2aaa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h @@ -80,6 +80,6 @@ class UnregisterAppInterfaceRequest } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h index 13d8b549e8..d1ac004ca0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h @@ -76,6 +76,6 @@ class UnregisterAppInterfaceResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNREGISTER_APP_INTERFACE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h index 8cbaafbfe1..51c10642cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h @@ -84,6 +84,6 @@ class UnsubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h index 1db067acce..efd5478363 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h @@ -74,6 +74,6 @@ class UnsubscribeButtonResponse }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h index fe14f5c7eb..e83e9b7509 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h @@ -79,8 +79,8 @@ class UnsubscribeWayPointsRequest DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsRequest); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h index c578bf9f99..9ab167284a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h @@ -71,8 +71,8 @@ class UnsubscribeWayPointsResponse DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsResponse); }; -} // commands +} // namespace commands -} // application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_WAY_POINTS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h index 8766339f96..e1e5df2289 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_request.h @@ -97,6 +97,6 @@ class UpdateTurnListRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h index 59d3bf0b2c..80e143644f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/update_turn_list_response.h @@ -73,6 +73,6 @@ class UpdateTurnListResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UPDATE_TURN_LIST_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h index fb82cf37c2..935716aa30 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/extensions/system_capability_app_extension.h @@ -78,6 +78,6 @@ class SystemCapabilityAppExtension : public app_mngr_::AppExtension { SDLRPCPlugin& plugin_; app_mngr_::Application& app_; }; -} +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_EXTENSIONS_SYSTEM_CAPABILITY_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h index eee454fb00..95bb253120 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ -#include "application_manager/command_factory.h" #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -70,6 +70,6 @@ class HMICommandFactory : public app_mngr::CommandFactory { DISALLOW_COPY_AND_ASSIGN(HMICommandFactory); }; -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_HMI_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h index 44a4475b62..132b68aaec 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/mobile_command_factory.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ -#include "application_manager/command_factory.h" #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -77,6 +77,6 @@ class MobileCommandFactory : public app_mngr::CommandFactory { DISALLOW_COPY_AND_ASSIGN(MobileCommandFactory); }; -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_MOBILE_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h index 5b5f0ae49f..edbfe1bdc0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_command_factory.h @@ -36,11 +36,11 @@ #include <memory> #include "application_manager/application_manager.h" #include "application_manager/command_factory.h" -#include "sdl_rpc_plugin/hmi_command_factory.h" -#include "sdl_rpc_plugin/mobile_command_factory.h" -#include "application_manager/rpc_service.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" +#include "sdl_rpc_plugin/hmi_command_factory.h" +#include "sdl_rpc_plugin/mobile_command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -69,5 +69,5 @@ class SDLCommandFactory : public app_mngr::CommandFactory { std::unique_ptr<HMICommandFactory> hmi_command_factory_; std::unique_ptr<MobileCommandFactory> mobile_command_factory_; }; -} +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h index b57fcbec12..91298f4883 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/sdl_rpc_plugin.h @@ -32,8 +32,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H -#include "application_manager/plugin_manager/rpc_plugin.h" #include "application_manager/command_factory.h" +#include "application_manager/plugin_manager/rpc_plugin.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -47,7 +47,8 @@ class SDLRPCPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, @@ -64,8 +65,8 @@ class SDLRPCPlugin : public plugins::RPCPlugin { std::unique_ptr<application_manager::CommandFactory> command_factory_; }; -} +} // namespace sdl_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); - +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_SDL_RPC_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc index 19d01b594f..c6d181bf57 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_request.cc @@ -75,4 +75,4 @@ void ActivateAppRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc index d7e38c5d5b..b829ef711e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/activate_app_response.cc @@ -63,4 +63,4 @@ void ActivateAppResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc index 3e46bd353a..93999f704d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/add_statistics_info_notification.cc @@ -64,4 +64,4 @@ void AddStatisticsInfoNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc index b227dd79dc..68c7896a7f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_request.cc @@ -59,4 +59,4 @@ void AllowAllAppsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc index 2fdf29a7dd..c2182f4853 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_all_apps_response.cc @@ -59,4 +59,4 @@ void AllowAllAppsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc index 0c6e5145c7..6b5af76fb1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_request.cc @@ -59,4 +59,4 @@ void AllowAppRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc index 4853c3764a..c62645c6c0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/allow_app_response.cc @@ -70,4 +70,4 @@ void AllowAppResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_request.cc new file mode 100644 index 0000000000..b021faefd8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_request.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BasicCommunicationCloseApplicationRequest:: + BasicCommunicationCloseApplicationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +BasicCommunicationCloseApplicationRequest:: + ~BasicCommunicationCloseApplicationRequest() {} + +void BasicCommunicationCloseApplicationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendRequest(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_response.cc new file mode 100644 index 0000000000..2e56271cf2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_close_application_response.cc @@ -0,0 +1,65 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +BasicCommunicationCloseApplicationResponse:: + BasicCommunicationCloseApplicationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +BasicCommunicationCloseApplicationResponse:: + ~BasicCommunicationCloseApplicationResponse() {} + +void BasicCommunicationCloseApplicationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_CloseApplication); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc index fb87612e19..19c9fa91d8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_request.cc @@ -51,7 +51,7 @@ BasicCommunicationGetSystemTimeRequest::BasicCommunicationGetSystemTimeRequest( void BasicCommunicationGetSystemTimeRequest::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); - application_manager_.protocol_handler().NotifyOnFailedHandshake(); + application_manager_.protocol_handler().NotifyOnGetSystemTimeFailed(); } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc index c067debf36..e26753b3f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_get_system_time_response.cc @@ -62,4 +62,4 @@ void BasicCommunicationGetSystemTimeResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc index 0c39389116..361dc5fea6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -79,4 +79,4 @@ void OnAwakeSDLNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc index 04e44a6979..052a40a888 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_request.cc @@ -58,4 +58,4 @@ void BasicCommunicationSystemRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc index 5f8221fdbe..0b052de88d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/basic_communication_system_response.cc @@ -63,4 +63,4 @@ void BasicCommunicationSystemResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc index b86ab6a2b8..58cda68a2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_get_file_path_response.cc @@ -32,9 +32,9 @@ #include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h" #include "application_manager/application_impl.h" +#include "application_manager/event_engine/event.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/event_engine/event.h" namespace sdl_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc index cf2fbd9761..6696689174 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_request.cc @@ -60,4 +60,4 @@ void ButtonGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc index 628eaa2e58..b6ab822c47 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc @@ -78,4 +78,4 @@ void ButtonGetCapabilitiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc index 84a47b9deb..988794f668 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_request.cc @@ -58,4 +58,4 @@ void ClosePopupRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc index 25396af337..072e1960e9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/close_popup_response.cc @@ -58,4 +58,4 @@ void ClosePopupResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc index 0e09c14650..71782ef575 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_request.cc @@ -59,4 +59,4 @@ void DecryptCertificateRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc index 694298ed91..cf2a4d092c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/decrypt_certificate_response.cc @@ -64,5 +64,5 @@ void DecryptCertificateResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc index 63f5c2e815..97b5109642 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_request.cc @@ -61,4 +61,4 @@ void DialNumberRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc index 6d37ece2bf..4ff6785052 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/dial_number_response.cc @@ -63,4 +63,4 @@ void DialNumberResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc index c06c90973d..8546252119 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_request.cc @@ -61,4 +61,4 @@ void GetSystemInfoRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc index aef428b39f..baff925a4e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc @@ -31,6 +31,7 @@ */ #include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -90,4 +91,4 @@ const SystemInfo GetSystemInfoResponse::GetSystemInfo( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc deleted file mode 100644 index ae375e4087..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls.cc +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2018, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sdl_rpc_plugin/commands/hmi/get_urls.h" -#include "application_manager/message.h" -#include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" -#include "application_manager/policies/policy_handler.h" -#include "utils/helpers.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; -namespace commands { - -GetUrls::GetUrls(const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) - : RequestFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} - -GetUrls::~GetUrls() {} - -void GetUrls::Run() { - LOG4CXX_AUTO_TRACE(logger_); - namespace Common_Result = hmi_apis::Common_Result; - using policy::EndpointUrls; - - if (!policy_handler_.PolicyEnabled()) { - SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); - return; - } - - const uint32_t service_to_check = - (*message_)[strings::msg_params][hmi_request::service].asUInt(); - - EndpointUrls endpoints; - policy_handler_.GetUpdateUrls(service_to_check, endpoints); - - if (endpoints.empty()) { - LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check); - SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); - return; - } - -#ifdef PROPRIETARY_MODE - const uint32_t policy_service = 7u; - - if (policy_service == service_to_check) { - ProcessPolicyServiceURLs(endpoints); - return; - } -#endif // PROPRIETARY_MODE - - ProcessServiceURLs(endpoints); -} - -void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { - namespace Common_Result = hmi_apis::Common_Result; - using smart_objects::SmartObject; - - (*message_)[strings::msg_params].erase(hmi_request::service); - SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls]; - - size_t index = 0; - for (size_t e = 0; e < endpoints.size(); ++e) { - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(endpoints[e].app_id); - -#ifndef PROPRIETARY_MODE - bool registered_not_default = false; - if (policy::kDefaultId != endpoints[e].app_id) { - if (!app) { - LOG4CXX_ERROR(logger_, - "Can't find application with policy id " - << endpoints[e].app_id - << " URLs adding for this application is skipped."); - continue; - } - registered_not_default = true; - } -#endif // EXTERNAL_PROPRIETARY_MODE || HTTP - for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { - const std::string& app_url = endpoints[e].url[u]; - SmartObject& service_info = urls[index]; - - service_info[strings::url] = app_url; -#ifndef PROPRIETARY_MODE - if (registered_not_default) { - service_info[strings::app_id] = app->hmi_app_id(); - } -#else // EXTERNAL_PROPRIETARY_MODE || HTTP - service_info[hmi_response::policy_app_id] = endpoints[e].app_id; -#endif - } - } - SendResponseToHMI(Common_Result::SUCCESS); -} - -void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { - (*message_)[strings::params][strings::message_type] = MessageType::kResponse; - (*message_)[strings::params][hmi_response::code] = result; - rpc_service_.ManageHMICommand(message_); -} - -#ifdef PROPRIETARY_MODE -struct PolicyAppIdComparator { - PolicyAppIdComparator(const std::string& policy_app_id) - : policy_app_id_(policy_app_id) {} - - bool operator()(const policy::EndpointData& data) { - return data.app_id == policy_app_id_; - } - std::string policy_app_id_; -}; - -void FillSODefaultUrls(smart_objects::SmartObject& urls, - const policy::EndpointUrls& endpoints) { - using smart_objects::SmartObject; - PolicyAppIdComparator comparator(policy::kDefaultId); - policy::EndpointUrls::const_iterator it = - std::find_if(endpoints.begin(), endpoints.end(), comparator); - if (it == endpoints.end()) { - return; - } - SmartObject service_info = SmartObject(smart_objects::SmartType_Map); - for (size_t i = 0; i < (*it).url.size(); ++i) { - service_info[strings::url] = (*it).url[i]; - urls[i] = service_info; - } -} - -void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { - LOG4CXX_AUTO_TRACE(logger_); - using namespace smart_objects; - using namespace application_manager; - using namespace strings; - using namespace hmi_apis; - - const uint32_t app_id_to_send_to = policy_handler_.GetAppIdForSending(); - - if (!app_id_to_send_to) { - LOG4CXX_ERROR(logger_, - "There are no available applications for processing."); - SmartObject urls(SmartType_Array); - FillSODefaultUrls(urls, endpoints); - if (!urls.empty()) { - (*message_)[msg_params][hmi_response::urls] = urls; - } - (*message_).erase(hmi_request::service); - SendResponseToHMI(Common_Result::SUCCESS); - return; - } - - ApplicationSharedPtr app = - application_manager_.application(app_id_to_send_to); - - if (app.use_count() == 0) { - LOG4CXX_WARN(logger_, - "There is no registered application with " - "connection key '" - << app_id_to_send_to << "'"); - SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); - return; - } - - SmartObject& object = *message_; - object[msg_params].erase(hmi_request::service); - object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array); - SmartObject& urls = object[msg_params][hmi_response::urls]; - const std::string mobile_app_id = app->policy_app_id(); - - size_t index = 0; - for (size_t i = 0; i < endpoints.size(); ++i) { - using namespace helpers; - - const bool to_add = Compare<std::string, EQ, ONE>( - endpoints[i].app_id, mobile_app_id, policy::kDefaultId); - const bool is_default = policy::kDefaultId == endpoints[i].app_id; - - if (to_add) { - for (size_t k = 0; k < endpoints[i].url.size(); ++k) { - if (!is_default) { - urls[index][strings::app_id] = app_id_to_send_to; - } - urls[index][strings::url] = endpoints[i].url[k]; - ++index; - } - } - } - SendResponseToHMI(Common_Result::SUCCESS); - return; -} -#endif // PROPRIETARY_MODE - -} // namespace commands -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc index 39f7e61c06..b8c61ca902 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_request.cc @@ -59,4 +59,4 @@ void MixingAudioSupportedRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc index 26fa967844..089e56e598 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/mixing_audio_supported_response.cc @@ -60,4 +60,4 @@ void MixingAudioSupportedResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc index ae3695b68e..8390fea5bc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_request.cc @@ -59,4 +59,4 @@ void NaviAlertManeuverRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc index 6a6307038a..a1603f069d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_alert_maneuver_response.cc @@ -63,4 +63,4 @@ void NaviAlertManeuverResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc index a9698d36ab..371f47a759 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc @@ -79,8 +79,8 @@ void AudioStartStreamRequest::Run() { application_manager_.application_by_hmi_app(application_id()); if (!app) { LOG4CXX_ERROR(logger_, - "Applcation with hmi_app_id " << application_id() - << " does not exist"); + "Application with hmi_app_id " << application_id() + << " does not exist"); return; } SetAllowedToTerminate(false); @@ -189,4 +189,4 @@ void AudioStartStreamRequest::RetryStartSession() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc index 362a46cc19..61d49577f6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_response.cc @@ -60,4 +60,4 @@ void AudioStartStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc index ba2b8c8157..a5d436f015 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_request.cc @@ -62,4 +62,4 @@ void AudioStopStreamRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc index 87ddc81696..98023ab571 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_stop_stream_response.cc @@ -56,4 +56,4 @@ void AudioStopStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc index 77ef3e3369..edc4afe1e4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_request.cc @@ -59,4 +59,4 @@ void NaviGetWayPointsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc index 0aad5e5724..0f0b652d01 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_get_way_points_response.cc @@ -63,4 +63,4 @@ void NaviGetWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc index 781b8d3045..15e5b46b36 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_request.cc @@ -84,4 +84,4 @@ void NaviIsReadyRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc index b4e64e2a3e..073513eda9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_is_ready_response.cc @@ -58,4 +58,4 @@ void NaviIsReadyResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc index a10f61310d..360870e21c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_request.cc @@ -59,4 +59,4 @@ void NaviSendLocationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc index f93e2e17c3..dc60f2fbf0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_send_location_response.cc @@ -61,4 +61,4 @@ void NaviSendLocationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc index 5e4426bd20..764315f37f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_request.cc @@ -65,9 +65,9 @@ void NaviSetVideoConfigRequest::Run() { 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"); + LOG4CXX_ERROR( + logger_, + "Application with hmi_app_id " << application_id() << "does not exist"); return; } @@ -100,9 +100,9 @@ void NaviSetVideoConfigRequest::on_event(const event_engine::Event& event) { LOG4CXX_DEBUG(logger_, "Received SetVideoConfig success response"); result = true; } else { - LOG4CXX_DEBUG(logger_, - "Received SetVideoConfig failure response (" << event.id() - << ")"); + 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 = @@ -153,4 +153,4 @@ void NaviSetVideoConfigRequest::onTimeOut() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc index c5f1c5307f..e4a30c9da5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_set_video_config_response.cc @@ -61,4 +61,4 @@ void NaviSetVideoConfigResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc index 22d604ab0d..95dd4561fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_request.cc @@ -59,4 +59,4 @@ void NaviShowConstantTBTRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc index d2ff26b645..f73099d29a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_show_constant_tbt_response.cc @@ -63,4 +63,4 @@ void NaviShowConstantTBTResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc index f3d971acba..90f7c2d0f1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc @@ -64,8 +64,9 @@ NaviStartStreamRequest::NaviStartStreamRequest( } NaviStartStreamRequest::~NaviStartStreamRequest() { - // unsubscribe_from_all_events() in EventObserver's destructor isn't enough; - // we must unsubscribe before this NaviStartStreamRequest instance is removed + // unsubscribe_from_all_hmi_events() in EventObserver's destructor isn't + // enough; we must unsubscribe before this NaviStartStreamRequest instance is + // removed unsubscribe_from_event(hmi_apis::FunctionID::Navigation_StartStream); } @@ -79,9 +80,9 @@ void NaviStartStreamRequest::Run() { ApplicationSharedPtr app = application_manager_.application_by_hmi_app(application_id()); if (!app) { - LOG4CXX_ERROR(logger_, - "Applcation with hmi_app_id " << application_id() - << "does not exist"); + LOG4CXX_ERROR( + logger_, + "Application with hmi_app_id " << application_id() << "does not exist"); return; } SetAllowedToTerminate(false); @@ -190,4 +191,4 @@ void NaviStartStreamRequest::RetryStartSession() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc index f09a334f51..eafd81148a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_response.cc @@ -60,4 +60,4 @@ void NaviStartStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc index 3e27692d62..ad09b0aee1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_request.cc @@ -62,4 +62,4 @@ void NaviStopStreamRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc index 61b8d5a1e2..ff8c0bddff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_stop_stream_response.cc @@ -56,4 +56,4 @@ void NaviStopStreamResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc index a4445ebce8..ba29f552b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_request.cc @@ -59,4 +59,4 @@ void NaviSubscribeWayPointsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc index ae5f236f6f..ddf8f75e58 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_subscribe_way_points_response.cc @@ -64,4 +64,4 @@ void NaviSubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc index ec22c93d8f..d3c998cfdf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc @@ -59,4 +59,4 @@ void NaviUnsubscribeWayPointsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc index c084bd52d3..beed29e1e2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_response.cc @@ -32,8 +32,8 @@ #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h" #include "application_manager/event_engine/event.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -65,4 +65,4 @@ void NaviUnsubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc index 9c507c3637..a8a258b1c0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_request.cc @@ -59,4 +59,4 @@ void NaviUpdateTurnListRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc index eb232e6d01..a2f737df38 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_update_turn_list_response.cc @@ -63,4 +63,4 @@ void NaviUpdateTurnListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc index 398c2dac30..204cc7d347 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_allow_sdl_functionality_notification.cc @@ -66,4 +66,4 @@ void OnAllowSDLFunctionalityNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc index 189596c58a..e882020f8b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_activated_notification.cc @@ -64,4 +64,4 @@ void OnAppActivatedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc index ee45f9bf1e..18b796eaa8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_deactivated_notification.cc @@ -66,4 +66,4 @@ void OnAppDeactivatedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc index e13299ece7..a1eb412c66 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_changed_notification.cc @@ -58,4 +58,4 @@ void OnAppPermissionChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc index cf83c48a5a..0033b392d2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc @@ -32,12 +32,12 @@ */ #include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "application_manager/application_manager.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/message_helper.h" #include <algorithm> #include <functional> #include <string> +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "policy/policy_types.h" #include "smart_objects/smart_object.h" @@ -178,5 +178,5 @@ void OnAppPermissionConsentNotification::Run() { policy_handler_.OnAppPermissionConsent(connection_key, permission_consent); #endif } -} // commands -} // namespace application_manager +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc index 24c5a94272..51c3125921 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_registered_notification.cc @@ -64,4 +64,4 @@ void OnAppRegisteredNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc index 001b9fa5e0..07aadada81 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_unregistered_notification.cc @@ -73,4 +73,4 @@ void OnAppUnregisteredNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc index e2cd6d2cbf..d9c1120409 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_audio_data_streaming_notification.cc @@ -58,4 +58,4 @@ void OnAudioDataStreamingNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc index 0677c97db8..1a104c0fa1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification.cc @@ -69,7 +69,8 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { hmi_apis::Common_SystemCapabilityType::eType system_capability_type = static_cast<hmi_apis::Common_SystemCapabilityType::eType>( msg_params[strings::system_capability] - [strings::system_capability_type].asInt()); + [strings::system_capability_type] + .asInt()); switch (system_capability_type) { case hmi_apis::Common_SystemCapabilityType::NAVIGATION: { smart_objects::SmartObject nav_capability(smart_objects::SmartType_Map); @@ -134,21 +135,24 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { for (size_t i = 0; i < updated_capabilities.length(); i++) { std::string service_id = updated_capabilities[i][strings::updated_app_service_record] - [strings::service_id].asString(); - auto matching_service_predicate = [&service_id]( - const smart_objects::SmartObject& app_service_capability) { - return service_id == - app_service_capability[strings::updated_app_service_record] - [strings::service_id].asString(); - }; + [strings::service_id] + .asString(); + auto matching_service_predicate = + [&service_id]( + const smart_objects::SmartObject& app_service_capability) { + return service_id == + app_service_capability[strings::updated_app_service_record] + [strings::service_id] + .asString(); + }; auto it = std::find_if(app_services->begin(), app_services->end(), matching_service_predicate); if (it != app_services->end()) { - LOG4CXX_DEBUG(logger_, - "Replacing updated record with service_id " - << service_id); + LOG4CXX_DEBUG( + logger_, + "Replacing updated record with service_id " << service_id); app_services->erase(it); } app_services->push_back(updated_capabilities[i]); @@ -157,6 +161,15 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { [strings::app_services_capabilities] = app_service_caps; break; } + case mobile_apis::SystemCapabilityType::DISPLAYS: { + if (!hmi_capabilities_.system_display_capabilities()) { + LOG4CXX_INFO(logger_, "system_display_capabilities are not available"); + return; + } + msg_params[strings::system_capability][strings::display_capabilities] = + *hmi_capabilities_.system_display_capabilities(); + break; + } default: return; } @@ -164,4 +177,4 @@ void OnBCSystemCapabilityUpdatedNotification::Run() { } } // namespace commands -} // namespace app_service_rpc_plugin +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.cc new file mode 100644 index 0000000000..f32aef1102 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.cc @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h" + +#include "application_manager/display_capabilities_builder.h" +#include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +OnBCSystemCapabilityUpdatedNotificationFromHMI:: + OnBCSystemCapabilityUpdatedNotificationFromHMI( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ~OnBCSystemCapabilityUpdatedNotificationFromHMI() {} + +OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ProcessSystemDisplayCapabilitiesResult + OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ProcessSystemDisplayCapabilities( + const smart_objects::SmartObject& display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + + if (!(*message_)[strings::msg_params].keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, "Updating general display capabilities"); + hmi_capabilities_.set_system_display_capabilities(display_capabilities); + return ProcessSystemDisplayCapabilitiesResult::SUCCESS; + } + + const auto app_id = + (*message_)[strings::msg_params][strings::app_id].asUInt(); + auto app = application_manager_.application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, + "Application with app_id " << app_id << " is not registered"); + return ProcessSystemDisplayCapabilitiesResult::FAIL; + } + + LOG4CXX_DEBUG(logger_, "Updating display capabilities for app " << app_id); + app->set_display_capabilities(display_capabilities); + + // Remove app_id from notification to mobile + (*message_)[strings::params][strings::connection_key] = + (*message_)[strings::msg_params][strings::app_id]; + (*message_)[strings::msg_params].erase(strings::app_id); + if (app->is_resuming() && app->is_app_data_resumption_allowed()) { + LOG4CXX_DEBUG(logger_, "Application is resuming"); + app->display_capabilities_builder().UpdateDisplayCapabilities( + display_capabilities); + return ProcessSystemDisplayCapabilitiesResult::CAPABILITIES_CACHED; + } + + return ProcessSystemDisplayCapabilitiesResult::SUCCESS; +} + +void OnBCSystemCapabilityUpdatedNotificationFromHMI::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + // Prepare SmartObject for mobile factory + (*message_)[strings::params][strings::function_id] = static_cast<int32_t>( + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID); + + const auto& system_capability = + (*message_)[strings::msg_params][strings::system_capability]; + + switch (system_capability[strings::system_capability_type].asInt()) { + case mobile_apis::SystemCapabilityType::DISPLAYS: { + if (system_capability.keyExists(strings::display_capabilities)) { + const auto result = ProcessSystemDisplayCapabilities( + system_capability[strings::display_capabilities]); + if (ProcessSystemDisplayCapabilitiesResult::FAIL == result) { + LOG4CXX_ERROR( + logger_, + "Failed to process display capabilities. Notification will " + "be ignored"); + return; + } else if (ProcessSystemDisplayCapabilitiesResult:: + CAPABILITIES_CACHED == result) { + LOG4CXX_TRACE(logger_, + "Capabilities are being cached for resuming app"); + return; + } + } + break; + } + case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: { + if (system_capability.keyExists(strings::rc_capability)) { + LOG4CXX_DEBUG(logger_, "Updating RC Capabilities"); + hmi_capabilities_.set_rc_capability( + system_capability[strings::rc_capability]); + } + break; + } + } + + SendNotificationToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc index 1f052b865b..f25e6202cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_event_notification.cc @@ -67,4 +67,4 @@ void OnButtonEventNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc index 6c5d8f5a43..fee6b1b485 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_press_notification.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "application_manager/application_impl.h" -#include "utils/logger.h" #include "application_manager/event_engine/event.h" +#include "utils/logger.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -69,4 +69,4 @@ void OnButtonPressNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc index 70ff1c3fad..4ac752d6c5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_button_subscription_notification.cc @@ -63,4 +63,4 @@ void OnButtonSubscriptionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc index 2c4f9a1ccc..f27c1fe5e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_chosen_notification.cc @@ -63,4 +63,4 @@ void OnDeviceChosenNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc index 307dccd09b..129ba8c9ba 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_device_state_changed_notification.cc @@ -30,12 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <algorithm> #include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include <algorithm> #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" -#include "interfaces/HMI_API.h" +#include "application_manager/policies/policy_handler_interface.h" #include "encryption/hashing.h" +#include "interfaces/HMI_API.h" namespace { // TODO(AOleynik) : replace this !!! @@ -72,7 +73,7 @@ std::string convert_to_bt_mac(std::string& deviceInternalId) { return bt_mac; } -} +} // namespace namespace sdl_rpc_plugin { using namespace application_manager; @@ -121,4 +122,4 @@ void OnDeviceStateChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc index a5fb9b206e..a743c58672 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc @@ -30,13 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <set> #include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include <set> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,12 +60,39 @@ struct OnDriverDistractionProcessor { void operator()(ApplicationSharedPtr application) { if (application) { - (*on_driver_distraction_so_)[strings::params][strings::connection_key] = - application->app_id(); + // Create modifiable copy of base message + smart_objects::SmartObject message = *on_driver_distraction_so_; + message[strings::params][strings::connection_key] = application->app_id(); const RPCParams params; policy::CheckPermissionResult result; application_manager_.GetPolicyHandler().CheckPermissions( - application, stringified_function_id_, params, result); + application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + stringified_function_id_, + params, + result); + auto& msg_params = message[strings::msg_params]; + const bool is_lock_screen_dismissal_exists = msg_params.keyExists( + mobile_notification::lock_screen_dismissal_enabled); + + if (is_lock_screen_dismissal_exists && + msg_params[mobile_notification::lock_screen_dismissal_enabled] + .asBool()) { + const auto language = + MessageHelper::MobileLanguageToString(application->ui_language()); + + const auto warning_message = + application_manager_.GetPolicyHandler() + .LockScreenDismissalWarningMessage(language); + // Only allow lock screen dismissal if a warning message is available + if (warning_message && !warning_message->empty()) { + msg_params[mobile_notification::lock_screen_dismissal_warning] = + *warning_message; + } else { + msg_params[mobile_notification::lock_screen_dismissal_enabled] = + false; + } + } if (result.hmi_level_permitted != policy::kRpcAllowed) { MobileMessageQueue messages; application->SwapMobileMessageQueue(messages); @@ -72,15 +100,19 @@ struct OnDriverDistractionProcessor { std::remove_if( messages.begin(), messages.end(), - [this](smart_objects::SmartObjectSPtr message) { + [](smart_objects::SmartObjectSPtr message) { return (*message)[strings::params][strings::function_id] - .asString() == stringified_function_id_; + .asUInt() == + mobile_api::FunctionID::OnDriverDistractionID; }), messages.end()); - application->PushMobileMessage(on_driver_distraction_so_); + application->SwapMobileMessageQueue(messages); + application->PushMobileMessage( + std::make_shared<smart_objects::SmartObject>(message)); return; } - command_.SendNotificationToMobile(on_driver_distraction_so_); + command_.SendNotificationToMobile( + std::make_shared<smart_objects::SmartObject>(message)); } } @@ -90,7 +122,7 @@ struct OnDriverDistractionProcessor { ApplicationManager& application_manager_; std::string stringified_function_id_; }; -} +} // namespace OnDriverDistractionNotification::OnDriverDistractionNotification( const application_manager::commands::MessageSharedPtr& message, @@ -108,14 +140,12 @@ OnDriverDistractionNotification::~OnDriverDistractionNotification() {} void OnDriverDistractionNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - const hmi_apis::Common_DriverDistractionState::eType state = + const auto state = static_cast<hmi_apis::Common_DriverDistractionState::eType>( (*message_)[strings::msg_params][hmi_notification::state].asInt()); application_manager_.set_driver_distraction_state(state); - smart_objects::SmartObjectSPtr on_driver_distraction = - std::make_shared<smart_objects::SmartObject>(); - + auto on_driver_distraction = std::make_shared<smart_objects::SmartObject>(); if (!on_driver_distraction) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; @@ -127,6 +157,17 @@ void OnDriverDistractionNotification::Run() { (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = state; + const auto lock_screen_dismissal = + application_manager_.GetPolicyHandler().LockScreenDismissalEnabledState(); + + if (lock_screen_dismissal && + hmi_apis::Common_DriverDistractionState::DD_ON == state) { + (*on_driver_distraction) + [strings::msg_params] + [mobile_notification::lock_screen_dismissal_enabled] = + *lock_screen_dismissal; + } + const ApplicationSet applications = application_manager_.applications().GetData(); @@ -139,4 +180,4 @@ void OnDriverDistractionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc index cd3f2c23e6..f6ea22ae34 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_event_changed_notification.cc @@ -61,4 +61,4 @@ void OnEventChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc index 9d250d288e..4c168f9eff 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_all_applications_notification.cc @@ -32,13 +32,13 @@ #include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" +#include <signal.h> #include <sys/types.h> #include <unistd.h> -#include <signal.h> #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -122,4 +122,4 @@ void OnExitAllApplicationsNotification::SendOnSDLPersistenceComplete() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc index 6658f41005..3eec6c5d1a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_exit_application_notification.cc @@ -33,11 +33,11 @@ #include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" #include "application_manager/application_impl.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/state_controller.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -119,14 +119,9 @@ void OnExitApplicationNotification::Run() { } } - application_manager_.state_controller().SetRegularState( - app_impl, - HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - VideoStreamingState::NOT_STREAMABLE, - false); + application_manager_.state_controller().ExitDefaultWindow(app_impl); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc index ec680c667d..e1f0e2b104 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_file_removed_notification.cc @@ -59,4 +59,4 @@ void OnFileRemovedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc index c74dd70c84..2e8f15387f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_find_applications.cc @@ -59,4 +59,4 @@ void OnFindApplications::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc index 9ff1851e3f..1e8da19c0a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ignition_cycle_over_notification.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,4 +60,4 @@ void OnIgnitionCycleOverNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc index 20f20ece08..f611b81764 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_tbt_client_state_notification.cc @@ -64,4 +64,4 @@ void OnNaviTBTClientStateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc index fa8819ca5b..2a1a9c29fb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc @@ -60,4 +60,4 @@ void OnNaviWayPointChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc index e069bea740..a0e75371b5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_policy_update.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -57,4 +58,4 @@ void OnPolicyUpdate::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc index 1524aa9ea2..441e36a385 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_put_file_notification.cc @@ -59,4 +59,4 @@ void OnPutFileNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc index 76c9115662..da3612b043 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ready_notification.cc @@ -62,4 +62,4 @@ void OnReadyNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc index 1eaef0b5e1..b2c9151b40 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_received_policy_update.cc @@ -30,9 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include <string> #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" #include "utils/file_system.h" namespace sdl_rpc_plugin { @@ -74,4 +75,4 @@ void OnReceivedPolicyUpdate::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc index 60699e5b9c..dbef717539 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_record_start_notification.cc @@ -59,4 +59,4 @@ void OnRecordStartdNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc index 9f8a713ffe..11d549655e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_resume_audio_source_notification.cc @@ -59,4 +59,4 @@ void OnResumeAudioSourceNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc index 65879edce6..d0c584c66c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_close_notification.cc @@ -59,4 +59,4 @@ void OnSDLCloseNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc index cf8feb4ca1..314a9e8f71 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_consent_needed_notification.cc @@ -59,4 +59,4 @@ void OnSDLConsentNeededNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc index 0ac4afd4d2..5db38d070b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_sdl_persistence_complete_notification.cc @@ -58,4 +58,4 @@ void OnSDLPersistenceCompleteNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_service_update_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_service_update_notification.cc new file mode 100644 index 0000000000..de03b75214 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_service_update_notification.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/on_service_update_notification.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +OnServiceUpdateNotification::OnServiceUpdateNotification( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnServiceUpdateNotification::~OnServiceUpdateNotification() {} + +void OnServiceUpdateNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + SendNotification(); +} + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc index 2cee7926bd..035def10e0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_start_device_discovery.cc @@ -59,4 +59,4 @@ void OnStartDeviceDiscovery::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc index 4cb01e7e90..5ee2ede198 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_status_update_notification.cc @@ -58,4 +58,4 @@ void OnStatusUpdateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc index 242fb1d8cd..bf52492ae1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_context_notification.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" #include "application_manager/application_impl.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/state_controller.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,13 +62,27 @@ void OnSystemContextNotification::Run() { (*message_)[strings::msg_params][hmi_notification::system_context] .asInt()); + WindowID window_id = mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + window_id = (*message_)[strings::msg_params][strings::window_id].asInt(); + } + ApplicationSharedPtr app; - if ((mobile_api::SystemContext::SYSCTXT_VRSESSION == system_context) || - (mobile_api::SystemContext::SYSCTXT_MENU == system_context) || - (mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED == system_context)) { + if (helpers:: + Compare<mobile_api::SystemContext::eType, helpers::EQ, helpers::ONE>( + system_context, + mobile_api::SystemContext::SYSCTXT_VRSESSION, + mobile_api::SystemContext::SYSCTXT_MENU, + mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED)) { app = application_manager_.active_application(); - } else if ((mobile_api::SystemContext::SYSCTXT_ALERT == system_context) || - (mobile_api::SystemContext::SYSCTXT_MAIN == system_context)) { + } + + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id || + helpers::Compare<mobile_api::SystemContext::eType, + helpers::EQ, + helpers::ONE>(system_context, + mobile_api::SystemContext::SYSCTXT_ALERT, + mobile_api::SystemContext::SYSCTXT_MAIN)) { if ((*message_)[strings::msg_params].keyExists(strings::app_id)) { app = application_manager_.application( (*message_)[strings::msg_params][strings::app_id].asUInt()); @@ -76,8 +90,8 @@ void OnSystemContextNotification::Run() { } if (app && mobile_api::SystemContext::INVALID_ENUM != system_context) { - application_manager_.state_controller().SetRegularState(app, - system_context); + application_manager_.state_controller().SetRegularState( + app, window_id, system_context); } else { LOG4CXX_ERROR(logger_, "Application does not exist"); } @@ -85,4 +99,4 @@ void OnSystemContextNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc index 5591d59355..9b8523e882 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_error_notification.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -64,4 +65,4 @@ void OnSystemErrorNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc index 11b2471294..171c144055 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_info_changed_notification.cc @@ -33,6 +33,7 @@ #include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -66,4 +67,4 @@ void OnSystemInfoChangedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc index d795896764..6d95febe71 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc @@ -32,11 +32,15 @@ #include "application_manager/application_impl.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" #include "application_manager/policies/policy_handler_interface.h" #include "interfaces/MOBILE_API.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" #include "utils/macro.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +#include "policy/ptu_retry_handler.h" +#endif // EXTERNAL_PROPRIETARY_MODE + using policy::PolicyHandlerInterface; namespace sdl_rpc_plugin { @@ -116,9 +120,20 @@ void OnSystemRequestNotification::Run() { "Sending request with application id " << app->policy_app_id()); params[strings::connection_key] = app->app_id(); + +#ifdef EXTERNAL_PROPRIETARY_MODE + using namespace rpc::policy_table_interface_base; + const auto request_type = + static_cast<rpc::policy_table_interface_base::RequestType>( + (*message_)[strings::msg_params][strings::request_type].asUInt()); + + if (RequestType::RT_PROPRIETARY == request_type) { + policy_handler_.ptu_retry_handler().OnSystemRequestReceived(); + } +#endif SendNotificationToMobile(message_); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc index b5fd1a007e..b068835545 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_time_ready_notification.cc @@ -59,4 +59,4 @@ void OnSystemTimeReadyNotification::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc index 5b5cfeefb1..f89baad737 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_language_change_notification.cc @@ -100,4 +100,4 @@ void OnTTSLanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc index 701dbe0538..8b60762b31 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_reset_timeout_notification.cc @@ -66,4 +66,4 @@ void OnTTSResetTimeoutNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc index 34ba82df1d..2d215b2ec9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_started_notification.cc @@ -60,4 +60,4 @@ void OnTTSStartedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc index 0935a36848..6910b188f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_tts_stopped_notification.cc @@ -63,4 +63,4 @@ void OnTTSStoppedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc index 21cf0d9628..6cc9f85d6f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_command_notification.cc @@ -65,4 +65,4 @@ void OnUICommandNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc index fbdd4fce2b..f069e4ed65 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_keyboard_input_notification.cc @@ -67,4 +67,4 @@ void OnUIKeyBoardInputNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc index 3bf5a5aed4..697b2036c4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_language_change_notification.cc @@ -99,4 +99,4 @@ void OnUILanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc index 953932cdb6..bd1e1b8ea7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_reset_timeout_notification.cc @@ -67,4 +67,4 @@ void OnUIResetTimeoutNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc index e5b321e1ff..193c3666d2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_ui_touch_event_notification.cc @@ -67,4 +67,4 @@ void OnUITouchEventNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc index 2a5e6ba797..e6275adab2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_update_device_list.cc @@ -56,4 +56,4 @@ void OnUpdateDeviceList::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc index c8ecba458a..99c6520fee 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_acc_pedal_position_notification.cc @@ -64,4 +64,4 @@ void OnVIAccPedalPositionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc index ee909d19dc..dbfd9487e3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_belt_status_notification.cc @@ -64,4 +64,4 @@ void OnVIBeltStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc index f0386646ce..b8e66b9c0f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_body_information_notification.cc @@ -64,4 +64,4 @@ void OnVIBodyInformationNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc index 549c73065a..418c751d1c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_device_status_notification.cc @@ -64,4 +64,4 @@ void OnVIDeviceStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc index 23f0d37068..29545fcd87 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_driver_braking_notification.cc @@ -64,4 +64,4 @@ void OnVIDriverBrakingNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc index 735a225225..4c2fb94400 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_engine_torque_notification.cc @@ -64,4 +64,4 @@ void OnVIEngineTorqueNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc index 0b4bfa893f..6ac26a74fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_external_temperature_notification.cc @@ -64,4 +64,4 @@ void OnVIExternalTemperatureNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc index a5e84f1108..1f1cad5b8b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_notification.cc @@ -64,4 +64,4 @@ void OnVIFuelLevelNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc index 950b5a36f1..31c80860fd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_fuel_level_state_notification.cc @@ -64,4 +64,4 @@ void OnVIFuelLevelStateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc index 0d94194f76..43ae3524ad 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_gps_data_notification.cc @@ -64,4 +64,4 @@ void OnVIGpsDataNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc index 80edb88e38..282a173b69 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_head_lamp_status_notification.cc @@ -64,4 +64,4 @@ void OnVIHeadLampStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc index a2b0b1a8fd..f9bb3eca3f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_instant_fuel_consumption_notification.cc @@ -65,4 +65,4 @@ void OnVIInstantFuelConsumptionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc index 5e3555bbc4..8f5e845c02 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_my_key_notification.cc @@ -64,4 +64,4 @@ void OnVIMyKeyNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc index 1dbef77fa3..ea5d8be9ca 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_odometer_notification.cc @@ -64,4 +64,4 @@ void OnVIOdometerNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc index d4ae93b324..73231ff4de 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_prndl_notification.cc @@ -64,4 +64,4 @@ void OnVIPrndlNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc index 77f694c92e..4587939b8f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_rpm_notification.cc @@ -64,4 +64,4 @@ void OnVIRpmNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc index e5860c9eec..df0bfd5cd7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_speed_notification.cc @@ -64,4 +64,4 @@ void OnVISpeedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc index db591d9da3..b7eaad7edf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_steering_wheel_angle_notification.cc @@ -64,4 +64,4 @@ void OnVISteeringWheelAngleNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc index b5c7e18803..5f438ef8d1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_tire_pressure_notification.cc @@ -64,4 +64,4 @@ void OnVITirePressureNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc index 323fe5b885..1b40da4c40 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_vin_notification.cc @@ -64,4 +64,4 @@ void OnVIVinNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc index 6a3b863e7c..7221e88ef1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vi_wiper_status_notification.cc @@ -64,4 +64,4 @@ void OnVIWiperStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc index 701dee5385..7d5c0165aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_video_data_streaming_notification.cc @@ -59,4 +59,4 @@ void OnVideoDataStreamingNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc index 386ef1d1c7..c4678f69e0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_command_notification.cc @@ -32,13 +32,13 @@ #include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/state_controller.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -65,14 +65,17 @@ void OnVRCommandNotification::Run() { (*message_)[strings::msg_params][strings::cmd_id].asUInt(); uint32_t max_cmd_id = application_manager_.get_settings().max_cmd_id(); - // Check if this is one of standart VR commands (i.e. "Help") + // Check if this is one of standard VR commands (i.e. "Help") if (cmd_id > max_cmd_id + 1) { LOG4CXX_INFO(logger_, "Switched App"); const uint32_t app_id = cmd_id - max_cmd_id; ApplicationSharedPtr app = application_manager_.application(app_id); if (app) { application_manager_.state_controller().SetRegularState( - app, mobile_apis::HMILevel::HMI_FULL, true); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_FULL, + true); } else { LOG4CXX_ERROR(logger_, "Unable to find appication " << app_id); } @@ -110,4 +113,4 @@ void OnVRCommandNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc index 6a58ab9ffa..c308af9b92 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_language_change_notification.cc @@ -33,9 +33,9 @@ #include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" #include "application_manager/application_impl.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" +#include "application_manager/state_controller.h" #include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { @@ -83,7 +83,10 @@ void OnVRLanguageChangeNotification::Run() { if (static_cast<int32_t>(app->language()) != (*message_)[strings::msg_params][strings::language].asInt()) { application_manager_.state_controller().SetRegularState( - app, mobile_api::HMILevel::HMI_NONE, false); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + false); rpc_service_.ManageMobileCommand( MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( @@ -98,4 +101,4 @@ void OnVRLanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc index 04eb9a9ed0..bfc033a865 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_started_notification.cc @@ -61,4 +61,4 @@ void OnVRStartedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc index 8fea5ddd1c..ede1efab85 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_vr_stopped_notification.cc @@ -61,4 +61,4 @@ void OnVRStoppedNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc index 5947454517..d8ad6087a6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_request.cc @@ -59,4 +59,4 @@ void RCGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc index b14c28426c..128b111c5e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc @@ -54,16 +54,26 @@ void RCGetCapabilitiesResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); HMICapabilities& hmi_capabilities = hmi_capabilities_; - bool capability_exists = + bool rc_capability_exists = (*message_)[strings::msg_params].keyExists(strings::rc_capability); - if (capability_exists) { + if (rc_capability_exists) { hmi_capabilities.set_rc_capability( (*message_)[strings::msg_params][strings::rc_capability]); } - hmi_capabilities.set_rc_supported(capability_exists); + + bool seat_location_capability_exists = + (*message_)[strings::msg_params].keyExists( + strings::seat_location_capability); + + if (seat_location_capability_exists) { + hmi_capabilities.set_seat_location_capability( + (*message_)[strings::msg_params][strings::seat_location_capability]); + } + + hmi_capabilities.set_rc_supported(rc_capability_exists); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc index d538878dc8..5e4af1503a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_request.cc @@ -105,4 +105,4 @@ void RCIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc index 7534567204..71e16a831c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_is_ready_response.cc @@ -58,4 +58,4 @@ void RCIsReadyResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 92a7020208..13690809bb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -31,8 +31,9 @@ */ #include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/state_controller.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -45,8 +46,7 @@ struct ProtoV4AppsOnDevice : std::unary_function<ApplicationSharedPtr, bool> { ProtoV4AppsOnDevice(const connection_handler::DeviceHandle handle) : handle_(handle) {} bool operator()(const ApplicationSharedPtr app) const { - return app - ? handle_ == app->device() && + return app ? handle_ == app->device() && Message::is_sufficient_version( protocol_handler::MajorProtocolVersion:: PROTOCOL_VERSION_4, @@ -80,7 +80,7 @@ struct SendLaunchApp return; } }; -} +} // namespace SDLActivateAppRequest::SDLActivateAppRequest( const application_manager::commands::MessageSharedPtr& message, @@ -317,4 +317,4 @@ ApplicationSharedPtr SDLActivateAppRequest::get_foreground_app( } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc index 3262b12759..560b75213c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_response.cc @@ -61,4 +61,4 @@ void SDLActivateAppResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc index 6b983d566a..c8266e0f39 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_request.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -64,4 +65,4 @@ void SDLGetListOfPermissionsRequest::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc index 784b4922d4..280d2cb071 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_list_of_permissions_response.cc @@ -61,4 +61,4 @@ void SDLGetListOfPermissionsResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc new file mode 100644 index 0000000000..2607754228 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_request.cc @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +SDLGetPolicyConfigurationDataRequest::SDLGetPolicyConfigurationDataRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SDLGetPolicyConfigurationDataRequest::~SDLGetPolicyConfigurationDataRequest() {} + +void SDLGetPolicyConfigurationDataRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + smart_objects::SmartObject response_value( + smart_objects::SmartType::SmartType_Array); + + hmi_apis::Common_Result::eType result_code = + PrepareResponseParams(response_value); + + if (hmi_apis::Common_Result::SUCCESS != result_code) { + LOG4CXX_ERROR(logger_, "Unable to PrepareResponseParams"); + SendErrorResponse( + correlation_id(), + hmi_apis::FunctionID::SDL_GetPolicyConfigurationData, + result_code, + "", + application_manager::commands::Command::SOURCE_SDL_TO_HMI); + return; + } + + smart_objects::SmartObject response_msg_params( + smart_objects::SmartType::SmartType_Map); + response_msg_params[strings::value] = response_value; + SendResponse(true, + correlation_id(), + hmi_apis::FunctionID::SDL_GetPolicyConfigurationData, + result_code, + &response_msg_params, + application_manager::commands::Command::SOURCE_SDL_TO_HMI); +} + +hmi_apis::Common_Result::eType +SDLGetPolicyConfigurationDataRequest::PrepareResponseParams( + smart_objects::SmartObject& response_out) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto policy_type = + (*message_)[strings::msg_params][strings::policy_type].asString(); + + const auto property = + (*message_)[strings::msg_params][strings::property].asString(); + + auto policy_table_data = policy_handler_.GetPolicyTableData(); + if (!policy_table_data.isMember(policy_type)) { + LOG4CXX_ERROR( + logger_, + "policy_type " << policy_type << " doesn't exist in policy table."); + return hmi_apis::Common_Result::DATA_NOT_AVAILABLE; + } + + auto& policy_section_table_data = policy_table_data[policy_type]; + if (!policy_section_table_data.isMember(property)) { + LOG4CXX_ERROR( + logger_, + "property " << property << " doesn't exist in " << policy_type); + return hmi_apis::Common_Result::DATA_NOT_AVAILABLE; + } + + auto& property_table_data = policy_section_table_data[property]; + response_out = GetValueParam(property_table_data); + + return hmi_apis::Common_Result::SUCCESS; +} + +void clear_new_line_symbol(std::string& str_to_clear) { + str_to_clear.erase( + std::remove_if(str_to_clear.begin(), + str_to_clear.end(), + [](char character) { return '\n' == character; }), + str_to_clear.end()); +} + +smart_objects::SmartObject SDLGetPolicyConfigurationDataRequest::GetValueParam( + const Json::Value& policy_property) const { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject value(smart_objects::SmartType_Array); + + auto put_element_in_value_array = [&value](const Json::Value& element, + const int32_t index) { + Json::FastWriter writer; + std::string str; + if (element.type() == Json::objectValue) { + str = writer.write(element); + clear_new_line_symbol(str); + } else { + str = element.asString(); + } + value[index] = str; + }; + + if (policy_property.type() == Json::arrayValue) { + for (Json::ArrayIndex i = 0; i < policy_property.size(); i++) { + put_element_in_value_array(policy_property[i], i); + } + return value; + } + put_element_in_value_array(policy_property, 0); + return value; +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc index 57c925e08f..21b7dea41c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_urls_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_policy_configuration_data_response.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,14 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h" #include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; + namespace commands { -GetUrlsResponse::GetUrlsResponse( +SDLGetPolicyConfigurationDataResponse::SDLGetPolicyConfigurationDataResponse( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, rpc_service::RPCService& rpc_service, @@ -49,15 +50,15 @@ GetUrlsResponse::GetUrlsResponse( hmi_capabilities, policy_handle) {} -GetUrlsResponse::~GetUrlsResponse() {} +SDLGetPolicyConfigurationDataResponse:: + ~SDLGetPolicyConfigurationDataResponse() {} -void GetUrlsResponse::Run() { +void SDLGetPolicyConfigurationDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; (*message_)[strings::params][strings::protocol_version] = protocol_version_; - rpc_service_.SendMessageToHMI(message_); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc index 9a6c0fd520..b494be56e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_request.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" #include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,4 +60,4 @@ void SDLGetStatusUpdateRequest::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc index 8fc85da481..4b0f3d0ca8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_status_update_response.cc @@ -61,4 +61,4 @@ void SDLGetStatusUpdateResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc index ab8ec4e3d9..38a63611fa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_request.cc @@ -32,6 +32,7 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -93,4 +94,4 @@ void SDLGetUserFriendlyMessageRequest::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc index c5b3450723..b95591c4fa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_get_user_friendly_message_response.cc @@ -61,4 +61,4 @@ void SDLGetUserFriendlyMessageResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc index aef2e286d7..5f69903548 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update.cc @@ -64,4 +64,4 @@ void SDLPolicyUpdate::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc index d16fc578ab..12cdfb4ad9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc @@ -56,4 +56,4 @@ void SDLPolicyUpdateResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc index 163d749426..988be68a80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_request.cc @@ -59,4 +59,4 @@ void TTSChangeRegistrationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc index 2c28d615d3..e5e38ef34a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_change_registration_response.cc @@ -63,4 +63,4 @@ void TTSChangeRegistratioResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc index 49623e01d7..9baaabf401 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_request.cc @@ -59,4 +59,4 @@ void TTSGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc index 1cef3daf15..c0581a6380 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc @@ -69,4 +69,4 @@ void TTSGetCapabilitiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc index 5533537b33..7d2c15a9bf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_request.cc @@ -59,4 +59,4 @@ void TTSGetLanguageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc index ac423a2bf3..627056dce1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc @@ -77,4 +77,4 @@ void TTSGetLanguageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc index 8b87b9c6ea..2cb47380d5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_request.cc @@ -59,4 +59,4 @@ void TTSGetSupportedLanguagesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc index a4e97d9d70..a70d1c89a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc @@ -69,4 +69,4 @@ void TTSGetSupportedLanguagesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc index c7e2c0c4cb..89b5961895 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_request.cc @@ -31,8 +31,8 @@ */ #include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -112,4 +112,4 @@ void TTSIsReadyRequest::SendMessageToHMI() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc index c7d634bee2..67e0fb6396 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_is_ready_response.cc @@ -59,4 +59,4 @@ void TTSIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc index 8c7443d465..0b3d9a77bf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_request.cc @@ -59,4 +59,4 @@ void TTSSetGlobalPropertiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc index dae06d75f9..0901378c4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_set_global_properties_response.cc @@ -63,4 +63,4 @@ void TTSSetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc index 96b93b724f..6dce94f931 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_request.cc @@ -59,4 +59,4 @@ void TTSSpeakRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc index cb2346083b..69be5ab160 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_speak_response.cc @@ -32,8 +32,8 @@ #include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" #include "application_manager/event_engine/event.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -64,4 +64,4 @@ void TTSSpeakResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc index 25a05f085b..43c595040c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_request.cc @@ -59,4 +59,4 @@ void TTSStopSpeakingRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc index a2620c1340..892b3e6295 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_stop_speaking_response.cc @@ -62,4 +62,4 @@ void TTSStopSpeakingResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc index 749b3ad56b..7c95e8a919 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_request.cc @@ -59,4 +59,4 @@ void UIAddCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc index 266dffd225..72d841a878 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_command_response.cc @@ -62,4 +62,4 @@ void UIAddCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc index de338d4670..15342c6ecb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_request.cc @@ -59,4 +59,4 @@ void UIAddSubmenuRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc index 85e600c87d..ae699dc2bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_add_submenu_response.cc @@ -63,4 +63,4 @@ void UIAddSubmenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc index ae5f861ba6..793e70d9e1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_request.cc @@ -47,7 +47,11 @@ UIAlertRequest::UIAlertRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::duration].asUInt(); + default_timeout_ += request_timeout; +} UIAlertRequest::~UIAlertRequest() {} @@ -59,4 +63,4 @@ void UIAlertRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc index 3076eabc4c..f53f14e050 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_alert_response.cc @@ -63,4 +63,4 @@ void UIAlertResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_request.cc new file mode 100644 index 0000000000..c186077b1e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICancelInteractionRequest::UICancelInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICancelInteractionRequest::~UICancelInteractionRequest() {} + +void UICancelInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_response.cc new file mode 100644 index 0000000000..2d5db4eecb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_cancel_interaction_response.cc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICancelInteractionResponse::UICancelInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICancelInteractionResponse::~UICancelInteractionResponse() {} + +void UICancelInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_CancelInteraction); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc index d109987009..bb001b37c7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_request.cc @@ -59,4 +59,4 @@ void UIChangeRegistrationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc index 6557269e49..8acd654488 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_change_registration_response.cc @@ -63,4 +63,4 @@ void UIChangeRegistratioResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc new file mode 100644 index 0000000000..b354009e3f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICreateWindowRequest::UICreateWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICreateWindowRequest::~UICreateWindowRequest() {} + +void UICreateWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc new file mode 100644 index 0000000000..c3a323818d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_create_window_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UICreateWindowResponse::UICreateWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UICreateWindowResponse::~UICreateWindowResponse() {} + +void UICreateWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc index 9e52f5fc18..1d741bba74 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_request.cc @@ -59,4 +59,4 @@ void UIDeleteCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc index a8f5b59d39..40a5ec8a73 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_command_response.cc @@ -63,4 +63,4 @@ void UIDeleteCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc index 1b84df8bed..fdca37cee6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_request.cc @@ -59,4 +59,4 @@ void UIDeleteSubmenuRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc index ec4025bea1..9d522431dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_submenu_response.cc @@ -63,4 +63,4 @@ void UIDeleteSubmenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc new file mode 100644 index 0000000000..7933574d92 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_request.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteWindowRequest::UIDeleteWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteWindowRequest::~UIDeleteWindowRequest() {} + +void UIDeleteWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc new file mode 100644 index 0000000000..ba703e18ae --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_delete_window_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +UIDeleteWindowResponse::UIDeleteWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIDeleteWindowResponse::~UIDeleteWindowResponse() {} + +void UIDeleteWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc index fe11185c62..92f51bc9cf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_request.cc @@ -59,4 +59,4 @@ void UIEndAudioPassThruRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc index 3a6d4efbe4..b6639dcbb9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_end_audio_pass_thru_response.cc @@ -63,4 +63,4 @@ void UIEndAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc index 3bd56a0682..5f8704b3e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_request.cc @@ -59,4 +59,4 @@ void UIGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc index cd5f3c9a42..a3eb9244bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc @@ -73,9 +73,17 @@ void UIGetCapabilitiesResponse::Run() { msg_params[hmi_response::soft_button_capabilities]); } - if (msg_params.keyExists(strings::audio_pass_thru_capabilities)) { + // use newer parameter "audioPassThruCapabilitiesList" when available + if (msg_params.keyExists(strings::audio_pass_thru_capabilities_list)) { hmi_capabilities.set_audio_pass_thru_capabilities( - msg_params[strings::audio_pass_thru_capabilities]); + msg_params[strings::audio_pass_thru_capabilities_list]); + } else if (msg_params.keyExists(strings::audio_pass_thru_capabilities)) { + smart_objects::SmartObject audio_pass_thru_capabilities_list( + smart_objects::SmartType_Array); + audio_pass_thru_capabilities_list[0] = + msg_params[strings::audio_pass_thru_capabilities]; + hmi_capabilities.set_audio_pass_thru_capabilities( + audio_pass_thru_capabilities_list); } if (msg_params.keyExists(strings::hmi_capabilities)) { @@ -113,9 +121,15 @@ void UIGetCapabilitiesResponse::Run() { msg_params[strings::system_capabilities] [strings::video_streaming_capability]); } + if (msg_params[strings::system_capabilities].keyExists( + strings::display_capabilities)) { + hmi_capabilities.set_system_display_capabilities( + msg_params[strings::system_capabilities] + [strings::display_capabilities]); + } } } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc index 8acba42493..d3b44d1168 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_request.cc @@ -59,4 +59,4 @@ void UIGetLanguageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc index 27e46e52b4..2a5c0ab016 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc @@ -78,4 +78,4 @@ void UIGetLanguageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc index 2f8ef12a25..0665612525 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_request.cc @@ -59,4 +59,4 @@ void UIGetSupportedLanguagesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc index d20dd8545f..19ee62e51d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc @@ -69,4 +69,4 @@ void UIGetSupportedLanguagesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc index 2eab211690..2546b704b2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_request.cc @@ -112,4 +112,4 @@ void UIIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc index e25e8ee8ab..96a2d1212c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_is_ready_response.cc @@ -60,4 +60,4 @@ void UIIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc index cca89e3073..18d5376b25 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_request.cc @@ -59,4 +59,4 @@ void UIPerformAudioPassThruRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc index 057448ab33..afbd1bbed7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_audio_pass_thru_response.cc @@ -62,4 +62,4 @@ void UIPerformAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc index d5696a39e7..a07c72cbf4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_request.cc @@ -47,7 +47,11 @@ UIPerformInteractionRequest::UIPerformInteractionRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} UIPerformInteractionRequest::~UIPerformInteractionRequest() {} @@ -59,4 +63,4 @@ void UIPerformInteractionRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc index 7629faa131..4cbc58d278 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_perform_interaction_response.cc @@ -61,4 +61,4 @@ void UIPerformInteractionResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc index dbe0ceb529..cad68e23aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_request.cc @@ -47,7 +47,11 @@ UIScrollableMessageRequest::UIScrollableMessageRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} UIScrollableMessageRequest::~UIScrollableMessageRequest() {} @@ -59,4 +63,4 @@ void UIScrollableMessageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc index a96b9fa3ee..4e844095b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_scrollable_message_response.cc @@ -62,4 +62,4 @@ void UIScrollableMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc index f5f8f7bafd..4a538ac992 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_request.cc @@ -58,4 +58,4 @@ void UISendHapticDataRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc index 4555d81a0a..92afdaaa4a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_send_haptic_data_response.cc @@ -62,4 +62,4 @@ void UISendHapticDataResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc index d25bbd1cd9..821f78a046 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_request.cc @@ -59,4 +59,4 @@ void UISetAppIconRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc index 711b5767f2..68e96725d4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_app_icon_response.cc @@ -62,4 +62,4 @@ void UISetAppIconResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc index 73b813d0eb..63166157c8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_request.cc @@ -58,4 +58,4 @@ void UiSetDisplayLayoutRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc index d5d2e02e33..f35427895e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_display_layout_response.cc @@ -63,4 +63,4 @@ void UiSetDisplayLayoutResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc index 0664404361..0aaaae7cc7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_request.cc @@ -59,4 +59,4 @@ void UISetGlobalPropertiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc index 2e5fecf2af..48d73d146c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_global_properties_response.cc @@ -62,4 +62,4 @@ void UISetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc index 4e87b9ccc3..4c8fcefcdf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_request.cc @@ -59,4 +59,4 @@ void UISetMediaClockTimerRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc index 39e7e1c232..fb5b25fc2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_media_clock_timer_response.cc @@ -62,4 +62,4 @@ void UISetMediaClockTimerResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_request.cc new file mode 100644 index 0000000000..c2c8566e82 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_request.cc @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +UIShowAppMenuRequest::UIShowAppMenuRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIShowAppMenuRequest::~UIShowAppMenuRequest() {} + +void UIShowAppMenuRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + SendRequest(); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_response.cc new file mode 100644 index 0000000000..14bbc79e03 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_app_menu_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h" +#include "application_manager/event_engine/event.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +UIShowAppMenuResponse::UIShowAppMenuResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UIShowAppMenuResponse::~UIShowAppMenuResponse() {} + +void UIShowAppMenuResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::event_engine::Event event(hmi_apis::FunctionID::UI_ShowAppMenu); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc index 5b7568abfe..d7160dc70b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_request.cc @@ -59,4 +59,4 @@ void UIShowRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc index 3e3c0b79d8..768069bf3a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_show_response.cc @@ -61,4 +61,4 @@ void UIShowResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc index 4df3adbe14..eae8cc523c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_request.cc @@ -47,7 +47,11 @@ UISliderRequest::UISliderRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} UISliderRequest::~UISliderRequest() {} @@ -59,4 +63,4 @@ void UISliderRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc index 2431c65ddf..9cf7224ddb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_slider_response.cc @@ -62,4 +62,4 @@ void UISliderResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc index 05b08cb723..c5966fcb36 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_request.cc @@ -59,4 +59,4 @@ void UpdateAppListRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc index 3dd03993ef..7fc830b4e6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_app_list_response.cc @@ -59,4 +59,4 @@ void UpdateAppListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc index 7736f2b1e6..3a014480c1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc @@ -100,4 +100,4 @@ bool UpdateDeviceListRequest::CleanUp() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc index 25dc9be5bd..d69e683f2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_response.cc @@ -58,4 +58,4 @@ void UpdateDeviceListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc index cafacea28f..a52f03b998 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_request.cc @@ -32,6 +32,7 @@ */ #include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -61,4 +62,4 @@ void UpdateSDLRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc index a35571ec26..c02cde4111 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_sdl_response.cc @@ -61,4 +61,4 @@ void UpdateSDLResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc index 72ce387f77..788eda5a87 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_request.cc @@ -59,4 +59,4 @@ void VRAddCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc index 19d43616ff..37b3e4696d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_add_command_response.cc @@ -63,4 +63,4 @@ void VRAddCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc index 9ba5fa3571..d1be04ad44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_request.cc @@ -59,4 +59,4 @@ void VRChangeRegistrationRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc index 42c5b6d65b..27bde2bafa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_change_registration_response.cc @@ -62,4 +62,4 @@ void VRChangeRegistrationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc index efc09dc157..ebcfe78fa9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_request.cc @@ -59,4 +59,4 @@ void VRDeleteCommandRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc index f8f7535e68..d1d725b356 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_delete_command_response.cc @@ -62,4 +62,4 @@ void VRDeleteCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc index 7e9c846857..b06bfa0e77 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_request.cc @@ -59,4 +59,4 @@ void VRGetCapabilitiesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc index 47ffb3a675..80c308ea40 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc @@ -61,4 +61,4 @@ void VRGetCapabilitiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc index d57faa08fd..84179f6357 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_request.cc @@ -59,4 +59,4 @@ void VRGetLanguageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc index 469452d108..6b7fec736d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc @@ -78,4 +78,4 @@ void VRGetLanguageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc index bb27168a77..351940bf68 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_request.cc @@ -59,4 +59,4 @@ void VRGetSupportedLanguagesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc index 722040388d..4c725267fa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc @@ -31,8 +31,8 @@ */ #include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -69,4 +69,4 @@ void VRGetSupportedLanguagesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc index 22afb03945..12414eab10 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_request.cc @@ -112,4 +112,4 @@ void VRIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc index 48d9c3e075..373f97bf80 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_is_ready_response.cc @@ -59,4 +59,4 @@ void VRIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc index 26e308a0bc..4257158f6a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_request.cc @@ -47,7 +47,11 @@ VRPerformInteractionRequest::VRPerformInteractionRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) {} + policy_handle) { + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); + default_timeout_ += request_timeout; +} VRPerformInteractionRequest::~VRPerformInteractionRequest() {} @@ -59,4 +63,4 @@ void VRPerformInteractionRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc index dec371e889..16378ab55a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_perform_interaction_response.cc @@ -60,4 +60,4 @@ void VRPerformInteractionResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index 155f819761..a57d222765 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include "sdl_rpc_plugin/commands/mobile/add_command_request.h" +#include <string> #include "application_manager/application.h" #include "application_manager/message_helper.h" +#include "utils/custom_string.h" #include "utils/file_system.h" #include "utils/helpers.h" -#include "utils/custom_string.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -126,9 +126,9 @@ void AddCommandRequest::Run() { } if (((*message_)[strings::msg_params][strings::menu_params].keyExists( hmi_request::parent_id)) && - (0 != - (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asUInt())) { + (0 != (*message_)[strings::msg_params][strings::menu_params] + [hmi_request::parent_id] + .asUInt())) { if (!CheckCommandParentId(app)) { SendResponse( false, mobile_apis::Result::INVALID_ID, "Parent ID doesn't exist"); @@ -224,7 +224,8 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { if ((*message_)[strings::msg_params][strings::menu_params].keyExists( hmi_request::parent_id)) { parent_id = (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asUInt(); + [hmi_request::parent_id] + .asUInt(); } for (; commands.end() != i; ++i) { @@ -239,7 +240,8 @@ bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { } if (((*i->second)[strings::menu_params][strings::menu_name].asString() == (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name].asString()) && + [strings::menu_name] + .asString()) && (saved_parent_id == parent_id)) { LOG4CXX_INFO(logger_, "AddCommandRequest::CheckCommandName received" @@ -293,7 +295,8 @@ bool AddCommandRequest::CheckCommandParentId(ApplicationConstSharedPtr app) { const int32_t parent_id = (*message_)[strings::msg_params][strings::menu_params] - [hmi_request::parent_id].asInt(); + [hmi_request::parent_id] + .asInt(); smart_objects::SmartObject* parent = app->FindSubMenu(parent_id); if (!parent) { @@ -524,7 +527,8 @@ bool AddCommandRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { str = (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name].asCharArray(); + [strings::menu_name] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid menu name syntax check failed."); return true; @@ -624,4 +628,4 @@ void AddCommandRequest::RemoveCommand() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc index ccb84cecbb..24ff3b5a28 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_response.cc @@ -61,4 +61,4 @@ void AddCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc index 183b445326..89ccfb8bd7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application.h" +#include "application_manager/message_helper.h" #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -109,15 +109,28 @@ void AddSubMenuRequest::Run() { smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + if (received_msg_params.keyExists(strings::menu_layout)) { + auto menu_layout = static_cast<mobile_apis::MenuLayout::eType>( + received_msg_params[strings::menu_layout].asUInt()); + if (app->menu_layout_supported(menu_layout)) { + msg_params[strings::menu_layout] = + received_msg_params[strings::menu_layout]; + } else { + is_menu_layout_available_ = false; + } + } + msg_params[strings::menu_id] = received_msg_params[strings::menu_id]; if (received_msg_params.keyExists(strings::position)) { msg_params[strings::menu_params][strings::position] = received_msg_params[strings::position]; } + if (received_msg_params.keyExists(strings::menu_icon)) { + msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; + } msg_params[strings::menu_params][strings::menu_name] = received_msg_params[strings::menu_name]; msg_params[strings::app_id] = app->app_id(); - msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); @@ -150,11 +163,22 @@ void AddSubMenuRequest::on_event(const event_engine::Event& event) { application->AddSubMenu( (*message_)[strings::msg_params][strings::menu_id].asInt(), (*message_)[strings::msg_params]); + response_info = + "The MenuLayout specified is unsupported, the " + "default MenuLayout will be used." + + response_info; + SendResponse(result, + is_menu_layout_available_ + ? MessageHelper::HMIToMobileResult(result_code) + : mobile_apis::Result::WARNINGS, + is_menu_layout_available_ ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + } else { + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); } - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); break; } default: { @@ -183,4 +207,4 @@ bool AddSubMenuRequest::CheckSubMenuName() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc index d0ec635dd0..d91f13f1df 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,4 +62,4 @@ void AddSubMenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc index 5dda34b743..9f36f260ae 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_request.cc @@ -25,12 +25,12 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" #include <cstring> #include <string> -#include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" #include "application_manager/application_impl.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -107,9 +107,9 @@ void AlertManeuverRequest::Run() { MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_chunks are not present"); @@ -288,4 +288,4 @@ bool AlertManeuverRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc index d3e527f6ae..97c93d7455 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_maneuver_response.cc @@ -62,4 +62,4 @@ void AlertManeuverResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc index 2806ac1d93..57912e7087 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc @@ -35,12 +35,12 @@ #include <string.h> -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler.h" -#include "utils/helpers.h" #include "smart_objects/smart_object.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -73,18 +73,15 @@ AlertRequest::~AlertRequest() {} bool AlertRequest::Init() { /* Timeout in milliseconds. - If omitted a standard value of 10000 milliseconds is used.*/ - if ((*message_)[strings::msg_params].keyExists(strings::duration)) { - default_timeout_ = - (*message_)[strings::msg_params][strings::duration].asUInt(); - } else { - const int32_t def_value = 5000; - default_timeout_ = def_value; - } + If omitted a standard value of 10000 milliseconds is used.*/ + auto& msg_params = (*message_)[strings::msg_params]; + uint32_t duration_timeout = msg_params[strings::duration].asUInt(); + + default_timeout_ += duration_timeout; // If soft buttons are present, SDL will not use initiate timeout tracking for // response. - if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { + if (msg_params.keyExists(strings::soft_buttons)) { LOG4CXX_INFO(logger_, "Request contains soft buttons - request timeout " "will be set to 0."); @@ -251,7 +248,8 @@ bool AlertRequest::Validate(uint32_t app_id) { return false; } - if (mobile_apis::HMILevel::HMI_BACKGROUND == app->hmi_level() && + if (mobile_apis::HMILevel::HMI_BACKGROUND == + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) && app->AreCommandLimitsExceeded( static_cast<mobile_apis::FunctionID::eType>(function_id()), application_manager::TLimitSource::POLICY_TABLE)) { @@ -298,9 +296,9 @@ bool AlertRequest::Validate(uint32_t app_id) { MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_chunks are not present"); @@ -321,6 +319,11 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { msg_params[hmi_request::alert_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + int32_t index = 0; if ((*message_)[strings::msg_params].keyExists(strings::alert_text1)) { msg_params[hmi_request::alert_strings][index][hmi_request::field_name] = @@ -349,10 +352,30 @@ void AlertRequest::SendAlertRequest(int32_t app_id) { (*message_)[strings::msg_params][strings::soft_buttons]; MessageHelper::SubscribeApplicationToSoftButton( (*message_)[strings::msg_params], app, function_id()); + msg_params[strings::duration] = 0; + } else { + msg_params[strings::duration] = + (*message_)[strings::msg_params][strings::duration].asUInt(); + } + + if ((*message_)[strings::msg_params].keyExists(strings::alert_icon)) { + auto verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::alert_icon], + app, + application_manager_); + + if (mobile_apis::Result::INVALID_DATA == verification_result) { + LOG4CXX_ERROR(logger_, "Image verification failed."); + SendResponse(false, verification_result); + return; + } + + msg_params[strings::alert_icon] = + (*message_)[strings::msg_params][strings::alert_icon]; } + // app_id msg_params[strings::app_id] = app_id; - msg_params[strings::duration] = default_timeout_; // NAVI platform progressIndicator if ((*message_)[strings::msg_params].keyExists(strings::progress_indicator)) { @@ -450,4 +473,4 @@ bool AlertRequest::HasHmiResponsesToWait() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc index bab5e5a5d8..b709d13958 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_response.cc @@ -32,10 +32,10 @@ */ #include "sdl_rpc_plugin/commands/mobile/alert_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -64,4 +64,4 @@ void AlertResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc new file mode 100644 index 0000000000..82e0703da1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_request.cc @@ -0,0 +1,117 @@ + +/* +Copyright (c) 2019, Ford Motor Company, Livio +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 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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CancelInteractionRequest::CancelInteractionRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CancelInteractionRequest::~CancelInteractionRequest() {} + +void CancelInteractionRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + auto function_id = static_cast<mobile_apis::FunctionID::eType>( + (*message_)[strings::msg_params][strings::func_id].asInt()); + + if (helpers:: + Compare<mobile_apis::FunctionID::eType, helpers::NEQ, helpers::ALL>( + function_id, + mobile_apis::FunctionID::PerformInteractionID, + mobile_apis::FunctionID::AlertID, + mobile_apis::FunctionID::ScrollableMessageID, + mobile_apis::FunctionID::SliderID)) { + LOG4CXX_ERROR(logger_, "Bad function ID" << function_id); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params; + msg_params[strings::app_id] = connection_key(); + msg_params[strings::func_id] = function_id; + + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + + SendHMIRequest(hmi_apis::FunctionID::UI_CancelInteraction, &msg_params, true); +} + +void CancelInteractionRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (event.id() != hmi_apis::FunctionID::UI_CancelInteraction) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + auto message = event.smart_object(); + + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_UI); + + auto msg_params = message[strings::msg_params]; + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(success, result, info, &msg_params); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_response.cc new file mode 100644 index 0000000000..af73e72a6f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/cancel_interaction_response.cc @@ -0,0 +1,60 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CancelInteractionResponse::CancelInteractionResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CancelInteractionResponse::~CancelInteractionResponse() {} + +void CancelInteractionResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin
\ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc index 6af930ea53..50217a9c8a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc @@ -31,14 +31,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" #include <string.h> #include <algorithm> -#include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" -#include "application_manager/application_manager.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace { namespace custom_str = utils::custom_string; @@ -49,9 +50,9 @@ struct IsSameNickname { } private: - const custom_str::CustomString& app_id_; + const custom_str::CustomString app_id_; }; -} +} // namespace namespace sdl_rpc_plugin { using namespace application_manager; @@ -160,7 +161,7 @@ void ChangeRegistrationRequest::Run() { return; } - if (mobile_apis::Result::SUCCESS != CheckCoincidence()) { + if (mobile_apis::Result::SUCCESS != CheckCoincidence(app->device())) { SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); return; } @@ -194,9 +195,9 @@ void ChangeRegistrationRequest::Run() { MessageHelper::VerifyTtsFiles(tts_name, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_name are not present"); @@ -216,9 +217,9 @@ void ChangeRegistrationRequest::Run() { hmi_interfaces.GetInterfaceState( HmiInterfaces::InterfaceID::HMI_INTERFACE_TTS); + using helpers::ALL; using helpers::Compare; using helpers::EQ; - using helpers::ALL; if (Compare<HmiInterfaces::InterfaceState, EQ, ALL>( HmiInterfaces::InterfaceState::STATE_NOT_AVAILABLE, @@ -578,36 +579,46 @@ bool ChangeRegistrationRequest::IsWhiteSpaceExist() { return false; } -mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { +mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence( + const connection_handler::DeviceHandle& device_id) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - ApplicationSet accessor = application_manager_.applications().GetData(); + auto compare_tts_name = [](const smart_objects::SmartObject& obj_1, + const smart_objects::SmartObject& obj_2) { + return obj_1[application_manager::strings::text] + .asCustomString() + .CompareIgnoreCase( + obj_2[application_manager::strings::text].asCustomString()); + }; + + const auto& accessor = application_manager_.applications().GetData(); custom_str::CustomString app_name; - uint32_t app_id = connection_key(); + const uint32_t app_id = connection_key(); if (msg_params.keyExists(strings::app_name)) { app_name = msg_params[strings::app_name].asCustomString(); } - ApplicationSetConstIt it = accessor.begin(); - for (; accessor.end() != it; ++it) { - if (app_id == (*it)->app_id()) { + for (const auto& app : accessor) { + if (app->device() != device_id) { + continue; + } + + if (app->app_id() == app_id) { continue; } - const custom_str::CustomString& cur_name = (*it)->name(); + const auto& cur_name = app->name(); if (msg_params.keyExists(strings::app_name)) { if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); return mobile_apis::Result::DUPLICATE_NAME; } - - const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); - const std::vector<smart_objects::SmartObject>* curr_vr = NULL; - if (NULL != vr) { - curr_vr = vr->asArray(); + const auto vr = app->vr_synonyms(); + if (vr) { + const auto curr_vr = vr->asArray(); CoincidencePredicateVR v(app_name); if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { @@ -617,18 +628,37 @@ mobile_apis::Result::eType ChangeRegistrationRequest::CheckCoincidence() { } } - // vr check + // VR check if (msg_params.keyExists(strings::vr_synonyms)) { - const std::vector<smart_objects::SmartObject>* new_vr = - msg_params[strings::vr_synonyms].asArray(); + const auto new_vr = msg_params[strings::vr_synonyms].asArray(); CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); return mobile_apis::Result::DUPLICATE_NAME; } - } // end vr check - } // application for end + } // End vr check + + // TTS check + if (msg_params.keyExists(strings::tts_name) && app->tts_name()) { + const auto tts_array = msg_params[strings::tts_name].asArray(); + const auto tts_curr = app->tts_name()->asArray(); + const auto& it_tts = std::find_first_of(tts_array->begin(), + tts_array->end(), + tts_curr->begin(), + tts_curr->end(), + compare_tts_name); + if (it_tts != tts_array->end()) { + LOG4CXX_ERROR( + logger_, + "TTS name: " + << (*it_tts)[strings::text].asCustomString().AsMBString() + << " is known already"); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // End tts check + + } // Application for end return mobile_apis::Result::SUCCESS; } @@ -638,9 +668,9 @@ bool ChangeRegistrationRequest::IsNicknameAllowed( ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, - "Can't find appication with connection key " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "Can't find appication with connection key " << connection_key()); return false; } @@ -681,4 +711,4 @@ bool ChangeRegistrationRequest::IsNicknameAllowed( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc index 2dae92cd9b..78c60bc746 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_response.cc @@ -61,4 +61,4 @@ void ChangeRegistrationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc new file mode 100644 index 0000000000..275f1d82a6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_request.cc @@ -0,0 +1,119 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/close_application_request.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CloseApplicationRequest::CloseApplicationRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CloseApplicationRequest::~CloseApplicationRequest() {} + +void CloseApplicationRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (app.use_count() == 0) { + LOG4CXX_ERROR(logger_, "Application does not exist"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + smart_objects::SmartObject msg_params; + msg_params[strings::app_id] = connection_key(); + SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_CloseApplication, + &msg_params, + true); +} + +void CloseApplicationRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + auto msg_params = message[strings::msg_params]; + + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + mobile_apis::Result::eType result = + MessageHelper::HMIToMobileResult(hmi_result); + bool success = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_BasicCommunication); + if (success) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (app.use_count() == 0) { + LOG4CXX_ERROR(logger_, "Application does not exist"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + auto on_app_exit = [app](plugin_manager::RPCPlugin& plugin) { + plugin.OnApplicationEvent(plugin_manager::kApplicationExit, app); + }; + + application_manager_.GetPluginManager().ForEachPlugin(on_app_exit); + application_manager_.state_controller().SetRegularState( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + false); + } + + const char* info = msg_params.keyExists(strings::info) + ? msg_params[strings::info].asCharArray() + : NULL; + + SendResponse(success, result, info, &msg_params); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_response.cc new file mode 100644 index 0000000000..934804e1b1 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/close_application_response.cc @@ -0,0 +1,61 @@ +/* + Copyright (c) 2019, Ford Motor Company, Livio + 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 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. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/close_application_response.h" +#include "application_manager/application_impl.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +CloseApplicationResponse::CloseApplicationResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CloseApplicationResponse::~CloseApplicationResponse() {} + +void CloseApplicationResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index 416f4f2085..258aefd63f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -31,11 +31,11 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string> -#include <cstring> +#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" #include <algorithm> +#include <cstring> +#include <string> #include <vector> -#include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" @@ -218,9 +218,9 @@ bool CreateInteractionChoiceSetRequest::compareSynonyms( CreateInteractionChoiceSetRequest::compareStr); if (it != vr_cmds_1->end()) { - LOG4CXX_INFO(logger_, - "Incoming choice set has duplicated VR synonyms " - << it->asString()); + LOG4CXX_INFO( + logger_, + "Incoming choice set has duplicated VR synonyms " << it->asString()); return true; } @@ -332,9 +332,9 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( VRCommandInfo vr_command(vr_cmd_id); sent_commands_map_[vr_corr_id] = vr_command; - LOG4CXX_DEBUG(logger_, - "VR_command sent corr_id " << vr_corr_id << " cmd_id " - << vr_corr_id); + LOG4CXX_DEBUG( + logger_, + "VR_command sent corr_id " << vr_corr_id << " cmd_id " << vr_corr_id); } expected_chs_count_ = chs_num; LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); @@ -480,4 +480,4 @@ void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc index 807770ed12..43dba2f238 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_response.cc @@ -72,4 +72,4 @@ void CreateInteractionChoiceSetResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc new file mode 100644 index 0000000000..b69b0ee801 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_request.cc @@ -0,0 +1,376 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/create_window_request.h" + +#include <algorithm> + +#include "application_manager/application_impl.h" +#include "application_manager/application_state.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +using app_mngr::ApplicationSharedPtr; + +namespace commands { + +CreateWindowRequest::CreateWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CreateWindowRequest::~CreateWindowRequest() {} + +bool CreateWindowRequest::CheckWindowName( + app_mngr::ApplicationSharedPtr app, + const app_mngr::WindowID window_id, + const std::string& window_name) const { + if (mobile_apis::PredefinedWindows::PRIMARY_WIDGET == window_id) { + LOG4CXX_DEBUG(logger_, + "Window name check is ignored for the primary widgets"); + return true; + } + + const bool names_are_equal = window_name == app->name().c_str(); + if (names_are_equal && + mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_ERROR(logger_, + "Regular widget can't have the same name as application: " + << window_name); + return false; + } + + const WindowNames window_names = app->GetWindowNames(); + return !helpers::in_range(window_names, window_name); +} + +void CreateWindowRequest::ApplyWindowInitialState( + ApplicationSharedPtr app) const { + const mobile_apis::WindowType::eType window_type = + static_cast<mobile_apis::WindowType::eType>( + (*message_)[strings::msg_params][strings::window_type].asInt()); + + // State should be initialized with INVALID_ENUM value to let state controller + // trigger OnHmiStatus notifiation sending + HmiStatePtr initial_state = application_manager_.CreateRegularState( + app, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::INVALID_ENUM); + + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + const std::string window_name = + (*message_)[strings::msg_params][strings::window_name].asString(); + + smart_objects::SmartObject window_info(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists( + strings::associated_service_type)) { + window_info[strings::associated_service_type] = + (*message_)[strings::msg_params][strings::associated_service_type]; + } + if ((*message_)[strings::msg_params].keyExists( + strings::duplicate_updates_from_window_id)) { + window_info[strings::duplicate_updates_from_window_id] = + (*message_)[strings::msg_params] + [strings::duplicate_updates_from_window_id]; + } + + window_info[strings::window_name] = window_name; + + app->SetWindowInfo(window_id, window_info); + + app->SetInitialState(window_id, window_name, initial_state); + + // Default HMI level for all windows except the main one is always NONE + application_manager_.state_controller().OnAppWindowAdded( + app, window_id, window_type, mobile_apis::HMILevel::HMI_NONE); +} + +app_mngr::WindowID CreateWindowRequest::window_id() const { + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + +void CreateWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + const auto application = application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + const auto window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + if (application->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does already exist"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + const auto window_type = + (*message_)[strings::msg_params][strings::window_type].asInt(); + + if (mobile_apis::WindowType::eType::MAIN == window_type) { + LOG4CXX_ERROR(logger_, "MAIN application window already exists"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + + if ((*message_)[strings::msg_params].keyExists( + strings::duplicate_updates_from_window_id)) { + const auto duplicate_updates_from_window_id = + (*message_)[strings::msg_params] + [strings::duplicate_updates_from_window_id] + .asInt(); + if (!application->WindowIdExists(duplicate_updates_from_window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << duplicate_updates_from_window_id + << " does not exist"); + SendResponse(false, mobile_apis::Result::INVALID_DATA); + return; + } + } + + const std::string window_name = + (*message_)[strings::msg_params][strings::window_name].asString(); + if (!CheckWindowName(application, window_id, window_name)) { + LOG4CXX_ERROR(logger_, + "Window name \"" << window_name + << "\" is disallowed for window #" + << window_id); + SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); + return; + } + + if (!ValidateWindowCreation(application, window_id)) { + return; + } + + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_CreateWindow, &msg_params, true); +} + +void CreateWindowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::UI_CreateWindow != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + auto application = application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + LOG4CXX_INFO(logger_, "Received CreateWindow event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + const smart_objects::SmartObject& response_message = event.smart_object(); + const auto result_code = CommandRequestImpl::GetMobileResultCode( + static_cast<hmi_apis::Common_Result::eType>( + response_message[strings::params][hmi_response::code].asInt())); + + const bool is_success = IsMobileResultSuccess(result_code); + std::string response_info; + GetInfo(response_message, response_info); + + if (!is_success) { + LOG4CXX_ERROR(logger_, "CreateWindow request has failed on HMI side"); + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); + return; + } + + ApplyWindowInitialState(application); + + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); +} + +bool CreateWindowRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +bool CreateWindowRequest::IsWindowForAssociatedServiceCreated( + app_mngr::ApplicationSharedPtr app) const { + LOG4CXX_AUTO_TRACE(logger_); + + const auto window_optional_params_map = + app->window_optional_params_map().GetData(); + + if (!(*message_)[strings::msg_params].keyExists( + strings::associated_service_type)) { + return false; + } + + const auto associated_service_type = + (*message_)[strings::msg_params][strings::associated_service_type] + .asString(); + + const auto find_res = std::find_if( + window_optional_params_map.begin(), + window_optional_params_map.end(), + [&associated_service_type]( + const std::pair<WindowID, smart_objects::SmartObjectSPtr>& element) { + LOG4CXX_DEBUG(logger_, + "Searching for " << associated_service_type + << " in window info for id " + << element.first); + if (element.second->keyExists(strings::associated_service_type) && + associated_service_type == + (*element.second)[strings::associated_service_type] + .asString()) { + return true; + } + + return false; + }); + + return find_res != window_optional_params_map.end(); +} + +bool CreateWindowRequest::DoesExceedMaxAllowedWindows( + app_mngr::ApplicationSharedPtr app) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto get_current_number_of_windows = + [&app](const mobile_apis::WindowType::eType window_type) -> size_t { + switch (window_type) { + case mobile_apis::WindowType::MAIN: { + return 1u; + } + case mobile_apis::WindowType::WIDGET: { + return app->window_optional_params_map().GetData().size(); + } + + default: { + LOG4CXX_WARN(logger_, "Unknown window type"); + return 0u; + } + } + }; + + const auto window_type = static_cast<mobile_apis::WindowType::eType>( + (*message_)[strings::msg_params][strings::window_type].asInt()); + + auto display_capabilities = hmi_capabilities_.system_display_capabilities(); + if (app->display_capabilities()) { + display_capabilities = app->display_capabilities(); + } + + if (!display_capabilities) { + LOG4CXX_WARN(logger_, "Application has no capabilities"); + return false; + } + + MessageHelper::PrintSmartObject(*display_capabilities); + + const auto windowTypeSupported = + (*display_capabilities)[0][strings::window_type_supported].asArray(); + + DCHECK(windowTypeSupported); + + const auto find_res = std::find_if( + windowTypeSupported->begin(), + windowTypeSupported->end(), + [&window_type](const smart_objects::SmartObject& element) { + if (window_type == static_cast<mobile_apis::WindowType::eType>( + element[strings::window_type].asInt())) { + return true; + } + + return false; + }); + + if (find_res == windowTypeSupported->end()) { + LOG4CXX_WARN(logger_, "Requested Window Type is not supported by the HMI"); + return true; + } + + if (get_current_number_of_windows(window_type) + 1 > + (*find_res)[strings::maximum_number_of_windows].asUInt()) { + return true; + } + + return false; +} + +bool CreateWindowRequest::ValidateWindowCreation( + app_mngr::ApplicationSharedPtr app, const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + + if (DoesExceedMaxAllowedWindows(app)) { + std::string info("Maximum allowed amount of windows is exceeded"); + LOG4CXX_WARN(logger_, info); + SendResponse(false, mobile_apis::Result::REJECTED, info.c_str()); + return false; + } + + if (IsWindowForAssociatedServiceCreated(app)) { + std::string info( + "Window for this associated service type is already created"); + LOG4CXX_WARN(logger_, info); + SendResponse(false, mobile_apis::Result::REJECTED, info.c_str()); + return false; + } + + return true; +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc new file mode 100644 index 0000000000..0d9bbc2815 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_window_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/create_window_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +CreateWindowResponse::CreateWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +CreateWindowResponse::~CreateWindowResponse() {} + +void CreateWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc index 38069c341e..363b14f92f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc @@ -35,8 +35,8 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -204,8 +204,9 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { if (!command) { LOG4CXX_ERROR(logger_, - "Command id " << cmd_id << " not found for " - "application with connection key " + "Command id " << cmd_id + << " not found for " + "application with connection key " << connection_key()); return; } @@ -232,4 +233,4 @@ bool DeleteCommandRequest::IsPendingResponseExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc index 8f85d50e28..919385ee50 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_response.cc @@ -61,4 +61,4 @@ void DeleteCommandResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc index cf8a6d259f..46af8353b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_request.cc @@ -68,7 +68,9 @@ void DeleteFileRequest::Run() { return; } - if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + if ((mobile_api::HMILevel::HMI_NONE == + application->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) && (application_manager_.get_settings().delete_file_in_none() <= application->delete_file_in_none_count())) { // If application is in the HMI_NONE level the quantity of allowed @@ -129,4 +131,4 @@ void DeleteFileRequest::SendFileRemovedNotification( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc index 66c61c9e4a..732a1e56b5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_file_response.cc @@ -72,4 +72,4 @@ void DeleteFileResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc index a9db3975db..7950595b1c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -34,9 +34,9 @@ #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -63,9 +63,9 @@ void DeleteInteractionChoiceSetRequest::Run() { ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, - "No application associated with connection key " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "No application associated with connection key " << connection_key()); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } @@ -165,4 +165,4 @@ void DeleteInteractionChoiceSetRequest::SendVrDeleteCommand( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc index 18ca60f255..cf5ad3a2c2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_response.cc @@ -34,8 +34,8 @@ #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -81,4 +81,4 @@ void DeleteInteractionChoiceSetResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc index 9a01163702..6aaa2406e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" #include "utils/helpers.h" @@ -200,4 +200,4 @@ bool DeleteSubMenuRequest::Init() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc index 6831a66e1e..3cefef5c38 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_response.cc @@ -61,4 +61,4 @@ void DeleteSubMenuResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc new file mode 100644 index 0000000000..7f253e25fd --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_request.cc @@ -0,0 +1,162 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/delete_window_request.h" + +#include <algorithm> + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteWindowRequest::DeleteWindowRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +DeleteWindowRequest::~DeleteWindowRequest() {} + +bool DeleteWindowRequest::CheckWindowId( + app_mngr::ApplicationSharedPtr app) const { + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id) { + LOG4CXX_ERROR(logger_, "Main application window can't be deleted"); + return false; + } + + if (!app->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does not exist"); + return false; + } + + return true; +} + +app_mngr::WindowID DeleteWindowRequest::window_id() const { + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + +void DeleteWindowRequest::DeleteWindow( + app_mngr::ApplicationSharedPtr app) const { + const WindowID window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + app->RemoveWindowInfo(window_id); + app->RemoveHMIState(window_id, HmiState::StateID::STATE_ID_REGULAR); + app->remove_window_capability(window_id); +} + +void DeleteWindowRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (!CheckWindowId(application)) { + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; + msg_params[strings::app_id] = application->hmi_app_id(); + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_DeleteWindow, &msg_params, true); +} + +void DeleteWindowRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + if (hmi_apis::FunctionID::UI_DeleteWindow != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); + return; + } + + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + + if (!application) { + LOG4CXX_ERROR(logger_, "Application is not registered"); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + LOG4CXX_INFO(logger_, "Received DeleteWindow event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + + const smart_objects::SmartObject& response_message = event.smart_object(); + const auto result_code = CommandRequestImpl::GetMobileResultCode( + static_cast<hmi_apis::Common_Result::eType>( + response_message[strings::params][hmi_response::code].asInt())); + + const bool is_success = IsMobileResultSuccess(result_code); + std::string response_info; + GetInfo(response_message, response_info); + + if (!is_success) { + LOG4CXX_ERROR(logger_, "DeleteWindow request has failed on HMI side"); + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); + return; + } + + DeleteWindow(application); + + SendResponse(is_success, + result_code, + response_info.empty() ? nullptr : response_info.c_str()); +} + +bool DeleteWindowRequest::Init() { + hash_update_mode_ = HashUpdateMode::kDoHashUpdate; + return true; +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc new file mode 100644 index 0000000000..f9ac9a46d6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_window_response.cc @@ -0,0 +1,64 @@ +/* + + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/delete_window_response.h" +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +DeleteWindowResponse::DeleteWindowResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +DeleteWindowResponse::~DeleteWindowResponse() {} + +void DeleteWindowResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc index ee0297ded6..1de7a3ea03 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_request.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" #include <algorithm> #include <string> -#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" #include "application_manager/application_impl.h" @@ -153,4 +153,4 @@ void DialNumberRequest::StripNumberParam(std::string& number) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc index a264f96e0d..4385b3fe90 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/dial_number_response.cc @@ -60,4 +60,4 @@ void DialNumberResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc index 3650a8226c..66ff7b48d5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_request.cc @@ -97,4 +97,4 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc index f9f9f89d11..6c9bd05e09 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/end_audio_pass_thru_response.cc @@ -61,4 +61,4 @@ void EndAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc index b0715225e4..fda6cc64e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/generic_response.cc @@ -63,4 +63,4 @@ void GenericResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc index 34ed30c243..0b7e611e59 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_request.cc @@ -1,4 +1,5 @@ #include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc index 813a9e7006..f50897303a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_cloud_app_properties_response.cc @@ -1,6 +1,6 @@ +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -28,4 +28,4 @@ void GetCloudAppPropertiesResponse::Run() { } } // namespace commands -} // namespace sdl_rpc_plugins +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc index a582670426..75263494c2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_file_request.cc @@ -32,20 +32,20 @@ #include "sdl_rpc_plugin/commands/mobile/get_file_request.h" +#include <boost/crc.hpp> #include "application_manager/app_service_manager.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/message_helper.h" #include "utils/file_system.h" -#include <boost/crc.hpp> namespace { /** -* Calculates CRC32 checksum -* @param binary_data - input data for which CRC32 should be calculated -* @return calculated CRC32 checksum -*/ + * Calculates CRC32 checksum + * @param binary_data - input data for which CRC32 should be calculated + * @return calculated CRC32 checksum + */ uint32_t GetCrc32CheckSum(const std::vector<uint8_t>& binary_data) { const std::size_t file_size = binary_data.size(); boost::crc_32_type result; @@ -195,9 +195,9 @@ void GetFileRequest::Run() { } if (offset_ > file_size) { - LOG4CXX_ERROR(logger_, - "Offset " << offset_ << " greater than file size " - << file_size); + LOG4CXX_ERROR( + logger_, + "Offset " << offset_ << " greater than file size " << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Offset greater than file size", @@ -309,9 +309,9 @@ void GetFileRequest::on_event(const app_mngr::event_engine::Event& event) { } if (offset_ > file_size) { - LOG4CXX_ERROR(logger_, - "Offset " << offset_ << " greater than file size " - << file_size); + LOG4CXX_ERROR( + logger_, + "Offset " << offset_ << " greater than file size " << file_size); SendResponse(false, mobile_apis::Result::INVALID_DATA, "Offset greater than file size", diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc index 5c6839660f..6121747ccc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_request.cc @@ -32,10 +32,10 @@ #include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" -#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include <set> #include "application_manager/app_service_manager.h" #include "application_manager/message_helper.h" -#include <set> +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -133,6 +133,17 @@ void GetSystemCapabilityRequest::Run() { } break; } + case mobile_apis::SystemCapabilityType::SEAT_LOCATION: { + if (hmi_capabilities.seat_location_capability()) { + response_params[strings::system_capability] + [strings::seat_location_capability] = + *hmi_capabilities.seat_location_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] @@ -146,9 +157,26 @@ void GetSystemCapabilityRequest::Run() { case mobile_apis::SystemCapabilityType::APP_SERVICES: { auto all_services = application_manager_.GetAppServiceManager().GetAllServiceRecords(); - response_params - [strings::system_capability][strings::app_services_capabilities] = - MessageHelper::CreateAppServiceCapabilities(all_services); + response_params[strings::system_capability] + [strings::app_services_capabilities] = + MessageHelper::CreateAppServiceCapabilities( + all_services); + break; + } + case mobile_apis::SystemCapabilityType::DISPLAYS: { + auto capabilities = hmi_capabilities.system_display_capabilities(); + if (app->display_capabilities()) { + capabilities = app->display_capabilities(); + } + + if (!capabilities) { + SendResponse(false, mobile_apis::Result::DATA_NOT_AVAILABLE); + LOG4CXX_INFO(logger_, "system_display_capabilities are not available"); + return; + } + + response_params[strings::system_capability] + [strings::display_capabilities] = *capabilities; break; } default: // Return unsupported resource @@ -156,22 +184,33 @@ void GetSystemCapabilityRequest::Run() { return; } - if ((*message_)[app_mngr::strings::msg_params].keyExists( - strings::subscribe)) { - auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); - if ((*message_)[app_mngr::strings::msg_params][strings::subscribe] - .asBool() == true) { - LOG4CXX_DEBUG(logger_, - "Subscribe to system capability: " << response_type); - ext.SubscribeTo(response_type); - } else { - LOG4CXX_DEBUG(logger_, - "Unsubscribe from system capability: " << response_type); - ext.UnsubscribeFrom(response_type); + const char* info = nullptr; + // Ignore subscription/unsubscription for DISPLAYS type + if (mobile_apis::SystemCapabilityType::DISPLAYS != response_type) { + if ((*message_)[app_mngr::strings::msg_params].keyExists( + strings::subscribe)) { + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + if ((*message_)[app_mngr::strings::msg_params][strings::subscribe] + .asBool() == true) { + LOG4CXX_DEBUG(logger_, + "Subscribe to system capability: " << response_type); + ext.SubscribeTo(response_type); + } else { + LOG4CXX_DEBUG(logger_, + "Unsubscribe from system capability: " << response_type); + ext.UnsubscribeFrom(response_type); + } + } + } else { + if ((*message_)[app_mngr::strings::msg_params].keyExists( + strings::subscribe)) { + info = + "Subscribe parameter is ignored. Auto Subscription/Unsubscription is " + "used for DISPLAY capability type."; } } - SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + SendResponse(true, mobile_apis::Result::SUCCESS, info, &response_params); } void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) { @@ -179,4 +218,4 @@ void GetSystemCapabilityRequest::on_event(const event_engine::Event& event) { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc index dd5461081c..5df0c72607 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_system_capability_response.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -61,4 +61,4 @@ void GetSystemCapabilityResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc index 7dc9eb9ad9..cd7d7a37b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/get_way_points_request.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace sdl_rpc_plugin { @@ -113,4 +113,4 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc index 7581990273..e481c926b8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_response.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/get_way_points_response.h" +#include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { @@ -61,4 +61,4 @@ void GetWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc index e671dab463..b8714b4784 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_request.cc @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include "sdl_rpc_plugin/commands/mobile/list_files_request.h" +#include <string> #include "application_manager/application_impl.h" @@ -70,7 +70,9 @@ void ListFilesRequest::Run() { return; } - if ((mobile_api::HMILevel::HMI_NONE == application->hmi_level()) && + if ((mobile_api::HMILevel::HMI_NONE == + application->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) && (application_manager_.get_settings().list_files_in_none() <= application->list_files_in_none_count())) { // If application is in the HMI_NONE level the quantity of allowed @@ -112,4 +114,4 @@ void ListFilesRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc index d025f05358..ffa8a443d5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/list_files_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/list_files_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,4 +62,4 @@ void ListFilesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc index 128ce1e3bf..5714043a51 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_interface_unregistered_notification.cc @@ -60,4 +60,4 @@ void OnAppInterfaceUnregisteredNotification::Run() { SendNotification(); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc index ff88ae96bd..3088c7df33 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_audio_pass_thru_notification.cc @@ -57,4 +57,4 @@ void OnAudioPassThruNotification::Run() { SendNotification(); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index 79fb1f4272..0bf9b40cb6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -79,9 +79,8 @@ void OnButtonEventNotification::Run() { (*message_)[strings::msg_params][strings::app_id].asUInt()); // custom_button_id is mandatory for CUSTOM_BUTTON notification - if (false == - (*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { + if (false == (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonEvent without custom_button_id."); return; @@ -103,8 +102,11 @@ void OnButtonEventNotification::Run() { return; } - if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { + const auto window_id = app->GetSoftButtonWindowID(custom_btn_id); + (*message_)[strings::msg_params][strings::window_id] = window_id; + const auto window_hmi_level = app->hmi_level(window_id); + if ((mobile_api::HMILevel::HMI_FULL != window_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != window_hmi_level)) { LOG4CXX_WARN(logger_, "CUSTOM_BUTTON OnButtonEvent notification is allowed only " << "in FULL or LIMITED hmi level"); @@ -128,8 +130,11 @@ void OnButtonEventNotification::Run() { } // Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + const mobile_apis::HMILevel::eType app_hmi_level = + subscribed_app->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + if ((mobile_api::HMILevel::HMI_FULL != app_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != app_hmi_level)) { LOG4CXX_WARN(logger_, "OnButtonEvent notification is allowed only" << "in FULL or LIMITED hmi level"); @@ -180,6 +185,11 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][strings::custom_button_id]; } + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + (*on_btn_event)[strings::msg_params][strings::window_id] = + (*message_)[strings::msg_params][strings::window_id]; + } + message_ = on_btn_event; SendNotification(); } @@ -188,4 +198,4 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index c73f2b4b98..8c22844865 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -80,9 +80,8 @@ void OnButtonPressNotification::Run() { (*message_)[strings::msg_params][strings::app_id].asUInt()); // custom_button_id is mandatory for CUSTOM_BUTTON notification - if (false == - (*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { + if (false == (*message_)[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonPress without custom_button_id."); return; @@ -105,8 +104,12 @@ void OnButtonPressNotification::Run() { } // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { + const auto window_id = app->GetSoftButtonWindowID(custom_btn_id); + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + (*message_)[strings::msg_params][strings::window_id] = window_id; + const auto window_hmi_level = app->hmi_level(window_id); + if ((mobile_api::HMILevel::HMI_FULL != window_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != window_hmi_level)) { LOG4CXX_WARN(logger_, "CUSTOM_BUTTON OnButtonPress notification is allowed only " << "in FULL or LIMITED hmi level"); @@ -130,8 +133,11 @@ void OnButtonPressNotification::Run() { } // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + const mobile_apis::HMILevel::eType app_hmi_level = + subscribed_app->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + if ((mobile_api::HMILevel::HMI_FULL != app_hmi_level) && + (mobile_api::HMILevel::HMI_LIMITED != app_hmi_level)) { LOG4CXX_WARN(logger_, "OnButtonPress notification is allowed only" << "in FULL or LIMITED hmi level"); @@ -188,6 +194,11 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*message_)[strings::msg_params][strings::custom_button_id]; } + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + (*on_btn_press)[strings::msg_params][strings::window_id] = + (*message_)[strings::msg_params][strings::window_id]; + } + message_ = on_btn_press; SendNotification(); } @@ -196,4 +207,4 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc index dff3aa6808..9c7edf74e6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_command_notification.cc @@ -84,4 +84,4 @@ void OnCommandNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc index ca5d4bfed4..42a1928f2e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_driver_distraction_notification.cc @@ -67,4 +67,4 @@ void OnDriverDistractionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc index e252b031e6..c2ce2550b9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hash_change_notification.cc @@ -34,9 +34,9 @@ #include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" +#include <string> #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" -#include <string> namespace sdl_rpc_plugin { using namespace application_manager; @@ -81,4 +81,4 @@ void OnHashChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc index 6b5838e40a..df3bce0154 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h" -#include "application_manager/message_helper.h" #include "application_manager/message.h" +#include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { @@ -92,4 +92,4 @@ void OnHMIStatusNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc index c4ee22afed..28325a40f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification_from_mobile.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h" -#include "application_manager/message_helper.h" #include "application_manager/message.h" +#include "application_manager/message_helper.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -132,4 +132,4 @@ void OnHMIStatusNotificationFromMobile::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc index 04b52f29e1..1c0609e17d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_keyboard_input_notification.cc @@ -76,7 +76,8 @@ void OnKeyBoardInputNotification::Run() { break; } - if (mobile_apis::HMILevel::eType::HMI_FULL == app->hmi_level()) { + if (mobile_apis::HMILevel::eType::HMI_FULL == + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) { LOG4CXX_INFO(logger_, "There is application in HMI_FULL level"); app_to_notify = app; } @@ -93,4 +94,4 @@ void OnKeyBoardInputNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc index fdbdd910a0..9605fd6074 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_language_change_notification.cc @@ -60,4 +60,4 @@ void OnLanguageChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc index 32d940aca2..f64ca34bf2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_permissions_change_notification.cc @@ -62,4 +62,4 @@ void OnPermissionsChangeNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc index a8544ae643..cc6ab7b65b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_capability_updated_notification.cc @@ -2,6 +2,7 @@ #include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" +#include "application_manager/display_capabilities_builder.h" #include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" #include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" @@ -31,10 +32,11 @@ void OnSystemCapabilityUpdatedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - mobile_apis::SystemCapabilityType::eType system_capability_type = static_cast< - mobile_apis::SystemCapabilityType::eType>( - msg_params[strings::system_capability][strings::system_capability_type] - .asInt()); + const auto system_capability_type = + static_cast<mobile_apis::SystemCapabilityType::eType>( + msg_params[strings::system_capability] + [strings::system_capability_type] + .asInt()); switch (system_capability_type) { case mobile_apis::SystemCapabilityType::NAVIGATION: { @@ -100,21 +102,24 @@ void OnSystemCapabilityUpdatedNotification::Run() { for (size_t i = 0; i < updated_capabilities.length(); i++) { std::string service_id = updated_capabilities[i][strings::updated_app_service_record] - [strings::service_id].asString(); - auto matching_service_predicate = [&service_id]( - const smart_objects::SmartObject& app_service_capability) { - return service_id == - app_service_capability[strings::updated_app_service_record] - [strings::service_id].asString(); - }; + [strings::service_id] + .asString(); + auto matching_service_predicate = + [&service_id]( + const smart_objects::SmartObject& app_service_capability) { + return service_id == + app_service_capability[strings::updated_app_service_record] + [strings::service_id] + .asString(); + }; auto it = std::find_if(app_services->begin(), app_services->end(), matching_service_predicate); if (it != app_services->end()) { - LOG4CXX_DEBUG(logger_, - "Replacing updated record with service_id " - << service_id); + LOG4CXX_DEBUG( + logger_, + "Replacing updated record with service_id " << service_id); app_services->erase(it); } app_services->push_back(updated_capabilities[i]); @@ -123,8 +128,21 @@ void OnSystemCapabilityUpdatedNotification::Run() { [strings::app_services_capabilities] = app_service_caps; break; } - default: + + case mobile_apis::SystemCapabilityType::DISPLAYS: { + // Display capabilities content will be populated in the code after the + // switch so just breaking here + break; + } + + default: { + LOG4CXX_ERROR(logger_, + "Unknown system capability type: " + << msg_params[strings::system_capability] + [strings::system_capability_type] + .asInt()); return; + } } const char* capability_type_string; @@ -132,11 +150,34 @@ void OnSystemCapabilityUpdatedNotification::Run() { mobile_apis::SystemCapabilityType::eType>:: EnumToCString(system_capability_type, &capability_type_string); + const auto initial_connection_key = + (*message_)[strings::params][strings::connection_key].asUInt(); + auto subscribed_to_capability_predicate = - [&system_capability_type](const ApplicationSharedPtr app) { + [&system_capability_type, + &initial_connection_key](const ApplicationSharedPtr app) { DCHECK_OR_RETURN(app, false); auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); - return ext.IsSubscribedTo(system_capability_type); + if (!ext.IsSubscribedTo(system_capability_type)) { + LOG4CXX_DEBUG(logger_, + "App " << app->app_id() + << " is not subscribed to this capability type"); + return false; + } + + if (mobile_apis::SystemCapabilityType::DISPLAYS == + system_capability_type && + initial_connection_key > 0) { + LOG4CXX_DEBUG(logger_, + "Display capabilities notification for app " + << initial_connection_key << " only"); + return app->app_id() == initial_connection_key; + } + + LOG4CXX_DEBUG(logger_, + "App " << app->app_id() + << " is subscribed to specified capability type"); + return true; }; const std::vector<ApplicationSharedPtr>& applications = FindAllApps( @@ -163,6 +204,40 @@ void OnSystemCapabilityUpdatedNotification::Run() { ext.UnsubscribeFrom(system_capability_type); continue; } + + if (mobile_apis::SystemCapabilityType::DISPLAYS == system_capability_type) { + LOG4CXX_DEBUG(logger_, "Using common display capabilities"); + auto capabilities = hmi_capabilities_.system_display_capabilities(); + if (app->is_resuming() && app->is_app_data_resumption_allowed()) { + LOG4CXX_DEBUG(logger_, + "Application " + << app->app_id() + << " is resuming. Providing cached capabilities"); + auto display_caps = + app->display_capabilities_builder().display_capabilities(); + capabilities = display_caps; + } else if (app->display_capabilities()) { + LOG4CXX_DEBUG(logger_, + "Application " << app->app_id() + << " has specific display capabilities"); + const WindowID window_id = + msg_params[strings::system_capability] + [strings::display_capabilities][0] + [strings::window_capabilities][0][strings::window_id] + .asInt(); + capabilities = app->display_capabilities(window_id); + } + + if (!capabilities) { + LOG4CXX_WARN(logger_, + "No available display capabilities for sending. Skipping"); + continue; + } + + msg_params[strings::system_capability][strings::display_capabilities] = + *capabilities; + } + LOG4CXX_INFO(logger_, "Sending OnSystemCapabilityUpdated " << capability_type_string << " application id " @@ -174,4 +249,4 @@ void OnSystemCapabilityUpdatedNotification::Run() { } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index 10b0b41a58..fc99bb323c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -30,16 +30,16 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <cstring> +#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" #include <cstdio> +#include <cstring> #include <string> -#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" +#include "application_manager/application_manager.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/MOBILE_API.h" +#include "policy/policy_table/enums.h" #include "utils/file_system.h" #include "utils/helpers.h" -#include "policy/policy_table/enums.h" -#include "application_manager/application_manager.h" -#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -86,8 +86,8 @@ void OnSystemRequestNotification::Run() { static_cast<rpc::policy_table_interface_base::RequestType>( request_type)); - if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(), - request_type)) { + if (!policy_handler.IsRequestTypeAllowed( + app->device(), app->policy_app_id(), request_type)) { LOG4CXX_WARN(logger_, "Request type " << stringified_request_type << " is not allowed by policies"); @@ -129,11 +129,11 @@ void OnSystemRequestNotification::Run() { } if (mobile_apis::RequestType::PROPRIETARY == request_type) { -/* According to requirements: - "If the requestType = PROPRIETARY, add to mobile API fileType = JSON - If the requestType = HTTP, add to mobile API fileType = BINARY" - Also in Genivi SDL we don't save the PT to file - we put it directly in - binary_data */ + /* According to requirements: + "If the requestType = PROPRIETARY, add to mobile API fileType = JSON + If the requestType = HTTP, add to mobile API fileType = BINARY" + Also in Genivi SDL we don't save the PT to file - we put it directly in + binary_data */ #if defined(PROPRIETARY_MODE) AddHeader(binary_data); @@ -246,4 +246,4 @@ size_t OnSystemRequestNotification::ParsePTString( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc index 503f1b04d5..0a8420b6a3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_tbt_client_state_notification.cc @@ -67,7 +67,8 @@ void OnTBTClientStateNotification::Run() { std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin(); for (; applications.end() != it; ++it) { ApplicationSharedPtr app = *it; - if (mobile_apis::HMILevel::eType::HMI_NONE != app->hmi_level()) { + if (mobile_apis::HMILevel::eType::HMI_NONE != + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) { (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotification(); } @@ -76,4 +77,4 @@ void OnTBTClientStateNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc index 502f0ae57d..6ceb381d2e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_touch_event_notification.cc @@ -93,4 +93,4 @@ void OnTouchEventNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc index 2f666ffc03..e89ede53b9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc @@ -67,4 +67,4 @@ void OnWayPointChangeNotification::Run() { } } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc index c90038a8b7..0481542565 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <cstring> #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" +#include <cstring> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" @@ -87,7 +87,8 @@ void PerformAudioPassThruRequest::Run() { return; } - if (mobile_api::HMILevel::HMI_NONE == app->hmi_level()) { + if (mobile_api::HMILevel::HMI_NONE == + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) { LOG4CXX_ERROR(logger_, "application isn't activated"); SendResponse(false, mobile_apis::Result::REJECTED); return; @@ -113,9 +114,9 @@ void PerformAudioPassThruRequest::Run() { initial_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse( false, mobile_apis::Result::FILE_NOT_FOUND, @@ -450,4 +451,4 @@ bool PerformAudioPassThruRequest::IsWaitingHMIResponse() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc index a5eb98f2ba..5dae6327eb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_response.cc @@ -61,4 +61,4 @@ void PerformAudioPassThruResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index 42489fd8bd..622f64f792 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -31,20 +31,20 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <numeric> +#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" #include <string.h> +#include <numeric> #include <string> -#include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" -#include "utils/file_system.h" -#include "utils/helpers.h" +#include "interfaces/MOBILE_API.h" #include "utils/custom_string.h" +#include "utils/file_system.h" #include "utils/gen_hash.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -82,17 +82,18 @@ PerformInteractionRequest::~PerformInteractionRequest() {} bool PerformInteractionRequest::Init() { /* Timeout in milliseconds. If omitted a standard value of 10000 milliseconds is used.*/ - if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { - default_timeout_ = - (*message_)[strings::msg_params][strings::timeout].asUInt(); - } + const auto& msg_params = (*message_)[strings::msg_params]; + uint32_t request_timeout = msg_params[strings::timeout].asUInt(); interaction_mode_ = static_cast<mobile_apis::InteractionMode::eType>( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()); + msg_params[strings::interaction_mode].asInt()); if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { - default_timeout_ *= 2; + const uint32_t increase_value = 2; + default_timeout_ += request_timeout * increase_value; + } else { + default_timeout_ += request_timeout; } return true; } @@ -284,7 +285,7 @@ void PerformInteractionRequest::onTimeOut() { CommandRequestImpl::onTimeOut(); } else { application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout_); } break; } @@ -341,7 +342,7 @@ bool PerformInteractionRequest::ProcessVRResponse( } LOG4CXX_DEBUG(logger_, "Update timeout for UI"); application_manager_.updateRequestTimeout( - connection_key(), correlation_id(), default_timeout()); + connection_key(), correlation_id(), default_timeout_); return false; } @@ -358,6 +359,13 @@ bool PerformInteractionRequest::ProcessVRResponse( msg_params[strings::choice_id] = choice_id; } + if (mobile_apis::InteractionMode::BOTH == interaction_mode_ || + mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { + LOG4CXX_DEBUG(logger_, "Update timeout for UI"); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), default_timeout_); + } + const bool is_vr_result_success = Compare<Common_Result::eType, EQ, ONE>( vr_result_code_, Common_Result::SUCCESS, Common_Result::WARNINGS); @@ -449,6 +457,11 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + mobile_apis::InteractionMode::eType mode = static_cast<mobile_apis::InteractionMode::eType>( (*message_)[strings::msg_params][strings::interaction_mode].asInt()); @@ -471,12 +484,8 @@ void PerformInteractionRequest::SendUIPerformInteractionRequest( } } - if (mobile_apis::InteractionMode::BOTH == mode || - mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - msg_params[strings::timeout] = default_timeout_ / 2; - } else { - msg_params[strings::timeout] = default_timeout_; - } + msg_params[strings::timeout] = + (*message_)[strings::msg_params][strings::timeout].asUInt(); msg_params[strings::app_id] = app->app_id(); if (mobile_apis::InteractionMode::VR_ONLY != mode) { msg_params[strings::choice_set] = @@ -532,6 +541,11 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + smart_objects::SmartObject& choice_list = (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; @@ -560,9 +574,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("help_prompt"); } else { msg_params[strings::help_prompt] = help_prompt; @@ -608,9 +622,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( timeout_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("timeout_prompt"); } else { msg_params[strings::timeout_prompt] = timeout_prompt; @@ -629,9 +643,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( initial_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("initial_prompt"); } else { msg_params[strings::initial_prompt] = initial_prompt; @@ -652,16 +666,9 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( return; } - mobile_apis::InteractionMode::eType mode = - static_cast<mobile_apis::InteractionMode::eType>( - (*message_)[strings::msg_params][strings::interaction_mode].asInt()); - - if (mobile_apis::InteractionMode::BOTH == mode || - mobile_apis::InteractionMode::MANUAL_ONLY == mode) { - msg_params[strings::timeout] = default_timeout_ / 2; - } else { - msg_params[strings::timeout] = default_timeout_; - } + msg_params[strings::timeout] = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + ; msg_params[strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VR); SendHMIRequest( @@ -1065,4 +1072,4 @@ void PerformInteractionRequest::SendBothModeResponse( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc index 85bef9b2ad..fa02641c2b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_response.cc @@ -61,4 +61,4 @@ void PerformInteractionResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc index b418f52fa3..e25215fb48 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc @@ -31,22 +31,22 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <algorithm> #include "sdl_rpc_plugin/commands/mobile/put_file_request.h" +#include <algorithm> -#include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/rpc_service.h" -#include "utils/file_system.h" #include <boost/crc.hpp> +#include "utils/file_system.h" namespace { /** -* Calculates CRC32 checksum -* @param binary_data - input data for which CRC32 should be calculated -* @return calculated CRC32 checksum -*/ + * Calculates CRC32 checksum + * @param binary_data - input data for which CRC32 should be calculated + * @return calculated CRC32 checksum + */ uint32_t GetCrc32CheckSum(const std::vector<uint8_t>& binary_data) { const std::size_t file_size = binary_data.size(); boost::crc_32_type result; @@ -94,7 +94,9 @@ void PutFileRequest::Run() { return; } - if (mobile_api::HMILevel::HMI_NONE == application->hmi_level() && + if (mobile_api::HMILevel::HMI_NONE == + application->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW) && application_manager_.get_settings().put_file_in_none() <= application->put_file_in_none_count()) { // If application is in the HMI_NONE level the quantity of allowed @@ -284,9 +286,7 @@ void PutFileRequest::Run() { } SendResponse(true, save_result, "File was downloaded", &response_params); - if (is_system_file) { - SendOnPutFileNotification(); - } + SendOnPutFileNotification(is_system_file); break; } default: @@ -297,7 +297,7 @@ void PutFileRequest::Run() { } } -void PutFileRequest::SendOnPutFileNotification() { +void PutFileRequest::SendOnPutFileNotification(bool is_system_file) { LOG4CXX_INFO(logger_, "SendOnPutFileNotification"); smart_objects::SmartObjectSPtr notification = std::make_shared<smart_objects::SmartObject>( @@ -316,9 +316,10 @@ void PutFileRequest::SendOnPutFileNotification() { message[strings::msg_params][strings::length] = length_; message[strings::msg_params][strings::persistent_file] = is_persistent_file_; message[strings::msg_params][strings::file_type] = file_type_; + message[strings::msg_params][strings::is_system_file] = is_system_file; rpc_service_.ManageHMICommand(notification); } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc index 8c54970a5c..f9ddbf7717 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/put_file_response.h" -#include "utils/file_system.h" #include "application_manager/application_impl.h" +#include "utils/file_system.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -70,4 +70,4 @@ void PutFileResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 924705f82b..14a94fd1a2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -33,19 +33,19 @@ #include "sdl_rpc_plugin/commands/mobile/register_app_interface_request.h" +#include <string.h> #include <unistd.h> #include <algorithm> #include <map> -#include <string.h> -#include "application_manager/application_manager.h" -#include "application_manager/policies/policy_handler_interface.h" -#include "application_manager/application_impl.h" #include "application_manager/app_launch/app_launch_ctrl.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager.h" +#include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" -#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/helpers/application_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/rpc_service.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" @@ -158,15 +158,16 @@ class SmartArrayValueExtractor { }; struct IsSameNickname { - IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} + IsSameNickname(const custom_str::CustomString app_name) + : app_name_(app_name) {} bool operator()(const policy::StringArray::value_type& nickname) const { - return app_id_.CompareIgnoreCase(nickname.c_str()); + return app_name_.CompareIgnoreCase(nickname.c_str()); } private: - const custom_str::CustomString& app_id_; + const custom_str::CustomString app_name_; }; -} +} // namespace namespace sdl_rpc_plugin { using namespace application_manager; @@ -184,7 +185,8 @@ RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( rpc_service, hmi_capabilities, policy_handler) - , result_code_(mobile_apis::Result::INVALID_ENUM) {} + , result_code_(mobile_apis::Result::INVALID_ENUM) + , device_handle_(0) {} RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} @@ -224,20 +226,38 @@ void RegisterAppInterfaceRequest::Run() { return; } + // Cache the original app ID (for legacy behavior) + const auto policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); + + if (application_manager_.IsApplicationForbidden(connection_key(), + policy_app_id)) { + SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); + return; + } + + if (!GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_)) { + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Could not find a session for your connection key!"); + return; + } + + LOG4CXX_DEBUG( + logger_, + "device_handle: " << device_handle_ << " device_id: " << device_id_); + if (IsApplicationSwitched()) { return; } ApplicationSharedPtr application = - application_manager_.application(connection_key()); + application_manager_.application(device_id_, policy_app_id); if (application) { SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return; } - // cache the original app ID (for legacy behavior) - const std::string policy_app_id = - application_manager_.GetCorrectMobileIDFromMessage(message_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -260,11 +280,6 @@ void RegisterAppInterfaceRequest::Run() { ::tolower); (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; } - if (application_manager_.IsApplicationForbidden(connection_key(), - policy_app_id)) { - SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); - return; - } if (IsApplicationWithSameAppIdRegistered()) { SendResponse(false, mobile_apis::Result::DISALLOWED); @@ -400,9 +415,9 @@ void RegisterAppInterfaceRequest::Run() { tts_name, application, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_WARN(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_WARN( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); response_info_ = "One or more files needed for tts_name are not present"; result_code_ = mobile_apis::Result::WARNINGS; } @@ -454,17 +469,16 @@ void RegisterAppInterfaceRequest::Run() { // Add device to policy table and set device info, if any policy::DeviceParams dev_params; - if (-1 == - application_manager_.connection_handler() - .get_session_observer() - .GetDataOnDeviceID(application->device(), - &dev_params.device_name, - NULL, - &dev_params.device_mac_address, - &dev_params.device_connection_type)) { - LOG4CXX_ERROR(logger_, - "Failed to extract information for device " - << application->device()); + if (-1 == application_manager_.connection_handler() + .get_session_observer() + .GetDataOnDeviceID(application->device(), + &dev_params.device_name, + NULL, + &dev_params.device_mac_address, + &dev_params.device_connection_type)) { + LOG4CXX_ERROR( + logger_, + "Failed to extract information for device " << application->device()); } policy::DeviceInfo device_info; device_info.AdoptDeviceType(dev_params.device_connection_type); @@ -614,15 +628,9 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, } if (hmi_capabilities.audio_pass_thru_capabilities()) { - if (smart_objects::SmartType_Array == - hmi_capabilities.audio_pass_thru_capabilities()->getType()) { - // hmi_capabilities json contains array and HMI response object - response_params[strings::audio_pass_thru_capabilities] = - *hmi_capabilities.audio_pass_thru_capabilities(); - } else { - response_params[strings::audio_pass_thru_capabilities][0] = - *hmi_capabilities.audio_pass_thru_capabilities(); - } + // hmi_capabilities json contains array and HMI response object + response_params[strings::audio_pass_thru_capabilities] = + *hmi_capabilities.audio_pass_thru_capabilities(); } response_params[strings::hmi_capabilities] = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -634,6 +642,11 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, hmi_capabilities.video_streaming_supported(); response_params[strings::hmi_capabilities][strings::remote_control] = hmi_capabilities.rc_supported(); + response_params[strings::hmi_capabilities][strings::app_services] = true; + // Apps are automatically subscribed to the SystemCapability: DISPLAYS + response_params[strings::hmi_capabilities][strings::displays] = true; + response_params[strings::hmi_capabilities][strings::seat_location] = + hmi_capabilities.seat_location_capability() ? true : false; } void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( @@ -786,15 +799,16 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( return; } - bool resumption = + const bool hash_id_present = (*message_)[strings::msg_params].keyExists(strings::hash_id); + const std::string hash_id = + (*message_)[strings::msg_params][strings::hash_id].asString(); + const bool resumption = hash_id_present && !hash_id.empty(); bool need_restore_vr = resumption; - std::string hash_id; std::string add_info; if (resumption) { - hash_id = (*message_)[strings::msg_params][strings::hash_id].asString(); if (!resumer.CheckApplicationHash(application, hash_id)) { LOG4CXX_WARN(logger_, "Hash from RAI does not match to saved resume data."); @@ -808,6 +822,8 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( need_restore_vr = false; } else { add_info = "Resume succeeded."; + application->set_app_data_resumption_allowance(true); + application->set_is_resuming(true); } } if ((mobile_apis::Result::SUCCESS == result_code) && @@ -816,10 +832,18 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( result_code = result_code_; } - // in case application exist in resumption we need to send resumeVrgrammars - if (false == resumption) { - resumption = resumer.IsApplicationSaved(application->policy_app_id(), - application->mac_address()); + // In case application exist in resumption we need to send resumeVrgrammars + const bool is_app_saved_in_resumption = resumer.IsApplicationSaved( + application->policy_app_id(), application->mac_address()); + + // If app is in resuming state + // DisplayCapabilitiesBuilder has to collect all the information + // from incoming HMI notifications and send only one notification + // to mobile app, even if hash does not match, which means that app data + // will not be resumed, notification should be sent for default window as + // it will be resumed in any case + if (resumption || is_app_saved_in_resumption) { + resumer.StartWaitingForDisplayCapabilitiesUpdate(application); } AppHmiTypes hmi_types; @@ -836,14 +860,15 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } } policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( - application->policy_app_id(), hmi_types); + application->mac_address(), application->policy_app_id(), hmi_types); response_params[strings::icon_resumed] = file_system::FileExists(application->app_icon_path()); SendResponse(true, result_code, add_info.c_str(), &response_params); if (msg_params.keyExists(strings::app_hmi_type)) { - GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(), + GetPolicyHandler().SetDefaultHmiTypes(application->device(), + application->policy_app_id(), &(msg_params[strings::app_hmi_type])); } @@ -857,11 +882,13 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( // Start PTU after successfull registration // Sends OnPermissionChange notification to mobile right after RAI response // and HMI level set-up - GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id()); + GetPolicyHandler().OnAppRegisteredOnMobile(application->mac_address(), + application->policy_app_id()); - if (result_code != mobile_apis::Result::RESUME_FAILED) { + if (result_code != mobile_apis::Result::RESUME_FAILED && + application->is_app_data_resumption_allowed()) { resumer.StartResumption(application, hash_id); - } else { + } else if (is_app_saved_in_resumption) { resumer.StartResumptionOnlyHMILevel(application); } @@ -962,48 +989,72 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence( const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - ApplicationSet accessor = application_manager_.applications().GetData(); + auto compare_tts_name = [](const smart_objects::SmartObject& obj_1, + const smart_objects::SmartObject& obj_2) { + return obj_1[application_manager::strings::text] + .asCustomString() + .CompareIgnoreCase( + obj_2[application_manager::strings::text].asCustomString()); + }; - ApplicationSetConstIt it = accessor.begin(); - const custom_str::CustomString& app_name = - msg_params[strings::app_name].asCustomString(); + const auto& accessor = application_manager_.applications().GetData(); + const auto& app_name = msg_params[strings::app_name].asCustomString(); - for (; accessor.end() != it; ++it) { - // name check - const custom_str::CustomString& cur_name = (*it)->name(); + for (const auto& app : accessor) { + if (app->device() != device_handle_) { + continue; + } + // Name check + const auto& cur_name = app->name(); if (app_name.CompareIgnoreCase(cur_name)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } - - const smart_objects::SmartObject* vr = (*it)->vr_synonyms(); - const std::vector<smart_objects::SmartObject>* curr_vr = NULL; - if (NULL != vr) { - curr_vr = vr->asArray(); + const auto vr = app->vr_synonyms(); + if (vr) { + const auto curr_vr = vr->asArray(); CoincidencePredicateVR v(app_name); if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) { LOG4CXX_ERROR(logger_, "Application name is known already."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } } - // vr check + // VR check if (msg_params.keyExists(strings::vr_synonyms)) { - const std::vector<smart_objects::SmartObject>* new_vr = - msg_params[strings::vr_synonyms].asArray(); + const auto new_vr = msg_params[strings::vr_synonyms].asArray(); CoincidencePredicateVR v(cur_name); if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) { LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name ."); - out_duplicate_apps.push_back(*it); + out_duplicate_apps.push_back(app); continue; } - } // end vr check + } // End vr check + + // TTS check + if (msg_params.keyExists(strings::tts_name) && app->tts_name()) { + const auto tts_array = msg_params[strings::tts_name].asArray(); + const auto tts_curr = app->tts_name()->asArray(); + const auto& it_tts = std::find_first_of(tts_array->begin(), + tts_array->end(), + tts_curr->begin(), + tts_curr->end(), + compare_tts_name); + if (it_tts != tts_array->end()) { + LOG4CXX_ERROR( + logger_, + "TTS name: " + << (*it_tts)[strings::text].asCustomString().AsMBString() + << " is known already"); + return mobile_apis::Result::DUPLICATE_NAME; + } + } // End tts check - } // application for end + } // Application for end if (!out_duplicate_apps.empty()) { return mobile_apis::Result::DUPLICATE_NAME; @@ -1132,14 +1183,19 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { const custom_string::CustomString mobile_app_id( application_manager_.GetCorrectMobileIDFromMessage(message_)); - const ApplicationSet& applications = - application_manager_.applications().GetData(); - - ApplicationSetConstIt it = applications.begin(); - ApplicationSetConstIt it_end = applications.end(); - - for (; it != it_end; ++it) { - if (mobile_app_id.CompareIgnoreCase((*it)->policy_app_id().c_str())) { + const auto& applications = application_manager_.applications().GetData(); + + for (const auto& app : applications) { + if (mobile_app_id.CompareIgnoreCase(app->policy_app_id().c_str())) { + if (app->device() != device_handle_) { + LOG4CXX_DEBUG(logger_, + "These policy_app_id equal, but applications have " + "different device id" + << " mobile_app_id: " << mobile_app_id.c_str() + << " device_handle: " << device_handle_ + << " device_handle: " << app->device()); + continue; + } return true; } } @@ -1212,7 +1268,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::hardware)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::hardware].asCharArray(); + [strings::hardware] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info hardware syntax check failed"); @@ -1223,7 +1280,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::firmware_rev)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::firmware_rev].asCharArray(); + [strings::firmware_rev] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info firmware_rev syntax check failed"); @@ -1244,7 +1302,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::os_version)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::os_version].asCharArray(); + [strings::os_version] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info os_version syntax check failed"); @@ -1255,7 +1314,8 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params][strings::device_info].keyExists( strings::carrier)) { str = (*message_)[strings::msg_params][strings::device_info] - [strings::carrier].asCharArray(); + [strings::carrier] + .asCharArray(); if (strlen(str) && !CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid device_info carrier syntax check failed"); @@ -1305,13 +1365,12 @@ void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam( void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { using namespace smart_objects; - using namespace hmi_apis; - SmartObject msg_params = SmartObject(SmartType_Map); msg_params[strings::app_id] = connection_key(); - msg_params[strings::name] = Common_ButtonName::CUSTOM_BUTTON; + msg_params[strings::name] = hmi_apis::Common_ButtonName::CUSTOM_BUTTON; msg_params[strings::is_suscribed] = true; - CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); + CreateHMINotification(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + msg_params); } bool RegisterAppInterfaceRequest::IsApplicationSwitched() { @@ -1319,24 +1378,26 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { application_manager_.GetCorrectMobileIDFromMessage(message_); LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); - - auto app = application_manager_.application_by_policy_id(policy_app_id); + auto app = + application_manager_.reregister_application_by_policy_id(policy_app_id); if (!app) { - LOG4CXX_DEBUG(logger_, - "Application with policy id " << policy_app_id - << " is not found."); + LOG4CXX_DEBUG( + logger_, + "Application with policy id " << policy_app_id << " is not found."); return false; } LOG4CXX_DEBUG(logger_, "Application with policy id " << policy_app_id << " is found."); - if (!application_manager_.IsAppInReconnectMode(policy_app_id)) { + + const auto app_device_handle = app->device(); + if (app_device_handle == device_handle_) { LOG4CXX_DEBUG(logger_, - "Policy id " << policy_app_id - << " is not found in reconnection list."); + "Application " << policy_app_id + << " is already registered from this device."); SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); - return false; + return true; } LOG4CXX_DEBUG(logger_, "Application is found in reconnection list."); @@ -1355,13 +1416,61 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() { application_manager_.ProcessReconnection(app, connection_key()); SendRegisterAppInterfaceResponseToMobile(app_type); - application_manager_.SendHMIStatusNotification(app); + MessageHelper::SendHMIStatusNotification( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + application_manager_); application_manager_.OnApplicationSwitched(app); return true; } +bool RegisterAppInterfaceRequest::GetDataOnSessionKey( + const uint32_t key, + connection_handler::DeviceHandle* device_id, + std::string* mac_address) const { + LOG4CXX_AUTO_TRACE(logger_); + + if ((nullptr == mac_address) && (nullptr == device_id)) { + LOG4CXX_ERROR(logger_, + "Can't get data on session key because device id and mac " + "address are empty."); + return false; + } + + connection_handler::DeviceHandle device_handle = 0; + auto& connect_handler = application_manager_.connection_handler(); + + auto result = connect_handler.GetDataOnSessionKey( + connection_key(), nullptr, nullptr, &device_handle); + + if (result) { + LOG4CXX_DEBUG( + logger_, + "Failed to get device info for connection key: " << connection_key()); + return false; + } + + if (mac_address) { + result = connect_handler.get_session_observer().GetDataOnDeviceID( + device_handle, nullptr, nullptr, mac_address, nullptr); + } + + if (result) { + LOG4CXX_DEBUG(logger_, + "Failed get unique address info for connection key: " + << connection_key()); + return false; + } + + if (device_id) { + *device_id = device_handle; + } + + return true; +} + policy::PolicyHandlerInterface& RegisterAppInterfaceRequest::GetPolicyHandler() { return policy_handler_; @@ -1369,4 +1478,4 @@ RegisterAppInterfaceRequest::GetPolicyHandler() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc index 584d7db075..b5683c62cb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -32,11 +32,10 @@ */ #include "sdl_rpc_plugin/commands/mobile/register_app_interface_response.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/application_manager.h" #include "application_manager/policies/policy_handler_interface.h" #include "connection_handler/connection_handler.h" -#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -128,4 +127,4 @@ void RegisterAppInterfaceResponse::SetHeartBeatTimeout( } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc index ab6e1cc143..ffd8a7dc81 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_request.cc @@ -36,8 +36,8 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -161,7 +161,8 @@ void ResetGlobalPropertiesRequest::Run() { key_board_properties[hmi_request::limited_character_list] = limited_character_list;*/ - key_board_properties[hmi_request::auto_complete_text] = ""; + key_board_properties[hmi_request::auto_complete_list] = + smart_objects::SmartObject(smart_objects::SmartType_Array); msg_params[hmi_request::keyboard_properties] = key_board_properties; } @@ -333,4 +334,4 @@ bool ResetGlobalPropertiesRequest::IsPendingResponseExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc index f5542ab26b..07aa23d9c9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/reset_global_properties_response.cc @@ -61,4 +61,4 @@ void ResetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc index 0b28e09210..90dbb91b5f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_request.cc @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string.h> #include "sdl_rpc_plugin/commands/mobile/scrollable_message_request.h" +#include <string.h> #include "application_manager/application_impl.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -65,13 +65,9 @@ ScrollableMessageRequest::~ScrollableMessageRequest() {} bool ScrollableMessageRequest::Init() { /* Timeout in milliseconds. If omitted a standard value of 10000 milliseconds is used.*/ - if ((*message_)[strings::msg_params].keyExists(strings::timeout)) { - default_timeout_ = - (*message_)[strings::msg_params][strings::timeout].asUInt(); - } else { - const int32_t def_value = 30000; - default_timeout_ = def_value; - } + uint32_t request_timeout = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + default_timeout_ += request_timeout; return true; } @@ -110,7 +106,13 @@ void ScrollableMessageRequest::Run() { msg_params[hmi_request::message_text][hmi_request::field_text] = (*message_)[strings::msg_params][strings::scroll_message_body]; msg_params[strings::app_id] = app->app_id(); - msg_params[strings::timeout] = default_timeout_; + msg_params[strings::timeout] = + (*message_)[strings::msg_params][strings::timeout].asUInt(); + + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } if ((*message_)[strings::msg_params].keyExists(strings::soft_buttons)) { msg_params[strings::soft_buttons] = @@ -160,4 +162,4 @@ void ScrollableMessageRequest::on_event(const event_engine::Event& event) { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc index 4eee819497..6236506c00 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/scrollable_message_response.cc @@ -69,4 +69,4 @@ void ScrollableMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc index a09434ebb6..6e745fe0db 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_request.cc @@ -105,4 +105,4 @@ void SendHapticDataRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc index f4515472a4..79a0516928 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_haptic_data_response.cc @@ -60,4 +60,4 @@ void SendHapticDataResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc index 2719d0674d..1df4d788d2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -30,8 +30,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <algorithm> #include "sdl_rpc_plugin/commands/mobile/send_location_request.h" +#include <algorithm> #include "application_manager/message_helper.h" #include "utils/custom_string.h" @@ -281,4 +281,4 @@ bool SendLocationRequest::CheckHMICapabilities( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc index 59dab4a9a7..934008b816 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/send_location_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -63,4 +63,4 @@ void SendLocationResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc index e79fb315ce..b2363e870f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_request.cc @@ -34,10 +34,10 @@ #include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" #include <algorithm> -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/file_system.h" #include "utils/helpers.h" @@ -148,10 +148,12 @@ void SetAppIconRequest::CopyToIconStorage( if (storage_max_size < file_size) { LOG4CXX_ERROR(logger_, - "Icon size (" << file_size << ") is bigger, than " - " icons storage maximum size (" - << storage_max_size << ")." - "Copying skipped."); + "Icon size (" << file_size + << ") is bigger, than " + " icons storage maximum size (" + << storage_max_size + << ")." + "Copying skipped."); return; } @@ -203,12 +205,12 @@ void SetAppIconRequest::CopyToIconStorage( void SetAppIconRequest::RemoveOldestIcons(const std::string& storage, const uint32_t icons_amount) const { const std::vector<std::string> icons_list = file_system::ListFiles(storage); - auto compareTime = [](const time_t t1, const time_t t2) - -> bool { return difftime(t1, t2) > 0; }; - std::map<time_t, - std::string, - std::function<bool(const time_t, const time_t)> > - icon_modification_time(compareTime); + auto compareTime = [](const time_t t1, const time_t t2) -> bool { + return difftime(t1, t2) > 0; + }; + std:: + map<time_t, std::string, std::function<bool(const time_t, const time_t)> > + icon_modification_time(compareTime); std::vector<std::string>::const_iterator it = icons_list.begin(); for (; it != icons_list.end(); ++it) { const std::string file_name = *it; @@ -271,7 +273,8 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { const std::string& path = (*message_)[strings::msg_params][strings::sync_file_name] - [strings::value].asString(); + [strings::value] + .asString(); if (is_icons_saving_enabled_) { CopyToIconStorage(path); @@ -298,4 +301,4 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc index aa8731f062..55255920d0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_app_icon_response.cc @@ -61,4 +61,4 @@ void SetAppIconResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc index 5173be56d6..3bb1e1c107 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_request.cc @@ -1,4 +1,5 @@ #include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -40,4 +41,4 @@ void SetCloudAppPropertiesRequest::on_event( } } // namespace commands -} // namespace sdl_rpc_plugin
\ No newline at end of file +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc index 6d27ce8b3e..39d2ea7f90 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_cloud_app_properties_response.cc @@ -1,6 +1,6 @@ +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -28,4 +28,4 @@ void SetCloudAppPropertiesResponse::Run() { } } // namespace commands -} // namespace sdl_rpc_plugins +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc index 32164b8f0e..5ba1076084 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_request.cc @@ -33,8 +33,8 @@ #include "sdl_rpc_plugin/commands/mobile/set_display_layout_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -75,8 +75,8 @@ void SetDisplayLayoutRequest::Run() { new_layout = msg_params[strings::display_layout].asString(); } - if (new_layout != old_layout && - !new_layout.empty()) { // Template switched, allow any color change + if (new_layout != old_layout && !new_layout.empty()) { + // Template switched, hence allow any color change LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest New Layout: " << new_layout); app->set_display_layout(new_layout); @@ -85,22 +85,20 @@ void SetDisplayLayoutRequest::Run() { // Template layout is the same as previous layout // Reject message if colors are set if (msg_params.keyExists(strings::day_color_scheme) && - app->day_color_scheme() != NULL && - !(msg_params[strings::day_color_scheme] == - *(app->day_color_scheme()))) { - // Color scheme param exists and has been previously set, do not allow - // color change + app->day_color_scheme().getType() != smart_objects::SmartType_Null && + msg_params[strings::day_color_scheme] != app->day_color_scheme()) { + // Color scheme param exists and has been previously set, + // hence do not allow color change LOG4CXX_DEBUG(logger_, "Reject Day Color Scheme Change"); SendResponse(false, mobile_apis::Result::REJECTED); return; } if (msg_params.keyExists(strings::night_color_scheme) && - app->night_color_scheme() != NULL && - !(msg_params[strings::night_color_scheme] == - *(app->night_color_scheme()))) { - // Color scheme param exists and has been previously set, do not allow - // color change + app->night_color_scheme().getType() != smart_objects::SmartType_Null && + msg_params[strings::night_color_scheme] != app->night_color_scheme()) { + // Color scheme param exists and has been previously set, + // hence do not allow color change LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); SendResponse(false, mobile_apis::Result::REJECTED); return; @@ -127,6 +125,14 @@ void SetDisplayLayoutRequest::Run() { void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { 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; + } + const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::UI_SetDisplayLayout: { @@ -143,21 +149,32 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { if (response_success) { HMICapabilities& hmi_capabilities = hmi_capabilities_; - // in case templates_available is empty copy from hmi capabilities + // In case templates_available is empty copy from hmi capabilities if (msg_params.keyExists(hmi_response::display_capabilities)) { - if (0 == - msg_params[hmi_response::display_capabilities] - [hmi_response::templates_available].length()) { + if (0 == msg_params[hmi_response::display_capabilities] + [hmi_response::templates_available] + .length()) { msg_params[hmi_response::display_capabilities] [hmi_response::templates_available] = hmi_capabilities.display_capabilities()->getElement( hmi_response::templates_available); } } + const Version& app_version = app->version(); + if (app_version.max_supported_api_version >= APIVersion::kAPIV6) { + // In case of successful response warn user that this RPC is + // deprecated from 6.0 and higher API versions + result_code = hmi_apis::Common_Result::WARNINGS; + info = + "The RPC is deprecated and will be removed in a future version. " + "The requested display layout is set to the main window. Please " + "use `Show.templateConfiguration` instead."; + } } + SendResponse(response_success, MessageHelper::HMIToMobileResult(result_code), - info.empty() ? NULL : info.c_str(), + info.empty() ? nullptr : info.c_str(), &msg_params); break; } @@ -170,4 +187,4 @@ void SetDisplayLayoutRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc index 4bab4a3e5b..0999b596b5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_display_layout_response.cc @@ -62,4 +62,4 @@ void SetDisplayLayoutResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index 0c217b6b4f..a567d1b32f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -30,14 +30,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" #include <string.h> -#include <numeric> #include <algorithm> -#include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" +#include <numeric> #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" + #include "utils/helpers.h" namespace sdl_rpc_plugin { @@ -45,6 +46,24 @@ using namespace application_manager; namespace commands { +namespace { +bool IsResultCodeWarning(const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) { + const bool first_is_ok_second_is_warn = + (first.is_ok || first.is_not_used) && + (hmi_apis::Common_Result::WARNINGS == second.result_code) && + (hmi_apis::Common_Result::WARNINGS == third.result_code); + + const bool final_warnings = + hmi_apis::Common_Result::WARNINGS == first.result_code && + ((hmi_apis::Common_Result::WARNINGS == second.result_code) && + (hmi_apis::Common_Result::WARNINGS == third.result_code)); + + return first_is_ok_second_is_warn || final_warnings; +} +} // namespace + SetGlobalPropertiesRequest::SetGlobalPropertiesRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, @@ -58,25 +77,27 @@ SetGlobalPropertiesRequest::SetGlobalPropertiesRequest( policy_handler) , is_ui_send_(false) , is_tts_send_(false) + , is_rc_send_(false) , is_ui_received_(false) , is_tts_received_(false) + , is_rc_received_(false) , ui_result_(hmi_apis::Common_Result::INVALID_ENUM) - , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) {} + , tts_result_(hmi_apis::Common_Result::INVALID_ENUM) + , rc_result_(hmi_apis::Common_Result::INVALID_ENUM) {} SetGlobalPropertiesRequest::~SetGlobalPropertiesRequest() {} void SetGlobalPropertiesRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; + smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, - "No application associated with connection key " - << connection_key()); + LOG4CXX_ERROR( + logger_, + "No application associated with connection key " << connection_key()); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } @@ -90,11 +111,9 @@ void SetGlobalPropertiesRequest::Run() { mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; - if ((*message_)[strings::msg_params].keyExists(strings::menu_icon)) { + if (msg_params.keyExists(strings::menu_icon)) { verification_result = MessageHelper::VerifyImage( - (*message_)[strings::msg_params][strings::menu_icon], - app, - application_manager_); + msg_params[strings::menu_icon], app, application_manager_); if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR( logger_, "MessageHelper::VerifyImage return " << verification_result); @@ -103,18 +122,29 @@ void SetGlobalPropertiesRequest::Run() { } } // Check for image file(s) in vrHelpItem - if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { + if (msg_params.keyExists(strings::vr_help)) { if (mobile_apis::Result::INVALID_DATA == MessageHelper::VerifyImageVrHelpItems( - (*message_)[strings::msg_params][strings::vr_help], - app, - application_manager_)) { + msg_params[strings::vr_help], app, application_manager_)) { LOG4CXX_ERROR(logger_, "MessageHelper::VerifyImage return INVALID_DATA!"); SendResponse(false, mobile_apis::Result::INVALID_DATA); return; } } + if (msg_params.keyExists(strings::keyboard_properties)) { + if (!msg_params[strings::keyboard_properties].keyExists( + strings::auto_complete_list) && + msg_params[strings::keyboard_properties].keyExists( + strings::auto_complete_text)) { + LOG4CXX_ERROR(logger_, "Replacing deprecated autoCompleteText property"); + msg_params[strings::keyboard_properties][strings::auto_complete_list][0] = + msg_params[strings::keyboard_properties][strings::auto_complete_text] + .asString(); + } + msg_params[strings::keyboard_properties].erase(strings::auto_complete_text); + } + if (IsWhiteSpaceExist()) { LOG4CXX_ERROR(logger_, "White spaces found"); SendResponse(false, mobile_apis::Result::INVALID_DATA); @@ -138,6 +168,19 @@ void SetGlobalPropertiesRequest::Run() { return; } + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + if (msg_params.keyExists(strings::menu_layout)) { + auto menu_layout = static_cast<mobile_apis::MenuLayout::eType>( + msg_params[strings::menu_layout].asUInt()); + if (app->menu_layout_supported(menu_layout)) { + params[strings::menu_layout] = msg_params[strings::menu_layout]; + } else { + is_menu_layout_available_ = false; + } + } + /* Need to set flags before sending request to HMI * for correct processing this flags in method on_event */ if (is_help_prompt_present || is_timeout_prompt_present) { @@ -154,9 +197,6 @@ void SetGlobalPropertiesRequest::Run() { return; } - smart_objects::SmartObject params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - PrepareUIRequestVRHelpData(app, msg_params, params); PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); @@ -169,9 +209,6 @@ void SetGlobalPropertiesRequest::Run() { LOG4CXX_DEBUG(logger_, "VRHelp params does not present"); DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present); - smart_objects::SmartObject params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); // Preparing data @@ -183,45 +220,71 @@ void SetGlobalPropertiesRequest::Run() { } } + // Check RC params + const bool is_user_location_present = + msg_params.keyExists(strings::user_location); + if (is_user_location_present) { + if (msg_params[strings::user_location].empty()) { + SendResponse( + false, mobile_apis::Result::INVALID_DATA, "UserLocation is empty"); + return; + } + LOG4CXX_DEBUG(logger_, "Userlocation params presents"); + const auto& user_location = msg_params[strings::user_location]; + app->set_user_location(user_location); + + auto on_global_properties_updated = [app]( + plugin_manager::RPCPlugin& plugin) { + plugin.OnApplicationEvent(plugin_manager::kGlobalPropertiesUpdated, app); + }; + + application_manager_.GetPluginManager().ForEachPlugin( + on_global_properties_updated); + + smart_objects::SmartObject params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + params[strings::app_id] = app->app_id(); + params[strings::user_location] = user_location; + SendRCRequest(params, true); + } + // check TTS params if (is_help_prompt_present || is_timeout_prompt_present) { LOG4CXX_DEBUG(logger_, "TTS params presents"); - smart_objects::SmartObject params = - smart_objects::SmartObject(smart_objects::SmartType_Map); + auto tts_params = smart_objects::SmartObject(smart_objects::SmartType_Map); std::vector<std::string> invalid_params; if (is_help_prompt_present) { smart_objects::SmartObject& help_prompt = (*message_)[strings::msg_params][strings::help_prompt]; - mobile_apis::Result::eType verification_result = + verification_result = MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("help_prompt"); } else { app->set_help_prompt(help_prompt); - params[strings::help_prompt] = (*app->help_prompt()); + tts_params[strings::help_prompt] = (*app->help_prompt()); } } if (is_timeout_prompt_present) { smart_objects::SmartObject& timeout_prompt = (*message_)[strings::msg_params][strings::timeout_prompt]; - mobile_apis::Result::eType verification_result = - MessageHelper::VerifyTtsFiles( - timeout_prompt, app, application_manager_); + verification_result = MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); invalid_params.push_back("timeout_prompt"); } else { app->set_timeout_prompt(timeout_prompt); - params[strings::timeout_prompt] = (*app->timeout_prompt()); + tts_params[strings::timeout_prompt] = (*app->timeout_prompt()); } } @@ -239,11 +302,18 @@ void SetGlobalPropertiesRequest::Run() { return; } - params[strings::app_id] = app->app_id(); - SendTTSRequest(params, true); + tts_params[strings::app_id] = app->app_id(); + SendTTSRequest(tts_params, true); auto& help_prompt_manager = app->help_prompt_manager(); - help_prompt_manager.OnSetGlobalPropertiesReceived(params, false); + help_prompt_manager.OnSetGlobalPropertiesReceived(tts_params, false); + } else if (!is_ui_send_ && !is_rc_send_) { + std::string response_info = "There are no parameters present in request."; + if (!is_menu_layout_available_) { + response_info += " The MenuLayout specified is unsupported."; + } + SendResponse( + false, mobile_apis::Result::INVALID_DATA, response_info.c_str()); } } @@ -278,7 +348,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { - LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); + LOG4CXX_DEBUG(logger_, "Received UI_SetGlobalProperties event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); is_ui_received_ = true; ui_result_ = static_cast<hmi_apis::Common_Result::eType>( @@ -291,7 +361,7 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { break; } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { - LOG4CXX_INFO(logger_, "Received TTS_SetGlobalProperties event"); + LOG4CXX_DEBUG(logger_, "Received TTS_SetGlobalProperties event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); is_tts_received_ = true; tts_result_ = static_cast<hmi_apis::Common_Result::eType>( @@ -303,6 +373,15 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { } break; } + case hmi_apis::FunctionID::RC_SetGlobalProperties: { + LOG4CXX_DEBUG(logger_, "Received RC_SetGlobalProperties event"); + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_RC); + is_rc_received_ = true; + rc_result_ = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + GetInfo(message, rc_response_info_); + break; + } default: { LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); return; @@ -317,10 +396,21 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { std::string response_info; const bool result = PrepareResponseParameters(result_code, response_info); - SendResponse(result, - result_code, - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); + if (result && !is_menu_layout_available_) { + response_info = + "The MenuLayout specified is unsupported, the " + "default MenuLayout will be used." + + response_info; + SendResponse(result, + mobile_apis::Result::WARNINGS, + response_info.c_str(), + &(message[strings::msg_params])); + } else { + SendResponse(result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + } } bool SetGlobalPropertiesRequest::Init() { @@ -338,28 +428,173 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters( app_mngr::commands::ResponseInfo tts_properties_info( tts_result_, HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); - const bool result = - PrepareResultForMobileResponse(ui_properties_info, tts_properties_info); + + app_mngr::commands::ResponseInfo rc_properties_info( + rc_result_, HmiInterfaces::HMI_INTERFACE_RC, application_manager_); + + bool result = false; + + if (!is_rc_send_) { + result = CommandRequestImpl::PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info); + } else { + result = PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + } if (result && (HmiInterfaces::STATE_AVAILABLE == tts_properties_info.interface_state) && (tts_properties_info.is_unsupported_resource)) { result_code = mobile_apis::Result::WARNINGS; tts_response_info_ = "Unsupported phoneme type sent in a prompt"; - info = app_mngr::commands::MergeInfos(tts_properties_info, - tts_response_info_, - ui_properties_info, - ui_response_info_); + info = MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_, + rc_properties_info, + rc_response_info_); return result; } - result_code = - PrepareResultCodeForResponse(ui_properties_info, tts_properties_info); - info = app_mngr::commands::MergeInfos(tts_properties_info, - tts_response_info_, - ui_properties_info, - ui_response_info_); + + if (!is_rc_send_) { + result_code = CommandRequestImpl::PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info); + } else { + result_code = PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + } + info = MergeInfos(tts_properties_info, + tts_response_info_, + ui_properties_info, + ui_response_info_, + rc_properties_info, + rc_response_info_); return result; } +bool SetGlobalPropertiesRequest::PrepareResultForMobileResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) const { + LOG4CXX_AUTO_TRACE(logger_); + + app_mngr::commands::ResponseInfo both_info; + std::vector<hmi_apis::Common_Result::eType> success_result_codes{ + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED}; + + both_info.is_ok = + helpers::in_range(success_result_codes, first.result_code) && + helpers::in_range(success_result_codes, second.result_code); + + both_info.is_not_used = + (hmi_apis::Common_Result::INVALID_ENUM == first.result_code) || + (hmi_apis::Common_Result::INVALID_ENUM == second.result_code); + + both_info.is_unsupported_resource = + (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == first.result_code) || + (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == second.result_code); + + const bool final_result = CommandRequestImpl::CheckResult(both_info, third) || + CommandRequestImpl::CheckResult(third, both_info); + + return final_result; +} + +mobile_apis::Result::eType +SetGlobalPropertiesRequest::PrepareResultCodeForResponse( + const app_mngr::commands::ResponseInfo& first, + const app_mngr::commands::ResponseInfo& second, + const app_mngr::commands::ResponseInfo& third) { + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; + if (IsResultCodeUnsupported(first, second, third) || + IsResultCodeUnsupported(second, third, first) || + IsResultCodeUnsupported(third, first, second)) { + return mobile_apis::Result::UNSUPPORTED_RESOURCE; + } + if (IsResultCodeWarning(first, second, third) || + IsResultCodeWarning(second, third, first) || + IsResultCodeWarning(third, first, second)) { + return mobile_apis::Result::WARNINGS; + } + // If response contains erroneous result code SDL need return erroneous + // result code. + auto first_result = hmi_apis::Common_Result::INVALID_ENUM; + auto second_result = hmi_apis::Common_Result::INVALID_ENUM; + auto third_result = hmi_apis::Common_Result::INVALID_ENUM; + + if (!first.is_unsupported_resource) { + first_result = first.result_code; + } + if (!second.is_unsupported_resource) { + second_result = second.result_code; + } + if (!third.is_unsupported_resource) { + third_result = third.result_code; + } + + hmi_apis::Common_Result::eType intermediate_result = + std::max(first_result, second_result); + result_code = MessageHelper::HMIToMobileResult( + std::max(intermediate_result, third_result)); + + return result_code; +} + +bool SetGlobalPropertiesRequest::IsResultCodeUnsupported( + const application_manager::commands::ResponseInfo& first, + const application_manager::commands::ResponseInfo& second, + const application_manager::commands::ResponseInfo& third) const { + const bool first_ok_second_or_third_unsupported = + (first.is_ok || first.is_not_used) && + (second.is_unsupported_resource || third.is_unsupported_resource); + const bool final_unsupported = first.is_unsupported_resource && + second.is_unsupported_resource && + third.is_unsupported_resource; + + return first_ok_second_or_third_unsupported || final_unsupported; +} + +std::string SetGlobalPropertiesRequest::MergeInfos( + const app_mngr::commands::ResponseInfo& first_info, + const std::string& first_str, + const app_mngr::commands::ResponseInfo& second_info, + const std::string& second_str, + const app_mngr::commands::ResponseInfo& third_info, + const std::string& third_str) { + if ((first_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + + ((second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !second_str.empty()) && + ((third_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !third_str.empty())) { + return second_str; + } + + if ((second_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + ((first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !first_str.empty()) && + ((third_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !third_str.empty())) { + return first_str; + } + + if ((third_info.interface_state == HmiInterfaces::STATE_NOT_AVAILABLE) && + ((first_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !first_str.empty()) && + ((second_info.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE) && + !second_str.empty())) { + return third_str; + } + + std::string intermediate_result = + app_mngr::commands::MergeInfos(first_str, second_str); + return app_mngr::commands::MergeInfos(intermediate_result, third_str); +} + void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData( const ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params, @@ -422,8 +657,19 @@ void SetGlobalPropertiesRequest::SendUIRequest( hmi_apis::FunctionID::UI_SetGlobalProperties, ¶ms, use_events); } +void SetGlobalPropertiesRequest::SendRCRequest( + const ns_smart_device_link::ns_smart_objects::SmartObject& params, + bool use_events) { + LOG4CXX_AUTO_TRACE(logger_); + is_rc_send_ = true; + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_RC); + SendHMIRequest( + hmi_apis::FunctionID::RC_SetGlobalProperties, ¶ms, use_events); +} + bool SetGlobalPropertiesRequest::IsPendingResponseExist() { - return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_; + return is_ui_send_ != is_ui_received_ || is_tts_send_ != is_tts_received_ || + is_rc_send_ != is_rc_received_; } bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( @@ -435,7 +681,9 @@ bool SetGlobalPropertiesRequest::ValidateConditionalMandatoryParameters( params.keyExists(strings::vr_help) || params.keyExists(strings::menu_title) || params.keyExists(strings::menu_icon) || - params.keyExists(strings::keyboard_properties); + params.keyExists(strings::keyboard_properties) || + params.keyExists(strings::menu_layout) || + params.keyExists(strings::user_location); } bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { @@ -531,7 +779,8 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { strings::limited_character_list)) { const smart_objects::SmartArray* lcl_array = msg_params[strings::keyboard_properties] - [strings::limited_character_list].asArray(); + [strings::limited_character_list] + .asArray(); smart_objects::SmartArray::const_iterator it_lcl = lcl_array->begin(); smart_objects::SmartArray::const_iterator it_lcl_end = lcl_array->end(); @@ -548,16 +797,21 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { } if (msg_params[strings::keyboard_properties].keyExists( - strings::auto_complete_text)) { - str = - msg_params[strings::keyboard_properties][strings::auto_complete_text] - .asCharArray(); + strings::auto_complete_list)) { + const smart_objects::SmartArray* acl_array = + msg_params[strings::keyboard_properties][strings::auto_complete_list] + .asArray(); - if (!CheckSyntax(str)) { - LOG4CXX_ERROR(logger_, - "Invalid keyboard_properties " - "auto_complete_text syntax check failed"); - return true; + smart_objects::SmartArray::const_iterator it = acl_array->begin(); + + for (; it != acl_array->end(); ++it) { + str = it->asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, + "Invalid keyboard_properties " + "auto_complete_list syntax check failed"); + return true; + } } } } @@ -565,4 +819,4 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc index 567a1a088b..1de2b97d3a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_response.cc @@ -61,4 +61,4 @@ void SetGlobalPropertiesResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc index 55bd164368..d610090aa4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc @@ -33,10 +33,10 @@ #include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h" -#include "application_manager/message_helper.h" #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -163,4 +163,4 @@ bool SetMediaClockRequest::isDataValid() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc index e777533ce4..948ff84156 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_response.cc @@ -61,4 +61,4 @@ void SetMediaClockTimerResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc new file mode 100644 index 0000000000..36278168dc --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_request.cc @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_request.h" + +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +ShowAppMenuRequest::ShowAppMenuRequest( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandRequestImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ShowAppMenuRequest::~ShowAppMenuRequest() {} + +void ShowAppMenuRequest::Run() { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR( + logger_, + "Application with id " << connection_key() << " is not registered."); + SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); + return; + } + + if (mobile_apis::HMILevel::HMI_FULL != + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) || + helpers::Compare<mobile_apis::SystemContext::eType, + helpers::NEQ, + helpers::ALL>( + app->system_context(mobile_apis::PredefinedWindows::DEFAULT_WINDOW), + mobile_apis::SystemContext::SYSCTXT_MAIN, + mobile_apis::SystemContext::SYSCTXT_MENU)) { + LOG4CXX_ERROR( + logger_, + "Application with id " << connection_key() << " is not activated."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + auto msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); + + const auto& received_msg_params = (*message_)[strings::msg_params]; + if (received_msg_params.keyExists(strings::menu_id)) { + const int32_t menu_id = received_msg_params[strings::menu_id].asInt(); + if (!app->FindSubMenu(menu_id)) { + LOG4CXX_ERROR(logger_, "Menu with id " << menu_id << " is not found."); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + msg_params[strings::menu_id] = menu_id; + } + + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + SendHMIRequest(hmi_apis::FunctionID::UI_ShowAppMenu, &msg_params, true); +} + +void ShowAppMenuRequest::on_event(const app_mngr::event_engine::Event& event) { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + + switch (event.id()) { + case hmi_apis::FunctionID::UI_ShowAppMenu: { + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); + const auto result_code = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + result_code, HmiInterfaces::HMI_INTERFACE_UI); + + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Application with id " << connection_key() + << " is not registered."); + return; + } + + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &message[strings::msg_params]); + break; + } + default: { + LOG4CXX_ERROR(logger_, "Received unknown event: " << event.id()); + return; + } + } +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_response.cc new file mode 100644 index 0000000000..2b952ea9ac --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_app_menu_response.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_response.h" + +#include "application_manager/rpc_service.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +ShowAppMenuResponse::ShowAppMenuResponse( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandResponseImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ShowAppMenuResponse::~ShowAppMenuResponse() {} + +void ShowAppMenuResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + rpc_service_.SendMessageToMobile(message_); +} + +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc index 3b2936e6cd..b439c1cb16 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -31,15 +31,15 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <cstring> #include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h" +#include <cstring> -#include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/policies/policy_handler_interface.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -228,7 +228,8 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() { if ((*message_)[strings::msg_params].keyExists(strings::next_turn_icon)) { str = (*message_)[strings::msg_params][strings::next_turn_icon] - [strings::value].asCharArray(); + [strings::value] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid next_turn_icon value syntax check failed"); @@ -289,4 +290,4 @@ bool ShowConstantTBTRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc index 239040a3b3..d027daf77d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_response.cc @@ -63,4 +63,4 @@ void ShowConstantTBTResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc index e0c3e1da9a..84d11f8e09 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc @@ -30,12 +30,12 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <string.h> #include "sdl_rpc_plugin/commands/mobile/show_request.h" +#include <string.h> -#include "application_manager/policies/policy_handler.h" #include "application_manager/application.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler.h" #include "utils/file_system.h" #include "utils/helpers.h" @@ -55,7 +55,12 @@ ShowRequest::ShowRequest( rpc_service, hmi_capabilities, policy_handler) - , core_result_code_(mobile_apis::Result::INVALID_ENUM) {} + , core_result_code_(mobile_apis::Result::INVALID_ENUM) + , current_window_id_(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) + , template_config_(smart_objects::SmartType::SmartType_Null) + , layout_change_required_(false) + , dcs_change_required_(false) + , ncs_change_required_(false) {} ShowRequest::~ShowRequest() {} @@ -94,6 +99,137 @@ void ShowRequest::HandleMetadata(const char* field_id, } } +bool ShowRequest::CheckTemplateConfigurationForApp( + application_manager::Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + current_window_id_ = + (*message_)[strings::msg_params][strings::window_id].asInt(); + } + + const auto set_window_layout = [&app, this]() -> bool { + const auto new_template_layout = + template_config_[strings::template_layout].asString(); + const auto old_template_layout = app.window_layout(current_window_id_); + LOG4CXX_DEBUG(logger_, "New layout: " << new_template_layout); + LOG4CXX_DEBUG(logger_, "Old layout: " << old_template_layout); + + const bool layouts_equal = (new_template_layout == old_template_layout); + + if (!new_template_layout.empty() && !layouts_equal) { + // Template switched, hence allow any color change + LOG4CXX_DEBUG(logger_, + "Show Request: Setting new Layout: " << new_template_layout + << " for window ID: " + << current_window_id_); + layout_change_required_ = true; + return true; + } + LOG4CXX_DEBUG(logger_, "Show Request: No Layout Change"); + return false; + }; + + const auto set_day_color_scheme = [&app, this]() -> bool { + if (!template_config_.keyExists(strings::day_color_scheme)) { + return false; + } + if (app.day_color_scheme(current_window_id_).getType() != + smart_objects::SmartType_Null && + template_config_[strings::day_color_scheme] != + app.day_color_scheme(current_window_id_)) { + // Color scheme param exists and has been previously set, + // hence do not allow color change + LOG4CXX_DEBUG(logger_, "Day Color Scheme change is rejected"); + return false; + } + LOG4CXX_DEBUG(logger_, "Day Color Scheme change is allowed"); + dcs_change_required_ = true; + + return true; + }; + + const auto set_night_color_scheme = [&app, this]() -> bool { + if (!template_config_.keyExists(strings::night_color_scheme)) { + return false; + } + if (app.night_color_scheme(current_window_id_).getType() != + smart_objects::SmartType_Null && + template_config_[strings::night_color_scheme] != + app.night_color_scheme(current_window_id_)) { + // Color scheme param exists and has been previously set, + // hence do not allow color change + LOG4CXX_DEBUG(logger_, "Night Color Scheme change is rejected"); + return false; + } + LOG4CXX_DEBUG(logger_, "Night Color Scheme Change is allowed"); + ncs_change_required_ = true; + + return true; + }; + + const bool set_layout_result = set_window_layout(); + + if (set_layout_result) { + set_day_color_scheme(); + set_night_color_scheme(); + return true; + } + + if (!template_config_.keyExists(strings::night_color_scheme) && + !template_config_.keyExists(strings::day_color_scheme)) { + // In case current layout was not changed and day and night color + // schemes are absent in mobile message SDL has to forward message + // to HMI with the only layout even it was not changed + return true; + } + + const bool set_schemes_result = + (set_day_color_scheme() && set_night_color_scheme()); + + return set_schemes_result; +} + +void ShowRequest::ApplyTemplateConfigurationForApp( + mobile_apis::Result::eType result, application_manager::Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + if (helpers::Compare<mobile_apis::Result::eType, helpers::EQ, helpers::ONE>( + result, + mobile_apis::Result::SUCCESS, + mobile_apis::Result::WARNINGS)) { + if (layout_change_required_) { + const std::string new_layout = + template_config_[strings::template_layout].asString(); + LOG4CXX_DEBUG(logger_, "New layout : " << new_layout << " is applied"); + app.set_window_layout(current_window_id_, new_layout); + + if (template_config_.keyExists(strings::day_color_scheme)) { + app.set_day_color_scheme(current_window_id_, + template_config_[strings::day_color_scheme]); + } + + if (template_config_.keyExists(strings::night_color_scheme)) { + app.set_night_color_scheme( + current_window_id_, template_config_[strings::night_color_scheme]); + } + + return; + } + + if (dcs_change_required_) { + LOG4CXX_DEBUG(logger_, "New day color scheme is applied"); + app.set_day_color_scheme(current_window_id_, + template_config_[strings::day_color_scheme]); + } + + if (ncs_change_required_) { + LOG4CXX_DEBUG(logger_, "New night color scheme is applied"); + app.set_night_color_scheme(current_window_id_, + template_config_[strings::night_color_scheme]); + } + } +} + void ShowRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); @@ -138,7 +274,8 @@ void ShowRequest::Run() { mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; if (((*message_)[strings::msg_params].keyExists(strings::graphic)) && ((*message_)[strings::msg_params][strings::graphic][strings::value] - .asString()).length()) { + .asString()) + .length()) { verification_result = MessageHelper::VerifyImage( (*message_)[strings::msg_params][strings::graphic], app, @@ -217,6 +354,14 @@ void ShowRequest::Run() { HandleMetadata(strings::main_field_4, main_field_4_index, msg_params); } + if ((*message_)[strings::msg_params].keyExists(strings::template_title)) { + msg_params[hmi_request::show_strings][index][hmi_request::field_name] = + static_cast<int32_t>(hmi_apis::Common_TextFieldName::templateTitle); + msg_params[hmi_request::show_strings][index][hmi_request::field_text] = + (*message_)[strings::msg_params][strings::template_title]; + ++index; + } + if ((*message_)[strings::msg_params].keyExists(strings::media_clock)) { msg_params[hmi_request::show_strings][index][hmi_request::field_name] = static_cast<int32_t>(hmi_apis::Common_TextFieldName::mediaClock); @@ -263,7 +408,7 @@ void ShowRequest::Run() { app->UnsubscribeFromSoftButtons(function_id()); } else { MessageHelper::SubscribeApplicationToSoftButton( - (*message_)[strings::msg_params], app, function_id()); + (*message_)[strings::msg_params], app, function_id(), window_id()); } } @@ -272,6 +417,33 @@ void ShowRequest::Run() { (*message_)[strings::msg_params][strings::custom_presets]; } + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + const auto window_id = + (*message_)[strings::msg_params][strings::window_id].asInt(); + if (!app->WindowIdExists(window_id)) { + LOG4CXX_ERROR(logger_, + "Window with id #" << window_id << " does not exist"); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return; + } + msg_params[strings::window_id] = window_id; + } + + if ((*message_)[strings::msg_params].keyExists( + strings::template_configuration)) { + template_config_ = + (*message_)[strings::msg_params][strings::template_configuration]; + const bool result = CheckTemplateConfigurationForApp(*app); + if (!result) { + const char* info( + "Color schemes can not be changed without a new template set"); + SendResponse(false, mobile_apis::Result::REJECTED, info); + return; + } + msg_params[strings::template_configuration] = + (*message_)[strings::msg_params][strings::template_configuration]; + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Show, &msg_params, true); @@ -285,6 +457,13 @@ void ShowRequest::on_event(const event_engine::Event& event) { using namespace helpers; const smart_objects::SmartObject& message = event.smart_object(); + 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; + } switch (event.id()) { case hmi_apis::FunctionID::UI_Show: { @@ -304,6 +483,9 @@ void ShowRequest::on_event(const event_engine::Event& event) { } mobile_apis::Result::eType converted_result_code = MessageHelper::HMIToMobileResult(result_code); + + ApplyTemplateConfigurationForApp(converted_result_code, *app); + if (mobile_apis::Result::SUCCESS == converted_result_code && mobile_apis::Result::INVALID_ENUM != core_result_code_) { converted_result_code = core_result_code_; @@ -354,6 +536,14 @@ bool ShowRequest::CheckStringsOfShowRequest() { return false; } } + if ((*message_)[strings::msg_params].keyExists(strings::template_title)) { + str = + (*message_)[strings::msg_params][strings::template_title].asCharArray(); + if (strlen(str) && !CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid templateTitle syntax check failed"); + return false; + } + } if ((*message_)[strings::msg_params].keyExists(strings::status_bar)) { str = (*message_)[strings::msg_params][strings::status_bar].asCharArray(); if (strlen(str) && !CheckSyntax(str)) { @@ -398,7 +588,8 @@ bool ShowRequest::CheckStringsOfShowRequest() { if ((*message_)[strings::msg_params].keyExists(strings::secondary_graphic)) { str = (*message_)[strings::msg_params][strings::secondary_graphic] - [strings::value].asCharArray(); + [strings::value] + .asCharArray(); if (!CheckSyntax(str)) { LOG4CXX_ERROR(logger_, "Invalid secondary_graphic value syntax check failed"); @@ -410,4 +601,4 @@ bool ShowRequest::CheckStringsOfShowRequest() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc index 4e167e7531..f5667189b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/show_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -63,4 +63,4 @@ void ShowResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc index 08b4775d3f..dd7b426b40 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc @@ -35,8 +35,8 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "utils/helpers.h" #include "config_profile/profile.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -116,6 +116,11 @@ void SliderRequest::Run() { msg_params[strings::timeout] = default_timeout_; } + if ((*message_)[strings::msg_params].keyExists(strings::cancel_id)) { + msg_params[strings::cancel_id] = + (*message_)[strings::msg_params][strings::cancel_id].asInt(); + } + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_Slider, &msg_params, true); } @@ -204,4 +209,4 @@ bool SliderRequest::IsWhiteSpaceExist() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc index 4d6e714e88..4ac96a272e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_response.cc @@ -61,4 +61,4 @@ void SliderResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc index e14321c488..0730a8730f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_request.cc @@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string.h> #include "sdl_rpc_plugin/commands/mobile/speak_request.h" +#include <string.h> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" @@ -84,9 +84,9 @@ void SpeakRequest::Run() { MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { - LOG4CXX_ERROR(logger_, - "MessageHelper::VerifyTtsFiles return " - << verification_result); + LOG4CXX_ERROR( + logger_, + "MessageHelper::VerifyTtsFiles return " << verification_result); SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, "One or more files needed for tts_chunks are not present"); @@ -181,4 +181,4 @@ bool SpeakRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc index f57bd91cd5..69b04977ef 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/speak_response.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/speak_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/HMI_API.h" namespace sdl_rpc_plugin { @@ -63,4 +63,4 @@ void SpeakResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc index f76b6ab210..1acb2a7438 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -126,6 +126,26 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed( (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { return false; } + + if (!app->is_navi() && + ((mobile_apis::ButtonName::NAV_CENTER_LOCATION == btn_id) || + (mobile_apis::ButtonName::NAV_ZOOM_IN == btn_id) || + (mobile_apis::ButtonName::NAV_ZOOM_OUT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_UP == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_UP_RIGHT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_RIGHT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_DOWN_RIGHT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_DOWN == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_DOWN_LEFT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_LEFT == btn_id) || + (mobile_apis::ButtonName::NAV_PAN_UP_LEFT == btn_id) || + (mobile_apis::ButtonName::NAV_TILT_TOGGLE == btn_id) || + (mobile_apis::ButtonName::NAV_ROTATE_CLOCKWISE == btn_id) || + (mobile_apis::ButtonName::NAV_ROTATE_COUNTERCLOCKWISE == btn_id) || + (mobile_apis::ButtonName::NAV_HEADING_TOGGLE == btn_id))) { + return false; + } + return true; } @@ -144,4 +164,4 @@ void SubscribeButtonRequest::SendSubscribeButtonNotification() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc index 1350cfb66e..e584f84f4c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_response.cc @@ -70,4 +70,4 @@ void SubscribeButtonResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc index eb4ca42568..2ee7771833 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace sdl_rpc_plugin { @@ -120,4 +120,4 @@ bool SubscribeWayPointsRequest::Init() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc index 7d051df7e9..45486792d7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_response.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -61,4 +61,4 @@ void SubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index ca9182469a..9be5a270f5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -33,19 +33,19 @@ Copyright (c) 2018, Ford Motor Company #include "sdl_rpc_plugin/commands/mobile/system_request.h" -#include <vector> -#include <string> #include <stdio.h> #include <algorithm> #include <sstream> +#include <string> +#include <vector> #include "application_manager/policies/policy_handler_interface.h" -#include "interfaces/MOBILE_API.h" -#include "utils/file_system.h" -#include "policy/policy_table/enums.h" #include "formatters/CFormatterJsonBase.h" +#include "interfaces/MOBILE_API.h" #include "json/json.h" -#include "utils/helpers.h" +#include "policy/policy_table/enums.h" #include "utils/custom_string.h" +#include "utils/file_system.h" +#include "utils/helpers.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -170,17 +170,18 @@ class QueryAppsDataValidator { << "Package name length [" << app_data[json::android][json::packageName] .asString() - .length() << "] exceeds max length [" - << kPackageNameLengthMax << "]in json file."); + .length() + << "] exceeds max length [" << kPackageNameLengthMax + << "]in json file."); return false; } } // Languages verification if (!app_data[os_type].keyExists(json::languages)) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "'languages' doesn't exist"); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "'languages' doesn't exist"); return false; } if (!ValidateLanguages(app_data[os_type][json::languages], @@ -217,9 +218,9 @@ class QueryAppsDataValidator { ApplicationSharedPtr registered_app = manager_.application_by_policy_id(app_id); if (registered_app) { - LOG4CXX_INFO(logger_, - "Application with the id: " << app_id - << " is already registered."); + LOG4CXX_INFO( + logger_, + "Application with the id: " << app_id << " is already registered."); } // And app name length const std::string appName(app_data[json::name].asString()); @@ -250,9 +251,9 @@ class QueryAppsDataValidator { for (size_t idx = 0; idx < languages_array_size; ++idx) { const smart_objects::SmartObject& language = languages.getElement(idx); if (smart_objects::SmartType_Map != language.getType()) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "language is not a map."); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "language is not a map."); return false; } if (language.length() != 1) { @@ -263,9 +264,9 @@ class QueryAppsDataValidator { } const std::string language_name = (*language.map_begin()).first; if (!language_name.length()) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "language name is empty"); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "language name is empty"); return false; } // Verify default language defined @@ -329,9 +330,9 @@ class QueryAppsDataValidator { const smart_objects::SmartArray* synonyms_array = language[language_name][json::vrSynonyms].asArray(); if (!synonyms_array) { - LOG4CXX_WARN(logger_, - kQueryAppsValidationFailedPrefix - << "vrSynonyms is not array."); + LOG4CXX_WARN( + logger_, + kQueryAppsValidationFailedPrefix << "vrSynonyms is not array."); return false; } const size_t synonyms_array_size = synonyms_array->size(); @@ -421,7 +422,7 @@ class QueryAppsDataValidator { DISALLOW_COPY_AND_ASSIGN(QueryAppsDataValidator); }; -} +} // namespace namespace commands { @@ -469,8 +470,8 @@ void SystemRequest::Run() { static_cast<rpc::policy_table_interface_base::RequestType>( request_type)); - if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(), - request_type)) { + if (!policy_handler.IsRequestTypeAllowed( + application->device(), application->policy_app_id(), request_type)) { LOG4CXX_ERROR(logger_, "RequestType " << stringified_request_type << " is DISALLOWED by policies"); @@ -699,9 +700,9 @@ void SystemRequest::on_event(const event_engine::Event& event) { bool SystemRequest::ValidateQueryAppData( smart_objects::SmartObject& data) const { if (!data.isValid()) { - LOG4CXX_ERROR(logger_, - kQueryAppsValidationFailedPrefix - << "QueryApps response is not valid."); + LOG4CXX_ERROR( + logger_, + kQueryAppsValidationFailedPrefix << "QueryApps response is not valid."); return false; } if (!data.keyExists(json::response)) { @@ -718,4 +719,4 @@ bool SystemRequest::ValidateQueryAppData( } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc index dc2e3ea3f5..428901a1c5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_response.cc @@ -61,4 +61,4 @@ void SystemResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc index 9119fb48da..3ba0513aeb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_request.cc @@ -32,8 +32,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -62,4 +62,4 @@ void UnregisterAppInterfaceRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc index 4e7c879b58..7c90639968 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unregister_app_interface_response.cc @@ -45,4 +45,4 @@ void UnregisterAppInterfaceResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc index 0c30f567b4..ec8de68c9e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -94,7 +94,7 @@ void UnsubscribeButtonRequest::Run() { if (!app->UnsubscribeFromButton( static_cast<mobile_apis::ButtonName::eType>(btn_id))) { - LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id); + LOG4CXX_ERROR(logger_, "App doesn't subscribe to button " << btn_id); SendResponse(false, mobile_apis::Result::IGNORED); return; } @@ -123,4 +123,4 @@ void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc index 592b91851e..c69d49bca1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_response.cc @@ -71,4 +71,4 @@ void UnsubscribeButtonResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc index 4b40b7a9ce..17326a99a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace sdl_rpc_plugin { @@ -125,4 +125,4 @@ bool UnsubscribeWayPointsRequest::Init() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc index 67e3466a44..a7a180fb46 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_response.cc @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" +#include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" namespace sdl_rpc_plugin { @@ -61,4 +61,4 @@ void UnsubscribeWayPointsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc index c04ad34f5f..8c2cce9765 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include "sdl_rpc_plugin/commands/mobile/update_turn_list_request.h" +#include <string> -#include "application_manager/policies/policy_handler.h" #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "utils/custom_string.h" namespace sdl_rpc_plugin { @@ -240,4 +240,4 @@ bool UpdateTurnListRequest::IsWhiteSpaceExist() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc index 5ddf355f88..eca9e3703c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_response.cc @@ -62,4 +62,4 @@ void UpdateTurnListResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc index 130585a927..5ffbbd83bb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/extensions/system_capability_app_extension.cc @@ -25,9 +25,9 @@ bool SystemCapabilityAppExtension::SubscribeTo( bool SystemCapabilityAppExtension::UnsubscribeFrom( const SystemCapabilityType system_capability_type) { - LOG4CXX_INFO(logger_, - "Unsubscribing from System Capability " - << system_capability_type); + LOG4CXX_INFO( + logger_, + "Unsubscribing from System Capability " << system_capability_type); auto it = subscribed_data_.find(system_capability_type); if (it != subscribed_data_.end()) { subscribed_data_.erase(it); @@ -95,4 +95,4 @@ SystemCapabilityAppExtension& SystemCapabilityAppExtension::ExtractExtension( DCHECK(app_extension); return *app_extension; } -}
\ No newline at end of file +} // namespace sdl_rpc_plugin
\ No newline at end of file diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index fb809e8834..6a231f8e35 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -35,215 +35,226 @@ #include "application_manager/message.h" #include "interfaces/HMI_API.h" -#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" -#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" -#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h" #include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" #include "sdl_rpc_plugin/commands/hmi/allow_app_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" -#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" -#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" #include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" +#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" -#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_policy_configuration_data_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_create_window_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_window_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_add_command_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" #ifdef EXTERNAL_PROPRIETARY_MODE #include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h" #include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h" #endif // EXTERNAL_PROPRIETARY_MODE +#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_close_application_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" -#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/get_urls.h" -#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_cancel_interaction_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_app_menu_response.h" -#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" #include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_request.h" #include "sdl_rpc_plugin/commands/hmi/bc_get_file_path_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_service_update_notification.h" +#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_bc_system_capability_updated_notification_from_hmi.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -293,7 +304,8 @@ bool HMICommandFactory::IsAbleToProcess( return get_creator_factory( static_cast<hmi_apis::FunctionID::eType>(function_id), hmi_apis::messageType::INVALID_ENUM, - message_source).CanBeCreated(); + message_source) + .CanBeCreated(); } CommandCreator& HMICommandFactory::get_creator_factory( @@ -317,6 +329,13 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::ActivateAppRequest>() : factory.GetCreator<commands::ActivateAppResponse>(); } + case hmi_apis::FunctionID::BasicCommunication_CloseApplication: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::BasicCommunicationCloseApplicationRequest>() + : factory.GetCreator< + commands::BasicCommunicationCloseApplicationResponse>(); + } #ifdef EXTERNAL_PROPRIETARY_MODE case hmi_apis::FunctionID::BasicCommunication_DecryptCertificate: { return hmi_apis::messageType::request == message_type @@ -339,11 +358,6 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::SDLPolicyUpdate>() : factory.GetCreator<commands::SDLPolicyUpdateResponse>(); } - case hmi_apis::FunctionID::SDL_GetURLS: { - return hmi_apis::messageType::request == message_type - ? factory.GetCreator<commands::GetUrls>() - : factory.GetCreator<commands::GetUrlsResponse>(); - } case hmi_apis::FunctionID::SDL_OnAppPermissionChanged: { return factory.GetCreator<commands::OnAppPermissionChangedNotification>(); } @@ -366,6 +380,13 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::SDLGetStatusUpdateRequest>() : factory.GetCreator<commands::SDLGetStatusUpdateResponse>(); } + case hmi_apis::FunctionID::SDL_GetPolicyConfigurationData: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator< + commands::SDLGetPolicyConfigurationDataRequest>() + : factory.GetCreator< + commands::SDLGetPolicyConfigurationDataResponse>(); + } case hmi_apis::FunctionID::SDL_OnStatusUpdate: { return factory.GetCreator<commands::OnStatusUpdateNotification>(); } @@ -385,6 +406,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::UIAddCommandRequest>() : factory.GetCreator<commands::UIAddCommandResponse>(); } + case hmi_apis::FunctionID::UI_CancelInteraction: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UICancelInteractionRequest>() + : factory.GetCreator<commands::UICancelInteractionResponse>(); + } case hmi_apis::FunctionID::UI_DeleteCommand: { return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::UIDeleteCommandRequest>() @@ -400,6 +426,16 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::UIDeleteSubmenuRequest>() : factory.GetCreator<commands::UIDeleteSubmenuResponse>(); } + case hmi_apis::FunctionID::UI_ShowAppMenu: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIShowAppMenuRequest>() + : factory.GetCreator<commands::UIShowAppMenuResponse>(); + } + case hmi_apis::FunctionID::UI_DeleteWindow: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UIDeleteWindowRequest>() + : factory.GetCreator<commands::UIDeleteWindowResponse>(); + } case hmi_apis::FunctionID::UI_SetMediaClockTimer: { return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::UISetMediaClockTimerRequest>() @@ -448,6 +484,11 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::UIChangeRegistrationRequest>() : factory.GetCreator<commands::UIChangeRegistratioResponse>(); } + case hmi_apis::FunctionID::UI_CreateWindow: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::UICreateWindowRequest>() + : factory.GetCreator<commands::UICreateWindowResponse>(); + } case hmi_apis::FunctionID::UI_PerformAudioPassThru: { return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::UIPerformAudioPassThruRequest>() @@ -828,6 +869,9 @@ CommandCreator& HMICommandFactory::get_creator_factory( ? factory.GetCreator<commands::hmi::DialNumberRequest>() : factory.GetCreator<commands::hmi::DialNumberResponse>(); } + case hmi_apis::FunctionID::BasicCommunication_OnServiceUpdate: { + return factory.GetCreator<commands::hmi::OnServiceUpdateNotification>(); + } case hmi_apis::FunctionID::Navigation_OnWayPointChange: { return factory.GetCreator<commands::OnNaviWayPointChangeNotification>(); } @@ -852,11 +896,16 @@ CommandCreator& HMICommandFactory::get_creator_factory( : factory.GetCreator<commands::BCGetFilePathResponse>(); } case hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated: { - return factory - .GetCreator<commands::OnBCSystemCapabilityUpdatedNotification>(); + return (application_manager::commands::Command::CommandSource:: + SOURCE_HMI == source) + ? factory.GetCreator< + commands:: + OnBCSystemCapabilityUpdatedNotificationFromHMI>() + : factory.GetCreator< + commands::OnBCSystemCapabilityUpdatedNotification>(); } default: { return factory.GetCreator<InvalidCommand>(); } } } -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index fbbe5183df..c6f4b64636 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -31,29 +31,44 @@ */ #include "sdl_rpc_plugin/mobile_command_factory.h" +#include "interfaces/MOBILE_API.h" #include "sdl_rpc_plugin/commands/mobile/add_command_request.h" #include "sdl_rpc_plugin/commands/mobile/add_command_response.h" -#include "sdl_rpc_plugin/commands/mobile/delete_command_request.h" -#include "sdl_rpc_plugin/commands/mobile/delete_command_response.h" #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_request.h" #include "sdl_rpc_plugin/commands/mobile/add_sub_menu_response.h" -#include "sdl_rpc_plugin/commands/mobile/alert_request.h" -#include "sdl_rpc_plugin/commands/mobile/alert_response.h" #include "sdl_rpc_plugin/commands/mobile/alert_maneuver_request.h" #include "sdl_rpc_plugin/commands/mobile/alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/mobile/alert_request.h" +#include "sdl_rpc_plugin/commands/mobile/alert_response.h" +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_request.h" +#include "sdl_rpc_plugin/commands/mobile/cancel_interaction_response.h" #include "sdl_rpc_plugin/commands/mobile/change_registration_request.h" #include "sdl_rpc_plugin/commands/mobile/change_registration_response.h" +#include "sdl_rpc_plugin/commands/mobile/close_application_request.h" +#include "sdl_rpc_plugin/commands/mobile/close_application_response.h" #include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h" #include "sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_response.h" +#include "sdl_rpc_plugin/commands/mobile/create_window_request.h" +#include "sdl_rpc_plugin/commands/mobile/create_window_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_command_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_command_response.h" #include "sdl_rpc_plugin/commands/mobile/delete_file_request.h" #include "sdl_rpc_plugin/commands/mobile/delete_file_response.h" #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_request.h" #include "sdl_rpc_plugin/commands/mobile/delete_interaction_choice_set_response.h" #include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_request.h" #include "sdl_rpc_plugin/commands/mobile/delete_sub_menu_response.h" +#include "sdl_rpc_plugin/commands/mobile/delete_window_request.h" +#include "sdl_rpc_plugin/commands/mobile/delete_window_response.h" +#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" +#include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" #include "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/end_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/generic_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" +#include "sdl_rpc_plugin/commands/mobile/get_file_request.h" +#include "sdl_rpc_plugin/commands/mobile/get_file_response.h" #include "sdl_rpc_plugin/commands/mobile/get_system_capability_request.h" #include "sdl_rpc_plugin/commands/mobile/get_system_capability_response.h" #include "sdl_rpc_plugin/commands/mobile/get_way_points_request.h" @@ -64,16 +79,19 @@ #include "sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_button_event_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_button_press_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_command_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_hmi_status_notification_from_mobile.h" +#include "sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_language_change_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_command_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_permissions_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_hash_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_system_capability_updated_notification.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" @@ -86,14 +104,22 @@ #include "sdl_rpc_plugin/commands/mobile/reset_global_properties_response.h" #include "sdl_rpc_plugin/commands/mobile/scrollable_message_request.h" #include "sdl_rpc_plugin/commands/mobile/scrollable_message_response.h" +#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" +#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/mobile/send_location_request.h" +#include "sdl_rpc_plugin/commands/mobile/send_location_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_app_icon_response.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" +#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" #include "sdl_rpc_plugin/commands/mobile/set_display_layout_request.h" #include "sdl_rpc_plugin/commands/mobile/set_display_layout_response.h" #include "sdl_rpc_plugin/commands/mobile/set_global_properties_request.h" #include "sdl_rpc_plugin/commands/mobile/set_global_properties_response.h" -#include "sdl_rpc_plugin/commands/mobile/set_app_icon_request.h" -#include "sdl_rpc_plugin/commands/mobile/set_app_icon_response.h" #include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_request.h" #include "sdl_rpc_plugin/commands/mobile/set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_request.h" +#include "sdl_rpc_plugin/commands/mobile/show_app_menu_response.h" #include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_request.h" #include "sdl_rpc_plugin/commands/mobile/show_constant_tbt_response.h" #include "sdl_rpc_plugin/commands/mobile/show_request.h" @@ -106,32 +132,16 @@ #include "sdl_rpc_plugin/commands/mobile/subscribe_button_response.h" #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_response.h" -#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" -#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" +#include "sdl_rpc_plugin/commands/mobile/system_request.h" +#include "sdl_rpc_plugin/commands/mobile/system_response.h" #include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_request.h" #include "sdl_rpc_plugin/commands/mobile/unregister_app_interface_response.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h" #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_response.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" +#include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_response.h" #include "sdl_rpc_plugin/commands/mobile/update_turn_list_request.h" #include "sdl_rpc_plugin/commands/mobile/update_turn_list_response.h" -#include "sdl_rpc_plugin/commands/mobile/system_request.h" -#include "sdl_rpc_plugin/commands/mobile/system_response.h" -#include "sdl_rpc_plugin/commands/mobile/on_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_touch_event_notification.h" -#include "sdl_rpc_plugin/commands/mobile/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/mobile/send_location_request.h" -#include "sdl_rpc_plugin/commands/mobile/send_location_response.h" -#include "sdl_rpc_plugin/commands/mobile/dial_number_request.h" -#include "sdl_rpc_plugin/commands/mobile/dial_number_response.h" -#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_request.h" -#include "sdl_rpc_plugin/commands/mobile/send_haptic_data_response.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_request.h" -#include "sdl_rpc_plugin/commands/mobile/set_cloud_app_properties_response.h" -#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_request.h" -#include "sdl_rpc_plugin/commands/mobile/get_cloud_app_properties_response.h" -#include "sdl_rpc_plugin/commands/mobile/get_file_request.h" -#include "sdl_rpc_plugin/commands/mobile/get_file_response.h" -#include "interfaces/MOBILE_API.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") namespace sdl_rpc_plugin { @@ -170,6 +180,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator<commands::AddCommandRequest>() : factory.GetCreator<commands::AddCommandResponse>(); } + case mobile_apis::FunctionID::CreateWindowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::CreateWindowRequest>() + : factory.GetCreator<commands::CreateWindowResponse>(); + } case mobile_apis::FunctionID::DeleteCommandID: { return mobile_api::messageType::request == message_type ? factory.GetCreator<commands::DeleteCommandRequest>() @@ -185,6 +200,16 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator<commands::DeleteSubMenuRequest>() : factory.GetCreator<commands::DeleteSubMenuResponse>(); } + case mobile_apis::FunctionID::ShowAppMenuID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::ShowAppMenuRequest>() + : factory.GetCreator<commands::ShowAppMenuResponse>(); + } + case mobile_apis::FunctionID::DeleteWindowID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::DeleteWindowRequest>() + : factory.GetCreator<commands::DeleteWindowResponse>(); + } case mobile_apis::FunctionID::DeleteInteractionChoiceSetID: { return mobile_api::messageType::request == message_type ? factory.GetCreator< @@ -212,6 +237,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( ? factory.GetCreator<commands::PerformAudioPassThruRequest>() : factory.GetCreator<commands::PerformAudioPassThruResponse>(); } + case mobile_apis::FunctionID::CancelInteractionID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::CancelInteractionRequest>() + : factory.GetCreator<commands::CancelInteractionResponse>(); + } case mobile_apis::FunctionID::CreateInteractionChoiceSetID: { return mobile_api::messageType::request == message_type ? factory.GetCreator< @@ -356,6 +386,11 @@ CommandCreator& MobileCommandFactory::get_command_creator( : factory .GetCreator<commands::GetCloudAppPropertiesResponse>(); } + case mobile_apis::FunctionID::CloseApplicationID: { + return mobile_api::messageType::request == message_type + ? factory.GetCreator<commands::CloseApplicationRequest>() + : factory.GetCreator<commands::CloseApplicationResponse>(); + } case mobile_apis::FunctionID::GenericResponseID: { using app_mngr::commands::Command; return factory.GetCreator<commands::GenericResponse>(); @@ -512,4 +547,4 @@ CommandSharedPtr MobileCommandFactory::CreateCommand( return get_creator_factory(function_id, message_type, source).create(message); } -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc index d745cd8f44..21f15a33fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_command_factory.cc @@ -77,4 +77,4 @@ bool SDLCommandFactory::IsAbleToProcess( : is_mobile_command_factory_able_to_process; } -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc index c448b41ff1..35d3fbe2f6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/sdl_rpc_plugin.cc @@ -30,10 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/plugin_manager/plugin_keys.h" #include "sdl_rpc_plugin/sdl_rpc_plugin.h" -#include "sdl_rpc_plugin/sdl_command_factory.h" +#include "application_manager/plugin_manager/plugin_keys.h" #include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "sdl_rpc_plugin/sdl_command_factory.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -44,7 +44,9 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "SdlRPCPlugin") bool SDLRPCPlugin::Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + UNUSED(last_state); command_factory_.reset(new sdl_rpc_plugin::SDLCommandFactory( app_manager, rpc_service, hmi_capabilities, policy_handler)); return true; @@ -70,8 +72,14 @@ void SDLRPCPlugin::OnApplicationEvent( plugins::ApplicationEvent event, app_mngr::ApplicationSharedPtr application) { if (plugins::ApplicationEvent::kApplicationRegistered == event) { - application->AddExtension( - std::make_shared<SystemCapabilityAppExtension>(*this, *application)); + auto sys_cap_ext_ptr = + std::make_shared<SystemCapabilityAppExtension>(*this, *application); + application->AddExtension(sys_cap_ext_ptr); + // Processing automatic subscription to SystemCapabilities for DISPLAY type + const auto capability_type = + mobile_apis::SystemCapabilityType::eType::DISPLAYS; + LOG4CXX_DEBUG(logger_, "Subscription to DISPLAYS capability is enabled"); + sys_cap_ext_ptr->SubscribeTo(capability_type); } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { ClearSubscriptions(application); } @@ -84,6 +92,14 @@ void SDLRPCPlugin::ClearSubscriptions(app_mngr::ApplicationSharedPtr app) { } // namespace sdl_rpc_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new sdl_rpc_plugin::SDLRPCPlugin(); } + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(sdl_rpc_plugin::logger_); +} diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt index 1a206c2cce..b21ab9dca8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -23,15 +23,8 @@ file(GLOB SOURCES ) set(LIBRARIES + sdl_rpc_plugin_static gmock - Utils - SmartObjects - HMI_API - MOBILE_API - connectionHandler - sdl_rpc_plugin - jsoncpp - Policy ) create_cotired_test("sdl_commands_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc index 50b7aae42a..7dadad59fe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/activate_app_request_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/activate_app_request.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -47,9 +47,9 @@ using ::testing::_; namespace am = ::application_manager; namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::ActivateAppRequest; -using am::commands::CommandImpl; using ::test::components::application_manager_test::MockApplication; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc index a5707488dd..01487284a4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/add_statistics_info_notification_test.cc @@ -30,15 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/add_statistics_info_notification.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/policies/policy_handler.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/policies/policy_handler.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -49,11 +49,11 @@ namespace add_statistics_info_notification { namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_notification = ::application_manager::hmi_notification; -using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::AddStatisticsInfoNotification; using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; using policy::PolicyHandler; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::AddStatisticsInfoNotification; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc index a2fcf8f605..251fe230fc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_all_apps_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/allow_all_apps_response.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { @@ -53,7 +53,7 @@ typedef std::shared_ptr<AllowAllAppsResponse> ResponsePtr; namespace { const bool kResponseIsAllowed = true; -} // +} // namespace class AllowAllAppsResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc index 2ce400542a..a0e23d7b9d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/allow_app_response_test.cc @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/allow_app_response.h" +#include "gtest/gtest.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" @@ -53,7 +53,7 @@ namespace hmi_response = ::application_manager::hmi_response; namespace { const uint32_t kConnectionKey = 1u; const bool kIsResponseAllowed = true; -} +} // namespace typedef std::shared_ptr<AllowAppResponse> ResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc index a3f0ab6933..9cd87b053d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_request_test.cc @@ -28,7 +28,7 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. -*/ + */ #include "hmi/basic_communication_get_system_time_request.h" @@ -60,7 +60,7 @@ TEST_F(BasicCommunicationGetSystemTimeRequestTest, OnTimeout) { ON_CALL(app_mngr_, protocol_handler()) .WillByDefault(ReturnRef(mock_protocol_handler)); - EXPECT_CALL(mock_protocol_handler, NotifyOnFailedHandshake()); + EXPECT_CALL(mock_protocol_handler, NotifyOnGetSystemTimeFailed()); command->onTimeOut(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc index 8f56c6462c..0c8e986fc6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/basic_communication_get_system_time_response_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "hmi/basic_communication_get_system_time_response.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc index 6ed15bebeb..7d9ed899a6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/button_get_capabilities_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/button_get_capabilities_response.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_hmi_capabilities.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { @@ -45,8 +45,8 @@ namespace button_get_capabilities_response { using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::ButtonGetCapabilitiesResponse; -using ::testing::ReturnRef; using ::testing::NiceMock; +using ::testing::ReturnRef; namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; @@ -100,7 +100,8 @@ TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeAborted_SUCCESS) { EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)) .Times(0); EXPECT_CALL(mock_hmi_capabilities_, - set_preset_bank_capabilities(preset_bank_capabilities_)).Times(0); + set_preset_bank_capabilities(preset_bank_capabilities_)) + .Times(0); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc index 6914a4ca7e..087109c871 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/close_popup_response_test.cc @@ -35,13 +35,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/close_popup_response.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" #include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "hmi/close_popup_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -50,9 +50,9 @@ namespace hmi_commands_test { namespace close_popup_response { namespace am = ::application_manager; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::ClosePopupResponse; -using am::commands::CommandImpl; typedef std::shared_ptr<ResponseFromHMI> ResponseFromHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index 874d27b4b0..c66cb81141 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -37,194 +37,191 @@ #include <vector> #include "gtest/gtest.h" +#include "hmi/activate_app_request.h" +#include "hmi/activate_app_response.h" +#include "hmi/add_statistics_info_notification.h" #include "hmi/allow_all_apps_request.h" #include "hmi/allow_all_apps_response.h" #include "hmi/allow_app_request.h" #include "hmi/allow_app_response.h" +#include "hmi/basic_communication_system_request.h" +#include "hmi/basic_communication_system_response.h" +#include "hmi/bc_get_file_path_request.h" +#include "hmi/bc_get_file_path_response.h" +#include "hmi/button_get_capabilities_request.h" +#include "hmi/button_get_capabilities_response.h" +#include "hmi/close_popup_request.h" +#include "hmi/close_popup_response.h" +#include "hmi/dial_number_request.h" +#include "hmi/dial_number_response.h" +#include "hmi/get_system_info_request.h" +#include "hmi/get_system_info_response.h" +#include "hmi/mixing_audio_supported_request.h" +#include "hmi/mixing_audio_supported_response.h" +#include "hmi/navi_alert_maneuver_request.h" +#include "hmi/navi_alert_maneuver_response.h" #include "hmi/navi_audio_start_stream_request.h" #include "hmi/navi_audio_start_stream_response.h" #include "hmi/navi_audio_stop_stream_request.h" #include "hmi/navi_audio_stop_stream_response.h" -#include "hmi/update_device_list_request.h" -#include "hmi/update_device_list_response.h" -#include "hmi/on_update_device_list.h" -#include "hmi/on_start_device_discovery.h" -#include "hmi/update_app_list_request.h" -#include "hmi/update_app_list_response.h" -#include "hmi/on_find_applications.h" -#include "hmi/sdl_get_list_of_permissions_request.h" -#include "hmi/sdl_get_list_of_permissions_response.h" -#include "hmi/sdl_get_user_friendly_message_request.h" -#include "hmi/sdl_get_user_friendly_message_response.h" -#include "hmi/sdl_get_status_update_request.h" -#include "hmi/sdl_get_status_update_response.h" -#include "hmi/on_status_update_notification.h" -#include "hmi/update_sdl_request.h" -#include "hmi/update_sdl_response.h" -#include "hmi/activate_app_request.h" -#include "hmi/activate_app_response.h" -#include "hmi/mixing_audio_supported_request.h" -#include "hmi/mixing_audio_supported_response.h" +#include "hmi/navi_get_way_points_request.h" +#include "hmi/navi_get_way_points_response.h" +#include "hmi/navi_is_ready_request.h" +#include "hmi/navi_is_ready_response.h" +#include "hmi/navi_send_location_request.h" +#include "hmi/navi_send_location_response.h" +#include "hmi/navi_show_constant_tbt_request.h" +#include "hmi/navi_show_constant_tbt_response.h" +#include "hmi/navi_start_stream_request.h" +#include "hmi/navi_start_stream_response.h" +#include "hmi/navi_stop_stream_request.h" +#include "hmi/navi_stop_stream_response.h" +#include "hmi/navi_subscribe_way_points_request.h" +#include "hmi/navi_subscribe_way_points_response.h" +#include "hmi/navi_unsubscribe_way_points_request.h" +#include "hmi/navi_unsubscribe_way_points_response.h" +#include "hmi/navi_update_turn_list_request.h" +#include "hmi/navi_update_turn_list_response.h" #include "hmi/on_allow_sdl_functionality_notification.h" +#include "hmi/on_app_activated_notification.h" +#include "hmi/on_app_deactivated_notification.h" #include "hmi/on_app_permission_changed_notification.h" #include "hmi/on_app_permission_consent_notification.h" -#include "hmi/on_app_activated_notification.h" +#include "hmi/on_app_registered_notification.h" +#include "hmi/on_app_unregistered_notification.h" #include "hmi/on_audio_data_streaming_notification.h" -#include "hmi/on_video_data_streaming_notification.h" -#include "hmi/on_sdl_consent_needed_notification.h" +#include "hmi/on_button_event_notification.h" +#include "hmi/on_button_press_notification.h" +#include "hmi/on_button_subscription_notification.h" +#include "hmi/on_device_chosen_notification.h" +#include "hmi/on_device_state_changed_notification.h" +#include "hmi/on_driver_distraction_notification.h" +#include "hmi/on_event_changed_notification.h" #include "hmi/on_exit_all_applications_notification.h" #include "hmi/on_exit_application_notification.h" +#include "hmi/on_file_removed_notification.h" +#include "hmi/on_find_applications.h" +#include "hmi/on_ignition_cycle_over_notification.h" +#include "hmi/on_navi_tbt_client_state_notification.h" +#include "hmi/on_navi_way_point_change_notification.h" +#include "hmi/on_policy_update.h" #include "hmi/on_put_file_notification.h" +#include "hmi/on_ready_notification.h" +#include "hmi/on_received_policy_update.h" +#include "hmi/on_record_start_notification.h" #include "hmi/on_resume_audio_source_notification.h" -#include "hmi/on_ignition_cycle_over_notification.h" +#include "hmi/on_sdl_close_notification.h" +#include "hmi/on_sdl_consent_needed_notification.h" +#include "hmi/on_sdl_persistence_complete_notification.h" +#include "hmi/on_start_device_discovery.h" +#include "hmi/on_status_update_notification.h" +#include "hmi/on_system_context_notification.h" +#include "hmi/on_system_error_notification.h" #include "hmi/on_system_info_changed_notification.h" -#include "hmi/get_system_info_request.h" -#include "hmi/get_system_info_response.h" -#include "hmi/close_popup_request.h" -#include "hmi/close_popup_response.h" -#include "hmi/button_get_capabilities_request.h" -#include "hmi/button_get_capabilities_response.h" +#include "hmi/on_system_request_notification.h" +#include "hmi/on_tts_language_change_notification.h" +#include "hmi/on_tts_reset_timeout_notification.h" +#include "hmi/on_tts_started_notification.h" +#include "hmi/on_tts_stopped_notification.h" +#include "hmi/on_ui_command_notification.h" +#include "hmi/on_ui_keyboard_input_notification.h" +#include "hmi/on_ui_language_change_notification.h" +#include "hmi/on_ui_reset_timeout_notification.h" +#include "hmi/on_ui_touch_event_notification.h" +#include "hmi/on_update_device_list.h" +#include "hmi/on_video_data_streaming_notification.h" +#include "hmi/on_vr_command_notification.h" +#include "hmi/on_vr_language_change_notification.h" +#include "hmi/on_vr_started_notification.h" +#include "hmi/on_vr_stopped_notification.h" +#include "hmi/sdl_activate_app_request.h" +#include "hmi/sdl_activate_app_response.h" +#include "hmi/sdl_get_list_of_permissions_request.h" +#include "hmi/sdl_get_list_of_permissions_response.h" +#include "hmi/sdl_get_status_update_request.h" +#include "hmi/sdl_get_status_update_response.h" +#include "hmi/sdl_get_user_friendly_message_request.h" +#include "hmi/sdl_get_user_friendly_message_response.h" +#include "hmi/sdl_policy_update.h" +#include "hmi/sdl_policy_update_response.h" +#include "hmi/tts_change_registration_request.h" +#include "hmi/tts_change_registration_response.h" +#include "hmi/tts_get_capabilities_request.h" +#include "hmi/tts_get_capabilities_response.h" +#include "hmi/tts_get_language_request.h" +#include "hmi/tts_get_language_response.h" +#include "hmi/tts_get_supported_languages_request.h" +#include "hmi/tts_get_supported_languages_response.h" +#include "hmi/tts_is_ready_request.h" +#include "hmi/tts_is_ready_response.h" +#include "hmi/tts_set_global_properties_request.h" +#include "hmi/tts_set_global_properties_response.h" +#include "hmi/tts_speak_request.h" +#include "hmi/tts_speak_response.h" +#include "hmi/tts_stop_speaking_request.h" +#include "hmi/tts_stop_speaking_response.h" #include "hmi/ui_add_command_request.h" #include "hmi/ui_add_command_response.h" -#include "hmi/ui_delete_command_request.h" -#include "hmi/ui_delete_command_response.h" #include "hmi/ui_add_submenu_request.h" #include "hmi/ui_add_submenu_response.h" +#include "hmi/ui_alert_request.h" +#include "hmi/ui_alert_response.h" +#include "hmi/ui_change_registration_request.h" +#include "hmi/ui_change_registration_response.h" +#include "hmi/ui_delete_command_request.h" +#include "hmi/ui_delete_command_response.h" #include "hmi/ui_delete_submenu_request.h" #include "hmi/ui_delete_submenu_response.h" -#include "hmi/ui_get_supported_languages_request.h" -#include "hmi/ui_get_supported_languages_response.h" -#include "hmi/ui_get_language_request.h" -#include "hmi/ui_get_language_response.h" +#include "hmi/ui_end_audio_pass_thru_request.h" +#include "hmi/ui_end_audio_pass_thru_response.h" #include "hmi/ui_get_capabilities_request.h" #include "hmi/ui_get_capabilities_response.h" -#include "hmi/ui_change_registration_request.h" -#include "hmi/ui_change_registration_response.h" -#include "hmi/ui_show_request.h" -#include "hmi/ui_show_response.h" -#include "hmi/ui_alert_request.h" -#include "hmi/ui_alert_response.h" +#include "hmi/ui_get_language_request.h" +#include "hmi/ui_get_language_response.h" +#include "hmi/ui_get_supported_languages_request.h" +#include "hmi/ui_get_supported_languages_response.h" #include "hmi/ui_is_ready_request.h" #include "hmi/ui_is_ready_response.h" -#include "hmi/ui_slider_request.h" -#include "hmi/ui_slider_response.h" -#include "hmi/ui_set_media_clock_timer_request.h" -#include "hmi/ui_set_media_clock_timer_response.h" -#include "hmi/ui_set_global_properties_request.h" -#include "hmi/ui_set_global_properties_response.h" +#include "hmi/ui_perform_audio_pass_thru_request.h" +#include "hmi/ui_perform_audio_pass_thru_response.h" +#include "hmi/ui_perform_interaction_request.h" +#include "hmi/ui_perform_interaction_response.h" #include "hmi/ui_scrollable_message_request.h" #include "hmi/ui_scrollable_message_response.h" #include "hmi/ui_set_app_icon_request.h" #include "hmi/ui_set_app_icon_response.h" -#include "hmi/ui_perform_audio_pass_thru_response.h" -#include "hmi/ui_perform_audio_pass_thru_request.h" -#include "hmi/ui_end_audio_pass_thru_request.h" -#include "hmi/ui_end_audio_pass_thru_response.h" -#include "hmi/ui_perform_interaction_request.h" -#include "hmi/ui_perform_interaction_response.h" -#include "hmi/vr_is_ready_request.h" -#include "hmi/vr_is_ready_response.h" +#include "hmi/ui_set_display_layout_request.h" +#include "hmi/ui_set_display_layout_response.h" +#include "hmi/ui_set_global_properties_request.h" +#include "hmi/ui_set_global_properties_response.h" +#include "hmi/ui_set_media_clock_timer_request.h" +#include "hmi/ui_set_media_clock_timer_response.h" +#include "hmi/ui_show_request.h" +#include "hmi/ui_show_response.h" +#include "hmi/ui_slider_request.h" +#include "hmi/ui_slider_response.h" +#include "hmi/update_app_list_request.h" +#include "hmi/update_app_list_response.h" +#include "hmi/update_device_list_request.h" +#include "hmi/update_device_list_response.h" +#include "hmi/update_sdl_request.h" +#include "hmi/update_sdl_response.h" #include "hmi/vr_add_command_request.h" #include "hmi/vr_add_command_response.h" -#include "hmi/vr_delete_command_request.h" -#include "hmi/vr_delete_command_response.h" #include "hmi/vr_change_registration_request.h" #include "hmi/vr_change_registration_response.h" -#include "hmi/vr_get_supported_languages_request.h" -#include "hmi/vr_get_supported_languages_response.h" -#include "hmi/vr_get_language_request.h" -#include "hmi/vr_get_language_response.h" +#include "hmi/vr_delete_command_request.h" +#include "hmi/vr_delete_command_response.h" #include "hmi/vr_get_capabilities_request.h" #include "hmi/vr_get_capabilities_response.h" -#include "hmi/tts_is_ready_request.h" -#include "hmi/tts_is_ready_response.h" -#include "hmi/tts_change_registration_request.h" -#include "hmi/tts_change_registration_response.h" -#include "hmi/tts_get_supported_languages_request.h" -#include "hmi/tts_get_supported_languages_response.h" -#include "hmi/tts_get_language_request.h" -#include "hmi/tts_get_language_response.h" -#include "hmi/tts_stop_speaking_request.h" -#include "hmi/tts_stop_speaking_response.h" -#include "hmi/tts_speak_request.h" -#include "hmi/tts_speak_response.h" -#include "hmi/tts_set_global_properties_request.h" -#include "hmi/tts_set_global_properties_response.h" -#include "hmi/tts_get_capabilities_request.h" -#include "hmi/tts_get_capabilities_response.h" +#include "hmi/vr_get_language_request.h" +#include "hmi/vr_get_language_response.h" +#include "hmi/vr_get_supported_languages_request.h" +#include "hmi/vr_get_supported_languages_response.h" +#include "hmi/vr_is_ready_request.h" +#include "hmi/vr_is_ready_response.h" #include "hmi/vr_perform_interaction_request.h" #include "hmi/vr_perform_interaction_response.h" -#include "hmi/sdl_activate_app_request.h" -#include "hmi/sdl_activate_app_response.h" -#include "hmi/on_app_permission_changed_notification.h" -#include "hmi/on_event_changed_notification.h" -#include "hmi/navi_is_ready_request.h" -#include "hmi/navi_show_constant_tbt_request.h" -#include "hmi/navi_show_constant_tbt_response.h" -#include "hmi/navi_is_ready_response.h" -#include "hmi/navi_alert_maneuver_request.h" -#include "hmi/navi_alert_maneuver_response.h" -#include "hmi/navi_update_turn_list_request.h" -#include "hmi/navi_update_turn_list_response.h" -#include "hmi/navi_subscribe_way_points_request.h" -#include "hmi/navi_subscribe_way_points_response.h" -#include "hmi/navi_unsubscribe_way_points_request.h" -#include "hmi/navi_unsubscribe_way_points_response.h" -#include "hmi/navi_get_way_points_request.h" -#include "hmi/navi_get_way_points_response.h" -#include "hmi/on_ready_notification.h" -#include "hmi/on_device_chosen_notification.h" -#include "hmi/on_file_removed_notification.h" -#include "hmi/on_system_context_notification.h" -#include "hmi/on_app_registered_notification.h" -#include "hmi/on_app_unregistered_notification.h" -#include "hmi/on_driver_distraction_notification.h" -#include "hmi/on_tts_started_notification.h" -#include "hmi/on_tts_stopped_notification.h" -#include "hmi/on_vr_started_notification.h" -#include "hmi/on_vr_stopped_notification.h" -#include "hmi/on_vr_command_notification.h" -#include "hmi/on_ui_command_notification.h" -#include "hmi/on_app_deactivated_notification.h" -#include "hmi/on_ui_language_change_notification.h" -#include "hmi/on_vr_language_change_notification.h" -#include "hmi/on_tts_language_change_notification.h" -#include "hmi/on_navi_tbt_client_state_notification.h" -#include "hmi/on_navi_way_point_change_notification.h" -#include "hmi/on_button_event_notification.h" -#include "hmi/on_button_press_notification.h" -#include "hmi/on_button_subscription_notification.h" -#include "hmi/on_ui_keyboard_input_notification.h" -#include "hmi/on_ui_touch_event_notification.h" -#include "hmi/on_ui_reset_timeout_notification.h" -#include "hmi/navi_start_stream_request.h" -#include "hmi/navi_start_stream_response.h" -#include "hmi/navi_stop_stream_request.h" -#include "hmi/navi_stop_stream_response.h" -#include "hmi/on_system_request_notification.h" -#include "hmi/ui_set_display_layout_request.h" -#include "hmi/ui_set_display_layout_response.h" -#include "hmi/on_sdl_close_notification.h" -#include "hmi/on_sdl_persistence_complete_notification.h" -#include "hmi/on_record_start_notification.h" -#include "hmi/add_statistics_info_notification.h" -#include "hmi/on_system_error_notification.h" -#include "hmi/basic_communication_system_request.h" -#include "hmi/basic_communication_system_response.h" -#include "hmi/sdl_policy_update.h" -#include "hmi/sdl_policy_update_response.h" -#include "hmi/on_received_policy_update.h" -#include "hmi/on_policy_update.h" -#include "hmi/get_urls.h" -#include "hmi/get_urls_response.h" -#include "hmi/on_device_state_changed_notification.h" -#include "hmi/navi_send_location_request.h" -#include "hmi/navi_send_location_response.h" -#include "hmi/on_tts_reset_timeout_notification.h" -#include "hmi/dial_number_request.h" -#include "hmi/dial_number_response.h" -#include "hmi/bc_get_file_path_request.h" -#include "hmi/bc_get_file_path_response.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" @@ -242,16 +239,16 @@ namespace dummy_hmi_commands_test { namespace commands = sdl_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; +using ::application_manager::ApplicationSharedPtr; using application_manager::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; template <class Command> class HMICommandsTest : public components::commands_test::CommandRequestTest< @@ -321,8 +318,6 @@ typedef Types<commands::OnStartDeviceDiscovery, commands::SDLActivateAppRequest, commands::SDLPolicyUpdateResponse, commands::SDLPolicyUpdate, - commands::GetUrlsResponse, - commands::GetUrls, commands::OnAppPermissionChangedNotification, commands::SDLGetListOfPermissionsResponse, commands::SDLGetListOfPermissionsRequest, @@ -359,7 +354,8 @@ typedef Types<commands::OnStartDeviceDiscovery, commands::UIGetLanguageRequest, commands::UIGetCapabilitiesResponse, commands::UIGetCapabilitiesRequest, - commands::UIChangeRegistratioResponse> HMICommandsListFirst; + commands::UIChangeRegistratioResponse> + HMICommandsListFirst; typedef Types<commands::UIChangeRegistrationRequest, commands::UIPerformAudioPassThruResponse, @@ -409,7 +405,8 @@ typedef Types<commands::UIChangeRegistrationRequest, commands::ClosePopupResponse, commands::ClosePopupRequest, commands::UIIsReadyResponse, - commands::UIIsReadyRequest> HMICommandsListSecond; + commands::UIIsReadyRequest> + HMICommandsListSecond; typedef Types<commands::NaviIsReadyResponse, commands::NaviIsReadyRequest, @@ -447,7 +444,8 @@ typedef Types<commands::NaviIsReadyResponse, commands::OnVRStoppedNotification, commands::OnVRCommandNotification, commands::OnUICommandNotification, - commands::OnAppDeactivatedNotification> HMICommandsListThird; + commands::OnAppDeactivatedNotification> + HMICommandsListThird; typedef Types<commands::hmi::OnButtonEventNotification, commands::hmi::OnButtonPressNotification, @@ -493,14 +491,16 @@ typedef Types<commands::hmi::OnButtonEventNotification, commands::OnNaviWayPointChangeNotification, commands::OnUILanguageChangeNotification, commands::OnVRLanguageChangeNotification, - commands::OnTTSLanguageChangeNotification> HMICommandsListFourth; + commands::OnTTSLanguageChangeNotification> + HMICommandsListFourth; typedef Types<commands::AllowAllAppsRequest, commands::AllowAllAppsResponse, commands::AllowAppRequest, commands::AllowAppResponse, commands::BCGetFilePathRequest, - commands::BCGetFilePathResponse> HMICommandsListFifth; + commands::BCGetFilePathResponse> + HMICommandsListFifth; TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst); TYPED_TEST_CASE(HMICommandsTestSecond, HMICommandsListSecond); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc index 4cbe7305ea..5b860499dd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_request_test.cc @@ -35,13 +35,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/commands/request_to_hmi.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/smart_object_keys.h" #include "hmi/get_system_info_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,9 +51,9 @@ namespace get_system_info_request { namespace am = ::application_manager; namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; using am::commands::RequestToHMI; using sdl_rpc_plugin::commands::GetSystemInfoRequest; -using am::commands::CommandImpl; typedef std::shared_ptr<RequestToHMI> RequestToHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc index 6908e21053..11589683be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc @@ -33,32 +33,32 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/get_system_info_response.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/get_system_info_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace hmi_commands_test { namespace get_system_info_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::GetSystemInfoResponse; using sdl_rpc_plugin::commands::SystemInfo; -using am::commands::CommandImpl; typedef std::shared_ptr<ResponseFromHMI> ResponseFromHMIPtr; typedef NiceMock< diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc deleted file mode 100644 index 20a05d8601..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_test.cc +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2018, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <stdint.h> -#include <string> - -#include "gtest/gtest.h" -#include "application_manager/message.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_application_manager.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command.h" -#include "hmi/get_urls.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/command_request_test.h" -#include "application_manager/commands/request_from_hmi.h" -#include "policy/mock_policy_manager.h" -#include "application_manager/event_engine/event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace get_urls { - -using namespace hmi_apis; -using namespace policy; -using ::testing::NiceMock; -using ::testing::_; -using ::testing::SetArgReferee; -using ::test::components::application_manager_test::MockApplication; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::RequestFromHMI; -using sdl_rpc_plugin::commands::GetUrls; -using am::commands::CommandImpl; -using policy::PolicyHandler; -using policy_test::MockPolicyHandlerInterface; - -typedef std::shared_ptr<RequestFromHMI> RequestFromHMIPtr; - -namespace { -const uint32_t kInvalidAppId_ = 0u; -const uint32_t kAppIdForSending = 1u; -const uint32_t kConnectionKey = 2u; -const uint32_t kServiceType = 0u; -const std::string kInitialService = "0x0"; -const std::string kPolicyService = "7"; -const std::string kDefaultUrl = "URL is not found"; -const std::string kDefaultId = "default"; -const std::string kPolicyAppId = "policy_app_id"; -} // namespace - -class GetUrlsTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr command_msg_; - RequestFromHMIPtr request_command_; - - GetUrlsTest() { - command_msg_ = - CreateMessage(ns_smart_device_link::ns_smart_objects::SmartType_Map); - (*command_msg_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kInitialService; - - request_command_ = CreateCommand<GetUrls>(command_msg_); - } -}; - -TEST_F(GetUrlsTest, RUN_SUCCESS) { - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - // EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(_, _)); - - request_command_->Run(); -} - -TEST_F(GetUrlsTest, RUN_PolicyNotEnabled_UNSUCCESS) { - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(false)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -TEST_F(GetUrlsTest, RUN_EmptyEndpoints_UNSUCCESS) { - EndpointUrls endpoints_; - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -#ifdef EXTENDED_POLICY -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr mock_app = CreateMockApp(); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppIdForSending)); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::SUCCESS, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); - - EXPECT_EQ(kAppIdForSending, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [strings::app_id].asInt()); - EXPECT_EQ(kDefaultUrl, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [strings::url].asString()); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_IncorrectIdForSending_UNSUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kInvalidAppId_)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - EXPECT_CALL(app_mngr_, application(kInvalidAppId_)).Times(0); - - request_command_->Run(); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_ApplicationIsNotValid_UNSUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr invalid_mock_app; - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(invalid_mock_app)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_FoundURLForApplication_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - data.app_id = kPolicyAppId; - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr mock_app = CreateMockApp(); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(mock_app)); - - EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(kPolicyAppId)); - - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(command_msg_, _)) - .WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::SUCCESS, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} -#endif - -TEST_F(GetUrlsTest, DISABLED_ProcessServiceURLs_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = - kDefaultUrl; - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id] = "1"; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - data.app_id = "1"; - endpoints_.push_back(data); - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - EXPECT_EQ(kDefaultUrl, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::strings::url].asString()); - EXPECT_EQ(endpoints_[0].app_id, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id].asString()); -} - -TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = - kDefaultUrl; - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id] = kDefaultId; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - MockAppPtr mock_app = CreateMockApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(_)) - .WillOnce(Return(mock_app)); - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - EXPECT_TRUE( - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - .keyExists(am::hmi_response::policy_app_id)); -} - -} // namespace get_urls -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index ca322ea425..26f7a63872 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -33,81 +33,81 @@ #include <stdint.h> #include <string> #include <vector> -#include "gtest/gtest.h" #include "application_manager/commands/commands_test.h" -#include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "gtest/gtest.h" +#include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" #include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" #include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "utils/lock.h" #include "utils/data_accessor.h" +#include "utils/lock.h" #include "utils/signals.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_rpc_plugin_manager.h" -#include "application_manager/mock_state_controller.h" +#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/mock_hmi_capabilities.h" -#include "transport_manager/mock_transport_manager.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/mock_rpc_plugin_manager.h" +#include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" #include "connection_handler/mock_connection_handler.h" #include "connection_handler/mock_connection_handler_settings.h" -#include "test/application_manager/mock_application_manager_settings.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" #include "protocol_handler/mock_session_observer.h" -#include "application_manager/mock_resume_ctrl.h" +#include "smart_objects/smart_object.h" +#include "test/application_manager/mock_application_manager_settings.h" +#include "transport_manager/mock_transport_manager.h" +#include "utils/file_system.h" namespace am = application_manager; @@ -117,22 +117,22 @@ namespace commands_test { namespace hmi_commands_test { namespace hmi_notifications_test { -using ::testing::_; -using ::testing::Test; -using ::testing::Types; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::InSequence; -using ::smart_objects::SmartObject; +using ::application_manager::ApplicationSharedPtr; +using ::application_manager::MockMessageHelper; using ::application_manager::commands::MessageSharedPtr; +using ::smart_objects::SmartObject; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; using ::test::components::event_engine_test::MockEventDispatcher; -using ::application_manager::MockMessageHelper; +using ::testing::_; +using ::testing::InSequence; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; +using ::testing::Test; +using ::testing::Types; using namespace sdl_rpc_plugin::commands; using namespace am::commands; @@ -148,6 +148,11 @@ typedef NiceMock< #define NAVI true #define NOT_NAVI false +namespace { +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + ACTION_P(GetEventId, event_id) { *event_id = arg0.id(); } @@ -155,8 +160,8 @@ ACTION_P(GetArg, arg) { *arg = arg0; } -ACTION_P(GetArg3, result) { - arg3 = *result; +ACTION_P(GetArg4, result) { + arg4 = *result; } ACTION_P2(GetConnectIdPermissionConsent, connect_id, consent) { @@ -192,6 +197,14 @@ const int32_t kMobileProtocolType_ = 0; const int32_t kProtocolVersion_ = 3; const uint32_t kCorrelationId_ = 1939u; const uint32_t kAppId_ = 2014u; +const std::string kDefaultLanguage = "en-us"; +const mobile_apis::Language::eType kMobileLanguage = + mobile_apis::Language::EN_US; + +// LSDW - lock screen dismissal warning +const std::string kLockScreenDismissalWarningMessage_en = + "Swipe down to dismiss, acknowledging that you are not the driver"; +const uint32_t kConnectionKey = 2u; } // namespace class HMICommandsNotificationsTest @@ -240,6 +253,9 @@ class HMICommandsNotificationsTest .WillByDefault(ReturnRef(mock_event_dispatcher_)); ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); + ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app_)); + ON_CALL(mock_message_helper_, MobileLanguageToString(kMobileLanguage)) + .WillByDefault(Return(kDefaultLanguage)); } am::ApplicationSharedPtr ConfigureApp(NiceMock<MockApplication>** app_mock, @@ -259,6 +275,8 @@ class HMICommandsNotificationsTest .WillByDefault(Return(vc)); ON_CALL(**app_mock, IsAudioApplication()) .WillByDefault(Return(media || navi || vc)); + ON_CALL(**app_mock, ui_language()) + .WillByDefault(ReturnRef(kMobileLanguage)); return app; } #if defined(OS_POSIX) @@ -319,7 +337,8 @@ typedef Types<OnAppPermissionChangedNotification, OnSDLPersistenceCompleteNotification, OnStatusUpdateNotification, OnVideoDataStreamingNotification, - OnRecordStartdNotification> HMIOnNotificationsListToHMITypes; + OnRecordStartdNotification> + HMIOnNotificationsListToHMITypes; typedef Types< CommandPair<OnAppActivatedNotification, @@ -1023,7 +1042,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); EXPECT_CALL(mock_message_helper_, GetOnAppInterfaceUnregisteredNotificationToMobile( - kAppId_, *it_mobile_reason)).WillOnce(Return(notification)); + kAppId_, *it_mobile_reason)) + .WillOnce(Return(notification)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(notification, Command::SOURCE_SDL)); EXPECT_CALL(app_mngr_, @@ -1088,6 +1108,7 @@ TEST_F(HMICommandsNotificationsTest, .WillOnce(ReturnRef(mock_state_controller_)); EXPECT_CALL(mock_state_controller_, SetRegularState(app_, + kDefaultWindowId, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, @@ -1112,12 +1133,7 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(app_, - mobile_apis::HMILevel::HMI_NONE, - mobile_apis::AudioStreamingState::NOT_AUDIBLE, - mobile_apis::VideoStreamingState::NOT_STREAMABLE, - false)); + EXPECT_CALL(mock_state_controller_, ExitDefaultWindow(app_)); command->Run(); } @@ -1135,7 +1151,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); EXPECT_CALL(mock_state_controller_, - SetRegularState(_, mobile_apis::HMILevel::HMI_FULL, true)); + SetRegularState( + _, kDefaultWindowId, mobile_apis::HMILevel::HMI_FULL, true)); EXPECT_CALL(app_mngr_, get_settings()) .WillOnce(ReturnRef(app_mngr_settings_)); @@ -1336,8 +1353,10 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, false)); + EXPECT_CALL( + mock_state_controller_, + SetRegularState( + app_, kDefaultWindowId, mobile_apis::HMILevel::HMI_NONE, false)); EXPECT_CALL(mock_message_helper_, GetOnAppInterfaceUnregisteredNotificationToMobile( kAppId_, @@ -1377,10 +1396,11 @@ TEST_F(HMICommandsNotificationsTest, [am::strings::id] = "2014"; std::shared_ptr<Command> command = CreateCommand<OnDeviceChosenNotification>(message); - EXPECT_CALL(app_mngr_, - ConnectToDevice( - (*message)[am::strings::msg_params][am::strings::device_info] - [am::strings::id].asString())); + EXPECT_CALL( + app_mngr_, + ConnectToDevice((*message)[am::strings::msg_params] + [am::strings::device_info][am::strings::id] + .asString())); command->Run(); } @@ -1413,7 +1433,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, active_application()).WillOnce(Return(app_)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, kDefaultWindowId, *it)); command->Run(); } } @@ -1462,7 +1483,8 @@ TEST_F(HMICommandsNotificationsTest, EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); EXPECT_CALL(app_mngr_, state_controller()) .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(app_, kDefaultWindowId, *it)); command->Run(); } } @@ -1790,11 +1812,26 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr message = CreateMessage(); (*message)[am::strings::msg_params][am::hmi_notification::state] = state; + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr<Command> command = CreateCommand<hmi::OnDriverDistractionNotification>(message); EXPECT_CALL(app_mngr_, set_driver_distraction_state(state)); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + typedef boost::optional<bool> OptionalBool; + + ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + std::string required_language = "en-us"; + ON_CALL(mock_policy_handler_, + LockScreenDismissalWarningMessage(required_language)) + .WillByDefault(Return( + boost::optional<std::string>(kLockScreenDismissalWarningMessage_en))); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); EXPECT_CALL(*app_ptr_, app_id()).Times(0); command->Run(); @@ -1802,16 +1839,28 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationInvalidApp) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr message = CreateMessage(); (*message)[am::strings::msg_params][am::hmi_notification::state] = state; + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr<Command> command = CreateCommand<hmi::OnDriverDistractionNotification>(message); ApplicationSharedPtr invalid_app; application_set_.insert(invalid_app); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + typedef boost::optional<bool> OptionalBool; + ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + std::string required_language = "en-us"; + ON_CALL(mock_policy_handler_, + LockScreenDismissalWarningMessage(required_language)) + .WillByDefault(Return( + boost::optional<std::string>(kLockScreenDismissalWarningMessage_en))); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(applications_)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); EXPECT_CALL(*app_ptr_, app_id()).Times(0); command->Run(); @@ -1822,21 +1871,33 @@ TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationValidApp) { hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr message = CreateMessage(); (*message)[am::strings::msg_params][am::mobile_notification::state] = state; + (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr<Command> command = CreateCommand<hmi::OnDriverDistractionNotification>(message); application_set_.insert(app_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + typedef boost::optional<bool> OptionalBool; + ON_CALL(mock_policy_handler_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + std::string required_language = "en-us"; + ON_CALL(mock_policy_handler_, + LockScreenDismissalWarningMessage(required_language)) + .WillByDefault(Return( + boost::optional<std::string>(kLockScreenDismissalWarningMessage_en))); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(applications_)); + policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcAllowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_)); - EXPECT_CALL(mock_policy_handler_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); + EXPECT_CALL(mock_policy_handler_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)) .WillOnce(GetMessage(message)); - EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); + ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); command->Run(); EXPECT_EQ( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc index 8164f957cb..64bf167f83 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_request_test.cc @@ -33,13 +33,13 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/commands/request_to_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/mixing_audio_supported_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,9 +51,9 @@ using ::testing::_; using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; +using am::commands::CommandImpl; using am::commands::RequestToHMI; using sdl_rpc_plugin::commands::MixingAudioSupportedRequest; -using am::commands::CommandImpl; typedef std::shared_ptr<RequestToHMI> RequestToHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc index aa651c2dca..8c2f07a1d6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/mixing_audio_supported_response_test.cc @@ -33,18 +33,18 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/commands/response_from_hmi.h" -#include "interfaces/HMI_API.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/mock_application.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,15 +52,15 @@ namespace commands_test { namespace hmi_commands_test { namespace mixing_audio_supported_response { +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::MixingAudioSupportedResponse; -using application_manager::commands::ResponseFromHMI; -using am::commands::CommandImpl; using am::HMICapabilities; +using am::commands::CommandImpl; +using application_manager::commands::ResponseFromHMI; +using sdl_rpc_plugin::commands::MixingAudioSupportedResponse; namespace hmi_response = ::application_manager::hmi_response; typedef std::shared_ptr<ResponseFromHMI> ResponseFromHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc index d8454bb98e..926e51446f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_audio_start_stream_request_test.cc @@ -36,13 +36,13 @@ #include "gtest/gtest.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/commands/commands_test.h" #include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,9 +54,9 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; namespace commands = am::commands; +using am::event_engine::Event; using commands::MessageSharedPtr; using sdl_rpc_plugin::commands::AudioStartStreamRequest; -using am::event_engine::Event; namespace { const uint32_t kHmiAppId = 13u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc index 1a03ecf523..5e13755a32 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_request_test.cc @@ -34,15 +34,15 @@ #include "gtest/gtest.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/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,8 +54,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::NaviIsReadyRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::NaviIsReadyRequest; namespace { const hmi_apis::FunctionID::eType kEventID = diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc index 23f01fac3f..e166928348 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_is_ready_response_test.cc @@ -33,12 +33,12 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" #include "hmi/navi_is_ready_response.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc index 3110a11fd8..d6ef540bc0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_request_test.cc @@ -36,14 +36,14 @@ #include "gtest/gtest.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/hmi_interfaces.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -55,8 +55,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::NaviSetVideoConfigRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::NaviSetVideoConfigRequest; namespace { const uint32_t kAppId = 1u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc index 06fa61db29..c4e7976bde 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_set_video_config_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "hmi/navi_set_video_config_response.h" +#include "application_manager/commands/commands_test.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" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace navi_set_video_config_response { using sdl_rpc_plugin::commands::NaviSetVideoConfigResponse; using test::components::event_engine_test::MockEventDispatcher; using testing::_; -using testing::ReturnRef; using ::testing::NiceMock; +using testing::ReturnRef; typedef NiceMock< ::test::components::application_manager_test::MockHMICapabilities> diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc index a7f50504fb..232d5ab628 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_start_stream_request_test.cc @@ -36,12 +36,12 @@ #include "gtest/gtest.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_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,9 +53,9 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; namespace commands = am::commands; +using am::event_engine::Event; using commands::MessageSharedPtr; using sdl_rpc_plugin::commands::NaviStartStreamRequest; -using am::event_engine::Event; namespace { const uint32_t kHmiAppId = 13u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc index e4a79997fd..b32189ce1a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/navi_stop_stream_requests_test.cc @@ -30,17 +30,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "hmi/navi_stop_stream_request.h" #include "hmi/navi_audio_stop_stream_request.h" +#include "hmi/navi_stop_stream_request.h" #include "gtest/gtest.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_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -76,7 +76,8 @@ class NaviStopStreamRequestsTest }; typedef testing::Types<commands::AudioStopStreamRequest, - commands::NaviStopStreamRequest> RequestCommandsList; + commands::NaviStopStreamRequest> + RequestCommandsList; TYPED_TEST_CASE(NaviStopStreamRequestsTest, RequestCommandsList); TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceNotAvailable_NoRequest) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_from_hmi_test.cc new file mode 100644 index 0000000000..f3ed480180 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_from_hmi_test.cc @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/on_bc_system_capability_updated_notification_from_hmi.h" + +#include "application_manager/commands/commands_test.h" +#include "gtest/gtest.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace on_bc_system_capability_updated_notification_from_hmi { + +using sdl_rpc_plugin::commands::OnBCSystemCapabilityUpdatedNotificationFromHMI; +using ::testing::_; +using ::testing::Return; + +typedef std::shared_ptr<OnBCSystemCapabilityUpdatedNotificationFromHMI> + OnBCSystemCapabilityUpdatedNotificationFromHMIPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kAppId = 1u; +} // namespace + +MATCHER(CheckMessageToMobile, "") { + const auto function_id = mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + + const bool is_function_id_matched = + function_id == static_cast<am::mobile_api::FunctionID::eType>( + (*arg)[strings::params][strings::function_id].asInt()); + const bool app_id_exist = + (*arg)[strings::msg_params].keyExists(strings::app_id); + bool is_connection_key_correct = true; + if ((*arg)[strings::msg_params].keyExists(strings::connection_key)) { + is_connection_key_correct = + (*arg)[strings::params][strings::connection_key] == kAppId; + } + return is_function_id_matched && !app_id_exist && is_connection_key_correct; +} + +MATCHER_P(CheckDisplayCapabilitiesNotChanged, display_capability, "") { + return display_capability == arg; +} + +class OnBCSystemCapabilityUpdatedNotificationFromHMITest + : public CommandsTest<CommandsTestMocks::kIsNice> { + protected: + OnBCSystemCapabilityUpdatedNotificationFromHMITest() + : message_(CreateMessage()) + , display_capability_( + (*message_)[am::strings::msg_params][strings::system_capability] + [strings::display_capabilities]) { + command_ = + CreateCommand<OnBCSystemCapabilityUpdatedNotificationFromHMI>(message_); + mock_app_ = CreateMockApp(); + } + + OnBCSystemCapabilityUpdatedNotificationFromHMIPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; + const SmartObject display_capability_; +}; + +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_AppIdNotPresentedInMessage_SetSystemDisplayCapabilitiesToHMICapabilities_SendMessageToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + EXPECT_CALL(mock_hmi_capabilities_, + set_system_display_capabilities( + CheckDisplayCapabilitiesNotChanged(display_capability_))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(), + ::application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_AppNotRegisteredWithPresentedAppIdInMessage_MessageNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + (*message_)[strings::msg_params][strings::app_id] = kAppId; + ApplicationSharedPtr app; // Empty application shared pointer + + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(app)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_AppRegisteredWithPresentedAppIdInMessage_SetDisplayCapabilitiesToApp_SendMessageToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + (*message_)[strings::msg_params][strings::app_id] = kAppId; + + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(*mock_app_, + set_display_capabilities( + CheckDisplayCapabilitiesNotChanged(display_capability_))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(), + ::application_manager::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace on_bc_system_capability_updated_notification_from_hmi +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc new file mode 100644 index 0000000000..cb8894749f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_bc_system_capability_updated_notification_test.cc @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/on_bc_system_capability_updated_notification.h" + +#include "application_manager/commands/commands_test.h" +#include "gtest/gtest.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace on_bc_system_capability_updated_notification { + +using sdl_rpc_plugin::commands::OnBCSystemCapabilityUpdatedNotification; +using ::testing::_; +using ::testing::Return; + +typedef std::shared_ptr<OnBCSystemCapabilityUpdatedNotification> + OnBCSystemCapabilityUpdatedNotificationPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +} + +MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") { + return display_capabilities == + (*arg)[strings::msg_params][strings::system_capability] + [strings::display_capabilities]; +} + +class OnBCSystemCapabilityUpdatedNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + command_ = CreateCommand<OnBCSystemCapabilityUpdatedNotification>(message_); + mock_app_ = CreateMockApp(); + } + + OnBCSystemCapabilityUpdatedNotificationPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; +}; + +TEST_F(OnBCSystemCapabilityUpdatedNotificationTest, + SystemDisplayCapabilities_SUCCESS) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Null); + + EXPECT_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .Times(2) + .WillRepeatedly(Return(system_display_capabilities)); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToHMI(CheckDisplayCapabilities(*system_display_capabilities))); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(OnBCSystemCapabilityUpdatedNotificationTest, + SystemDisplayCapabilities_DATA_NOT_AVAILABLE) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + EXPECT_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillOnce(Return(nullptr)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace on_bc_system_capability_updated_notification +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc index fc3899e861..fe6ba7c4e3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_driver_distraction_notification_test.cc @@ -33,17 +33,17 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "utils/lock.h" -#include "utils/data_accessor.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/on_driver_distraction_notification.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" +#include "utils/lock.h" namespace test { namespace components { @@ -52,22 +52,65 @@ namespace hmi_commands_test { namespace on_driver_distraction_notification { using ::testing::_; -using ::testing::Return; +using ::testing::DoAll; using ::testing::Eq; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; +using ::testing::SetArgumentPointee; + namespace am = ::application_manager; using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::hmi::OnDriverDistractionNotification; using namespace am::commands; +using test::components::commands_test::MobileResultCodeIs; + +namespace { +const std::string kDefaultLanguage = "en-us"; +const mobile_apis::Language::eType kMobileLanguage = + mobile_apis::Language::EN_US; -typedef std::shared_ptr<OnDriverDistractionNotification> NotificationPtr; +// LSDW - lock screen dismissal warning +const std::string kLockScreenDismissalWarningMessage_en = + "Swipe down to dismiss, acknowledging that you are not the driver"; +const uint32_t kConnectionKey = 2u; +} // namespace class HMIOnDriverDistractionNotificationTest : public CommandsTest<CommandsTestMocks::kIsNice> { public: HMIOnDriverDistractionNotificationTest() - : app_set_lock_(std::make_shared<sync_primitives::Lock>()) {} + : mock_app_(CreateMockApp()) + , app_set_lock_(std::make_shared<sync_primitives::Lock>()) + , accessor(app_set_, app_set_lock_) { + app_set_.insert(mock_app_); + InitMocksRelations(); + } + + typedef std::shared_ptr<OnDriverDistractionNotification> NotificationPtr; + typedef boost::optional<bool> OptionalBool; + + void SetUp() OVERRIDE { + ON_CALL(*mock_app_, ui_language()) + .WillByDefault(ReturnRef(kMobileLanguage)); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(mock_message_helper_, MobileLanguageToString(kMobileLanguage)) + .WillByDefault(Return(kDefaultLanguage)); + } + + MockAppPtr mock_app_; std::shared_ptr<sync_primitives::Lock> app_set_lock_; - policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; + am::ApplicationSet app_set_; + DataAccessor<am::ApplicationSet> accessor; + NiceMock<policy_test::MockPolicyHandlerInterface> + mock_policy_handler_interface_; + + void InitMocksRelations() { + ON_CALL(app_mngr_, applications()).WillByDefault(Return(accessor)); + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_interface_)); + } }; MATCHER_P2(CheckNotificationParams, function_id, state, "") { @@ -83,76 +126,238 @@ MATCHER_P2(CheckNotificationParams, function_id, state, "") { return is_function_id_matched && is_state_matched; } -ACTION_P(GetArg3, result) { - arg3 = *result; +ACTION_P(GetArg4, result) { + arg4 = *result; } -TEST_F(HMIOnDriverDistractionNotificationTest, Run_PushMobileMessage_SUCCESS) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; +ACTION_P(SetMessage, lockScreenDismissalWarning) { + smart_objects::SmartObject& notification = arg0; + + notification[application_manager::strings::msg_params] + [application_manager::mobile_notification:: + lock_screen_dismissal_warning] = lockScreenDismissalWarning; +} + +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_SUCCESS) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; NotificationPtr command( CreateCommand<OnDriverDistractionNotification>(commands_msg)); EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); - MockAppPtr mock_app = CreateMockApp(); - am::ApplicationSet app_set; - app_set.insert(mock_app); + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalWarningMessage(_)) + .WillByDefault(Return(kLockScreenDismissalWarningMessage_en)); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); + + MessageSharedPtr message_to_mobile( + CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckNotificationParams( + am::mobile_api::FunctionID::OnDriverDistractionID, state), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + command->Run(); + + ASSERT_TRUE((*message_to_mobile)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); + + auto LSDW_message = + (*message_to_mobile) + [am::strings::msg_params] + [am::mobile_notification::lock_screen_dismissal_warning] + .asString(); + + EXPECT_EQ(kLockScreenDismissalWarningMessage_en, LSDW_message); +} + +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_PushMobileMessage_If_DisallowedByPolicy) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + NotificationPtr command( + CreateCommand<OnDriverDistractionNotification>(commands_msg)); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(boost::optional<bool>(true))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalWarningMessage(_)) + .WillByDefault(Return(kLockScreenDismissalWarningMessage_en)); - DataAccessor<am::ApplicationSet> accessor(app_set, app_set_lock_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcDisallowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); + EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(3); + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); - EXPECT_CALL(*mock_app, + MessageSharedPtr pushed_message(CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(*mock_app_, PushMobileMessage(CheckNotificationParams( - am::mobile_api::FunctionID::OnDriverDistractionID, state))); + am::mobile_api::FunctionID::OnDriverDistractionID, state))) + .WillOnce(SaveArg<0>(&pushed_message)); + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); command->Run(); + + ASSERT_TRUE((*pushed_message)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); + + auto lock_screen_dismissal_warning_message = + (*pushed_message)[am::strings::msg_params] + [am::mobile_notification::lock_screen_dismissal_warning] + .asString(); + + EXPECT_EQ(kLockScreenDismissalWarningMessage_en, + lock_screen_dismissal_warning_message); } TEST_F(HMIOnDriverDistractionNotificationTest, - Run_SendNotificationToMobile_SUCCESS) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; + Run_SendNotificationIfLockScreenDismissalMissed) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; NotificationPtr command( CreateCommand<OnDriverDistractionNotification>(commands_msg)); + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(boost::optional<bool>())); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + ON_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillByDefault(GetArg4(&result)); + + MessageSharedPtr command_result; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + command->Run(); + + auto& msg_params = + (*command_result)[application_manager::strings::msg_params]; + EXPECT_FALSE(msg_params.keyExists( + application_manager::mobile_notification::lock_screen_dismissal_enabled)); + EXPECT_FALSE(msg_params.keyExists( + application_manager::mobile_notification::lock_screen_dismissal_warning)); +} + +// LSDW - lock screen dimissal +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_LSDWMessageIsAbsent_SUCCESS) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + NotificationPtr command( + CreateCommand<OnDriverDistractionNotification>(commands_msg)); + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); - MockAppPtr mock_app = CreateMockApp(); - am::ApplicationSet app_set; - app_set.insert(mock_app); + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(false))); - DataAccessor<am::ApplicationSet> accessor(app_set, app_set_lock_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); + // LockScreenDismissalWarning won't be added to message if value of + // LockScreenDismissalEnabledState is false + std::string required_language = "en-us"; + EXPECT_CALL(mock_policy_handler_interface_, + LockScreenDismissalWarningMessage(required_language)) + .Times(0); policy::CheckPermissionResult result; result.hmi_level_permitted = policy::kRpcAllowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); + MessageSharedPtr message_to_mobile( + CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(2); + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( CheckNotificationParams( am::mobile_api::FunctionID::OnDriverDistractionID, state), - Command::CommandSource::SOURCE_SDL)); - + Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); command->Run(); + + EXPECT_FALSE((*message_to_mobile)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); } -} // on_driver_distraction_notification +TEST_F(HMIOnDriverDistractionNotificationTest, + Run_SendNotificationToMobile_SpecifiedLanguageIsAbsent_SUCCESS) { + const auto state = hmi_apis::Common_DriverDistractionState::DD_ON; + MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); + (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; + (*commands_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + + NotificationPtr command( + CreateCommand<OnDriverDistractionNotification>(commands_msg)); + + EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalEnabledState()) + .WillByDefault(Return(OptionalBool(true))); + + ON_CALL(mock_policy_handler_interface_, LockScreenDismissalWarningMessage(_)) + .WillByDefault(Return(kLockScreenDismissalWarningMessage_en)); + + // In case when specified language is absent in policy table, will added + // message on default language (en-us) + const mobile_apis::Language::eType mobile_language = + mobile_apis::Language::FR_FR; + std::string required_language = "FR-FR"; + ON_CALL(*mock_app_, ui_language()).WillByDefault(ReturnRef(mobile_language)); + ON_CALL(mock_message_helper_, MobileLanguageToString(mobile_language)) + .WillByDefault(Return(required_language)); + + policy::CheckPermissionResult result; + result.hmi_level_permitted = policy::kRpcAllowed; + EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _, _)) + .WillOnce(GetArg4(&result)); + + MessageSharedPtr message_to_mobile( + CreateMessage(smart_objects::SmartType_Map)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckNotificationParams( + am::mobile_api::FunctionID::OnDriverDistractionID, state), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + command->Run(); + + ASSERT_TRUE((*message_to_mobile)[am::strings::msg_params].keyExists( + am::mobile_notification::lock_screen_dismissal_warning)); + + auto lock_screen_dismissal_warning_message = + (*message_to_mobile) + [am::strings::msg_params] + [am::mobile_notification::lock_screen_dismissal_warning] + .asString(); + + EXPECT_EQ(kLockScreenDismissalWarningMessage_en, + lock_screen_dismissal_warning_message); +} +} // namespace on_driver_distraction_notification } // namespace hmi_commands_test } // namespace commands_test } // namespace components diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_service_status_update_notification_test.cc index 339a749909..a9bc97f842 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_urls_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_service_status_update_notification_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,59 +29,67 @@ * 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 "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/application.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_to_hmi.h" -#include "hmi/get_urls_response.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/on_service_update_notification.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace hmi_commands_test { -namespace get_urls_response { +namespace on_service_update_notification { -using ::testing::_; -using ::testing::Return; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::GetUrlsResponse; -using am::commands::ResponseToHMI; -using am::commands::CommandImpl; +using namespace application_manager; +using sdl_rpc_plugin::commands::hmi::OnServiceUpdateNotification; -typedef std::shared_ptr<ResponseToHMI> ResponseToHMIPtr; +typedef std::shared_ptr<OnServiceUpdateNotification> NotificationPtr; +typedef hmi_apis::Common_ServiceType::eType ServiceType; +typedef hmi_apis::Common_ServiceEvent::eType ServiceEvent; namespace { -const uint32_t kConnectionKey = 2u; +const uint32_t kConnectionKey = 1232u; +const uint32_t kHmi_app_id = 321u; } // namespace -class GetUrlResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; +class OnServiceUpdateNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnServiceUpdateNotificationTest() + : message_(CreateMessage(smart_objects::SmartType_Map)) {} + + public: + MessageSharedPtr message_; + NotificationPtr command_; +}; + +TEST_F(OnServiceUpdateNotificationTest, SendNotificationToHMI) { + (*message_)[strings::msg_params][hmi_notification::service_type] = + ServiceType::AUDIO; + (*message_)[strings::msg_params][hmi_notification::service_event] = + ServiceEvent::REQUEST_ACCEPTED; + (*message_)[strings::msg_params][strings::app_id] = kConnectionKey; + command_ = CreateCommand<OnServiceUpdateNotification>(message_); + + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(message_)).Times(1); -TEST_F(GetUrlResponseTest, RUN_SendRequest_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; + auto mock_app = std::make_shared<NiceMock<MockApplication> >(); - ResponseToHMIPtr command(CreateCommand<GetUrlsResponse>(command_msg)); - EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app)); - command->Run(); + ON_CALL(*mock_app, hmi_app_id()).WillByDefault(Return(kHmi_app_id)); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); + command_->Init(); + command_->Run(); } -} // namespace get_urls_response +} // namespace on_service_update_notification } // namespace hmi_commands_test } // namespace commands_test } // namespace components diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc index 2d50ec2b72..f9dbbf259f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/on_system_time_ready_notification_test.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "hmi/on_system_time_ready_notification.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc index 8e62c1a409..67c36dce9c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_get_capabilities_response_test.cc @@ -34,13 +34,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.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 "hmi/rc_get_capabilities_response.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,8 +52,8 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; -using sdl_rpc_plugin::commands::RCGetCapabilitiesResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::RCGetCapabilitiesResponse; typedef std::shared_ptr<RCGetCapabilitiesResponse> RCGetCapabilitiesResponsePtr; typedef NiceMock< @@ -139,6 +139,7 @@ TEST_F(RCGetCapabilitiesResponseTest, RUN_SUCCESSS) { radio_control_capability["hdChannelAvailable"] = true; radio_control_capability["rdsDataAvailable"] = true; radio_control_capability["availableHDsAvailable"] = true; + radio_control_capability["availableHdChannelsAvailable"] = true; radio_control_capability["stateAvailable"] = true; radio_control_capability["signalStrengthAvailable"] = true; radio_control_capability["signalChangeThresholdAvailable"] = true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc index c7fbdb663b..539c0efeb3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_request_test.cc @@ -34,15 +34,15 @@ #include "gtest/gtest.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/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,8 +54,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::RCIsReadyRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::RCIsReadyRequest; typedef std::shared_ptr<RCIsReadyRequest> RCIsReadyRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc index a1a8c1c87e..4224e82b5f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/rc_is_ready_response_test.cc @@ -35,11 +35,11 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" #include "hmi/rc_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc index 25abefb010..3e7e6e6f59 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/response_from_hmi_test.cc @@ -32,24 +32,24 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "application_manager/commands/command.h" +#include "application_manager/commands/response_from_hmi.h" #include "application_manager/smart_object_keys.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" -#include "application_manager/commands/command.h" #include "application_manager/test/include/application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/response_from_hmi.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace hmi_commands_test { namespace response_from_hmi { +using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::SaveArg; -using ::testing::DoAll; -using ::test::components::event_engine_test::MockEventDispatcher; namespace am = ::application_manager; using application_manager::commands::ResponseFromHMI; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc index 917de81fb3..93344f1a0d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_request_test.cc @@ -32,19 +32,19 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "utils/lock.h" -#include "utils/helpers.h" -#include "hmi/sdl_activate_app_request.h" -#include "application_manager/mock_application.h" #include "application_manager/application_manager.h" -#include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_interface.h" #include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" +#include "hmi/sdl_activate_app_request.h" +#include "utils/helpers.h" +#include "utils/lock.h" namespace test { namespace components { @@ -55,18 +55,17 @@ namespace sdl_activate_app_request { namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +using am::ApplicationSet; using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using connection_handler_test::MockConnectionHandler; +using policy_test::MockPolicyHandlerInterface; using sdl_rpc_plugin::commands::SDLActivateAppRequest; -using am::ApplicationSet; +using testing::Gt; using testing::Mock; +using ::testing::NiceMock; using testing::Return; using testing::ReturnRef; -using testing::Mock; -using testing::Gt; -using ::testing::NiceMock; -using policy_test::MockPolicyHandlerInterface; -using connection_handler_test::MockConnectionHandler; -using am::event_engine::Event; namespace { const uint32_t kCorrelationID = 1u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc index bca316bcfa..b35ccde314 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_activate_app_response_test.cc @@ -33,12 +33,12 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/sdl_activate_app_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -48,8 +48,8 @@ namespace sdl_activate_app_response { namespace am = ::application_manager; namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::SDLActivateAppResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::SDLActivateAppResponse; typedef std::shared_ptr<SDLActivateAppResponse> SDLActivateAppResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc index 262ac5fc7d..c8cc4bb18c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc @@ -32,11 +32,11 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "hmi/sdl_get_list_of_permissions_request.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "hmi/sdl_get_list_of_permissions_request.h" namespace test { namespace components { @@ -46,8 +46,8 @@ namespace sdl_get_list_of_permissions_request { using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SDLGetListOfPermissionsRequest; -using test::components::policy_test::MockPolicyHandlerInterface; using smart_objects::SmartObject; +using test::components::policy_test::MockPolicyHandlerInterface; using testing::Return; using testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc new file mode 100644 index 0000000000..8e802bbd7d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_policy_configuration_data_request_test.cc @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/sdl_get_policy_configuration_data_request.h" +#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace sdl_get_policy_configuration_data_request { + +using testing::Return; + +using sdl_rpc_plugin::commands::SDLGetPolicyConfigurationDataRequest; +using test::components::policy_test::MockPolicyHandlerInterface; + +namespace strings = ::app_mngr::strings; +namespace hmi_response = ::app_mngr::hmi_response; + +class SDLGetPolicyConfigurationDataRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P(GetPolicyConfigurationDataFirstElementMatches, + string_first_element_value, + "") { + auto message = static_cast<smart_objects::SmartObject>(*arg); + if (!message.keyExists(strings::msg_params) || + !message[strings::msg_params].keyExists(strings::value)) { + return false; + } + + if (message[strings::msg_params][strings::value].getType() != + smart_objects::SmartType::SmartType_Array || + message[strings::msg_params][strings::value].empty()) { + return false; + } + + Json::Reader reader; + Json::Value msg_json_value(Json::ValueType::arrayValue); + + auto msg_value_first = message[strings::msg_params][strings::value][0]; + return msg_value_first.asString() == string_first_element_value; +} + +MATCHER_P(HMIResultCodeIs, result_code, "") { + return result_code == + static_cast<hmi_apis::Common_Result::eType>( + (*arg)[strings::params][hmi_response::code].asInt()); +} + +TEST_F(SDLGetPolicyConfigurationDataRequestTest, Run_Fail_DataNotAvailable) { + std::string kInvalidKey = "invalid_key"; + + PolicyTable pt; + ON_CALL(mock_policy_handler_, GetPolicyTableData()) + .WillByDefault(Return(pt.ToJsonValue())); + + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][strings::policy_type] = kInvalidKey; + (*msg)[strings::msg_params][strings::property] = kInvalidKey; + + std::shared_ptr<SDLGetPolicyConfigurationDataRequest> command( + CreateCommand<SDLGetPolicyConfigurationDataRequest>(msg)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::Common_Result::DATA_NOT_AVAILABLE), + Command::SOURCE_SDL_TO_HMI)); + + command->Run(); +} + +void clear_new_line_symbol(std::string& str_to_clear) { + str_to_clear.erase( + std::remove_if(str_to_clear.begin(), + str_to_clear.end(), + [](char character) { return '\n' == character; }), + str_to_clear.end()); +} + +TEST_F(SDLGetPolicyConfigurationDataRequestTest, Run_Success) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][strings::policy_type] = "module_config"; + (*msg)[strings::msg_params][strings::property] = "endpoints"; + + std::shared_ptr<SDLGetPolicyConfigurationDataRequest> command( + CreateCommand<SDLGetPolicyConfigurationDataRequest>(msg)); + + policy_table::ModuleConfig module_config_with_endpoints; + policy_table::URLList endpoint_url_list; + policy_table::URL urls; + urls.push_back("https://url1.com"); + urls.push_back("https://url2.com"); + endpoint_url_list["default"] = urls; + module_config_with_endpoints.endpoints["0x9"] = endpoint_url_list; + + PolicyTable pt; + pt.mark_initialized(); + pt.module_config.mark_initialized(); + pt.module_config = module_config_with_endpoints; + + ON_CALL(mock_policy_handler_, GetPolicyTableData()) + .WillByDefault(Return(pt.ToJsonValue())); + + auto json_val = module_config_with_endpoints.endpoints.ToJsonValue(); + Json::FastWriter writer; + std::string expected_string = writer.write(json_val); + clear_new_line_symbol(expected_string); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(GetPolicyConfigurationDataFirstElementMatches( + expected_string), + Command::SOURCE_SDL_TO_HMI)); + command->Run(); +} + +TEST_F(SDLGetPolicyConfigurationDataRequestTest, + Run_RetriveStringValueFromPolicy) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::msg_params][strings::policy_type] = + "consumer_friendly_messages"; + (*msg)[strings::msg_params][strings::property] = "version"; + + auto command = CreateCommand<SDLGetPolicyConfigurationDataRequest>(msg); + + const std::string version_test_value("version string"); + PolicyTable pt; + pt.mark_initialized(); + pt.consumer_friendly_messages->mark_initialized(); + pt.consumer_friendly_messages->version = + rpc::String<1, 100>(version_test_value); + + ON_CALL(mock_policy_handler_, GetPolicyTableData()) + .WillByDefault(Return(pt.ToJsonValue())); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(GetPolicyConfigurationDataFirstElementMatches( + version_test_value), + Command::SOURCE_SDL_TO_HMI)); + + command->Run(); +} + +} // namespace sdl_get_policy_configuration_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc index fca8ed840f..021dfc8b1d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_status_update_request_test.cc @@ -32,11 +32,11 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "hmi/sdl_get_status_update_request.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "hmi/sdl_get_status_update_request.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc index b040f8ea40..5cac1c823f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc @@ -34,15 +34,15 @@ #include <string> #include <vector> -#include "gtest/gtest.h" -#include "hmi/sdl_get_user_friendly_message_request.h" +#include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_state_controller.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" +#include "hmi/sdl_get_user_friendly_message_request.h" #include "smart_objects/smart_object.h" -#include "application_manager/commands/command_request_test.h" namespace test { namespace components { @@ -50,11 +50,11 @@ namespace commands_test { namespace hmi_commands_test { namespace sdl_get_user_friendly_message_request { +using application_manager::MockMessageHelper; using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SDLGetUserFriendlyMessageRequest; -using application_manager::MockMessageHelper; -using test::components::policy_test::MockPolicyHandlerInterface; using test::components::application_manager_test::MockHMICapabilities; +using test::components::policy_test::MockPolicyHandlerInterface; using testing::_; using testing::Return; using testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc index 581913d3a5..57bb018273 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_notifications_test.cc @@ -34,8 +34,8 @@ #include "application_manager/commands/commands_test.h" -#include "application_manager/commands/notification_to_hmi.h" #include "application_manager/commands/command_notification_impl.h" +#include "application_manager/commands/notification_to_hmi.h" namespace test { namespace components { @@ -45,8 +45,8 @@ namespace simple_notifications_test { using namespace application_manager; -using ::testing::Types; using commands::NotificationToHMI; +using ::testing::Types; template <typename Command> class SimpleNotificationsTest : public CommandsTest<CommandsTestMocks::kIsNice> { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc index a69f6c71fc..fc2cd1cca4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_request_from_hmi_test.cc @@ -30,14 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/request_from_hmi.h" #include "application_manager/event_engine/event.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/request_from_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -46,12 +46,12 @@ namespace hmi_commands_test { namespace simple_requests_from_hmi_test { using ::testing::_; -using ::testing::Types; -using ::testing::NotNull; using ::testing::NiceMock; +using ::testing::NotNull; +using ::testing::Types; namespace commands = ::application_manager::commands; -using commands::MessageSharedPtr; using ::application_manager::event_engine::EventObserver; +using commands::MessageSharedPtr; using ::test::components::event_engine_test::MockEventDispatcher; class RequestFromHMITest : public CommandsTest<CommandsTestMocks::kIsNice> { @@ -89,7 +89,7 @@ TEST_F(RequestFromHMITest, SendResponse_SUCCESS) { hmi_apis::Common_Result::SUCCESS); } -} // namespace simple_requests_to_hmi_test +} // namespace simple_requests_from_hmi_test } // namespace hmi_commands_test } // namespace commands_test } // namespace components diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc index 599c7e50f2..162e832e9f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc @@ -30,16 +30,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/commands/command.h" -#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" +#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" #include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" #include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" @@ -53,21 +55,15 @@ #include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" -#include "application_manager/commands/request_to_hmi.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" #include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" @@ -81,6 +77,11 @@ #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" @@ -88,23 +89,11 @@ #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" -#include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" +#include "smart_objects/smart_object.h" #include "application_manager/mock_event_dispatcher.h" @@ -115,8 +104,8 @@ namespace hmi_commands_test { namespace simple_requests_to_hmi_test { using ::testing::_; -using ::testing::Types; using ::testing::NotNull; +using ::testing::Types; namespace am_commands = application_manager::commands; using am_commands::MessageSharedPtr; using event_engine_test::MockEventDispatcher; @@ -221,7 +210,8 @@ typedef Types<sdl_rpc_plugin::commands::UIScrollableMessageRequest, typedef Types<sdl_rpc_plugin::commands::TTSIsReadyRequest, sdl_rpc_plugin::commands::UIIsReadyRequest, sdl_rpc_plugin::commands::NaviIsReadyRequest, - sdl_rpc_plugin::commands::VRIsReadyRequest> RequestCommandsList3; + sdl_rpc_plugin::commands::VRIsReadyRequest> + RequestCommandsList3; TYPED_TEST_CASE(RequestToHMICommandsTest, RequestCommandsList); TYPED_TEST_CASE(RequestToHMICommandsTest2, RequestCommandsList2); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc index 4f415975ba..f232240c28 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc @@ -32,13 +32,18 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/notification_from_hmi.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/activate_app_response.h" #include "hmi/basic_communication_system_response.h" +#include "hmi/close_popup_response.h" +#include "hmi/dial_number_response.h" #include "hmi/navi_alert_maneuver_response.h" #include "hmi/navi_audio_start_stream_response.h" #include "hmi/navi_audio_stop_stream_response.h" @@ -50,20 +55,13 @@ #include "hmi/navi_subscribe_way_points_response.h" #include "hmi/navi_unsubscribe_way_points_response.h" #include "hmi/navi_update_turn_list_response.h" +#include "hmi/on_find_applications.h" +#include "hmi/on_update_device_list.h" +#include "hmi/sdl_policy_update_response.h" #include "hmi/tts_change_registration_response.h" -#include "hmi/ui_set_app_icon_response.h" -#include "hmi/ui_set_display_layout_response.h" -#include "hmi/ui_set_global_properties_response.h" -#include "hmi/ui_scrollable_message_response.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "hmi/dial_number_response.h" -#include "hmi/close_popup_response.h" #include "hmi/tts_set_global_properties_response.h" #include "hmi/tts_speak_response.h" #include "hmi/tts_stop_speaking_response.h" -#include "hmi/tts_change_registration_response.h" #include "hmi/ui_add_command_response.h" #include "hmi/ui_add_submenu_response.h" #include "hmi/ui_alert_response.h" @@ -73,28 +71,21 @@ #include "hmi/ui_end_audio_pass_thru_response.h" #include "hmi/ui_perform_audio_pass_thru_response.h" #include "hmi/ui_perform_interaction_response.h" +#include "hmi/ui_scrollable_message_response.h" +#include "hmi/ui_send_haptic_data_response.h" +#include "hmi/ui_set_app_icon_response.h" +#include "hmi/ui_set_display_layout_response.h" +#include "hmi/ui_set_global_properties_response.h" #include "hmi/ui_set_media_clock_timer_response.h" #include "hmi/ui_show_response.h" #include "hmi/ui_slider_response.h" +#include "hmi/update_app_list_response.h" +#include "hmi/update_device_list_response.h" #include "hmi/vr_add_command_response.h" #include "hmi/vr_change_registration_response.h" #include "hmi/vr_delete_command_response.h" #include "hmi/vr_perform_interaction_response.h" -#include "hmi/activate_app_response.h" -#include "hmi/basic_communication_system_response.h" -#include "hmi/navi_unsubscribe_way_points_response.h" -#include "hmi/navi_update_turn_list_response.h" -#include "hmi/navi_send_location_response.h" -#include "hmi/navi_show_constant_tbt_response.h" -#include "hmi/navi_start_stream_response.h" -#include "hmi/navi_subscribe_way_points_response.h" -#include "hmi/on_find_applications.h" -#include "hmi/on_update_device_list.h" -#include "hmi/sdl_policy_update_response.h" -#include "hmi/update_app_list_response.h" -#include "hmi/update_device_list_response.h" -#include "application_manager/commands/notification_from_hmi.h" -#include "hmi/ui_send_haptic_data_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -102,12 +93,12 @@ namespace commands_test { namespace hmi_commands_test { namespace simple_response_from_hmi_test { +using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; +using ::testing::Eq; using ::testing::Return; using ::testing::ReturnRef; using ::testing::Types; -using ::testing::Eq; -using ::test::components::event_engine_test::MockEventDispatcher; namespace am = ::application_manager; namespace commands = sdl_rpc_plugin::commands; @@ -218,7 +209,8 @@ typedef Types< CommandData<sdl_rpc_plugin::commands::UIScrollableMessageResponse, hmi_apis::FunctionID::UI_ScrollableMessage>, CommandData<sdl_rpc_plugin::commands::UISendHapticDataResponse, - hmi_apis::FunctionID::UI_SendHapticData> > ResponseCommandsList; + hmi_apis::FunctionID::UI_SendHapticData> > + ResponseCommandsList; typedef Types<sdl_rpc_plugin::commands::AudioStopStreamResponse, sdl_rpc_plugin::commands::NaviStopStreamResponse, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc index 643e21d818..910c3f2873 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_to_hmi_test.cc @@ -30,16 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/command.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_to_hmi.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" #include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" -#include "application_manager/commands/response_to_hmi.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -48,8 +48,8 @@ namespace hmi_commands_test { namespace simple_response_to_hmi_test { using ::testing::_; -using ::testing::Types; using ::testing::NotNull; +using ::testing::Types; namespace commands = sdl_rpc_plugin::commands; using application_manager::commands::MessageSharedPtr; @@ -63,7 +63,8 @@ class ResponseToHMICommandsTest typedef Types<commands::SDLActivateAppResponse, commands::SDLGetListOfPermissionsResponse, commands::SDLGetStatusUpdateResponse, - commands::SDLGetUserFriendlyMessageResponse> ResponseCommandsList; + commands::SDLGetUserFriendlyMessageResponse> + ResponseCommandsList; TYPED_TEST_CASE(ResponseToHMICommandsTest, ResponseCommandsList); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc index bc9d262e6d..c7b96f1acf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_capabilities_response_test.cc @@ -32,11 +32,11 @@ #include <string> +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" #include "gtest/gtest.h" #include "hmi/tts_get_capabilities_response.h" -#include "application_manager/mock_hmi_capabilities.h" #include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc index 0d22500f48..c0d23cb34b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_language_response_test.cc @@ -30,13 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/tts_get_language_response.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc index 417b8e1898..c0f187a85f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_get_supported_languages_response_test.cc @@ -33,17 +33,17 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/tts_get_supported_languages_response.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/tts_get_supported_languages_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,14 +52,14 @@ namespace hmi_commands_test { namespace tts_get_supported_languages_response { using ::testing::_; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::TTSGetSupportedLanguagesResponse; -using am::commands::CommandImpl; typedef std::shared_ptr<ResponseFromHMI> ResponseFromHMIPtr; typedef NiceMock< @@ -113,7 +113,8 @@ TEST_F(TTSGetSupportedLanguageResponseTest, RUN_UNSUCCESS) { CreateCommand<TTSGetSupportedLanguagesResponse>(command_msg)); EXPECT_CALL(mock_hmi_capabilities_, - set_tts_supported_languages(supported_languages)).Times(0); + set_tts_supported_languages(supported_languages)) + .Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc index 2fae8a6819..a2f4440c86 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/tts_is_ready_response_test.cc @@ -33,18 +33,18 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/commands/response_from_hmi.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/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/response_from_hmi.h" -#include "hmi/tts_is_ready_response.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/tts_is_ready_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,14 +53,14 @@ namespace hmi_commands_test { namespace tts_is_ready_response { using ::testing::_; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::TTSIsReadyResponse; -using am::commands::CommandImpl; using test::components::event_engine_test::MockEventDispatcher; typedef std::shared_ptr<ResponseFromHMI> ResponseFromHMIPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc index 31e4860d4a..4683fc62c7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -32,14 +32,14 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.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 "gtest/gtest.h" #include "hmi/ui_get_capabilities_response.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,9 +51,9 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using application_manager::commands::ResponseFromHMI; using sdl_rpc_plugin::commands::UIGetCapabilitiesResponse; -using am::commands::CommandImpl; typedef std::shared_ptr<ResponseFromHMI> ResponseFromHMIPtr; typedef NiceMock< @@ -113,8 +113,9 @@ TEST_F(UIGetCapabilitiesResponseTest, SetSoftButton_SUCCESS) { ResponseFromHMIPtr command( CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - smart_objects::SmartObject soft_button_capabilities_so = (*command_msg) - [strings::msg_params][hmi_response::soft_button_capabilities]; + smart_objects::SmartObject soft_button_capabilities_so = + (*command_msg)[strings::msg_params] + [hmi_response::soft_button_capabilities]; EXPECT_CALL(mock_hmi_capabilities_, set_soft_button_capabilities(soft_button_capabilities_so)); @@ -144,16 +145,48 @@ TEST_F(UIGetCapabilitiesResponseTest, SetHmiZone_SUCCESS) { TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThru_SUCCESS) { MessageSharedPtr command_msg = CreateCommandMsg(); (*command_msg)[strings::msg_params][strings::audio_pass_thru_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + smart_objects::SmartObject audio_pass_thru_capabilities_so = + (*command_msg)[strings::msg_params] + [strings::audio_pass_thru_capabilities]; + + // hmi_capabilities will receive a list of capabilities, the first element + // being audio_pass_thru_capabilities_so + smart_objects::SmartObject audio_pass_thru_capabilities_list_so = + smart_objects::SmartObject(smart_objects::SmartType_Array); + audio_pass_thru_capabilities_list_so[0] = audio_pass_thru_capabilities_so; + EXPECT_CALL( + mock_hmi_capabilities_, + set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_list_so)); + + command->Run(); +} + +TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThruList_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + + // if both audioPassThruCapabilities and audioPassThruCapabilitiesList are + // supplied, audioPassThruCapabilitiesList should be used + smart_objects::SmartObject audio_pass_thru_capabilities_so = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject audio_pass_thru_capabilities_list_so = smart_objects::SmartObject(smart_objects::SmartType_Array); + (*command_msg)[strings::msg_params][strings::audio_pass_thru_capabilities] = + audio_pass_thru_capabilities_so; + (*command_msg)[strings::msg_params] + [strings::audio_pass_thru_capabilities_list] = + audio_pass_thru_capabilities_list_so; ResponseFromHMIPtr command( CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - smart_objects::SmartObject audio_pass_thru_capabilities_so = (*command_msg) - [strings::msg_params][strings::audio_pass_thru_capabilities]; EXPECT_CALL( mock_hmi_capabilities_, - set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_so)); + set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_list_so)); command->Run(); } @@ -277,7 +310,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { video_streaming_capability[strings::preferred_resolution] [strings::resolution_width] = 800; video_streaming_capability[strings::preferred_resolution] - [strings::resolution_height] = 350; + [strings::resolution_height] = 354; video_streaming_capability[strings::max_bitrate] = 10000; @@ -295,6 +328,12 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { video_streaming_capability[strings::haptic_spatial_data_supported] = true; + video_streaming_capability[strings::diagonal_screen_size] = 7.47; + + video_streaming_capability[strings::pixel_per_inch] = 117.f; + + video_streaming_capability[strings::scale] = 1.f; + ResponseFromHMIPtr command( CreateCommand<UIGetCapabilitiesResponse>(command_msg)); @@ -304,6 +343,25 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { command->Run(); } +TEST_F(UIGetCapabilitiesResponseTest, SetSystemDisplayCapabilities_SUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::msg_params][strings::system_capabilities] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + ResponseFromHMIPtr command( + CreateCommand<UIGetCapabilitiesResponse>(command_msg)); + + const auto& display_capability_so = + (*command_msg)[strings::msg_params][strings::system_capabilities] + [strings::display_capabilities]; + + EXPECT_CALL(mock_hmi_capabilities_, + set_system_display_capabilities(display_capability_so)); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace ui_get_capabilities_response } // namespace hmi_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc index de69c5de5c..7e8040543d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_language_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/ui_get_language_response.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.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" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace ui_get_language_response { using sdl_rpc_plugin::commands::UIGetLanguageResponse; using test::components::event_engine_test::MockEventDispatcher; using testing::_; -using testing::ReturnRef; using ::testing::NiceMock; +using testing::ReturnRef; namespace strings = application_manager::strings; namespace hmi_response = application_manager::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc index 5626e2b0ee..10cf244bcf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_get_supported_languages_response_test.cc @@ -33,15 +33,15 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_application_manager.h" -#include "hmi/ui_get_supported_languages_response.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/ui_get_supported_languages_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -49,8 +49,8 @@ namespace commands_test { namespace hmi_commands_test { namespace ui_get_supported_languages_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; @@ -107,7 +107,8 @@ TEST_F(UIGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { CreateCommand<UIGetSupportedLanguagesResponse>(command_msg)); EXPECT_CALL(mock_hmi_capabilities_, - set_ui_supported_languages(supported_languages)).Times(0); + set_ui_supported_languages(supported_languages)) + .Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc index 70fc80bbd1..837b8438dc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_request_test.cc @@ -34,16 +34,16 @@ #include "gtest/gtest.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/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,12 +53,12 @@ namespace ui_is_ready_request { namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using sdl_rpc_plugin::commands::UIIsReadyRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::UIIsReadyRequest; -using am::event_engine::Event; typedef std::shared_ptr<UIIsReadyRequest> UIIsReadyRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc index cccdbdc44d..44b9504055 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/ui_is_ready_response_test.cc @@ -33,12 +33,12 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" #include "hmi/ui_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -46,8 +46,8 @@ namespace commands_test { namespace hmi_commands_test { namespace ui_is_ready_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc index c566702998..31c03a7ed5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc @@ -32,20 +32,20 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/HMI_API.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/application_manager.h" #include "application_manager/application_manager_impl.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_application.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "application_manager/request_controller_settings.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/request_controller_settings.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/update_device_list_request.h" +#include "interfaces/HMI_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,18 +53,18 @@ namespace commands_test { namespace hmi_commands_test { namespace update_device_list_request { -using testing::_; -using testing::ReturnRef; -using testing::Return; -using test::components::event_engine_test::MockEventDispatcher; using ::test::components::application_manager_test:: MockApplicationManagerSettings; +using test::components::event_engine_test::MockEventDispatcher; +using testing::_; +using testing::Return; +using testing::ReturnRef; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; +using am::commands::CommandImpl; using am::event_engine::Event; using sdl_rpc_plugin::commands::UpdateDeviceListRequest; -using am::commands::CommandImpl; typedef std::shared_ptr<UpdateDeviceListRequest> UpdateDeviceListRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc index af3b9bebf6..96f3b38fbf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_request_test.cc @@ -33,13 +33,13 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/update_sdl_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace commands_test { namespace hmi_commands_test { namespace update_sdl_request { -using ::testing::ReturnRef; using ::testing::NiceMock; +using ::testing::ReturnRef; namespace am = ::application_manager; namespace strings = ::application_manager::strings; using sdl_rpc_plugin::commands::UpdateSDLRequest; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc index 93c49724ce..62ffc6be4d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_sdl_response_test.cc @@ -33,12 +33,12 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" #include "hmi/update_sdl_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -48,8 +48,8 @@ namespace update_sdl_response { namespace am = ::application_manager; namespace strings = ::application_manager::strings; -using sdl_rpc_plugin::commands::UpdateSDLResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::UpdateSDLResponse; typedef std::shared_ptr<UpdateSDLResponse> UpdateSDLResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc index 15d38d4ef3..21acf2bb70 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_capabilities_response_test.cc @@ -32,14 +32,14 @@ #include <stdint.h> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.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 "gtest/gtest.h" #include "hmi/vr_get_capabilities_response.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -51,8 +51,8 @@ using ::testing::NiceMock; namespace am = ::application_manager; namespace strings = am::strings; namespace hmi_response = am::hmi_response; -using sdl_rpc_plugin::commands::VRGetCapabilitiesResponse; using am::commands::CommandImpl; +using sdl_rpc_plugin::commands::VRGetCapabilitiesResponse; typedef std::shared_ptr<VRGetCapabilitiesResponse> VRGetCapabilitiesResponsePtr; typedef NiceMock< diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc index 05ed186963..8b00b4dded 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_language_response_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "hmi/vr_get_language_response.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.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" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,8 +47,8 @@ namespace vr_get_language_response { using sdl_rpc_plugin::commands::VRGetLanguageResponse; using test::components::event_engine_test::MockEventDispatcher; using testing::_; -using testing::ReturnRef; using ::testing::NiceMock; +using testing::ReturnRef; namespace strings = application_manager::strings; namespace hmi_response = application_manager::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc index 56b11ad440..b81823624c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_get_supported_languages_response_test.cc @@ -33,15 +33,15 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application.h" #include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_application_manager.h" -#include "hmi/vr_get_supported_languages_response.h" +#include "application_manager/mock_hmi_capabilities.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "hmi/vr_get_supported_languages_response.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -49,8 +49,8 @@ namespace commands_test { namespace hmi_commands_test { namespace vr_get_supported_languages_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; @@ -107,7 +107,8 @@ TEST_F(VRGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { CreateCommand<VRGetSupportedLanguagesResponse>(command_msg)); EXPECT_CALL(mock_hmi_capabilities_, - set_vr_supported_languages(supported_languages)).Times(0); + set_vr_supported_languages(supported_languages)) + .Times(0); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc index 259fd0b92b..9bb8e4c2d5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_request_test.cc @@ -34,15 +34,15 @@ #include "gtest/gtest.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/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -54,8 +54,8 @@ using ::testing::_; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::VRIsReadyRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::VRIsReadyRequest; typedef std::shared_ptr<VRIsReadyRequest> VRIsReadyRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc index 0e56f5b483..8b7b0a94f4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vr_is_ready_response_test.cc @@ -33,12 +33,12 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_hmi_capabilities.h" +#include "gtest/gtest.h" #include "hmi/vr_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -46,8 +46,8 @@ namespace commands_test { namespace hmi_commands_test { namespace vr_is_ready_response { -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index 0023368b5a..b11312eb33 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -32,8 +32,8 @@ #include <stdint.h> #include <memory> -#include <string> #include <set> +#include <string> #include "mobile/add_command_request.h" @@ -41,16 +41,16 @@ #include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_help_prompt_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" namespace test { namespace components { @@ -60,17 +60,17 @@ namespace add_command_request { namespace am = application_manager; namespace am_test = application_manager_test; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; -using ::testing::_; -using ::testing::Return; -using ::testing::InSequence; -using sdl_rpc_plugin::commands::AddCommandRequest; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using am::event_engine::EventObserver; using ns_smart_device_link::ns_smart_objects::SmartObjectSPtr; +using sdl_rpc_plugin::commands::AddCommandRequest; using ::test::components::application_manager_test::MockApplication; -using am::event_engine::EventObserver; +using ::testing::_; +using ::testing::InSequence; +using ::testing::Return; using namespace smart_objects; namespace custom_str = utils::custom_string; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc index ecaa436529..a88a1ade69 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_sub_menu_request_test.cc @@ -35,14 +35,14 @@ #include "mobile/add_sub_menu_request.h" -#include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -51,9 +51,9 @@ namespace mobile_commands_test { namespace add_sub_menu_request { namespace am = ::application_manager; -using sdl_rpc_plugin::commands::AddSubMenuRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using sdl_rpc_plugin::commands::AddSubMenuRequest; using ::testing::_; using ::testing::Return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc index 7d2dd0b2c2..e726616345 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_maneuver_request_test.cc @@ -35,20 +35,20 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "mobile/alert_maneuver_request.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/alert_maneuver_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -60,9 +60,9 @@ using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::AlertManeuverRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using sdl_rpc_plugin::commands::AlertManeuverRequest; typedef std::shared_ptr<AlertManeuverRequest> CommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc index a66d0d557f..dc7731bfc8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/alert_request_test.cc @@ -31,19 +31,19 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/alert_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,12 +52,12 @@ namespace mobile_commands_test { namespace alert_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::AlertRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; using am::event_engine::Event; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::AlertRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; @@ -73,6 +73,8 @@ const uint32_t kDefaultTimeout = 1000u; const uint32_t kCorrelationId = 2u; const mobile_apis::FunctionID::eType kFunctionId = mobile_apis::FunctionID::AlertID; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { @@ -138,9 +140,9 @@ class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { *mock_app_, AreCommandLimitsExceeded(kFunctionId, am::TLimitSource::POLICY_TABLE)) .WillByDefault(Return(false)); - ON_CALL(*mock_app_, hmi_level()) + ON_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); - ON_CALL(*mock_app_, hmi_level()) + ON_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); } @@ -155,7 +157,8 @@ class AlertRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { } void ExpectCallHmiLevel(const mobile_apis::HMILevel::eType level) { - EXPECT_CALL(*mock_app_, hmi_level()).WillRepeatedly(Return(level)); + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) + .WillRepeatedly(Return(level)); } void ExpectManageMobileCommandWithResultCode( @@ -477,9 +480,10 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) { (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand<AlertRequest>(msg_)); command->Run(); @@ -508,9 +512,10 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand<AlertRequest>(msg_)); command->Run(); @@ -641,9 +646,10 @@ TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand<AlertRequest>(msg_)); command->Run(); @@ -690,9 +696,10 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { VerifyTtsFiles( (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak), _)) + .WillOnce(Return(true)); CommandPtr command(CreateCommand<AlertRequest>(msg_)); command->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc index 58755c8b36..4394c6fe5e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/change_registration_test.cc @@ -31,25 +31,25 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/change_registration_request.h" -#include "gtest/gtest.h" -#include "utils/helpers.h" -#include "utils/custom_string.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" -#include "policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.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/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "policy/policy_regular/policy/usage_statistics/mock_statistics_manager.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "utils/helpers.h" namespace test { namespace components { @@ -58,18 +58,18 @@ namespace mobile_commands_test { namespace change_registration_request { namespace am = application_manager; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::ChangeRegistrationRequest; +using ::test::components::application_manager_test::MockApplication; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SetArgPointee; -using sdl_rpc_plugin::commands::ChangeRegistrationRequest; -using policy_test::MockPolicyHandlerInterface; -using ::test::components::application_manager_test::MockApplication; namespace custom_str = utils::custom_string; namespace strings = ::application_manager::strings; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc index 3abda89234..73a0008624 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc @@ -31,24 +31,24 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/create_interaction_choice_set_request.h" #include "mobile/create_interaction_choice_set_response.h" -#include "gtest/gtest.h" -#include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "utils/helpers.h" namespace test { namespace components { @@ -57,18 +57,18 @@ namespace mobile_commands_test { namespace create_interaction_choice_set_request { namespace am = application_manager; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::AtLeast; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::CreateInteractionChoiceSetRequest; using sdl_rpc_plugin::commands::CreateInteractionChoiceSetResponse; using ::test::components::application_manager_test::MockApplication; +using ::testing::_; +using ::testing::AtLeast; +using ::testing::Return; +using ::testing::ReturnRef; namespace custom_str = utils::custom_string; namespace strings = ::application_manager::strings; @@ -920,4 +920,4 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc new file mode 100644 index 0000000000..905c6ceb72 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_window_request_test.cc @@ -0,0 +1,460 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdint.h> +#include <memory> +#include <set> +#include <string> + +#include "mobile/create_window_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_state_controller.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace create_window_request { + +namespace am = application_manager; +using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::CreateWindowRequest; +using namespace mobile_apis::PredefinedWindows; +using am::commands::Command; +using application_manager::WindowID; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kAppId = 1u; +const uint32_t kConnectionKey = 2u; +const int32_t kFunctionID = mobile_apis::FunctionID::CreateWindowID; +const WindowID kTestWindowId = 12; +const WindowID kDuplicateWindowID = 13; +const char* const kWindowName = "WindowName"; +const utils::custom_string::CustomString kAppName("TestApp"); +} // namespace + +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast<int32_t>(result_code); + return is_success && is_result_code_correct; +} + +class CreateWindowRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + CreateWindowRequestTest() { + mock_app_ = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + protected: + MessageSharedPtr CreateMsgParams() { + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + void SetupHelperApplyWindowInitialState(const MockAppPtr& app, + const MessageSharedPtr& msg) { + am::HmiStatePtr state(new am::HmiState(app, app_mngr_)); + const auto window_type = static_cast<mobile_apis::WindowType::eType>( + (*msg)[am::strings::msg_params][am::strings::window_type].asInt()); + const auto window_id = static_cast<mobile_apis::WindowType::eType>( + (*msg)[am::strings::msg_params][am::strings::window_id].asInt()); + const auto window_name = + (*msg)[am::strings::msg_params][am::strings::window_name].asString(); + + state->set_window_type(window_type); + state->set_hmi_level(mobile_apis::HMILevel::INVALID_ENUM); + state->set_audio_streaming_state( + mobile_apis::AudioStreamingState::INVALID_ENUM); + state->set_video_streaming_state( + mobile_apis::VideoStreamingState::INVALID_ENUM); + state->set_system_context(mobile_apis::SystemContext::INVALID_ENUM); + ApplicationSharedPtr AppPtr = app; + ON_CALL(app_mngr_, + CreateRegularState(AppPtr, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_apis::SystemContext::INVALID_ENUM)) + .WillByDefault(Return(state)); + ON_CALL(*mock_app_, SetInitialState(kTestWindowId, window_name, state)) + .WillByDefault(Return()); + ON_CALL(app_mngr_, state_controller()) + .WillByDefault(ReturnRef(mock_state_controller)); + ON_CALL( + mock_state_controller, + OnAppWindowAdded( + AppPtr, window_id, window_type, mobile_apis::HMILevel::HMI_NONE)) + .WillByDefault(Return()); + } + + void SetUp() OVERRIDE { + using namespace application_manager; + display_capabilities_ = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Array); + + smart_objects::SmartObject window_type_supported( + smart_objects::SmartType_Array); + + const uint32_t maximum_widgets_amount = 4; + smart_objects::SmartObject maximum_widgets(smart_objects::SmartType_Map); + maximum_widgets[strings::window_type] = mobile_apis::WindowType::WIDGET; + maximum_widgets[strings::maximum_number_of_windows] = + maximum_widgets_amount; + + window_type_supported[window_type_supported.length()] = maximum_widgets; + + (*display_capabilities_)[0][strings::window_type_supported] = + window_type_supported; + + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities_)); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(display_capabilities_)); + + window_params_map_lock_ptr_ = std::make_shared<sync_primitives::Lock>(); + + DataAccessor<am::WindowParamsMap> window_params_map( + test_window_params_map_, window_params_map_lock_ptr_); + ON_CALL(*mock_app_, window_optional_params_map()) + .WillByDefault(Return(window_params_map)); + } + + MockAppPtr mock_app_; + NiceMock<MockStateController> mock_state_controller; + std::shared_ptr<sync_primitives::Lock> window_params_map_lock_ptr_; + application_manager::WindowParamsMap test_window_params_map_; + smart_objects::SmartObjectSPtr display_capabilities_; +}; + +TEST_F(CreateWindowRequestTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMsgParams(); + const auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + +TEST_F(CreateWindowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_WindowIDAlreadyExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_CreateWindowForMAINWindowType_ExpectInvalidDataResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_DATA; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::MAIN; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + Run_DuplicateUpdatesFromNotExistingWindowId_ExpectInvalidDataResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_DATA; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(false)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + Run_DuplicateUpdatesFromExistingWindowId_ExpectUICreateWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + ON_CALL(*mock_app_, GetWindowNames()) + .WillByDefault(Return(std::vector<std::string>())); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::WIDGET; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_WindowNameAppNameAreEqual_ExpectDuplicateNameResponseToMobile) { + const auto result_code = mobile_apis::Result::DUPLICATE_NAME; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_name] = kAppName; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + Run_AllParametersCorrect_ExpectUICreateWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + const std::vector<std::string> windowNames = { + "WindowName_1", "WindowName_2", "WindowName_3"}; + ON_CALL(*mock_app_, GetWindowNames()).WillByDefault(Return(windowNames)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::associated_service_type] = + "MEDIA"; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::WIDGET; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F( + CreateWindowRequestTest, + CheckWindowName_AllParametersCorrectCreateWindowForPrimaryWidget_SendMessageToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_CreateWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, WindowIdExists(kTestWindowId)) + .WillByDefault(Return(false)); + ON_CALL(*mock_app_, WindowIdExists(kDuplicateWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + mobile_apis::PredefinedWindows::PRIMARY_WIDGET; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params] + [am::strings::duplicate_updates_from_window_id] = kDuplicateWindowID; + (*msg)[am::strings::msg_params][am::strings::associated_service_type] = + "MEDIA"; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::WIDGET; + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_InvalidFunctionId_MessageNotSendToMobile) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + auto msg = CreateMsgParams(); + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::UI_CreateWindow); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_RequestFailedOnHMISide_SendGenericErrorResponseToMobile) { + const auto result_code = mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::WIDGET; + + SetupHelperApplyWindowInitialState(mock_app_, msg); + + Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +TEST_F(CreateWindowRequestTest, + OnEvent_AllParametersCorrect_SendSuccessResponseToMobile) { + const auto result_code = mobile_apis::Result::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, true), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(1); + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::strings::window_name] = kWindowName; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + (*msg)[am::strings::msg_params][am::strings::window_type] = + mobile_apis::WindowType::eType::WIDGET; + + SetupHelperApplyWindowInitialState(mock_app_, msg); + + Event event(hmi_apis::FunctionID::UI_CreateWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<CreateWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +} // namespace create_window_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc index a87d172923..081058f05a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_command_request_test.cc @@ -37,15 +37,15 @@ #include "gtest/gtest.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/event_engine/event.h" #include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_help_prompt_manager.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -58,11 +58,11 @@ using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; namespace am_test = application_manager_test; -using sdl_rpc_plugin::commands::DeleteCommandRequest; +using am::MockHmiInterfaces; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; -using am::MockHmiInterfaces; +using sdl_rpc_plugin::commands::DeleteCommandRequest; typedef std::shared_ptr<DeleteCommandRequest> DeleteCommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc index 0ed7a92fa4..cce53bb480 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_file_test.cc @@ -31,32 +31,32 @@ */ #include <stdint.h> -#include <vector> -#include <string> #include <map> +#include <string> +#include <vector> #include "mobile/delete_file_request.h" #include "mobile/delete_file_response.h" #include "gtest/gtest.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/file_system.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/policy_handler.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" namespace test { namespace components { @@ -65,17 +65,17 @@ namespace mobile_commands_test { namespace delete_file { using ::testing::_; -using ::testing::Test; +using ::testing::AtLeast; using ::testing::Return; using ::testing::ReturnRef; using ::testing::SetArgReferee; -using ::testing::AtLeast; +using ::testing::Test; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::DeleteFileRequest; -using sdl_rpc_plugin::commands::DeleteFileResponse; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::DeleteFileRequest; +using sdl_rpc_plugin::commands::DeleteFileResponse; typedef std::shared_ptr<DeleteFileRequest> DeleteFileRequestPtr; typedef std::shared_ptr<DeleteFileResponse> DeleteFileResponsePtr; @@ -98,6 +98,8 @@ namespace { const uint32_t kConnectionKey = 1u; const uint32_t kCorrelationId = 10u; const int32_t kMenuId = 5; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class DeleteFileRequestTest @@ -134,7 +136,7 @@ TEST_F(DeleteFileRequestTest, Run_HMILevelNone_UNSUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE)); EXPECT_CALL(app_mngr_, get_settings()) @@ -161,7 +163,7 @@ TEST_F(DeleteFileRequestTest, Run_ValidFileName_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(app_mngr_, get_settings()) @@ -191,7 +193,7 @@ TEST_F(DeleteFileRequestTest, Run_InvalidFile_UNSUCCESS) { (*message_)[am::strings::msg_params][am::strings::sync_file_name] = file_name; EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(app_mngr_, get_settings()) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc index c209c4fea2..fa96b21ca7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc @@ -38,13 +38,13 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,15 +53,15 @@ namespace mobile_commands_test { namespace delete_interaction_choice_set { using ::testing::_; -using ::testing::Return; using ::testing::InSequence; +using ::testing::Return; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetRequest; -using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetResponse; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetRequest; +using sdl_rpc_plugin::commands::DeleteInteractionChoiceSetResponse; typedef std::shared_ptr<DeleteInteractionChoiceSetRequest> DeleteInteractionChoiceSetRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc index ff9e29c872..04f12568b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_sub_menu_test.cc @@ -36,14 +36,14 @@ #include "mobile/delete_sub_menu_request.h" #include "mobile/delete_sub_menu_response.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_help_prompt_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,15 +52,15 @@ namespace mobile_commands_test { namespace delete_sub_menu_request { using ::testing::_; +using ::testing::InSequence; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::InSequence; namespace am = ::application_manager; namespace am_test = application_manager_test; -using am::commands::MessageSharedPtr; -using am::event_engine::Event; using am::MockHmiInterfaces; using am::MockMessageHelper; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; using sdl_rpc_plugin::commands::DeleteSubMenuRequest; using sdl_rpc_plugin::commands::DeleteSubMenuResponse; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc new file mode 100644 index 0000000000..f951d5c2a7 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_window_request_test.cc @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdint.h> +#include <memory> +#include <set> +#include <string> + +#include "mobile/delete_window_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_state_controller.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace delete_window_request { + +namespace am = application_manager; +using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::DeleteWindowRequest; +using namespace mobile_apis::PredefinedWindows; +using am::commands::Command; +using application_manager::WindowID; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +namespace { +const uint32_t kConnectionKey = 2u; +const int32_t kFunctionID = mobile_apis::FunctionID::DeleteWindowID; +const WindowID kTestWindowId = 12; +} // namespace + +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast<int32_t>(result_code); + return is_success && is_result_code_correct; +} + +class DeleteWindowRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + public: + DeleteWindowRequestTest() { + mock_app_ = CreateMockApp(); + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + protected: + MessageSharedPtr CreateMsgParams() { + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + (*msg)[am::strings::params][am::strings::function_id] = kFunctionID; + return msg; + } + + MockAppPtr mock_app_; + NiceMock<MockStateController> mock_state_controller; +}; + +TEST_F(DeleteWindowRequestTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMsgParams(); + const auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + +TEST_F(DeleteWindowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_WindowIDForMainApplicationWindow_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_WindowIDNotExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + ON_CALL(*mock_app_, GetWindowIds()).WillByDefault(Return(am::WindowIds())); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_AllParametersCorrect_ExpectUIDeleteWindowIsSentToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + + ON_CALL(*mock_app_, GetWindowIds()) + .WillByDefault(Return(am::WindowIds(1, kTestWindowId))); + EXPECT_CALL(*mock_app_, WindowIdExists(kTestWindowId)).WillOnce(Return(true)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + Run_AllParametersCorrectDeleteWindowForPrimaryWidget_SendMessageToHMI) { + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_DeleteWindow), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + const auto primary_widget_window_id = + mobile_apis::PredefinedWindows::PRIMARY_WIDGET; + ON_CALL(*mock_app_, GetWindowIds()) + .WillByDefault(Return(am::WindowIds(1, primary_widget_window_id))); + EXPECT_CALL(*mock_app_, WindowIdExists(primary_widget_window_id)) + .WillOnce(Return(true)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = + primary_widget_window_id; + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_InvalidFunctionId_MessageNotSendToMobile) { + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + auto msg = CreateMsgParams(); + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::INVALID_ENUM); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_RequestFailedOnHMISide_SendGenericErrorResponseToMobile) { + const auto result_code = mobile_apis::Result::GENERIC_ERROR; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::GENERIC_ERROR; + + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +TEST_F(DeleteWindowRequestTest, + OnEvent_AllParametersCorrect_SendSuccessResponseToMobile) { + const auto result_code = mobile_apis::Result::SUCCESS; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, true), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, UpdateHash()).Times(1); + EXPECT_CALL(*mock_app_, RemoveHMIState(kTestWindowId, _)).Times(1); + + auto msg = CreateMsgParams(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::SUCCESS; + (*msg)[am::strings::msg_params][am::strings::window_id] = kTestWindowId; + + Event event(hmi_apis::FunctionID::UI_DeleteWindow); + event.set_smart_object(*msg); + + auto command = CreateCommand<DeleteWindowRequest>(msg); + EXPECT_TRUE(command->Init()); + command->on_event(event); +} + +} // namespace delete_window_request +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc index ffa1b833be..cf2634b37c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dial_number_request_test.cc @@ -36,16 +36,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "mobile/dial_number_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "mobile/dial_number_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -57,8 +57,8 @@ using ::testing::_; using ::testing::Return; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::DialNumberRequest; using am::event_engine::Event; +using sdl_rpc_plugin::commands::DialNumberRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr<DialNumberRequest> DialNumberRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index 9c20143c39..8f83a2dd10 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -131,8 +131,8 @@ #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" +#include "test/application_manager/mock_application_manager_settings.h" namespace am = application_manager; @@ -143,16 +143,16 @@ namespace mobile_commands_test { namespace dummy_mobile_commands_test { namespace commands = sdl_rpc_plugin::commands; -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; using am::commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::application_manager::ApplicationSharedPtr; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::_; +using ::testing::NotNull; +using ::testing::Types; namespace { const std::string kEmptyString_ = ""; @@ -283,7 +283,8 @@ typedef Types<commands::mobile::OnSystemRequestNotification, commands::SubscribeWayPointsRequest, commands::SubscribeWayPointsResponse, commands::SystemResponse, - commands::UnregisterAppInterfaceRequest> MobileCommandsListSecond; + commands::UnregisterAppInterfaceRequest> + MobileCommandsListSecond; typedef Types<commands::UnregisterAppInterfaceResponse, commands::UnsubscribeButtonRequest, @@ -291,7 +292,8 @@ typedef Types<commands::UnregisterAppInterfaceResponse, commands::UnsubscribeWayPointsRequest, commands::UnsubscribeWayPointsResponse, commands::UpdateTurnListRequest, - commands::UpdateTurnListResponse> MobileCommandsListThird; + commands::UpdateTurnListResponse> + MobileCommandsListThird; TYPED_TEST_CASE(MobileCommandsTestFirst, MobileCommandsListFirst); TYPED_TEST_CASE(MobileCommandsTestSecond, MobileCommandsListSecond); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc index 304cf13ffd..ba09e0dabe 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/end_audio_pass_thru_request_test.cc @@ -36,14 +36,14 @@ #include "mobile/end_audio_pass_thru_request.h" -#include "gtest/gtest.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,13 +52,13 @@ namespace mobile_commands_test { namespace end_audio_pass_thru_request { namespace am = ::application_manager; +using am::MockMessageHelper; +using am::commands::MessageSharedPtr; +using am::event_engine::Event; +using sdl_rpc_plugin::commands::EndAudioPassThruRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using am::commands::MessageSharedPtr; -using sdl_rpc_plugin::commands::EndAudioPassThruRequest; -using am::event_engine::Event; -using am::MockMessageHelper; typedef std::shared_ptr<EndAudioPassThruRequest> EndAudioPassThruRequestPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc new file mode 100644 index 0000000000..74c61410e8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_system_capability_request_test.cc @@ -0,0 +1,124 @@ +/* + Copyright (c) 2019, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "mobile/get_system_capability_request.h" + +#include "application_manager/commands/command_request_test.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace get_system_capability_request_test { + +using sdl_rpc_plugin::commands::GetSystemCapabilityRequest; +using ::testing::_; +using ::testing::Return; +typedef std::shared_ptr<GetSystemCapabilityRequest> + GetSystemCapabilityRequestPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +} + +class GetSystemCapabilityRequestTest + : public CommandRequestTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + command_ = CreateCommand<GetSystemCapabilityRequest>(message_); + mock_app_ = CreateMockApp(); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + } + + GetSystemCapabilityRequestPtr command_; + MessageSharedPtr message_; + MockAppPtr mock_app_; +}; + +TEST_F( + GetSystemCapabilityRequestTest, + Run_GetSystemDisplayCapabilities_SendMessageToMobileWithSUCCESSResultCode) { + (*message_)[strings::msg_params][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities( + std::make_shared<smart_objects::SmartObject>()); + + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), + Command::CommandSource::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + GetSystemCapabilityRequestTest, + Run_GetSystemDisplayCapabilities_CapabilitiesNotExistSendMessageToMobileWithDATA_NOT_AVAILABLEResultCode) { + (*message_)[strings::msg_params][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + EXPECT_CALL(*mock_app_, display_capabilities()).WillOnce(Return(nullptr)); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(nullptr)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::DATA_NOT_AVAILABLE), + Command::CommandSource::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace get_system_capability_request_test +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc index f450d4b671..7f7a8b55bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/get_way_points_request_test.cc @@ -32,18 +32,17 @@ #include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" -#include "mobile/get_way_points_request.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/mock_hmi_interface.h" -#include "application_manager/mock_message_helper.h" +#include "mobile/get_way_points_request.h" namespace test { namespace components { @@ -52,11 +51,11 @@ namespace mobile_commands_test { namespace get_way_points_request { using namespace mobile_apis::Result; -using ::testing::Return; -using ::testing::_; -using sdl_rpc_plugin::commands::GetWayPointsRequest; -using application_manager::MockMessageHelper; using application_manager::MockHmiInterfaces; +using application_manager::MockMessageHelper; +using sdl_rpc_plugin::commands::GetWayPointsRequest; +using ::testing::_; +using ::testing::Return; typedef std::shared_ptr<GetWayPointsRequest> CommandPtr; typedef mobile_apis::Result::eType MobileResult; @@ -67,7 +66,7 @@ const uint32_t kCorrelationId = 2u; const uint32_t kAppId = 3u; const uint32_t kConnectionKey = kAppId; const std::string kMethodName = "Navigation.GetWayPoints"; -} +} // namespace class GetWayPointsRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc index 3fcc4225f3..06ecc1116e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/list_files_request_test.cc @@ -35,15 +35,15 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" -#include "mobile/list_files_request.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/list_files_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,13 +52,18 @@ namespace mobile_commands_test { namespace list_files_request { using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::testing::SaveArg; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::ListFilesRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::ListFilesRequest; + +namespace { +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} class ListFilesRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { @@ -86,7 +91,7 @@ TEST_F(ListFilesRequestTest, Run_TooManyHmiNone_UNSUCCESS) { std::shared_ptr<ListFilesRequest> command(CreateCommand<ListFilesRequest>()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); - ON_CALL(*app, hmi_level()) + ON_CALL(*app, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_NONE)); const uint32_t kListFilesInNoneAllowed = 1u; @@ -121,7 +126,7 @@ TEST_F(ListFilesRequestTest, Run_SUCCESS) { ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); - ON_CALL(*app, hmi_level()) + ON_CALL(*app, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); ON_CALL(*app, increment_list_files_in_none_count()).WillByDefault(Return()); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc index a0e41cf728..c0305a15ca 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc @@ -33,16 +33,16 @@ #include <stdint.h> #include <string> +#include "application_manager/smart_object_keys.h" #include "gtest/gtest.h" #include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/commands/command_impl.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "mobile/on_button_event_notification.h" #include "mobile/on_button_press_notification.h" @@ -54,17 +54,19 @@ namespace on_button_notification { namespace am = ::application_manager; namespace commands = am::commands; +using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::mobile::OnButtonEventNotification; using sdl_rpc_plugin::commands::mobile::OnButtonPressNotification; using ::testing::_; -using ::testing::Types; using ::testing::Return; -using am::commands::MessageSharedPtr; +using ::testing::Types; namespace { const uint32_t kAppId = 5u; const uint32_t kCustomButtonId = 3u; const mobile_apis::ButtonName::eType kButtonName = mobile_apis::ButtonName::OK; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace template <class NotificationT, @@ -217,7 +219,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_CustomButton_SUCCESS) { this->template CreateCommand<Notification>(notification_msg)); typename TestFixture::MockAppPtr mock_app = this->CreateMockApp(); - ON_CALL(*mock_app, hmi_level()) + ON_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId)) @@ -264,7 +266,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_InvalidHmiLevel_UNSUCCESS) { std::vector<ApplicationSharedPtr> subscribed_apps_list; subscribed_apps_list.push_back(mock_app); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) @@ -290,7 +292,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, std::vector<ApplicationSharedPtr> subscribed_apps_list; subscribed_apps_list.push_back(mock_app); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) @@ -316,7 +318,7 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) { std::vector<ApplicationSharedPtr> subscribed_apps_list; subscribed_apps_list.push_back(mock_app); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); ON_CALL(*mock_app, IsFullscreen()).WillByDefault(Return(true)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc index 2fd6f6137d..1356b1c5fa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_command_notification_test.cc @@ -35,11 +35,11 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.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/commands_test.h" +#include "application_manager/smart_object_keys.h" #include "mobile/on_command_notification.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc index 1d6711e36f..15faa5c13f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hash_change_notification_test.cc @@ -32,12 +32,12 @@ #include <string> -#include "gtest/gtest.h" -#include "mobile/on_hash_change_notification.h" +#include "application_manager/commands/command_impl.h" #include "application_manager/mock_message_helper.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command_impl.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "gtest/gtest.h" +#include "mobile/on_hash_change_notification.h" namespace test { namespace components { @@ -47,13 +47,13 @@ namespace on_hash_change_notification { namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::mobile::OnHashChangeNotification; using application_manager::MockMessageHelper; using application_manager::commands::CommandImpl; +using sdl_rpc_plugin::commands::mobile::OnHashChangeNotification; +using testing::_; using testing::Mock; using testing::Return; using testing::ReturnRef; -using testing::_; class OnHashChangeNotificationTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc index 333c204d57..528f1d8618 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_from_mobile_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "mobile/on_hmi_status_notification_from_mobile.h" -#include "application_manager/commands/commands_test.h" #include <application_manager/smart_object_keys.h> -#include "application_manager/message.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/message.h" #include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -51,12 +51,12 @@ const connection_handler::DeviceHandle kHandle = 2u; namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::OnHMIStatusNotificationFromMobile; -using protocol_handler::MajorProtocolVersion; using application_manager::ApplicationSet; +using protocol_handler::MajorProtocolVersion; +using sdl_rpc_plugin::commands::OnHMIStatusNotificationFromMobile; +using testing::_; using testing::Mock; using testing::Return; -using testing::_; class OnHMIStatusNotificationFromMobileTest : public CommandsTest<CommandsTestMocks::kIsNice> { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc index ba3b1e8f1d..5bf68414e5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_hmi_status_notification_test.cc @@ -30,11 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "mobile/on_hmi_status_notification.h" -#include "application_manager/test/include/application_manager/commands/commands_test.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/test/include/application_manager/commands/commands_test.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -47,13 +47,13 @@ const uint32_t kConnectionKey = 1u; } // namespace namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::OnHMIStatusNotification; -using protocol_handler::MajorProtocolVersion; using application_manager::MockMessageHelper; using application_manager::commands::CommandImpl; +using protocol_handler::MajorProtocolVersion; +using sdl_rpc_plugin::commands::OnHMIStatusNotification; +using testing::_; using testing::Mock; using testing::Return; -using testing::_; class OnHMIStatusNotificationTest : public CommandsTest<CommandsTestMocks::kIsNice> { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc index 04f88e2b13..b7b827bb4c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_keyboard_input_notification_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include "mobile/on_keyboard_input_notification.h" -#include "application_manager/commands/commands_test.h" #include <application_manager/smart_object_keys.h> +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/message.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -48,15 +48,17 @@ namespace strings = application_manager::strings; namespace { const uint32_t kConnectionKey = 1u; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace -using sdl_rpc_plugin::commands::mobile::OnKeyBoardInputNotification; +using application_manager::ApplicationSet; using application_manager::MockMessageHelper; using application_manager::commands::CommandImpl; -using application_manager::ApplicationSet; +using sdl_rpc_plugin::commands::mobile::OnKeyBoardInputNotification; +using testing::_; using testing::Mock; using testing::Return; -using testing::_; class OnKeyBoardInputNotificationTest : public CommandsTest<CommandsTestMocks::kIsNice> { @@ -102,7 +104,7 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_ActionActive_SUCCESS) { EXPECT_CALL(*mock_app, is_perform_interaction_active()).WillOnce(Return(1)); EXPECT_CALL(*mock_app, perform_interaction_layout()) .WillOnce(Return(mobile_apis::LayoutMode::KEYBOARD)); - EXPECT_CALL(*mock_app, hmi_level()).Times(0); + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)).Times(0); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); @@ -126,7 +128,7 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_ActionNotActive_SUCCESS) { EXPECT_CALL(*mock_app, is_perform_interaction_active()) .WillRepeatedly(Return(0)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_FULL)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kConnectionKey)); @@ -151,7 +153,7 @@ TEST_F(OnKeyBoardInputNotificationTest, Run_InvalidApp_NoNotification) { EXPECT_CALL(*mock_app, is_perform_interaction_active()) .WillRepeatedly(Return(0)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::eType::HMI_BACKGROUND)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc new file mode 100644 index 0000000000..349ada66a2 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_capability_updated_notification_test.cc @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "mobile/on_system_capability_updated_notification.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/display_capabilities_builder.h" +#include "gtest/gtest.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" +#include "sdl_rpc_plugin/sdl_rpc_plugin.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace on_system_capability_updated_notification { + +using sdl_rpc_plugin::commands::mobile::OnSystemCapabilityUpdatedNotification; +using ::testing::_; +using ::testing::Return; + +typedef std::shared_ptr<OnSystemCapabilityUpdatedNotification> + OnSystemCapabilityUpdatedNotificationPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kAppId = 2u; +} // namespace + +MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") { + return *display_capabilities == + (*arg)[strings::msg_params][strings::system_capability] + [strings::display_capabilities]; +} + +class OnSystemCapabilityUpdatedNotificationTest + : public CommandsTest<CommandsTestMocks::kIsNice> { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + + command_ = CreateCommand<OnSystemCapabilityUpdatedNotification>(message_); + mock_app_ = CreateMockApp(); + } + + OnSystemCapabilityUpdatedNotificationPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; +}; + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppExistSubscribedToNotification_SystemDisplayCapabilitiesSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Null); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + std::shared_ptr<sdl_rpc_plugin::SystemCapabilityAppExtension> + system_capability_app_extension( + std::make_shared<sdl_rpc_plugin::SystemCapabilityAppExtension>( + sdl_rpc_plugin, *mock_app_)); + system_capability_app_extension->SubscribeTo( + mobile_apis::SystemCapabilityType::DISPLAYS); + application_manager::ApplicationSet apps({mock_app_}); + std::shared_ptr<sync_primitives::Lock> apps_lock_( + std::make_shared<sync_primitives::Lock>()); + DataAccessor<application_manager::ApplicationSet> apps_data( + DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr)); + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + application_manager::DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(CheckDisplayCapabilities(system_display_capabilities), + false)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppExistConnectionKeyNotEqualWithAppId_SystemDisplayCapabilitiesNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Null); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + std::shared_ptr<sdl_rpc_plugin::SystemCapabilityAppExtension> + system_capability_app_extension( + std::make_shared<sdl_rpc_plugin::SystemCapabilityAppExtension>( + sdl_rpc_plugin, *mock_app_)); + system_capability_app_extension->SubscribeTo( + mobile_apis::SystemCapabilityType::DISPLAYS); + application_manager::ApplicationSet apps({mock_app_}); + std::shared_ptr<sync_primitives::Lock> apps_lock_( + std::make_shared<sync_primitives::Lock>()); + DataAccessor<application_manager::ApplicationSet> apps_data( + DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr)); + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppExistNotSubscribedToNotification_SystemDisplayCapabilitiesNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + + smart_objects::SmartObjectSPtr system_display_capabilities = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Null); + + ON_CALL(mock_hmi_capabilities_, system_display_capabilities()) + .WillByDefault(Return(system_display_capabilities)); + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + std::shared_ptr<sdl_rpc_plugin::SystemCapabilityAppExtension> + system_capability_app_extension( + std::make_shared<sdl_rpc_plugin::SystemCapabilityAppExtension>( + sdl_rpc_plugin, *mock_app_)); + + application_manager::ApplicationSet apps({mock_app_}); + std::shared_ptr<sync_primitives::Lock> apps_lock_( + std::make_shared<sync_primitives::Lock>()); + DataAccessor<application_manager::ApplicationSet> apps_data( + DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, display_capabilities()).WillByDefault(Return(nullptr)); + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnSystemCapabilityUpdatedNotificationTest, + Run_AppDataEmpty_SystemDisplayCapabilitiesUpdatedNotificationNotSendToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::DISPLAYS; + application_manager::ApplicationSet apps; + std::shared_ptr<sync_primitives::Lock> apps_lock_( + std::make_shared<sync_primitives::Lock>()); + DataAccessor<application_manager::ApplicationSet> apps_data( + DataAccessor<application_manager::ApplicationSet>(apps, apps_lock_)); + + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_data)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +} // namespace on_system_capability_updated_notification +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc index 4981301e07..ffa7203f1f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_system_request_notification_test.cc @@ -32,14 +32,13 @@ #include <string> -#include "gtest/gtest.h" -#include "mobile/on_system_request_notification.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" +#include "mobile/on_system_request_notification.h" namespace test { namespace components { @@ -49,20 +48,21 @@ namespace on_system_request_notification { namespace strings = application_manager::strings; -using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; -using application_manager::commands::CommandImpl; using application_manager::MockMessageHelper; +using application_manager::commands::CommandImpl; +using sdl_rpc_plugin::commands::mobile::OnSystemRequestNotification; using test::components::policy_test::MockPolicyHandlerInterface; using namespace mobile_apis; -using testing::SaveArg; +using testing::_; using testing::Mock; using testing::Return; using testing::ReturnRef; -using testing::_; +using testing::SaveArg; namespace { const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "fake-app-id"; +const connection_handler::DeviceHandle kDeviceId = 1u; } // namespace class OnSystemRequestNotificationTest @@ -74,6 +74,7 @@ class OnSystemRequestNotificationTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_, device()).WillByDefault(Return(kDeviceId)); } protected: @@ -91,12 +92,14 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { std::shared_ptr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillRepeatedly(Return(true)); #ifdef PROPRIETARY_MODE @@ -131,10 +134,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { std::shared_ptr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)) @@ -168,7 +174,7 @@ TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(MockAppPtr())); EXPECT_CALL(*mock_app_, policy_app_id()).Times(0); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)).Times(0); + EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _, _)).Times(0); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -188,10 +194,13 @@ TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { std::shared_ptr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); + PreConditions(); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId)); - EXPECT_CALL(mock_policy_handler_, IsRequestTypeAllowed(_, _)) + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(false)); EXPECT_CALL(mock_message_helper_, PrintSmartObject(_)).Times(0); @@ -215,7 +224,7 @@ TEST_F( PreConditions(); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) @@ -242,7 +251,7 @@ TEST_F(OnSystemRequestNotificationTest, PreConditions(); EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kPolicyAppId, request_type)) + IsRequestTypeAllowed(kDeviceId, kPolicyAppId, request_type)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc index 3d989db478..c43dea76e1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_tbt_client_state_notification_test.cc @@ -36,10 +36,10 @@ #include "gtest/gtest.h" #include "mobile/on_tbt_client_state_notification.h" -#include "smart_objects/smart_object.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/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" #include "utils/helpers.h" namespace test { @@ -60,6 +60,8 @@ typedef std::shared_ptr<OnTBTClientStateNotification> NotificationPtr; namespace { const uint32_t kAppId = 1u; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class OnTBTClientStateNotificationTest @@ -79,7 +81,7 @@ TEST_F(OnTBTClientStateNotificationTest, Run_HmiLevelNone_UNSUCCESS) { EXPECT_CALL(app_mngr_, applications_with_navi()) .WillOnce(Return(applications_with_navi)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(*mock_app, app_id()).Times(0); @@ -122,7 +124,7 @@ TEST_F(OnTBTClientStateNotificationTest, EXPECT_CALL(app_mngr_, applications_with_navi()) .WillOnce(Return(applications_with_navi)); - EXPECT_CALL(*mock_app, hmi_level()) + EXPECT_CALL(*mock_app, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc index f69dd5da2e..95020328b4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_touch_event_notification_test.cc @@ -36,10 +36,10 @@ #include "gtest/gtest.h" #include "mobile/on_touch_event_notification.h" -#include "smart_objects/smart_object.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/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" #include "utils/helpers.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc index ed0a9b07d2..83958954cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_way_point_change_notification_test.cc @@ -36,10 +36,10 @@ #include "gtest/gtest.h" #include "mobile/on_way_point_change_notification.h" -#include "smart_objects/smart_object.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/commands_test.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" #include "utils/helpers.h" namespace test { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc index acda9b9fc7..2915418d43 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -31,18 +31,18 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/perform_audio_pass_thru_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -51,14 +51,14 @@ namespace mobile_commands_test { namespace perform_audio_pass_thru_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::PerformAudioPassThruRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::PerformAudioPassThruRequest; using ::testing::_; +using ::testing::InSequence; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::InSequence; namespace { const int32_t kCommandId = 1; @@ -72,6 +72,8 @@ const std::string kCorrectDisplayText1 = "CorrectDisplayText1"; const std::string kCorrectDisplayText2 = "CorrectDisplayText2"; const std::string kFunctionId = "FunctionId"; const uint32_t kTimeoutForTTSSpeak = 1u; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace class PerformAudioPassThruRequestTest @@ -109,7 +111,7 @@ class PerformAudioPassThruRequestTest msg_params_[field] = "prompt\\n"; } - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); CallRun caller(*command_sptr_); @@ -206,7 +208,7 @@ TEST_F(PerformAudioPassThruRequestTest, (*mobile_request)[am::strings::msg_params][am::strings::initial_prompt] = initial_prompt; - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); std::shared_ptr<PerformAudioPassThruRequest> command = CreateCommand<PerformAudioPassThruRequest>(mobile_request); @@ -250,7 +252,8 @@ TEST_F(PerformAudioPassThruRequestTest, VerifyTtsFiles((*mobile_request)[am::strings::msg_params] [am::strings::initial_prompt], _, - _)).WillOnce(Return(mobile_apis::Result::SUCCESS)); + _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); command->Run(); command->on_event(event_tts); @@ -285,7 +288,7 @@ TEST_F(PerformAudioPassThruRequestTest, } TEST_F(PerformAudioPassThruRequestTest, Run_HmiLevelNone_Rejected) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_NONE)); CallRun caller(*command_sptr_); @@ -318,7 +321,7 @@ TEST_F(PerformAudioPassThruRequestTest, // First we need to call SendSpeakRequest() // to enable the "is_active_tts_speak" key - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -406,7 +409,7 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F(PerformAudioPassThruRequestTest, Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteTrue) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -463,10 +466,12 @@ TEST_F(PerformAudioPassThruRequestTest, .asString(); const std::string result_display_text_1 = perform_msg_params[am::hmi_request::audio_pass_display_texts][0] - [am::hmi_request::field_text].asString(); + [am::hmi_request::field_text] + .asString(); const std::string result_display_text_2 = perform_msg_params[am::hmi_request::audio_pass_display_texts][1] - [am::hmi_request::field_text].asString(); + [am::hmi_request::field_text] + .asString(); EXPECT_EQ(kCorrectPrompt, result_initial_prompt); EXPECT_EQ(kCorrectType, result_prompt_type); @@ -478,7 +483,7 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F(PerformAudioPassThruRequestTest, Run_InitPromptCorrect_SpeakAndPerformAPTRequestsSendMuteFalse) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -533,7 +538,7 @@ TEST_F(PerformAudioPassThruRequestTest, TEST_F( PerformAudioPassThruRequestTest, Run_InitPromptEmpty_PerformAndRecordStartNotificationsAndStartRecording) { - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); MessageSharedPtr start_record_result_msg; @@ -579,7 +584,8 @@ TEST_F( const hmi_apis::FunctionID::eType start_record_result_function_id = static_cast<hmi_apis::FunctionID::eType>( (*start_record_result_msg)[am::strings::params] - [am::strings::function_id].asInt()); + [am::strings::function_id] + .asInt()); EXPECT_EQ(hmi_apis::FunctionID::UI_OnRecordStart, start_record_result_function_id); } @@ -762,7 +768,7 @@ TEST_F(PerformAudioPassThruRequestTest, EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, StopAudioPassThru(_)); - EXPECT_CALL(*application_sptr_, hmi_level()) + EXPECT_CALL(*application_sptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(am::mobile_api::HMILevel::HMI_FULL)); msg_params_[am::strings::initial_prompt][0][am::strings::text] = @@ -831,4 +837,4 @@ TEST_F(PerformAudioPassThruRequestTest, } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc index 3b68d3ea72..f1f7c4c907 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/perform_interaction_test.cc @@ -31,22 +31,22 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/perform_interaction_request.h" -#include "gtest/gtest.h" -#include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" +#include "utils/helpers.h" namespace test { namespace components { @@ -55,16 +55,16 @@ namespace mobile_commands_test { namespace perform_interaction_request { namespace am = application_manager; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::PerformInteractionRequest; +using ::test::components::application_manager_test::MockApplication; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; -using sdl_rpc_plugin::commands::PerformInteractionRequest; -using ::test::components::application_manager_test::MockApplication; namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; @@ -258,4 +258,4 @@ TEST_F(PerformInteractionRequestTest, } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc index 415b559f82..8db533f446 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/put_file_test.cc @@ -36,18 +36,18 @@ #include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" -#include "mobile/put_file_response.h" #include "mobile/put_file_request.h" +#include "mobile/put_file_response.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/application.h" #include "application_manager/mock_application.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/file_system.h" namespace test { namespace components { @@ -56,16 +56,16 @@ namespace mobile_commands_test { namespace put_file { using ::testing::_; +using ::testing::AtLeast; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::AtLeast; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::PutFileRequest; -using sdl_rpc_plugin::commands::PutFileResponse; using am::commands::MessageSharedPtr; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::PutFileRequest; +using sdl_rpc_plugin::commands::PutFileResponse; typedef std::shared_ptr<PutFileRequest> PutFileRequestPtr; typedef std::shared_ptr<PutFileResponse> PutFileResponsePtr; @@ -78,7 +78,9 @@ const int64_t kZeroOffset = 0u; const std::string kStorageFolder = "./storage"; const std::string kFolder = "folder"; const std::string kAppFolder = "app_folder"; -} +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} // namespace class PutFileRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { @@ -99,7 +101,7 @@ class PutFileRequestTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); - ON_CALL(*mock_app_, hmi_level()) + ON_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillByDefault(Return(mobile_apis::HMILevel::HMI_FULL)); } @@ -179,7 +181,7 @@ TEST_F(PutFileRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { } TEST_F(PutFileRequestTest, Run_HmiLevelNone_UNSUCCESS) { - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); const uint32_t settings_put_file_in_none = 1u; @@ -319,7 +321,8 @@ TEST_F(PutFileRequestTest, Run_SendOnPutFileNotification_SUCCESS) { mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::BasicCommunication_OnPutFile), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index 868d353a85..636175c56f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -34,25 +34,25 @@ #include <string> #include <vector> -#include "gtest/gtest.h" -#include "mobile/register_app_interface_request.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_helper.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/policies/mock_policy_handler_interface.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/mock_hmi_capabilities.h" -#include "application_manager/mock_resume_ctrl.h" #include "application_manager/mock_hmi_interface.h" -#include "utils/data_accessor.h" +#include "application_manager/mock_resume_ctrl.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/register_app_interface_request.h" +#include "protocol_handler/mock_session_observer.h" +#include "smart_objects/smart_object.h" #include "utils/custom_string.h" +#include "utils/data_accessor.h" #include "utils/lock.h" #include "utils/macro.h" #include "utils/semantic_version.h" @@ -64,9 +64,11 @@ namespace mobile_commands_test { namespace register_app_interface_request { using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; +using ::testing::SaveArg; +using ::testing::SetArgPointee; namespace am = ::application_manager; @@ -75,12 +77,16 @@ using sdl_rpc_plugin::commands::RegisterAppInterfaceRequest; namespace { const uint32_t kConnectionKey = 1u; +const uint32_t kConnectionKey2 = 2u; +const connection_handler::DeviceHandle kDeviceHandle = 3u; const hmi_apis::Common_Language::eType kHmiLanguage = hmi_apis::Common_Language::EN_US; const mobile_apis::Language::eType kMobileLanguage = mobile_apis::Language::EN_US; -const std::string kMacAddress = "test_mac_address"; -const std::string kAppId = "test_app_id"; +const std::string kMacAddress1 = "test_mac_address1"; +const std::string kMacAddress2 = "test_mac_address2"; +const std::string kAppId1 = "test_app1_id"; +const std::string kAppId2 = "test_app2_id"; const std::string kFullAppId = "test_app_id_long"; const std::string kDummyString = "test_string"; const std::vector<uint32_t> kDummyDiagModes; @@ -94,6 +100,7 @@ class RegisterAppInterfaceRequestTest : msg_(CreateMessage()) , command_(CreateCommand<RegisterAppInterfaceRequest>(msg_)) , app_name_("test_app_name_") + , app2_name_("test_app2_name_") , lock_ptr_(std::make_shared<sync_primitives::Lock>()) , mock_application_helper_( application_manager_test::MockApplicationHelper:: @@ -112,7 +119,7 @@ class RegisterAppInterfaceRequestTest void InitBasicMessage() { (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; - (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId1; (*msg_)[am::strings::msg_params][am::strings::full_app_id] = kFullAppId; (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_; (*msg_)[am::strings::msg_params][am::strings::language_desired] = @@ -130,11 +137,11 @@ class RegisterAppInterfaceRequestTest MockAppPtr CreateBasicMockedApp() { MockAppPtr mock_app = CreateMockApp(); ON_CALL(*mock_app, name()).WillByDefault(ReturnRef(app_name_)); - ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress)); + ON_CALL(*mock_app, mac_address()).WillByDefault(ReturnRef(kMacAddress1)); ON_CALL(*mock_app, app_icon_path()).WillByDefault(ReturnRef(kDummyString)); ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage)); ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage)); - ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId1)); ON_CALL(*mock_app, msg_version()) .WillByDefault(ReturnRef(mock_semantic_version)); return mock_app; @@ -154,7 +161,7 @@ class RegisterAppInterfaceRequestTest void InitGetters() { ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_)) - .WillByDefault(Return(kAppId)); + .WillByDefault(Return(kAppId1)); ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); ON_CALL(app_mngr_, resume_controller()) .WillByDefault(ReturnRef(mock_resume_crt_)); @@ -168,7 +175,7 @@ class RegisterAppInterfaceRequestTest .WillByDefault(ReturnRef(kDummyString)); ON_CALL(app_mngr_settings_, supported_diag_modes()) .WillByDefault(ReturnRef(kDummyDiagModes)); - ON_CALL(mock_policy_handler_, GetAppRequestTypes(_)) + ON_CALL(mock_policy_handler_, GetAppRequestTypes(_, _)) .WillByDefault(Return(std::vector<std::string>())); ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_)) .WillByDefault(Return(policy::RequestType::State::EMPTY)); @@ -180,7 +187,7 @@ class RegisterAppInterfaceRequestTest .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed)); ON_CALL(app_mngr_, GetDeviceTransportType(_)) .WillByDefault(Return(hmi_apis::Common_TransportType::WIFI)); - ON_CALL(app_mngr_, IsAppInReconnectMode(_)).WillByDefault(Return(false)); + ON_CALL(app_mngr_, IsAppInReconnectMode(_, _)).WillByDefault(Return(false)); ON_CALL(app_mngr_, application_by_policy_id(_)) .WillByDefault(Return(ApplicationSharedPtr())); ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) @@ -201,7 +208,7 @@ class RegisterAppInterfaceRequestTest void SetCommonExpectionsOnSwitchedApplication( MockAppPtr mock_app, mobile_apis::Result::eType response_result_code) { - EXPECT_CALL(mock_policy_handler_, AddApplication(_, _)).Times(0); + EXPECT_CALL(mock_policy_handler_, AddApplication(_, _, _)).Times(0); EXPECT_CALL( mock_rpc_service_, @@ -212,13 +219,15 @@ class RegisterAppInterfaceRequestTest ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - _)).Times(0); + _)) + .Times(0); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), - _)).Times(0); + _)) + .Times(0); EXPECT_CALL( mock_rpc_service_, @@ -248,6 +257,7 @@ class RegisterAppInterfaceRequestTest std::shared_ptr<RegisterAppInterfaceRequest> command_; const utils::custom_string::CustomString app_name_; + const utils::custom_string::CustomString app2_name_; std::shared_ptr<sync_primitives::Lock> lock_ptr_; am::ApplicationSet app_set_; @@ -278,7 +288,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Init_SUCCESS) { TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { InitBasicMessage(); - (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1; EXPECT_CALL(app_mngr_, IsStopping()) .WillOnce(Return(false)) .WillOnce(Return(true)) @@ -287,20 +297,32 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + connection_handler::DeviceHandle handle = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(handle), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(handle, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(ApplicationSharedPtr())) - .WillRepeatedly(Return(mock_app)); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); ON_CALL(app_mngr_, applications()) .WillByDefault( Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); - ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) .WillByDefault(Return(true)); policy::StatusNotifier notify_upd_manager = std::make_shared<utils::CallNothing>(); - ON_CALL(mock_policy_handler_, AddApplication(_, _)) + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _)) .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); @@ -309,16 +331,19 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -356,10 +381,21 @@ TEST_F(RegisterAppInterfaceRequestTest, EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); + connection_handler::DeviceHandle handle = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(handle), Return(0))); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(_, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(ApplicationSharedPtr())) - .WillRepeatedly(Return(mock_app)); + .WillOnce(Return(mock_app)); MessageSharedPtr expected_message = CreateMessage(smart_objects::SmartType_Map); @@ -397,11 +433,11 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillByDefault( Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); - ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId, _, _)) + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) .WillByDefault(Return(true)); policy::StatusNotifier notify_upd_manager = std::make_shared<utils::CallNothing>(); - ON_CALL(mock_policy_handler_, AddApplication(_, _)) + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress1, kAppId1, _)) .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); @@ -413,29 +449,34 @@ TEST_F(RegisterAppInterfaceRequestTest, ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), - _)).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), - _)).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), - _)).WillOnce(Return(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), _)) + .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); - + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -447,10 +488,19 @@ TEST_F(RegisterAppInterfaceRequestTest, (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) - .WillRepeatedly(Return(mock_app)); + app_set_.insert(mock_app); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); + + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -460,7 +510,8 @@ TEST_F(RegisterAppInterfaceRequestTest, mock_resume_crt_, CheckApplicationHash( std::static_pointer_cast<application_manager::Application>(mock_app), - request_hash_id)).WillOnce(Return(true)); + request_hash_id)) + .WillOnce(Return(true)); EXPECT_CALL(mock_resume_crt_, RemoveApplicationFromSaved(_)).Times(0); @@ -472,6 +523,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::SUCCESS); + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -482,11 +534,18 @@ TEST_F(RegisterAppInterfaceRequestTest, const std::string request_hash_id = "abc123"; (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; - MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) - .WillRepeatedly(Return(mock_app)); + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -494,7 +553,8 @@ TEST_F(RegisterAppInterfaceRequestTest, mock_resume_crt_, CheckApplicationHash( std::static_pointer_cast<application_manager::Application>(mock_app), - request_hash_id)).WillOnce(Return(false)); + request_hash_id)) + .WillOnce(Return(false)); EXPECT_CALL( mock_application_helper_, @@ -509,7 +569,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::RESUME_FAILED); - + ASSERT_TRUE(command_->Init()); command_->Run(); } @@ -517,11 +577,18 @@ TEST_F(RegisterAppInterfaceRequestTest, SwitchApplication_NoHash_ExpectCleanupResumeFailed) { InitBasicMessage(); - MockAppPtr mock_app = CreateBasicMockedApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(kAppId)) - .WillRepeatedly(Return(mock_app)); + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); - EXPECT_CALL(app_mngr_, IsAppInReconnectMode(kAppId)).WillOnce(Return(true)); + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + MockAppPtr mock_app = CreateBasicMockedApp(); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -539,6 +606,137 @@ TEST_F(RegisterAppInterfaceRequestTest, SetCommonExpectionsOnSwitchedApplication(mock_app, mobile_apis::Result::RESUME_FAILED); + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + RegisterApp_SameAppId_SameDeviceFailed) { + using namespace am; + + InitBasicMessage(); + + MockAppPtr mock_app1 = CreateBasicMockedApp(); + + app_set_.insert(mock_app1); + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + + MockAppPtr mock_app2 = CreateBasicMockedApp(); + + connection_handler::DeviceHandle device_id = 1; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); + + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, application(kMacAddress1, kAppId1)) + .WillOnce(Return(mock_app1)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs( + mobile_apis::Result::APPLICATION_REGISTERED_ALREADY), + am::commands::Command::SOURCE_SDL)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(RegisterAppInterfaceRequestTest, + RegisterApp_SameAppId_DifferentDevicesSuccess) { + MockAppPtr mock_app1 = CreateBasicMockedApp(); + const connection_handler::DeviceHandle device_id1 = 1u; + ON_CALL(*mock_app1, device()).WillByDefault(Return(device_id1)); + app_set_.insert(mock_app1); + ON_CALL(app_mngr_, applications()) + .WillByDefault( + Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_))); + + InitBasicMessage(); + (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey2; + EXPECT_CALL(app_mngr_, IsStopping()) + .WillOnce(Return(false)) + .WillOnce(Return(true)) + .WillOnce(Return(false)); + ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false)); + EXPECT_CALL(app_mngr_, updateRequestTimeout(kConnectionKey2, _, _)); + EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1)) + .WillOnce(Return(false)); + + connection_handler::DeviceHandle device_id2 = 2u; + ON_CALL(mock_connection_handler_, + GetDataOnSessionKey(kConnectionKey2, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(device_id2), Return(0))); + + ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id2, _, _, _, _)) + .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress2), Return(0))); + + MockAppPtr mock_app2 = CreateBasicMockedApp(); + + ON_CALL(*mock_app2, device()).WillByDefault(Return(device_id2)); + ON_CALL(*mock_app2, mac_address()).WillByDefault(ReturnRef(kMacAddress2)); + EXPECT_CALL(app_mngr_, application(kMacAddress2, kAppId1)) + .WillRepeatedly(Return(ApplicationSharedPtr())); + EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) + .WillOnce(Return(ApplicationSharedPtr())); + + EXPECT_CALL(app_mngr_, application(kConnectionKey2)) + .WillOnce(Return(mock_app2)); + + ON_CALL(mock_policy_handler_, PolicyEnabled()).WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, GetInitialAppData(kAppId1, _, _)) + .WillByDefault(Return(true)); + policy::StatusNotifier notify_upd_manager = + std::make_shared<utils::CallNothing>(); + ON_CALL(mock_policy_handler_, AddApplication(kMacAddress2, kAppId1, _)) + .WillByDefault(Return(notify_upd_manager)); + + EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app2)); + + EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) + .WillRepeatedly(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs( + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::Buttons_OnButtonSubscription), + _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::VR_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::TTS_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_ChangeRegistration), _)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) + .Times(2); + EXPECT_CALL(app_mngr_, SendDriverDistractionState(_)); + + ASSERT_TRUE(command_->Init()); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc index 38585319e4..98c0ad098a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/reset_global_properties_test.cc @@ -37,17 +37,17 @@ #include "mobile/reset_global_properties_request.h" #include "mobile/reset_global_properties_response.h" -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "interfaces/HMI_API.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "gtest/gtest.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -61,11 +61,11 @@ using ::testing::ReturnRef; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::ResetGlobalPropertiesRequest; -using sdl_rpc_plugin::commands::ResetGlobalPropertiesResponse; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::ResetGlobalPropertiesRequest; +using sdl_rpc_plugin::commands::ResetGlobalPropertiesResponse; typedef std::shared_ptr<ResetGlobalPropertiesRequest> ResetGlobalPropertiesRequestPtr; @@ -237,10 +237,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, Run_SUCCESS) { EXPECT_CALL(*mock_app_, timeout_prompt()) .WillOnce(Return(so_help_prompt.get())); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -275,10 +276,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, smart_objects::SmartType_Map); EXPECT_CALL(mock_message_helper_, CreateAppVrHelp(_)) .WillOnce(Return(vr_help)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); command_->Run(); @@ -321,10 +323,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, (*ui_msg)[am::strings::params][am::strings::correlation_id] = kCorrelationId; (*ui_msg)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::eType::SUCCESS; - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -364,10 +367,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, OnEvent_InvalidApp_NoHashUpdate) { EXPECT_CALL(*mock_app_, reset_vr_help()); EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); smart_objects::SmartObjectSPtr vr_help = std::make_shared<smart_objects::SmartObject>( smart_objects::SmartType_Map); @@ -414,10 +418,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -480,10 +485,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( @@ -545,10 +551,11 @@ TEST_F(ResetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, set_reset_global_properties_active(true)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc index cf25a82972..6b17aa238d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/scrollable_message_test.cc @@ -31,20 +31,20 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/scrollable_message_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -57,10 +57,10 @@ namespace hmi_response = am::hmi_response; namespace mobile_result = mobile_apis::Result; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::ScrollableMessageRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::ScrollableMessageRequest; using ::testing::_; using ::testing::Eq; using ::testing::Ref; @@ -175,7 +175,7 @@ TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_SUCCESS) { mobile_apis::InteractionMode::MANUAL_ONLY; EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); command_->Init(); - EXPECT_EQ(kTimeOut, command_->default_timeout()); + EXPECT_EQ(kTimeOut + kDefaultTimeout_, command_->default_timeout()); } TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) { @@ -183,7 +183,7 @@ TEST_F(ScrollableMessageRequestTest, Init_CorrectTimeout_UNSUCCESS) { mobile_apis::InteractionMode::MANUAL_ONLY; EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); command_->Init(); - EXPECT_EQ(kTimeOut, command_->default_timeout()); + EXPECT_EQ(kDefaultTimeout_, command_->default_timeout()); } TEST_F(ScrollableMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { @@ -282,4 +282,4 @@ TEST_F(ScrollableMessageRequestTest, } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc index 19f799448a..3cb9642021 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_haptic_data_test.cc @@ -32,15 +32,15 @@ #include "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_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" +#include "interfaces/MOBILE_API.h" namespace test { namespace components { @@ -53,9 +53,9 @@ using ::testing::Return; namespace am = ::application_manager; +using am::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SendHapticDataRequest; using sdl_rpc_plugin::commands::SendHapticDataResponse; -using am::commands::MessageSharedPtr; typedef std::shared_ptr<SendHapticDataRequest> SendHapticDataRequestPtr; typedef std::shared_ptr<SendHapticDataResponse> SendHapticDataResponsePtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index 4cab3db2a3..5d90453278 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -32,10 +32,10 @@ #include <stdint.h> #include <string> -#include "gtest/gtest.h" -#include "mobile/send_location_request.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" +#include "mobile/send_location_request.h" #include "application_manager/commands/command_request_test.h" @@ -45,11 +45,11 @@ namespace commands_test { namespace mobile_commands_test { namespace send_location_request { +using application_manager::MockMessageHelper; using application_manager::commands::MessageSharedPtr; using sdl_rpc_plugin::commands::SendLocationRequest; -using application_manager::MockMessageHelper; -using test::components::application_manager_test::MockHMICapabilities; using smart_objects::SmartObject; +using test::components::application_manager_test::MockHMICapabilities; using testing::_; using testing::Return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc index d8d1faca47..116a796312 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_app_icon_test.cc @@ -31,20 +31,20 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/set_app_icon_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" #include "protocol_handler/mock_protocol_handler.h" #include "protocol_handler/mock_protocol_handler_settings.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" namespace test { namespace components { @@ -53,11 +53,11 @@ namespace mobile_commands_test { namespace set_app_icon_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SetAppIconRequest; +using am::MockHmiInterfaces; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; -using am::MockHmiInterfaces; +using sdl_rpc_plugin::commands::SetAppIconRequest; using test::components::protocol_handler_test::MockProtocolHandler; using test::components::protocol_handler_test::MockProtocolHandlerSettings; using ::testing::_; @@ -170,4 +170,4 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc index 10ca925739..cde15a2318 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_display_layout_test.cc @@ -31,19 +31,19 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/set_display_layout_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -53,10 +53,10 @@ namespace set_display_layout_request { namespace am = application_manager; namespace mobile_result = mobile_apis::Result; -using sdl_rpc_plugin::commands::SetDisplayLayoutRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::SetDisplayLayoutRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; @@ -160,6 +160,7 @@ TEST_F(SetDisplayLayoutRequestTest, ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) .WillOnce(DoAll(SaveArg<0>(&ui_command_result), Return(true))); + command->Init(); command->on_event(event); ResultCommandExpectations(ui_command_result, "UI is not supported by system"); @@ -178,6 +179,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_InvalidApp_UNSUCCESS) { MobileResultCodeIs(mobile_result::APPLICATION_NOT_REGISTERED), am::commands::Command::CommandSource::SOURCE_SDL)); + command->Init(); command->Run(); } @@ -188,7 +190,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, display_layout()).WillOnce(ReturnRef(kLayout)); + EXPECT_CALL(*mock_app, display_layout()).WillOnce(Return(kLayout)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -204,20 +206,60 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { ManageHMICommand(CheckMshCorrId(kCorrelationKey), _)) .WillOnce(Return(true)); + command->Init(); command->Run(); } TEST_F(SetDisplayLayoutRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { - CommandPtr command(CreateCommand<SetDisplayLayoutRequest>()); + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg)); + am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM); - SmartObject msg(smart_objects::SmartType_Map); - event.set_smart_object(msg); + event.set_smart_object(*msg); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + command->Init(); + command->on_event(event); +} + +TEST_F(SetDisplayLayoutRequestTest, OnEvent_AppVersion_v6_WARNING) { + 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); + + MessageSharedPtr dispaly_capabilities_msg = CreateMessage(); + (*dispaly_capabilities_msg)[am::hmi_response::templates_available] = + "templates_available"; + + EXPECT_CALL(mock_hmi_capabilities_, display_capabilities()) + .WillOnce(Return(dispaly_capabilities_msg.get())); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::WARNINGS), + am::commands::Command::CommandSource::SOURCE_SDL)); + + CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg)); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ::application_manager::Version app_version; + app_version.max_supported_api_version = + ::application_manager::APIVersion::kAPIV6; + EXPECT_CALL(*mock_app, version()).WillOnce(ReturnRef(app_version)); + command->Init(); command->on_event(event); } -TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { +TEST_F(SetDisplayLayoutRequestTest, OnEvent_AppVersion_v5_SUCCESS) { am::event_engine::Event event(hmi_apis::FunctionID::UI_SetDisplayLayout); MessageSharedPtr msg = CreateMessage(); @@ -239,6 +281,15 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { am::commands::Command::CommandSource::SOURCE_SDL)); CommandPtr command(CreateCommand<SetDisplayLayoutRequest>(msg)); + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + ::application_manager::Version app_version; + app_version.max_supported_api_version = + ::application_manager::APIVersion::kAPIV5; + EXPECT_CALL(*mock_app, version()).WillOnce(ReturnRef(app_version)); + + command->Init(); command->on_event(event); } @@ -246,4 +297,4 @@ TEST_F(SetDisplayLayoutRequestTest, OnEvent_SUCCESS) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index 94dbbc8b44..9b72d41f7e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -32,19 +32,20 @@ #include <stdint.h> #include <memory> -#include <string> #include <set> +#include <string> #include "mobile/set_global_properties_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/message_helper.h" #include "application_manager/mock_application.h" -#include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -53,15 +54,15 @@ namespace mobile_commands_test { namespace set_global_properties_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SetGlobalPropertiesRequest; +using am::CommandsMap; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; -using am::CommandsMap; -using utils::custom_string::CustomString; +using sdl_rpc_plugin::commands::SetGlobalPropertiesRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; +using utils::custom_string::CustomString; namespace { const int32_t kCommandId = 1; @@ -70,6 +71,13 @@ const uint32_t kCmdId = 1u; const uint32_t kConnectionKey = 1u; const std::string kText = "one"; const uint32_t kPosition = 1u; + +const std::vector<hmi_apis::Common_Result::eType> success_result_codes{ + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED}; } // namespace class SetGlobalPropertiesRequestTest @@ -233,9 +241,16 @@ class SetGlobalPropertiesRequestTest ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app_)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); - ON_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + ON_CALL(mock_app_manager_, hmi_interfaces()) + .WillByDefault(ReturnRef(mock_hmi_interfaces_)); + ON_CALL(mock_message_helper_, + MobileToHMIResult(mobile_apis::Result::UNSUPPORTED_RESOURCE)) + .WillByDefault(Return(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + ON_CALL(mock_message_helper_, + MobileToHMIResult(mobile_apis::Result::WARNINGS)) + .WillByDefault(Return(hmi_apis::Common_Result::WARNINGS)); } void ResultCommandExpectations(MessageSharedPtr msg, @@ -243,8 +258,8 @@ class SetGlobalPropertiesRequestTest EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::success].asBool(), true); EXPECT_EQ( - (*msg)[am::strings::msg_params][am::strings::result_code].asInt(), - static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE)); + static_cast<int32_t>(hmi_apis::Common_Result::UNSUPPORTED_RESOURCE), + (*msg)[am::strings::msg_params][am::strings::result_code].asInt()); EXPECT_EQ((*msg)[am::strings::msg_params][am::strings::info].asString(), info); } @@ -265,10 +280,128 @@ class SetGlobalPropertiesRequestTest GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_TTS)) .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); } + + // Checks total result code for each properties + void PrepareResultCodeForResponse_CheckTotalCode( + const hmi_apis::Common_Result::eType& ui_result, + const hmi_apis::Common_Result::eType& tts_result, + const hmi_apis::Common_Result::eType& rc_result, + const mobile_apis::Result::eType expected_total_result_code) { + using namespace application_manager; + using namespace hmi_apis; + + commands::ResponseInfo ui_properties_info( + ui_result, HmiInterfaces::HMI_INTERFACE_UI, mock_app_manager_); + commands::ResponseInfo tts_properties_info( + tts_result, HmiInterfaces::HMI_INTERFACE_TTS, mock_app_manager_); + commands::ResponseInfo rc_properties_info( + rc_result, HmiInterfaces::HMI_INTERFACE_RC, mock_app_manager_); + + MessageSharedPtr msg = CreateMsgParams(); + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + auto result = command->PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + EXPECT_EQ(expected_total_result_code, result); + } + + // Sets in rotation for each result UNSUPPROTED result code and checks total + // result code + void PrepareResultCodeForResponse_CheckAllResultsForSpecifiedTotalResult( + mobile_apis::Result::eType expected_total_result_code) { + using namespace application_manager; + using namespace hmi_apis; + + Common_Result::eType ui_result = + MessageHelper::MobileToHMIResult(expected_total_result_code); + Common_Result::eType tts_result = Common_Result::SUCCESS; + Common_Result::eType rc_result = Common_Result::SUCCESS; + + PrepareResultCodeForResponse_CheckTotalCode( + ui_result, tts_result, rc_result, expected_total_result_code); + + ui_result = Common_Result::SUCCESS; + tts_result = MessageHelper::MobileToHMIResult(expected_total_result_code); + + PrepareResultCodeForResponse_CheckTotalCode( + ui_result, tts_result, rc_result, expected_total_result_code); + + tts_result = Common_Result::SUCCESS; + rc_result = MessageHelper::MobileToHMIResult(expected_total_result_code); + + PrepareResultCodeForResponse_CheckTotalCode( + ui_result, tts_result, rc_result, expected_total_result_code); + } + + void PrepareResultForMobileResponse_CheckTotalReault( + const hmi_apis::Common_Result::eType& ui_result, + const hmi_apis::Common_Result::eType& tts_result, + const hmi_apis::Common_Result::eType& rc_result, + const bool expected_total_result) { + using namespace application_manager; + using namespace hmi_apis; + + commands::ResponseInfo ui_properties_info( + ui_result, HmiInterfaces::HMI_INTERFACE_UI, mock_app_manager_); + commands::ResponseInfo tts_properties_info( + tts_result, HmiInterfaces::HMI_INTERFACE_TTS, mock_app_manager_); + commands::ResponseInfo rc_properties_info( + rc_result, HmiInterfaces::HMI_INTERFACE_RC, mock_app_manager_); + + MessageSharedPtr msg = CreateMsgParams(); + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + bool result = command->PrepareResultForMobileResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + EXPECT_EQ(expected_total_result, result); + } + + void PrepareResultForMobileResponse_CheckResultsForAllCases() { + using namespace application_manager; + using namespace hmi_apis; + + Common_Result::eType ui_result = Common_Result::SUCCESS; + Common_Result::eType tts_result = Common_Result::SUCCESS; + Common_Result::eType rc_result = Common_Result::SUCCESS; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, true); + + // Result code isn't success + EXPECT_FALSE(helpers::in_range(success_result_codes, + Common_Result::UNSUPPORTED_REQUEST)); + + ui_result = Common_Result::UNSUPPORTED_REQUEST; + tts_result = Common_Result::SUCCESS; + rc_result = Common_Result::SUCCESS; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, false); + + ui_result = Common_Result::SUCCESS; + tts_result = Common_Result::UNSUPPORTED_REQUEST; + rc_result = Common_Result::SUCCESS; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, false); + + ui_result = Common_Result::SUCCESS; + tts_result = Common_Result::SUCCESS; + rc_result = Common_Result::UNSUPPORTED_REQUEST; + + PrepareResultForMobileResponse_CheckTotalReault( + ui_result, tts_result, rc_result, false); + } + std::shared_ptr<sync_primitives::Lock> lock_ptr_; MockAppPtr mock_app_; std::shared_ptr<application_manager_test::MockHelpPromptManager> mock_help_prompt_manager_; + NiceMock<MockApplicationManager> mock_app_manager_; }; TEST_F(SetGlobalPropertiesRequestTest, @@ -314,22 +447,25 @@ TEST_F(SetGlobalPropertiesRequestTest, EXPECT_CALL(*mock_app_, help_prompt_manager()) .WillRepeatedly(ReturnRef(*mock_help_prompt_manager_.get())); EXPECT_CALL(*mock_help_prompt_manager_, - OnSetGlobalPropertiesReceived(_, false)).Times(2); + OnSetGlobalPropertiesReceived(_, false)) + .Times(2); EXPECT_CALL( mock_message_helper_, VerifyTtsFiles( (*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand( - HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), - _)).WillOnce(Return(true)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand( + HMIResultCodeIs(hmi_apis::FunctionID::UI_SetGlobalProperties), _)) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageHMICommand( HMIResultCodeIs(hmi_apis::FunctionID::TTS_SetGlobalProperties), _)) .WillOnce(Return(true)); + (*msg_vr)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::SUCCESS; Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties); @@ -414,7 +550,8 @@ TEST_F(SetGlobalPropertiesRequestTest, command->Run(); EXPECT_CALL(*mock_help_prompt_manager_, - OnSetGlobalPropertiesReceived(_, true)).Times(2); + OnSetGlobalPropertiesReceived(_, true)) + .Times(2); command->on_event(event_ui); command->on_event(event_tts); @@ -1369,6 +1506,51 @@ TEST_F(SetGlobalPropertiesRequestTest, static_cast<int32_t>(hmi_apis::Common_Result::WARNINGS)); } +TEST_F(SetGlobalPropertiesRequestTest, + PrepareResultCodeForResponse_AllResultsAreSUCCESS_TotalResultSUCCESS) { + using namespace application_manager; + using namespace hmi_apis; + const auto expected_total_result = mobile_apis::Result::eType::SUCCESS; + + Common_Result::eType ui_result = Common_Result::SUCCESS; + Common_Result::eType tts_result = Common_Result::SUCCESS; + Common_Result::eType rc_result = Common_Result::SUCCESS; + + app_mngr::commands::ResponseInfo ui_properties_info( + ui_result, HmiInterfaces::HMI_INTERFACE_UI, mock_app_manager_); + + app_mngr::commands::ResponseInfo tts_properties_info( + tts_result, HmiInterfaces::HMI_INTERFACE_TTS, mock_app_manager_); + + app_mngr::commands::ResponseInfo rc_properties_info( + rc_result, HmiInterfaces::HMI_INTERFACE_RC, mock_app_manager_); + + MessageSharedPtr msg = CreateMsgParams(); + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + auto result = command->PrepareResultCodeForResponse( + ui_properties_info, tts_properties_info, rc_properties_info); + + EXPECT_EQ(expected_total_result, result); +} + +TEST_F(SetGlobalPropertiesRequestTest, + PrepareResultCodeForResponse_UNSUPPORTED) { + PrepareResultCodeForResponse_CheckAllResultsForSpecifiedTotalResult( + mobile_apis::Result::UNSUPPORTED_RESOURCE); +} + +TEST_F(SetGlobalPropertiesRequestTest, PrepareResultCodeForResponse_WARNINGS) { + PrepareResultCodeForResponse_CheckAllResultsForSpecifiedTotalResult( + mobile_apis::Result::WARNINGS); +} + +TEST_F(SetGlobalPropertiesRequestTest, + PrepareResultForMobileResponse_AllCases) { + PrepareResultForMobileResponse_CheckResultsForAllCases(); +} + } // namespace set_global_properties_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc index 04a7da60cf..86d15e76f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_media_clock_timer_test.cc @@ -35,13 +35,13 @@ #include "mobile/set_media_clock_timer_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -50,10 +50,10 @@ namespace mobile_commands_test { namespace set_media_clock_timer_request { namespace am = ::application_manager; -using sdl_rpc_plugin::commands::SetMediaClockRequest; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; using am::event_engine::Event; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::SetMediaClockRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index 4540980b9e..b8cfdd4bfc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -31,20 +31,21 @@ */ #include <stdint.h> +#include <array> #include <memory> -#include <string> #include <set> +#include <string> #include "mobile/show_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -53,10 +54,10 @@ namespace mobile_commands_test { namespace show_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::ShowRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; +using sdl_rpc_plugin::commands::ShowRequest; using test::components::policy_test::MockPolicyHandlerInterface; using ::testing::_; using ::testing::Return; @@ -68,8 +69,28 @@ const uint32_t kAppId = 1u; const uint32_t kCmdId = 1u; const uint32_t kConnectionKey = 2u; const uint32_t kFunctionID = 3u; +const std::string kCurrentTemplatelayout = "current_template_layout"; +const std::string kNewTemplateLayout = "new_template_layout"; +const app_mngr::WindowID kCurrentWindowID = 1; +typedef std::array<int, 3> rgb_color_scheme; +const rgb_color_scheme kCurrentDayColorRGB = {75, 75, 75}; +const rgb_color_scheme kCurrentNightColorRGB = {200, 200, 200}; +const rgb_color_scheme kNewDayColorRGB = {80, 80, 80}; +const rgb_color_scheme kNewNightColorRGB = {222, 222, 222}; +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } // namespace +MATCHER_P2(CheckMessageToMobile, result_code, success, "") { + const bool is_success = + (*arg)[am::strings::msg_params][am::strings::success].asBool() == success; + + const bool is_result_code_correct = + (*arg)[am::strings::msg_params][am::strings::result_code].asInt() == + static_cast<int32_t>(result_code); + return is_success && is_result_code_correct; +} + class ShowRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { public: ShowRequestTest() { @@ -104,6 +125,101 @@ class ShowRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { return msg; } + protected: + void SetUp() OVERRIDE { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + } + + smart_objects::SmartObject CreateColorScheme( + const rgb_color_scheme& rgb_color_scheme) { + using namespace application_manager; + + smart_objects::SmartObject primary_color(smart_objects::SmartType_Map); + smart_objects::SmartObject secondary_color(smart_objects::SmartType_Map); + smart_objects::SmartObject background_color(smart_objects::SmartType_Map); + + primary_color[strings::red] = rgb_color_scheme[0]; + primary_color[strings::green] = rgb_color_scheme[1]; + primary_color[strings::blue] = rgb_color_scheme[2]; + + secondary_color[strings::red] = rgb_color_scheme[0]; + secondary_color[strings::green] = rgb_color_scheme[1]; + secondary_color[strings::blue] = rgb_color_scheme[2]; + + background_color[strings::red] = rgb_color_scheme[0]; + background_color[strings::green] = rgb_color_scheme[1]; + background_color[strings::blue] = rgb_color_scheme[2]; + + smart_objects::SmartObject color_scheme(smart_objects::SmartType_Map); + color_scheme[strings::primary_color] = primary_color; + color_scheme[strings::secondary_color] = secondary_color; + color_scheme[strings::background_color] = background_color; + + return color_scheme; + } + + smart_objects::SmartObject CreateTemplateConfiguration( + const std::string& layout) { + using namespace application_manager; + + smart_objects::SmartObject template_configuration( + smart_objects::SmartType_Map); + + template_configuration[strings::template_layout] = layout; + + template_configuration[strings::day_color_scheme] = + CreateColorScheme(kCurrentDayColorRGB); + + template_configuration[strings::night_color_scheme] = + CreateColorScheme(kCurrentNightColorRGB); + + return template_configuration; + } + + MessageSharedPtr CreateMessageWithTemplateLayout(const std::string& layout) { + auto msg = CreateMsgParams(); + (*msg)[app_mngr::strings::msg_params][app_mngr::strings::window_id] = + kCurrentWindowID; + (*msg)[am::strings::msg_params][am::strings::template_configuration] = + CreateTemplateConfiguration(layout); + + return msg; + } + + std::shared_ptr<ShowRequest> SetupHelperLayout( + const std::string& layout, + const rgb_color_scheme& day_colors, + const rgb_color_scheme& night_colors) { + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Show), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + const auto current_day_color_scheme = CreateColorScheme(day_colors); + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + const auto current_night_color_scheme = CreateColorScheme(night_colors); + ON_CALL(*mock_app_, night_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + + auto msg = CreateMessageWithTemplateLayout(layout); + + auto command(CreateCommand<ShowRequest>(msg)); + return command; + } + void TestSetupHelper(MessageSharedPtr msg, hmi_apis::Common_TextFieldName::eType field_name, const char* field) { @@ -269,9 +385,9 @@ TEST_F(ShowRequestTest, Run_SoftButtonExists_SUCCESS) { msg_params[am::hmi_request::show_strings] = smart_objects::SmartObject(smart_objects::SmartType_Array); - EXPECT_CALL( - mock_message_helper_, - SubscribeApplicationToSoftButton(creation_msg_params, _, kFunctionID)); + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton( + creation_msg_params, _, kFunctionID, kDefaultWindowId)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)); EXPECT_CALL(*mock_app_, set_show_command(msg_params)); @@ -319,7 +435,8 @@ TEST_F(ShowRequestTest, Run_SoftButtonExists_Canceled) { EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, _)) + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton(_, _, _, kDefaultWindowId)) .Times(0); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); @@ -729,10 +846,14 @@ TEST_F(ShowRequestTest, Run_MainField1_MetadataTagWithNoFieldData) { hmi_apis::Common_Result::SUCCESS; (*ev_msg)[am::strings::msg_params][am::strings::app_id] = kConnectionKey; (*ev_msg)[am::strings::msg_params][am::strings::info] = ""; + (*ev_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; Event event(hmi_apis::FunctionID::UI_Show); event.set_smart_object(*ev_msg); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + MessageSharedPtr ui_command_result; EXPECT_CALL( mock_rpc_service_, @@ -886,34 +1007,328 @@ TEST_F(ShowRequestTest, Run_CustomPresets_WrongSyntax) { command->Run(); } -TEST_F(ShowRequestTest, Run_InvalidApp_Canceled) { +TEST_F(ShowRequestTest, + Run_AppDoesNotExist_ExpectAppNotRegisteredResponseToMobile) { + const auto result_code = mobile_apis::Result::APPLICATION_NOT_REGISTERED; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(nullptr)); + + auto msg = CreateMsgParams(); + auto command = CreateCommand<ShowRequest>(msg); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) { MessageSharedPtr msg = CreateMsgParams(); std::shared_ptr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(MockAppPtr())); + .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + ASSERT_TRUE(command->Init()); command->Run(); } -TEST_F(ShowRequestTest, Run_EmptyParams_Canceled) { - MessageSharedPtr msg = CreateMsgParams(); +TEST_F(ShowRequestTest, + Run_WindowWithIDDoesNotExist_ExpectInvalidIDResponseToMobile) { + const auto result_code = mobile_apis::Result::INVALID_ID; + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(CheckMessageToMobile(result_code, false), + Command::CommandSource::SOURCE_SDL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + ON_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillByDefault(Return(false)); - std::shared_ptr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + auto msg = CreateMsgParams(); + (*msg)[am::strings::msg_params][am::strings::window_id] = kCurrentWindowID; + + auto command = CreateCommand<ShowRequest>(msg); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, + Run_NoLayoutChangeWithoutBothColorScheme_SendRequestToHMI_SUCCESS) { + auto msg = CreateMsgParams(); + (*msg)[app_mngr::strings::msg_params][app_mngr::strings::window_id] = + kCurrentWindowID; + (*msg)[am::strings::msg_params][am::strings::template_configuration] + [am::strings::template_layout] = kCurrentTemplatelayout; + + auto command(CreateCommand<ShowRequest>(msg)); + + auto message_to_hmi = CreateMessage(); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&message_to_hmi), Return(true))); + + ASSERT_TRUE(command->Init()); + command->Run(); + + const auto template_layout = + (*message_to_hmi)[am::strings::msg_params] + [am::strings::template_configuration] + [am::strings::template_layout] + .asString(); + EXPECT_EQ(kCurrentTemplatelayout, template_layout); +} + +TEST_F(ShowRequestTest, + Run_NoLayoutChangeDayColorSchemesNotEqual_Response_REJECTED) { + auto msg = CreateMessageWithTemplateLayout(kCurrentTemplatelayout); + + const auto current_day_color_scheme = CreateColorScheme(kNewDayColorRGB); + + auto command(CreateCommand<ShowRequest>(msg)); + + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + + auto message_to_mobile = CreateMessage(); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + ASSERT_TRUE(command->Init()); + command->Run(); + + const bool success = + (*message_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(); + EXPECT_FALSE(success); + + const auto result_code = static_cast<mobile_apis::Result::eType>( + (*message_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asUInt()); + + EXPECT_EQ(mobile_apis::Result::REJECTED, result_code); +} + +TEST_F(ShowRequestTest, + Run_NoLayoutChangeNightColorSchemesNotEqual_Response_REJECTED) { + auto msg = CreateMessageWithTemplateLayout(kCurrentTemplatelayout); + + const auto current_night_color_scheme = CreateColorScheme(kNewNightColorRGB); + + auto command(CreateCommand<ShowRequest>(msg)); + + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + + auto message_to_mobile = CreateMessage(); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(_, am::commands::Command::CommandSource::SOURCE_SDL)) + .WillOnce(DoAll(SaveArg<0>(&message_to_mobile), Return(true))); + + ASSERT_TRUE(command->Init()); + command->Run(); + + const bool success = + (*message_to_mobile)[am::strings::msg_params][am::strings::success] + .asBool(); + EXPECT_FALSE(success); + const auto result_code = static_cast<mobile_apis::Result::eType>( + (*message_to_mobile)[am::strings::msg_params][am::strings::result_code] + .asUInt()); + + EXPECT_EQ(mobile_apis::Result::REJECTED, result_code); +} + +TEST_F(ShowRequestTest, + Run_LayoutNotChangeBothColorSchemeEqual_SendRequestToHMI_SUCCESS) { + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Show), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillOnce(Return(true)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); - EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); - EXPECT_CALL(*mock_app_, app_id()).Times(0); - EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)).Times(0); - EXPECT_CALL(*mock_app_, set_show_command(_)).Times(0); + const auto current_day_color_scheme = CreateColorScheme(kCurrentDayColorRGB); + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + const auto current_night_color_scheme = + CreateColorScheme(kCurrentNightColorRGB); + ON_CALL(*mock_app_, night_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + + auto msg = CreateMessageWithTemplateLayout(kCurrentTemplatelayout); + + auto command(CreateCommand<ShowRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, + Run_LayoutChangeBothColorSchemeNotEqual_SendRequestToHMI_SUCCESS) { + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_Show), + Command::CommandSource::SOURCE_SDL_TO_HMI)) + .WillOnce(Return(true)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_, WindowIdExists(kCurrentWindowID)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + const auto current_day_color_scheme = CreateColorScheme(kNewDayColorRGB); + ON_CALL(*mock_app_, day_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_day_color_scheme)); + const auto current_night_color_scheme = CreateColorScheme(kNewNightColorRGB); + ON_CALL(*mock_app_, night_color_scheme(kCurrentWindowID)) + .WillByDefault(Return(current_night_color_scheme)); + ON_CALL(*mock_app_, window_layout(kCurrentWindowID)) + .WillByDefault(Return(kCurrentTemplatelayout)); + + auto msg = CreateMessageWithTemplateLayout(kNewTemplateLayout); + + auto command(CreateCommand<ShowRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_ExpectSetWindowLayoutOnly) { + // Precondition + auto command = + SetupHelperLayout(kNewTemplateLayout, kNewDayColorRGB, kNewNightColorRGB); + ASSERT_TRUE(command->Init()); + command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, + set_window_layout(kCurrentWindowID, kNewTemplateLayout)); + EXPECT_CALL(*mock_app_, set_day_color_scheme(_, _)); + EXPECT_CALL(*mock_app_, set_night_color_scheme(_, _)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(ShowRequestTest, + OnEvent_SuccessResultCode_ExpectSetWindowLayoutAndSetDayColorScheme) { + // Precondition + auto command = SetupHelperLayout( + kNewTemplateLayout, kCurrentDayColorRGB, kNewNightColorRGB); + ASSERT_TRUE(command->Init()); + command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, + set_window_layout(kCurrentWindowID, kNewTemplateLayout)); + EXPECT_CALL(*mock_app_, + set_day_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentDayColorRGB))); + EXPECT_CALL(*mock_app_, set_night_color_scheme(_, _)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); +} +TEST_F(ShowRequestTest, + OnEvent_SuccessResultCode_ExpectSetWindowLayoutAndBothColorScheme) { + // Precondition + auto command = SetupHelperLayout( + kNewTemplateLayout, kCurrentDayColorRGB, kCurrentNightColorRGB); + ASSERT_TRUE(command->Init()); command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, + set_window_layout(kCurrentWindowID, kNewTemplateLayout)); + EXPECT_CALL(*mock_app_, + set_day_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentDayColorRGB))); + EXPECT_CALL(*mock_app_, + set_night_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentNightColorRGB))); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); +} + +TEST_F(ShowRequestTest, + OnEvent_SuccessResultCode_ExpectBothColorSchemeWithoutSetWindowLayout) { + // Precondition + auto command = SetupHelperLayout( + kCurrentTemplatelayout, kCurrentDayColorRGB, kCurrentNightColorRGB); + ASSERT_TRUE(command->Init()); + command->Run(); + // Expectation + EXPECT_CALL(*mock_app_, set_window_layout(_, _)).Times(0); + EXPECT_CALL(*mock_app_, + set_day_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentDayColorRGB))); + EXPECT_CALL(*mock_app_, + set_night_color_scheme(kCurrentWindowID, + CreateColorScheme(kCurrentNightColorRGB))); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckMessageToMobile(mobile_apis::Result::SUCCESS, true), + Command::CommandSource::SOURCE_SDL)); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + + auto msg = CreateMessage(); + (*msg)[am::strings::params][am::hmi_response::code] = + hmi_apis::Common_Result::eType::SUCCESS; + (*msg)[am::strings::msg_params] = SmartObject(smart_objects::SmartType_Map); + + Event event(hmi_apis::FunctionID::UI_Show); + event.set_smart_object(*msg); + + command->on_event(event); } TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) { @@ -931,7 +1346,7 @@ TEST_F(ShowRequestTest, OnEvent_SuccessResultCode_SUCCESS) { event.set_smart_object(*msg); EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(mock_app_)); - + ASSERT_TRUE(command->Init()); command->on_event(event); } @@ -957,6 +1372,10 @@ TEST_F(ShowRequestTest, OnEvent_WrongFunctionID_Canceled) { MessageSharedPtr msg = CreateMessage(); (*msg)[am::strings::params][am::hmi_response::code] = mobile_apis::Result::SUCCESS; + (*msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); std::shared_ptr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); @@ -971,4 +1390,4 @@ TEST_F(ShowRequestTest, OnEvent_WrongFunctionID_Canceled) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc index d96a9d7643..6e85aff281 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_notification_commands_test.cc @@ -35,16 +35,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "mobile/on_app_interface_unregistered_notification.h" #include "mobile/on_audio_pass_thru_notification.h" #include "mobile/on_driver_distraction_notification.h" #include "mobile/on_language_change_notification.h" #include "mobile/on_permissions_change_notification.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -56,8 +56,8 @@ namespace am = ::application_manager; namespace commands = sdl_rpc_plugin::commands; using ::testing::_; -using ::testing::Types; using ::testing::Return; +using ::testing::Types; template <class Command> class MobileNotificationCommandsTest diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc index bbd39874e0..0034dcf916 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/simple_response_commands_test.cc @@ -38,37 +38,36 @@ #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application_manager.h" -#include "mobile/delete_command_response.h" +#include "mobile/add_command_response.h" +#include "mobile/add_sub_menu_response.h" #include "mobile/alert_maneuver_response.h" #include "mobile/alert_response.h" -#include "mobile/list_files_response.h" -#include "mobile/subscribe_button_response.h" -#include "mobile/add_sub_menu_response.h" +#include "mobile/change_registration_response.h" +#include "mobile/delete_command_response.h" #include "mobile/dial_number_response.h" #include "mobile/end_audio_pass_thru_response.h" -#include "mobile/unregister_app_interface_response.h" -#include "mobile/unsubscribe_button_response.h" -#include "mobile/unsubscribe_way_points_response.h" -#include "mobile/update_turn_list_response.h" -#include "mobile/slider_response.h" -#include "mobile/speak_response.h" -#include "mobile/subscribe_way_points_response.h" -#include "mobile/system_response.h" +#include "mobile/generic_response.h" #include "mobile/get_way_points_response.h" -#include "mobile/perform_interaction_response.h" +#include "mobile/list_files_response.h" #include "mobile/perform_audio_pass_thru_response.h" +#include "mobile/perform_interaction_response.h" +#include "mobile/scrollable_message_response.h" +#include "mobile/send_location_response.h" +#include "mobile/set_app_icon_response.h" +#include "mobile/set_display_layout_response.h" #include "mobile/set_global_properties_response.h" #include "mobile/set_media_clock_timer_response.h" #include "mobile/show_constant_tbt_response.h" #include "mobile/show_response.h" -#include "mobile/add_command_response.h" -#include "mobile/send_location_response.h" -#include "mobile/set_app_icon_response.h" -#include "mobile/set_display_layout_response.h" -#include "mobile/generic_response.h" -#include "mobile/set_app_icon_response.h" -#include "mobile/scrollable_message_response.h" -#include "mobile/change_registration_response.h" +#include "mobile/slider_response.h" +#include "mobile/speak_response.h" +#include "mobile/subscribe_button_response.h" +#include "mobile/subscribe_way_points_response.h" +#include "mobile/system_response.h" +#include "mobile/unregister_app_interface_response.h" +#include "mobile/unsubscribe_button_response.h" +#include "mobile/unsubscribe_way_points_response.h" +#include "mobile/update_turn_list_response.h" namespace test { namespace components { @@ -120,7 +119,8 @@ typedef Types<commands::ListFilesResponse, commands::SendLocationResponse, commands::SetAppIconResponse, commands::SetDisplayLayoutResponse, - commands::ChangeRegistrationResponse> ResponseCommandsList; + commands::ChangeRegistrationResponse> + ResponseCommandsList; TYPED_TEST_CASE(MobileResponseCommandsTest, ResponseCommandsList); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc index 14e670a387..0450f06ee1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/slider_test.cc @@ -31,19 +31,19 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "mobile/slider_request.h" -#include "gtest/gtest.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "gtest/gtest.h" namespace test { namespace components { @@ -52,11 +52,11 @@ namespace mobile_commands_test { namespace slider_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SliderRequest; +using am::MockMessageHelper; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockMessageHelper; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::SliderRequest; using ::testing::_; using ::testing::Return; using ::testing::ReturnRef; @@ -337,4 +337,4 @@ TEST_F(SliderRequestTest, OnEvent_UISliderAborted_SUCCESS) { } // namespace mobile_commands_test } // namespace commands_test } // namespace components -} // namespace tests +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc index 5dcbd7e6b9..87320d3a7a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/speak_request_test.cc @@ -31,26 +31,26 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "mobile/speak_request.h" #include <string> #include "gtest/gtest.h" -#include "mobile/speak_request.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "utils/helpers.h" -#include "smart_objects/smart_object.h" -#include "utils/custom_string.h" #include "application_manager/application.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" namespace test { namespace components { @@ -62,24 +62,24 @@ namespace am = application_manager; namespace mobile_result = mobile_apis::Result; namespace hmi_response = ::application_manager::hmi_response; namespace strings = ::application_manager::strings; -using am::commands::CommandImpl; using am::ApplicationManager; -using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using am::MockMessageHelper; +using am::commands::CommandImpl; +using am::commands::MessageSharedPtr; using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; using sdl_rpc_plugin::commands::SpeakRequest; using ::test::components::application_manager_test::MockApplication; +using ::testing::Return; +using ::testing::ReturnRef; typedef std::shared_ptr<SpeakRequest> CommandPtr; namespace { const uint32_t kAppId = 10u; const uint32_t kConnectionKey = 5u; -} +} // namespace class SpeakRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { public: @@ -402,5 +402,5 @@ TEST_F(SpeakRequestTest, OnEvent_ApplicationIsNotRegistered_UNSUCCESS) { } // namespace speak_request } // namespace mobile_commands_test } // namespace commands_test -} // namespace component +} // namespace components } // namespace test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index df3e778ee6..786f2b6bd1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -35,16 +35,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "mobile/subscribe_button_request.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/subscribe_button_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -53,13 +53,13 @@ namespace mobile_commands_test { namespace subscribe_button_request { using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::testing::SaveArg; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::SubscribeButtonRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SubscribeButtonRequest; typedef std::shared_ptr<SubscribeButtonRequest> CommandPtr; @@ -106,6 +106,23 @@ TEST_F(SubscribeButtonRequestTest, Run_SubscriptionNotAllowed_UNSUCCESS) { .asInt())); } +TEST_F(SubscribeButtonRequestTest, Run_NavSubscriptionNotAllowed_UNSUCCESS) { + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = + mobile_apis::ButtonName::NAV_CENTER_LOCATION; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, is_navi()).WillByDefault(Return(false)); + + MessageSharedPtr result_msg(CatchMobileCommandResult(CallRun(*command))); + EXPECT_EQ(mobile_apis::Result::REJECTED, + static_cast<mobile_apis::Result::eType>( + (*result_msg)[am::strings::msg_params][am::strings::result_code] + .asInt())); +} + TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) { CommandPtr command(CreateCommand<SubscribeButtonRequest>()); @@ -199,7 +216,55 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { EXPECT_EQ(mobile_apis::Result::SUCCESS, static_cast<mobile_apis::Result::eType>( (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + [am::strings::result_code] + .asInt())); +} + +TEST_F(SubscribeButtonRequestTest, Run_NAV_SUCCESS) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::NAV_CENTER_LOCATION; + + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); + ON_CALL(*app, is_navi()).WillByDefault(Return(true)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + + ON_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillByDefault(Return(button_caps_ptr.get())); + + ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false)); + + MessageSharedPtr hmi_result_msg; + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); + + MessageSharedPtr mobile_result_msg; + EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + static_cast<hmi_apis::FunctionID::eType>( + (*hmi_result_msg)[am::strings::params][am::strings::function_id] + .asInt())); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast<mobile_apis::Result::eType>( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code] + .asInt())); } TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { @@ -252,7 +317,8 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { EXPECT_EQ(mobile_apis::Result::SUCCESS, static_cast<mobile_apis::Result::eType>( (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + [am::strings::result_code] + .asInt())); } } // namespace subscribe_button_request diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc index d08c13b3f3..56e4e05d48 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_way_points_request_test.cc @@ -32,17 +32,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_message_helper.h" -#include "mobile/subscribe_way_points_request.h" -#include "interfaces/MOBILE_API.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/MOBILE_API.h" +#include "mobile/subscribe_way_points_request.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -52,14 +52,14 @@ namespace subscribe_way_points_request { using ::testing::_; using ::testing::A; +using ::testing::DoAll; +using ::testing::InSequence; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::DoAll; using ::testing::SaveArg; -using ::testing::InSequence; namespace am = ::application_manager; -using sdl_rpc_plugin::commands::SubscribeWayPointsRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::SubscribeWayPointsRequest; typedef std::shared_ptr<SubscribeWayPointsRequest> CommandPtr; @@ -90,7 +90,8 @@ TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) { EXPECT_EQ(mobile_apis::Result::SUCCESS, static_cast<mobile_apis::Result::eType>( (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + [am::strings::result_code] + .asInt())); } TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc index 298661dc74..211888d6be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/system_request_test.cc @@ -31,18 +31,18 @@ */ #include <stdint.h> -#include <string> #include <set> +#include <string> #include "gtest/gtest.h" -#include "mobile/system_request.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "mobile/system_request.h" namespace test { namespace components { @@ -51,13 +51,13 @@ namespace mobile_commands_test { namespace system_request { namespace am = application_manager; -using sdl_rpc_plugin::commands::SystemRequest; +using am::MessageType; +using am::MockHmiInterfaces; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; -using am::MockHmiInterfaces; using am::event_engine::Event; -using am::MessageType; using policy_test::MockPolicyHandlerInterface; +using sdl_rpc_plugin::commands::SystemRequest; using ::testing::_; using ::testing::DoAll; @@ -74,6 +74,7 @@ const std::string kAppStorageFolder = "fake-storage"; const std::string kSystemFilesPath = "/fake/system/files"; const std::string kFileName = "Filename"; const uint32_t kHmiAppId = 3u; +const connection_handler::DeviceHandle kDeviceId = 1u; } // namespace class SystemRequestTest @@ -99,13 +100,15 @@ class SystemRequestTest ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId)); ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName)); ON_CALL(*mock_app_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); + ON_CALL(*mock_app_, device()).WillByDefault(Return(kDeviceId)); ON_CALL(app_mngr_settings_, system_files_path()) .WillByDefault(ReturnRef(kSystemFilesPath)); ON_CALL(app_mngr_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); - ON_CALL(mock_policy_handler_, IsRequestTypeAllowed(kAppPolicyId, _)) + ON_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kDeviceId, kAppPolicyId, _)) .WillByDefault(Return(true)); } @@ -146,9 +149,10 @@ TEST_F(SystemRequestTest, PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, @@ -191,9 +195,10 @@ TEST_F( PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(true)); EXPECT_CALL(mock_policy_handler_, @@ -216,9 +221,10 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { PreConditions(); - EXPECT_CALL(mock_policy_handler_, - IsRequestTypeAllowed(kAppPolicyId, - mobile_apis::RequestType::OEM_SPECIFIC)) + EXPECT_CALL( + mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::OEM_SPECIFIC)) .WillOnce(Return(false)); ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); @@ -229,6 +235,37 @@ TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { command->Run(); } +TEST_F(SystemRequestTest, Run_RequestType_IconURL_Success) { + PreConditions(); + MessageSharedPtr msg = CreateIVSUMessage(); + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::ICON_URL; + + const std::string url = "https://www.appsfakeiconurlendpoint.com/icon.png"; + + (*msg)[am::strings::msg_params][am::strings::file_name] = url; + const std::vector<uint8_t> binary_data = {1u, 2u}; + (*msg)[am::strings::params][am::strings::binary_data] = binary_data; + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed( + kDeviceId, kAppPolicyId, mobile_apis::RequestType::ICON_URL)) + .WillOnce(Return(true)); + EXPECT_CALL(app_mngr_settings_, app_icons_folder()) + .WillOnce(ReturnRef(kAppStorageFolder)); + EXPECT_CALL(app_mngr_, PolicyIDByIconUrl(url)).WillOnce(Return(kAppPolicyId)); + + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data, kAppStorageFolder, kAppPolicyId, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(app_mngr_, SetIconFileFromSystemRequest(kAppPolicyId)).Times(1); + + std::shared_ptr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace system_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc index 771374348b..f244acb8d6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unregister_app_interface_request_test.cc @@ -51,8 +51,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; -using sdl_rpc_plugin::commands::UnregisterAppInterfaceRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UnregisterAppInterfaceRequest; typedef std::shared_ptr<UnregisterAppInterfaceRequest> CommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc index 22893b771c..98d20dbbc4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -5,8 +5,8 @@ #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/mock_message_helper.h" #include "mobile/unsubscribe_button_request.h" namespace test { @@ -20,8 +20,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; -using sdl_rpc_plugin::commands::UnsubscribeButtonRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UnsubscribeButtonRequest; typedef std::shared_ptr<UnsubscribeButtonRequest> CommandPtr; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc index 05e15a78af..3165d57d44 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -34,18 +34,18 @@ #include <string> #include "gtest/gtest.h" -#include "mobile/unsubscribe_way_points_request.h" #include "interfaces/MOBILE_API.h" +#include "mobile/unsubscribe_way_points_request.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/event_engine/event.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -59,8 +59,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; using ::testing::Return; -using sdl_rpc_plugin::commands::UnsubscribeWayPointsRequest; using am::commands::MessageSharedPtr; +using sdl_rpc_plugin::commands::UnsubscribeWayPointsRequest; namespace { const uint32_t kConnectionKey = 3u; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index 78fca8681a..44628a8e89 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -34,20 +34,20 @@ #include <string> #include "gtest/gtest.h" -#include "mobile/update_turn_list_request.h" #include "interfaces/MOBILE_API.h" +#include "mobile/update_turn_list_request.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/event_engine/event.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -59,14 +59,14 @@ namespace am = ::application_manager; namespace mobile_result = mobile_apis::Result; using ::testing::_; +using ::testing::Eq; +using ::testing::Ref; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::Ref; -using ::testing::Eq; -using sdl_rpc_plugin::commands::UpdateTurnListRequest; using am::commands::MessageSharedPtr; using application_manager_test::MockHMICapabilities; +using sdl_rpc_plugin::commands::UpdateTurnListRequest; namespace { const uint32_t kConnectionKey = 3u; @@ -208,7 +208,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] [am::strings::turn_icon], Eq(mock_app), - Ref(app_mngr_))).WillOnce(Return(mobile_result::SUCCESS)); + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); @@ -223,8 +224,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { .keyExists(am::hmi_request::navi_text)); EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] - [am::hmi_request::navi_text].keyExists( - am::hmi_request::field_name)); + [am::hmi_request::navi_text] + .keyExists(am::hmi_request::field_name)); EXPECT_EQ( hmi_apis::Common_TextFieldName::turnText, (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] @@ -232,8 +233,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { .asInt()); EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] - [am::hmi_request::navi_text].keyExists( - am::hmi_request::field_text)); + [am::hmi_request::navi_text] + .keyExists(am::hmi_request::field_text)); EXPECT_EQ( kNavigationText, (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] @@ -268,7 +269,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] [am::strings::turn_icon], Eq(mock_app), - Ref(app_mngr_))).WillOnce(Return(mobile_result::WARNINGS)); + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::WARNINGS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton(_, _, kFunctionId)); @@ -283,8 +285,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { .keyExists(am::hmi_request::navi_text)); EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] - [am::hmi_request::navi_text].keyExists( - am::hmi_request::field_name)); + [am::hmi_request::navi_text] + .keyExists(am::hmi_request::field_name)); EXPECT_EQ( hmi_apis::Common_TextFieldName::turnText, (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] @@ -292,8 +294,8 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { .asInt()); EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] - [am::hmi_request::navi_text].keyExists( - am::hmi_request::field_text)); + [am::hmi_request::navi_text] + .keyExists(am::hmi_request::field_text)); EXPECT_EQ( kNavigationText, (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt index 0e556a6993..8c29cccfff 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt @@ -45,18 +45,25 @@ collect_sources(VEHICLE_INFO_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES HMI_API MOBILE_API + MessageHelper ApplicationManager v4_protocol_v1_2_no_extra SmartObjects Utils + jsoncpp + connectionHandler ) if(ENABLE_LOG) list(APPEND LIBRARIES log4cxx -L${LOG4CXX_LIBS_DIRECTORY}) endif() -add_library("vehicle_info_plugin" SHARED ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${VEHICLE_INFO_PLUGIN_SOURCES}) -target_link_libraries("vehicle_info_plugin" ${LIBRARIES}) +add_library("vehicle_info_plugin_static" ${MOBILE_COMMANDS} ${HMI_COMMANDS} ${VEHICLE_INFO_PLUGIN_SOURCES}) +target_link_libraries("vehicle_info_plugin_static" ${LIBRARIES}) + +add_library(vehicle_info_plugin SHARED "src/vehicle_info_plugin.cc" ) +target_link_libraries(vehicle_info_plugin vehicle_info_plugin_static) + set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h index 1fb9c0a008..be2f123f4a 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/on_vi_vehicle_data_notification.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VEHICLE_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VEHICLE_DATA_NOTIFICATION_H_ -#include "application_manager/commands/notification_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/notification_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -55,10 +56,7 @@ class OnVIVehicleDataNotification **/ OnVIVehicleDataNotification( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief OnVIVehicleDataNotification class destructor @@ -76,6 +74,6 @@ class OnVIVehicleDataNotification } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_ON_VI_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h index 0b0a9ef99e..6ae6d1f7f6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIDiagnosticMessageRequest : public app_mngr::commands::RequestToHMI { **/ VIDiagnosticMessageRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIDiagnosticMessageRequest class destructor @@ -73,6 +71,6 @@ class VIDiagnosticMessageRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h index 31fc73897e..9b172b9e74 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_diagnostic_message_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIDiagnosticMessageResponse : public app_mngr::commands::ResponseFromHMI { **/ VIDiagnosticMessageResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIDiagnosticMessageResponse class destructor @@ -73,6 +71,6 @@ class VIDiagnosticMessageResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_DIAGNOSTIC_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h index 67308a3898..c77464835b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIGetDTCsRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIGetDTCsRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIGetDTCsRequest class destructor @@ -72,6 +70,6 @@ class VIGetDTCsRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h index 0ddf225c93..f1ddcbe373 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIGetDTCsResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIGetDTCsResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIGetDTCsResponse class destructor @@ -72,6 +70,6 @@ class VIGetDTCsResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_DTCS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h index 1b4669cf24..bce49f8201 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +53,7 @@ class VIGetVehicleDataRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIGetVehicleDataRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleDataRequest class destructor @@ -67,11 +66,13 @@ class VIGetVehicleDataRequest : public app_mngr::commands::RequestToHMI { virtual void Run(); private: + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(VIGetVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h index df5e630aea..7504168aec 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_H_ -#include "application_manager/commands/response_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIGetVehicleDataResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIGetVehicleDataResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleDataResponse class destructor @@ -73,6 +71,6 @@ class VIGetVehicleDataResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h index 79a5270f8d..7f2e8389ad 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIGetVehicleTypeRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIGetVehicleTypeRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleTypeRequest class destructor @@ -72,6 +70,6 @@ class VIGetVehicleTypeRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h index baa4a936ae..f71eda8077 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -50,12 +51,8 @@ class VIGetVehicleTypeResponse : public app_mngr::commands::ResponseFromHMI { * * @param message Incoming SmartObject message **/ - VIGetVehicleTypeResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - application_manager::rpc_service::RPCService& rpc_service, - application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + VIGetVehicleTypeResponse(const app_mngr::commands::MessageSharedPtr& message, + const VehicleInfoCommandParams& params); /** * @brief VIGetVehicleTypeResponse class destructor @@ -73,6 +70,6 @@ class VIGetVehicleTypeResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_GET_VEHICLE_TYPE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h index 3f12a30c8d..fa9bfebad4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIIsReadyRequest : public app_mngr::commands::RequestToHMI, * @param message Incoming SmartObject message **/ VIIsReadyRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIIsReadyRequest class destructor @@ -88,6 +86,6 @@ class VIIsReadyRequest : public app_mngr::commands::RequestToHMI, } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h index 3531aa03c4..f87d9370f5 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_is_ready_response.h @@ -33,8 +33,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_RESPONSE_H_ -#include "application_manager/commands/response_from_hmi.h" #include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +53,7 @@ class VIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIIsReadyResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIIsReadyResponse class destructor @@ -73,6 +71,6 @@ class VIIsReadyResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_IS_READY_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h index 2d10bbf11d..63bbf10e41 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_request.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIReadDIDRequest : public app_mngr::commands::RequestToHMI { * @param message Incoming SmartObject message **/ VIReadDIDRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIReadDIDRequest class destructor @@ -72,6 +70,6 @@ class VIReadDIDRequest : public app_mngr::commands::RequestToHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h index 5ac655b499..307960e145 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_read_did_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -51,10 +52,7 @@ class VIReadDIDResponse : public app_mngr::commands::ResponseFromHMI { * @param message Incoming SmartObject message **/ VIReadDIDResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIReadDIDResponse class destructor @@ -72,6 +70,6 @@ class VIReadDIDResponse : public app_mngr::commands::ResponseFromHMI { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_READ_DID_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h index bd22a313e7..0e91006e52 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -52,10 +54,7 @@ class VISubscribeVehicleDataRequest : public app_mngr::commands::RequestToHMI { **/ VISubscribeVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VISubscribeVehicleDataRequest class destructor @@ -68,11 +67,13 @@ class VISubscribeVehicleDataRequest : public app_mngr::commands::RequestToHMI { virtual void Run(); private: + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(VISubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h index 1148a8b41a..523867d87e 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class VISubscribeVehicleDataResponse **/ VISubscribeVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VISubscribeVehicleDataResponse class destructor @@ -74,6 +72,6 @@ class VISubscribeVehicleDataResponse } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h index 3b39835fbf..4e3cc59c2e 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +55,7 @@ class VIUnsubscribeVehicleDataRequest **/ VIUnsubscribeVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIUnsubscribeVehicleDataRequest class destructor @@ -69,11 +68,13 @@ class VIUnsubscribeVehicleDataRequest virtual void Run(); private: + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(VIUnsubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h index ada6896520..e8f2267ce6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class VIUnsubscribeVehicleDataResponse **/ VIUnsubscribeVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + const VehicleInfoCommandParams& params); /** * @brief VIUnsubscribeVehicleDataResponse class destructor @@ -74,6 +72,6 @@ class VIUnsubscribeVehicleDataResponse } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_VI_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h index e2bc7c4dfd..56f0e39621 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_request.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ DiagnosticMessageRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief DiagnosticMessageRequest class destructor @@ -80,6 +78,6 @@ class DiagnosticMessageRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h index d69a6a0155..5308551f5a 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/diagnostic_message_response.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -54,10 +55,7 @@ class DiagnosticMessageResponse * @param message Incoming SmartObject message **/ DiagnosticMessageResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief DiagnosticMessageResponse class destructor @@ -74,6 +72,6 @@ class DiagnosticMessageResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_DIAGNOSTIC_MESSAGE_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h index 01f007697d..562d7f236b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_request.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ GetDTCsRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief GetDTCsRequest class destructor @@ -80,6 +78,6 @@ class GetDTCsRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h index 87024b1860..52836e895f 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_dtcs_response.h @@ -36,6 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +54,7 @@ class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl { * @param message Incoming SmartObject message **/ GetDTCsResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief GetDTCsResponse class destructor @@ -73,6 +71,6 @@ class GetDTCsResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_DTCS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h index 04a131da8f..8a594b0647 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h @@ -36,12 +36,11 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; -class SmartObject; - namespace commands { /** @@ -55,10 +54,7 @@ class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ GetVehicleDataRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief GetVehicleDataRequest class destructor @@ -73,10 +69,22 @@ class GetVehicleDataRequest : public app_mngr::commands::CommandRequestImpl { protected: virtual void on_event(const app_mngr::event_engine::Event& event); + private: + /** + * @brief CheckFrequency check if mobile does not spam SDL with frequent + * GetVehicleData requests + * @return + */ + bool CheckFrequency(application_manager::Application& app); + + std::set<std::string> pending_vehicle_data_; + + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(GetVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h index 22ec1a5a78..8d9722b2b6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/get_vehicle_data_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +53,7 @@ class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl { * @param message Incoming SmartObject message **/ GetVehicleDataResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief GetVehicleDataResponse class destructor @@ -73,6 +70,6 @@ class GetVehicleDataResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_GET_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h index 57c30164e4..9163e78b5e 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h @@ -34,9 +34,11 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -56,10 +58,7 @@ class OnVehicleDataNotification * @param message Incoming SmartObject message **/ OnVehicleDataNotification(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief OnVehicleDataNotification class destructor @@ -79,10 +78,12 @@ class OnVehicleDataNotification */ void SendVehicleData(app_mngr::ApplicationConstSharedPtr app); + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(OnVehicleDataNotification); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h index 9a8fbbd62e..8566075504 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_request.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +53,7 @@ class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl { * @param message Incoming SmartObject message **/ ReadDIDRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief ReadDIDRequest class destructor @@ -80,6 +77,6 @@ class ReadDIDRequest : public app_mngr::commands::CommandRequestImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h index 2b7ab04768..30e5aa45de 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/read_did_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -53,10 +53,7 @@ class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl { * @param message Incoming SmartObject message **/ ReadDIDResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief ReadDIDResponse class destructor @@ -73,6 +70,6 @@ class ReadDIDResponse : public app_mngr::commands::CommandResponseImpl { }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_READ_DID_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h index 7c6e1754da..deac8a8295 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h @@ -37,10 +37,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -60,10 +62,7 @@ class SubscribeVehicleDataRequest **/ SubscribeVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + VehicleInfoCommandParams params); /** * @brief SubscribeButtonCommandRequest class destructor @@ -94,7 +93,7 @@ class SubscribeVehicleDataRequest * @return true, if there are registered apps subscribed for VI parameter, * otherwise - false */ - bool IsSomeoneSubscribedFor(const uint32_t param_id) const; + bool IsSomeoneSubscribedFor(const std::string& param_name) const; /** * @brief Adds VI parameters being subscribed by another or the same app to @@ -104,14 +103,14 @@ class SubscribeVehicleDataRequest void AddAlreadySubscribedVI(smart_objects::SmartObject& msg_params) const; /** - * @brief Removes subscription for VI parameters which subsription attempt - * returned an error + * @brief Actual subscription to pending vehicle data after successful + * response from HMI * @param app Pointer to application sent subscribe request * @param msg_params 'message_parameters' response section reference */ - void UnsubscribeFailedSubscriptions( + bool SubscribePendingVehicleData( app_mngr::ApplicationSharedPtr app, - const smart_objects::SmartObject& msg_params) const; + const smart_objects::SmartObject& msg_params); /** * @brief Checks if current application and other applications @@ -134,6 +133,43 @@ class SubscribeVehicleDataRequest bool& out_result); /** + * @brief ConvertResponseToRequestName convert RPCSpec vehicle data names + * from response naming to request naming. + * This is workaround for cluster mode. + * Parameter named in request message as `cluster_mode` and in response + * message as `cluster_mode_status` + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertResponseToRequestName(const std::string& name); + + /** + * @brief ConvertRequestToResponseName convert RPCSpec vehicle data names from + * request to response + * * This is workaround for cluster mode. + * Parameter named in request message as `cluster_mode` and in response + * message as `cluster_mode_status` + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertRequestToResponseName(const std::string& name); + + /** + * @brief Appends data types for vehicle data in response to mobile + * @param msg_params 'message_parameters' response section reference + */ + void AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const; + + /** + * @brief Checks subscription status of certain vehicle_item + * @param vi_name name of vehicle item to be checked + * @param msg_params 'message_parameters' response section reference + */ + bool CheckSubscriptionStatus(std::string vi_name, + const smart_objects::SmartObject& msg_params); + + /** * @brief VI parameters which had been already subscribed by another apps * befor particular app subscribed for these parameters */ @@ -149,10 +185,12 @@ class SubscribeVehicleDataRequest */ VehicleInfoSubscriptions vi_waiting_for_subscribe_; + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(SubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h index 60670afee1..39af8b019b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -55,10 +55,7 @@ class SubscribeVehicleDataResponse **/ SubscribeVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief UnsubscribeVehicleDataCommandRequest class destructor @@ -75,6 +72,6 @@ class SubscribeVehicleDataResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h index e04d1fb97a..4f2a01244f 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_request.h @@ -34,10 +34,12 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -57,10 +59,7 @@ class UnsubscribeVehicleDataRequest **/ UnsubscribeVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief UnsubscribeVehicleDataRequest class destructor @@ -91,7 +90,7 @@ class UnsubscribeVehicleDataRequest * @return true, if there are registered apps subscribed for VI parameter, * otherwise - false */ - bool IsSomeoneSubscribedFor(const uint32_t param_id) const; + bool IsSomeoneSubscribedFor(const std::string& param_name) const; /** * @brief Adds VI parameters being unsubscribed by another or the same app to @@ -101,20 +100,71 @@ class UnsubscribeVehicleDataRequest void AddAlreadyUnsubscribedVI(smart_objects::SmartObject& response) const; /** + * @brief Actual unsubscription from all pending vehicle data. To be called + * after successful HMI response + * @param app shared pointer to application, which initialized unsubscription + * @param msg_params 'message_params' response section reference + */ + bool UnsubscribePendingVehicleData( + app_mngr::ApplicationSharedPtr app, + const smart_objects::SmartObject& msg_params); + + /** + * @brief ConvertRequestToResponseName convert RPCSpec vehicle data names + * from hmi api to mobile api + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertRequestToResponseName(const std::string& name); + + /** + * @brief ConvertResponseToRequestName convert RPCSpec vehicle data names + * from hmi api to mobile api + * @param name mobile RPCSpec vehicle data name + * @return hmi RPCSpec vehicle data name + */ + const std::string& ConvertResponseToRequestName(const std::string& name); + + /** + * @brief Appends data types for vehicle data in response to mobile + * @param msg_params 'message_parameters' response section reference + */ + void AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const; + + /** + * @brief Checks subscription status of certain vehicle_item + * @param key name of vehicle item to be checked + * @param msg_params 'message_parameters' response section reference + */ + bool CheckSubscriptionStatus(std::string key, + const smart_objects::SmartObject& msg_params); + + smart_objects::SmartObject response_params_; + + /** * @brief VI parameters which still being subscribed by another apps after * particular app had been unsubscribed from these parameters */ VehicleInfoSubscriptions vi_still_subscribed_by_another_apps_; /** - * @brief VI parameters which had been unsubscribed already by particular app + * @brief VI parameters which had been unsubscribed already by particular + * app */ VehicleInfoSubscriptions vi_already_unsubscribed_by_this_app_; + /** + * @brief VI parameters to be unsubscribed after HMI response + */ + VehicleInfoSubscriptions vi_waiting_for_unsubscribe_; + + CustomVehicleDataManager& custom_vehicle_data_manager_; + DISALLOW_COPY_AND_ASSIGN(UnsubscribeVehicleDataRequest); }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h index 397ae3cbce..f181e7f8c3 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/unsubscribe_vehicle_data_response.h @@ -36,7 +36,7 @@ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" - +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -55,10 +55,7 @@ class UnsubscribeVehicleDataResponse **/ UnsubscribeVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + const VehicleInfoCommandParams& params); /** * @brief UnsubscribeVehicleDataResponse class destructor @@ -75,6 +72,6 @@ class UnsubscribeVehicleDataResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h new file mode 100644 index 0000000000..9cac76b954 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager.h @@ -0,0 +1,55 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_ +#include <set> +#include <string> + +#include "application_manager/plugin_manager/rpc_plugin.h" +#include "application_manager/rpc_handler.h" +#include "smart_objects/smart_object.h" + +namespace vehicle_info_plugin { + +namespace plugin_manager = application_manager::plugin_manager; + +class CustomVehicleDataManager { + public: + /** + * @brief Creates message params (nested if needed) to be sent to HMI + * according to vehicle data item schema + * @param item_names set of names of vehicle data items to be processed + * @return smartMap with prepared message params + */ + virtual smart_objects::SmartObject CreateHMIMessageParams( + const std::set<std::string>& item_names) = 0; + + /** + * @brief Gets data type of vehicle data item + * @param vehicle_data_item_name name of vehicle data + * @return data type of vehicle_data if one found, item name otherwise + */ + virtual std::string GetVehicleDataItemType( + const std::string& vehicle_data_item_name) const = 0; + + /** + * @brief Creates message params (nested if needed) to be sent to Mobile + * according to vehicle data item schema + * @param input_params message params received from hmi + */ + virtual void CreateMobileMessageParams( + smart_objects::SmartObject& msg_params) = 0; + + virtual void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) = 0; + + virtual bool IsValidCustomVehicleDataName(const std::string& name) const = 0; + + /** + * @brief Checks whether custom vehicle data name was removed after the last + * PTU or not + * @param name vehicle item name to check + * @return true if vehicle data with this name was removed after the last PTU + */ + virtual bool IsRemovedCustomVehicleDataName( + const std::string& name) const = 0; +}; +} // namespace vehicle_info_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_CUSTOM_VEHICLE_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h new file mode 100644 index 0000000000..239c4edb90 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/custom_vehicle_data_manager_impl.h @@ -0,0 +1,103 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H + +#include <boost/optional.hpp> + +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" + +namespace rpc { +namespace policy_table_interface_base { +class VehicleDataItem; +} +} // namespace rpc + +namespace policy { +class VehicleDataItemProvider; +} + +namespace vehicle_info_plugin { +namespace policy_table = rpc::policy_table_interface_base; +namespace plugin_manager = application_manager::plugin_manager; + +typedef boost::optional<const policy_table::VehicleDataItem> OptionalDataItem; +typedef std::set<std::string> VehicleInfoSubscriptions; + +class CustomVehicleDataManagerImpl : public CustomVehicleDataManager { + public: + CustomVehicleDataManagerImpl( + policy::VehicleDataItemProvider& vehicle_data_provider, + application_manager::rpc_service::RPCService& rpc_service); + + virtual smart_objects::SmartObject CreateHMIMessageParams( + const std::set<std::string>& item_names) OVERRIDE; + + std::string GetVehicleDataItemType( + const std::string& vehicle_data_item_name) const OVERRIDE; + + virtual void CreateMobileMessageParams( + smart_objects::SmartObject& msg_params) OVERRIDE; + + void OnPolicyEvent(plugin_manager::PolicyEvent policy_event) OVERRIDE; + + bool IsValidCustomVehicleDataName(const std::string& name) const OVERRIDE; + + bool IsRemovedCustomVehicleDataName(const std::string& name) const OVERRIDE; + + private: + class RPCParams { + public: + RPCParams() {} + ~RPCParams() {} + + void addBoolParam( + const std::pair<std::string, smart_objects::SMember>& param) { + rpc_params_bool_.insert(param); + } + void addVDRParam( + const std::pair<std::string, smart_objects::SMember>& param) { + rpc_params_vdr_.insert(param); + } + void addParam(const std::pair<std::string, smart_objects::SMember>& param) { + rpc_params_.insert(param); + } + + const std::map<std::string, smart_objects::SMember>& getBoolParams() { + return rpc_params_bool_; + } + const std::map<std::string, smart_objects::SMember>& getVDRParams() { + return rpc_params_vdr_; + } + const std::map<std::string, smart_objects::SMember>& getParams() { + return rpc_params_; + } + + private: + std::map<std::string, smart_objects::SMember> rpc_params_bool_; + std::map<std::string, smart_objects::SMember> rpc_params_vdr_; + std::map<std::string, smart_objects::SMember> rpc_params_; + }; + + /** + * @brief Updates vehicle data schemas according to policy update. + */ + void UpdateVehicleDataItems(); + + const OptionalDataItem FindSchemaByNameNonRecursive( + const std::string& name) const; + const OptionalDataItem FindRemovedSchemaByNameNonRecursive( + const std::string& name) const; + const OptionalDataItem FindSchemaByKeyNonRecursive( + const std::string& key) const; + const OptionalDataItem FindSchemaByNameRecursive( + const std::string& name) const; + const OptionalDataItem FindSchemaByKeyRecursive( + const std::string& name) const; + + policy::VehicleDataItemProvider& vehicle_data_provider_; + application_manager::rpc_service::RPCService& rpc_service_; +}; + +} // namespace vehicle_info_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_VEHICLE_DATA_VALIDATION_MANAGER_IMPL_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h new file mode 100644 index 0000000000..5ea73e2dec --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_data_item_schema.h @@ -0,0 +1,115 @@ +#ifndef VEHICLE_DATA_ITEM_SCHEMA_H +#define VEHICLE_DATA_ITEM_SCHEMA_H +#include "policy/policy_table/types.h" +#include "smart_objects/always_false_schema_item.h" +#include "smart_objects/always_true_schema_item.h" +#include "smart_objects/array_schema_item.h" +#include "smart_objects/bool_schema_item.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/number_schema_item.h" +#include "smart_objects/object_schema_item.h" +#include "smart_objects/schema_item.h" +#include "smart_objects/schema_item_parameter.h" +#include "smart_objects/smart_object.h" +#include "smart_objects/string_schema_item.h" +#include "utils/logger.h" + +namespace vehicle_info_plugin { +namespace smart_objects = ns_smart_device_link::ns_smart_objects; +namespace policy_table = rpc::policy_table_interface_base; + +class VehicleDataItemSchema; +typedef std::shared_ptr<VehicleDataItemSchema> VehicleDataItemSchemaPtr; +typedef smart_objects::TSchemaItemParameter<policy_table::VehicleDataItem> + PolicyDataItem; + +/** + * @brief VehicleData schema item. + **/ +class VehicleDataItemSchema : public smart_objects::ISchemaItem { + public: + enum SchemaType { MOBILE = 0, HMI }; + + /** + * @brief Create a new schema item. + * @param PolicyDataItem& SchemaItem for VehicleDataItem elements. + * @return Shared pointer to a new schema item. + **/ + static VehicleDataItemSchemaPtr create(PolicyDataItem& policy_item, + SchemaType schema_type); + + /** + * @brief Validate smart object. + * @param Object Object to validate. + * @param report__ object for reporting errors during validation + * @param MessageVersion to check mobile RPC version against RPC Spec History + * @param allow_unknown_enums + * false - unknown enum values (left as string values after applySchema) + * will be considered invalid. + * true - such values will be considered valid. + * @return ns_smart_objects::errors::eType + **/ + smart_objects::errors::eType validate( + const smart_objects::SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion = utils::SemanticVersion(), + const bool allow_unknown_enums = false) OVERRIDE; + + private: + /** + * @brief Constructor. + * @param PolicyDataItem& SchemaItem for VehicleDataItem elements. + * @param SchemaType defines api type for schema to be generated. + **/ + VehicleDataItemSchema(PolicyDataItem& policy_item, SchemaType schema_type); + + /* + * @brief Check whether provided type is POD type + * @param const std::string& type_name - name of type to check + * @return true - if type is POD type and false - if not + */ + const bool isPODType(const std::string& type_name) const; + + /* + * @brief Get Enum schema for provided type + * @param const std::string& type_name - name of enum type to provide + * @return Shared pointer to a new schema item. If no schema found - nullptr + * is returned. + */ + smart_objects::ISchemaItemPtr getEnumSchema( + const std::string& type_name) const; + + /** + * @brief Apply schema. + * @param Object Object to apply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + * parameters from smart object otherwise contains false. + **/ + void applySchema(smart_objects::SmartObject& Object, + const bool remove_unknown_parameters, + const utils::SemanticVersion& MessageVersion) OVERRIDE; + + /** + * @brief Unapply schema. + * @param Object Object to unapply schema. + * @param remove_unknown_parameters contains true if need to remove unknown + * parameters + **/ + void unapplySchema(smart_objects::SmartObject& Object, + const bool remove_unknown_parameters) OVERRIDE; + + /* + * @brief Get schema for a POD type + * @param const VehicleDataItem& policy_item - item, that contains info about + * type + * @return Shared pointer to a new schema item. If no schema found - nullptr + * is returned. + */ + smart_objects::ISchemaItemPtr GetPODTypeSchema( + const policy_table::VehicleDataItem& policy_item, SchemaType schema_type); + + smart_objects::ISchemaItemPtr so_schema_item_; +}; + +} // namespace vehicle_info_plugin +#endif // VEHICLE_DATA_ITEM_SCHEMA_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h index ead6af841f..fb7c2b0f82 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_app_extension.h @@ -47,7 +47,7 @@ typedef mobile_apis::VehicleDataType::eType VehicleDataType; /** * @brief Defines set of vehicle info types */ -typedef std::set<mobile_apis::VehicleDataType::eType> VehicleInfoSubscriptions; +typedef std::set<std::string> VehicleInfoSubscriptions; class VehicleInfoAppExtension : public app_mngr::AppExtension { public: @@ -61,12 +61,12 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { virtual ~VehicleInfoAppExtension(); /** - * @brief subscribeToVehicleInfo add vehicle_data to list of subscriptions of - * application extension - * @param vehicle_data data to subscribe - * @return true in case if subscription is successful - */ - bool subscribeToVehicleInfo(const VehicleDataType vehicle_data); + * @brief subscribeToVehicleInfo add vehicle_data to list of subscriptions of + * application extension + * @param vehicle_data data to subscribe + * @return true in case if subscription is successful + */ + bool subscribeToVehicleInfo(const std::string& vehicle_data); /** * @brief unsubscribeFromVehicleInfo remove vehicle_data from list of @@ -74,7 +74,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { * @param vehicle_data data to unsubscribe * @return true in case if unsubscription is successful */ - bool unsubscribeFromVehicleInfo(const VehicleDataType vehicle_data); + bool unsubscribeFromVehicleInfo(const std::string& vehicle_data); /** * @brief unsubscribeFromVehicleInfo unsubscribe from all vehicle info data */ @@ -87,7 +87,7 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { * @return true if extension is subscribed this vehicle_data_type, otherwise * return false */ - bool isSubscribedToVehicleInfo(const VehicleDataType vehicle_data_type) const; + bool isSubscribedToVehicleInfo(const std::string& vehicle_data_type) const; /** * @brief Subscriptions get list of subscriptions for application extension @@ -130,6 +130,6 @@ class VehicleInfoAppExtension : public app_mngr::AppExtension { VehicleInfoPlugin& plugin_; app_mngr::Application& app_; }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_APP_EXTENSION_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h index e36611dfa6..3356f0f823 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_factory.h @@ -34,37 +34,38 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/vehicle_info_hmi_command_factory.h" #include "vehicle_info_plugin/vehicle_info_mobile_command_factory.h" namespace vehicle_info_plugin { -namespace app_mngr = application_manager; -namespace commands = application_manager::commands; - /** * @brief The Vehicle Info command factory. */ -class VehicleInfoCommandFactory : public app_mngr::CommandFactory { +class VehicleInfoCommandFactory : public application_manager::CommandFactory { public: - VehicleInfoCommandFactory(app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + VehicleInfoCommandFactory( + application_manager::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager); virtual ~VehicleInfoCommandFactory(); - app_mngr::CommandSharedPtr CreateCommand( - const commands::MessageSharedPtr& message, - commands::Command::CommandSource source) OVERRIDE; + application_manager::CommandSharedPtr CreateCommand( + const application_manager::commands::MessageSharedPtr& message, + application_manager::commands::Command::CommandSource source) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, - const commands::Command::CommandSource source) const OVERRIDE; + const application_manager::commands::Command::CommandSource source) + const OVERRIDE; private: - std::unique_ptr<app_mngr::CommandFactory> hmi_command_factory_; - std::unique_ptr<app_mngr::CommandFactory> mob_command_factory_; + std::unique_ptr<application_manager::CommandFactory> hmi_command_factory_; + std::unique_ptr<application_manager::CommandFactory> mob_command_factory_; }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h new file mode 100644 index 0000000000..df8dbfd802 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_command_params.h @@ -0,0 +1,31 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H + +namespace application_manager { +class ApplicationManager; +class HMICapabilities; +namespace rpc_service { +class RPCService; +} +class ApplicationManager; +} // namespace application_manager + +namespace policy { +class PolicyHandlerInterface; +} + +namespace vehicle_info_plugin { +namespace app_mngr = application_manager; + +class CustomVehicleDataManager; + +struct VehicleInfoCommandParams { + app_mngr::ApplicationManager& application_manager_; + app_mngr::rpc_service::RPCService& rpc_service_; + app_mngr::HMICapabilities& hmi_capabilities_; + policy::PolicyHandlerInterface& policy_handler_; + CustomVehicleDataManager& custom_vehicle_data_manager_; +}; +} // namespace vehicle_info_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_COMMAND_PARAMS_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h index 412949eedb..60d81b5446 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_hmi_command_factory.h @@ -34,6 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_HMI_COMMAND_FACTORY_H #include "application_manager/application_manager.h" +#include "application_manager/command_factory.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -47,7 +49,8 @@ class VehicleInfoHmiCommandFactory : public app_mngr::CommandFactory { app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager); app_mngr::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, @@ -62,12 +65,13 @@ class VehicleInfoHmiCommandFactory : public app_mngr::CommandFactory { app_mngr::rpc_service::RPCService& rpc_service_; app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + CustomVehicleDataManager& custom_vehicle_data_manager_; app_mngr::CommandCreator& buildCommandCreator( const int32_t function_id, const int32_t message_type) const; DISALLOW_COPY_AND_ASSIGN(VehicleInfoHmiCommandFactory); }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_HMI_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h index d38ef6fb90..e3403df5e5 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_mobile_command_factory.h @@ -34,7 +34,8 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_MOBILE_COMMAND_FACTORY_H #include "application_manager/application_manager.h" - +#include "application_manager/command_factory.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" namespace vehicle_info_plugin { namespace app_mngr = application_manager; @@ -47,7 +48,8 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory { app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager); app_mngr::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, @@ -62,6 +64,7 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory { app_mngr::rpc_service::RPCService& rpc_service_; app_mngr::HMICapabilities& hmi_capabilities_; policy::PolicyHandlerInterface& policy_handler_; + CustomVehicleDataManager& custom_vehicle_data_manager_; app_mngr::CommandCreator& get_creator_factory( const mobile_apis::FunctionID::eType function_id, @@ -75,6 +78,6 @@ class VehicleInfoMobileCommandFactory : public app_mngr::CommandFactory { DISALLOW_COPY_AND_ASSIGN(VehicleInfoMobileCommandFactory); }; -} +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_MOBILE_COMMAND_FACTORY_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h index b15b7006e6..f0f68af298 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/vehicle_info_plugin.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_PLUGIN_H #include "application_manager/command_factory.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" namespace vehicle_info_plugin { class VehicleInfoAppExtension; @@ -47,7 +48,8 @@ class VehicleInfoPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; bool IsAbleToProcess( const int32_t function_id, @@ -70,13 +72,17 @@ class VehicleInfoPlugin : public plugins::RPCPlugin { VehicleInfoAppExtension& ext); private: + void UnsubscribeFromRemovedVDItems(); + smart_objects::SmartObjectSPtr GetUnsubscribeIVIRequest( + const std::vector<std::string>& ivi_names); void DeleteSubscriptions(app_mngr::ApplicationSharedPtr app); std::unique_ptr<app_mngr::CommandFactory> command_factory_; + std::unique_ptr<CustomVehicleDataManager> custom_vehicle_data_manager_; app_mngr::ApplicationManager* application_manager_; }; -} +} // namespace vehicle_info_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); - +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_VEHICLE_INFO_PLUGIN_H diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc index 6125c4ee45..b8d1b3a100 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/on_vi_vehicle_data_notification.cc @@ -40,15 +40,12 @@ namespace commands { OnVIVehicleDataNotification::OnVIVehicleDataNotification( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : NotificationFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} OnVIVehicleDataNotification::~OnVIVehicleDataNotification() {} @@ -62,9 +59,8 @@ void OnVIVehicleDataNotification::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; if (msg_params.keyExists(strings::odometer)) { - application_manager_.IviInfoUpdated( - mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER, - msg_params[strings::odometer].asInt()); + application_manager_.IviInfoUpdated(strings::odometer, + msg_params[strings::odometer].asInt()); } SendNotificationToMobile(message_); @@ -72,4 +68,4 @@ void OnVIVehicleDataNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc index 8d3b9f13fb..ae64c74f26 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_request.cc @@ -38,16 +38,13 @@ using namespace application_manager; namespace commands { VIDiagnosticMessageRequest::VIDiagnosticMessageRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const app_mngr::commands::MessageSharedPtr& message, + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIDiagnosticMessageRequest::~VIDiagnosticMessageRequest() {} @@ -59,4 +56,4 @@ void VIDiagnosticMessageRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc index e22ba7ddb2..6482d97d10 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_diagnostic_message_response.cc @@ -40,15 +40,12 @@ namespace commands { VIDiagnosticMessageResponse::VIDiagnosticMessageResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIDiagnosticMessageResponse::~VIDiagnosticMessageResponse() {} @@ -63,4 +60,4 @@ void VIDiagnosticMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc index 71ce6331ab..620ee4c3e4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_request.cc @@ -39,15 +39,12 @@ namespace commands { VIGetDTCsRequest::VIGetDTCsRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetDTCsRequest::~VIGetDTCsRequest() {} @@ -59,4 +56,4 @@ void VIGetDTCsRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc index 9d39c60796..64e948a4e1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_dtcs_response.cc @@ -40,15 +40,12 @@ namespace commands { VIGetDTCsResponse::VIGetDTCsResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetDTCsResponse::~VIGetDTCsResponse() {} @@ -62,4 +59,4 @@ void VIGetDTCsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc index 9fc48c8820..eded6c685b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_request.cc @@ -31,6 +31,7 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h" +#include "application_manager/message_helper.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -39,24 +40,39 @@ namespace commands { VIGetVehicleDataRequest::VIGetVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} VIGetVehicleDataRequest::~VIGetVehicleDataRequest() {} void VIGetVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& msg_params = (*message_)[strings::msg_params]; + + smart_objects::SmartObject custom_data; + for (const auto& name : msg_params.enumerate()) { + const auto& found_it = rpc_spec_vehicle_data.find(name); + if (rpc_spec_vehicle_data.end() == found_it) { + custom_data[name] = msg_params[name]; + msg_params.erase(name); + } + } + + auto hmi_custom_msg_params = + custom_vehicle_data_manager_.CreateHMIMessageParams( + custom_data.enumerate()); + for (const auto& param : hmi_custom_msg_params.enumerate()) { + msg_params[param] = hmi_custom_msg_params[param]; + } SendRequest(); } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc index 73ba1a94fe..6a60cc968e 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_data_response.cc @@ -31,6 +31,8 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h" #include "application_manager/event_engine/event.h" +#include "application_manager/policies/policy_handler_interface.h" + #include "interfaces/HMI_API.h" namespace vehicle_info_plugin { @@ -39,15 +41,12 @@ namespace commands { VIGetVehicleDataResponse::VIGetVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetVehicleDataResponse::~VIGetVehicleDataResponse() {} @@ -86,4 +85,4 @@ void VIGetVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc index a1a221220a..250584bd12 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_request.cc @@ -39,15 +39,12 @@ namespace commands { VIGetVehicleTypeRequest::VIGetVehicleTypeRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetVehicleTypeRequest::~VIGetVehicleTypeRequest() {} @@ -59,4 +56,4 @@ void VIGetVehicleTypeRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc index 9f14b4e7ea..fb6eadf747 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc @@ -38,15 +38,12 @@ namespace commands { VIGetVehicleTypeResponse::VIGetVehicleTypeResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIGetVehicleTypeResponse::~VIGetVehicleTypeResponse() {} @@ -61,4 +58,4 @@ void VIGetVehicleTypeResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc index 04bcc435ba..93781a7420 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_request.cc @@ -31,8 +31,9 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_is_ready_request.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/rpc_service.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -41,16 +42,13 @@ namespace commands { VIIsReadyRequest::VIIsReadyRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) - , EventObserver(application_manager.event_dispatcher()) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , EventObserver(application_manager_.event_dispatcher()) {} VIIsReadyRequest::~VIIsReadyRequest() {} @@ -109,4 +107,4 @@ void VIIsReadyRequest::SendMessageToHMI() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc index 35907e11d2..349a1137ce 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_is_ready_response.cc @@ -38,15 +38,12 @@ namespace commands { VIIsReadyResponse::VIIsReadyResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIIsReadyResponse::~VIIsReadyResponse() {} @@ -59,4 +56,4 @@ void VIIsReadyResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc index b55c9e32a0..47373bb4bf 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_request.cc @@ -39,15 +39,12 @@ namespace commands { VIReadDIDRequest::VIReadDIDRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIReadDIDRequest::~VIReadDIDRequest() {} @@ -59,4 +56,4 @@ void VIReadDIDRequest::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc index 9d56b2aa78..7c2db1e875 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_read_did_response.cc @@ -39,15 +39,12 @@ namespace commands { VIReadDIDResponse::VIReadDIDResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIReadDIDResponse::~VIReadDIDResponse() {} @@ -61,4 +58,4 @@ void VIReadDIDResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc index 60e9dc88c3..4c5f067d0d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc @@ -31,6 +31,7 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h" +#include "application_manager/message_helper.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -39,24 +40,39 @@ namespace commands { VISubscribeVehicleDataRequest::VISubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} VISubscribeVehicleDataRequest::~VISubscribeVehicleDataRequest() {} void VISubscribeVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& msg_params = (*message_)[strings::msg_params]; + + smart_objects::SmartObject custom_data; + for (const auto& name : msg_params.enumerate()) { + const auto& found_it = rpc_spec_vehicle_data.find(name); + if (rpc_spec_vehicle_data.end() == found_it) { + custom_data[name] = msg_params[name]; + msg_params.erase(name); + } + } + + auto hmi_custom_msg_params = + custom_vehicle_data_manager_.CreateHMIMessageParams( + custom_data.enumerate()); + for (const auto& item : hmi_custom_msg_params.enumerate()) { + msg_params[item] = hmi_custom_msg_params[item]; + } SendRequest(); } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc index f004d6f3cd..061e13c766 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_response.cc @@ -39,15 +39,12 @@ namespace commands { VISubscribeVehicleDataResponse::VISubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VISubscribeVehicleDataResponse::~VISubscribeVehicleDataResponse() {} @@ -60,4 +57,4 @@ void VISubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc index 9056538514..aa24ac7375 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_request.cc @@ -31,6 +31,7 @@ */ #include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h" +#include "application_manager/message_helper.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -39,24 +40,39 @@ namespace commands { VIUnsubscribeVehicleDataRequest::VIUnsubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} VIUnsubscribeVehicleDataRequest::~VIUnsubscribeVehicleDataRequest() {} void VIUnsubscribeVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& msg_params = (*message_)[strings::msg_params]; + + smart_objects::SmartObject custom_data; + for (const auto& name : msg_params.enumerate()) { + const auto& found_it = rpc_spec_vehicle_data.find(name); + if (rpc_spec_vehicle_data.end() == found_it) { + custom_data[name] = msg_params[name]; + msg_params.erase(name); + } + } + + auto hmi_custom_msg_params = + custom_vehicle_data_manager_.CreateHMIMessageParams( + custom_data.enumerate()); + for (const auto& param : hmi_custom_msg_params.enumerate()) { + msg_params[param] = true; + } SendRequest(); } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc index 348bc1b269..01fc521b10 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_unsubscribe_vehicle_data_response.cc @@ -39,15 +39,12 @@ namespace commands { VIUnsubscribeVehicleDataResponse::VIUnsubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) + const VehicleInfoCommandParams& params) : ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} VIUnsubscribeVehicleDataResponse::~VIUnsubscribeVehicleDataResponse() {} @@ -60,4 +57,4 @@ void VIUnsubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc index 4eba894025..ef6c284faf 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_request.cc @@ -31,13 +31,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <algorithm> #include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" +#include <algorithm> #include "application_manager/application_impl.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -46,15 +46,12 @@ namespace commands { DiagnosticMessageRequest::DiagnosticMessageRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} DiagnosticMessageRequest::~DiagnosticMessageRequest() {} @@ -127,4 +124,4 @@ void DiagnosticMessageRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc index 54d8382f5d..f5ccc4d0a7 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/diagnostic_message_response.cc @@ -41,15 +41,12 @@ namespace commands { DiagnosticMessageResponse::DiagnosticMessageResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} DiagnosticMessageResponse::~DiagnosticMessageResponse() {} @@ -61,4 +58,4 @@ void DiagnosticMessageResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc index 6c04e874e8..dfa1cf305b 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_request.cc @@ -34,8 +34,8 @@ #include "vehicle_info_plugin/commands/mobile/get_dtcs_request.h" #include "application_manager/application_impl.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -44,15 +44,12 @@ namespace commands { GetDTCsRequest::GetDTCsRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetDTCsRequest::~GetDTCsRequest() {} @@ -116,4 +113,4 @@ void GetDTCsRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc index 3686094b73..33945a2f00 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_dtcs_response.cc @@ -41,15 +41,12 @@ namespace commands { GetDTCsResponse::GetDTCsResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetDTCsResponse::~GetDTCsResponse() {} @@ -61,4 +58,4 @@ void GetDTCsResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc index 87a9ace377..d15cf6a580 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc @@ -31,13 +31,16 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include "vehicle_info_plugin/commands/mobile/get_vehicle_data_request.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" + +#include <string> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "policy/policy_table/types.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -48,55 +51,57 @@ namespace str = strings; GetVehicleDataRequest::GetVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} GetVehicleDataRequest::~GetVehicleDataRequest() {} void GetVehicleDataRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - int32_t app_id = - (*message_)[strings::params][strings::connection_key].asUInt(); - ApplicationSharedPtr app = application_manager_.application(app_id); + auto app = application_manager_.application(connection_key()); if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); + LOG4CXX_ERROR(logger_, "No such application : " << connection_key()); SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - if (app->AreCommandLimitsExceeded( - static_cast<mobile_apis::FunctionID::eType>(function_id()), - application_manager::TLimitSource::CONFIG_FILE)) { - LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high."); + if (!CheckFrequency(*app)) { SendResponse(false, mobile_apis::Result::REJECTED); return; } - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - smart_objects::SmartObject msg_params = + + auto hmi_msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params[strings::app_id] = app->app_id(); - const uint32_t min_length_msg_params = 1; - for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[str::msg_params].keyExists(it->first) && - true == (*message_)[str::msg_params][it->first].asBool()) { - msg_params[it->first] = (*message_)[strings::msg_params][it->first]; + hmi_msg_params[strings::app_id] = app->app_id(); + + int params_count = 0; + auto& msg_params = (*message_)[strings::msg_params]; + for (const auto& name : msg_params.enumerate()) { + auto enabled = msg_params[name].asBool(); + if (!enabled) { + continue; } + hmi_msg_params[name] = msg_params[name]; + params_count++; } - if (msg_params.length() > min_length_msg_params) { + + const int minimal_params_count = 1; + + if (params_count >= minimal_params_count) { + for (const auto& param : msg_params.enumerate()) { + pending_vehicle_data_.insert(param); + } StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - SendHMIRequest( - hmi_apis::FunctionID::VehicleInfo_GetVehicleData, &msg_params, true); - return; + SendHMIRequest(hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + &hmi_msg_params, + true); } else if (HasDisallowedParams()) { SendResponse(false, mobile_apis::Result::DISALLOWED); } else { @@ -111,16 +116,31 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { switch (event.id()) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo); - hmi_apis::Common_Result::eType result_code = - static_cast<hmi_apis::Common_Result::eType>( - message[strings::params][hmi_response::code].asInt()); + auto result_code = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + auto mobile_result_code = GetMobileResultCode(result_code); bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_VehicleInfo); std::string response_info; GetInfo(message, response_info); - result = result || - ((hmi_apis::Common_Result::DATA_NOT_AVAILABLE == result_code) && - (message[strings::msg_params].length() > 1)); + + auto data_not_available_with_params = [this, &result_code, &message]() { + if (hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { + return false; + } + + const auto& vehicle_data = MessageHelper::vehicle_data(); + const auto& msg_params = message[strings::msg_params]; + for (const auto& item : msg_params.enumerate()) { + if (vehicle_data.end() != vehicle_data.find(item) || + custom_vehicle_data_manager_.IsValidCustomVehicleDataName(item)) { + return true; + } + } + return false; + }; + + result = result || data_not_available_with_params(); if (true == message[strings::msg_params].keyExists(hmi_response::method)) { @@ -129,8 +149,30 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { if (true == message[strings::params].keyExists(strings::error_msg)) { response_info = message[strings::params][strings::error_msg].asString(); } + + custom_vehicle_data_manager_.CreateMobileMessageParams( + const_cast<smart_objects::SmartObject&>( + message[strings::msg_params])); + + if (result) { + for (const auto& item : message[strings::msg_params].enumerate()) { + const auto& found_item = pending_vehicle_data_.find(item); + if (pending_vehicle_data_.end() == found_item) { + message[strings::msg_params].erase(item); + } + } + + if (message[strings::msg_params].empty() && + hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { + response_info = "Failed to retrieve data from vehicle"; + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, response_info.c_str()); + return; + } + } + SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), + mobile_result_code, response_info.empty() ? NULL : response_info.c_str(), &(message[strings::msg_params])); break; @@ -142,6 +184,15 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { } } -} // namespace commands +bool GetVehicleDataRequest::CheckFrequency(Application& app) { + if (app.AreCommandLimitsExceeded( + static_cast<mobile_apis::FunctionID::eType>(function_id()), + application_manager::TLimitSource::CONFIG_FILE)) { + LOG4CXX_ERROR(logger_, "GetVehicleData frequency is too high."); + return false; + } + return true; +} -} // namespace application_manager +} // namespace commands +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc index 3a7d663756..60a44745a5 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_response.cc @@ -42,15 +42,12 @@ namespace commands { GetVehicleDataResponse::GetVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetVehicleDataResponse::~GetVehicleDataResponse() {} @@ -62,4 +59,4 @@ void GetVehicleDataResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index f8553c84f8..79134cae40 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -34,11 +34,11 @@ #include "vehicle_info_plugin/commands/mobile/on_vehicle_data_notification.h" #include "application_manager/application_impl.h" +#include "application_manager/helpers/application_helper.h" #include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" -#include "vehicle_info_plugin/vehicle_info_app_extension.h" -#include "application_manager/helpers/application_helper.h" #include "utils/macro.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -47,90 +47,74 @@ namespace commands { OnVehicleDataNotification::OnVehicleDataNotification( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} OnVehicleDataNotification::~OnVehicleDataNotification() {} void OnVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - std::vector<ApplicationSharedPtr> appNotification; - std::vector<ApplicationSharedPtr>::iterator appNotification_it = - appNotification.begin(); + std::vector<ApplicationSharedPtr> notify_apps; + std::vector<ApplicationSharedPtr>::iterator notified_app_it = + notify_apps.begin(); std::vector<smart_objects::SmartObject> appSO; - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - - for (; vehicle_data.end() != it; ++it) { - if (true == (*message_)[strings::msg_params].keyExists(it->first)) { - LOG4CXX_ERROR(logger_, "vehicle_data nanme" << it->first); - auto vehicle_data_value = - (*message_)[strings::msg_params][it->first].asInt(); - - application_manager_.IviInfoUpdated(it->second, vehicle_data_value); - - auto subscribed_to_ivi_predicate = [&it](const ApplicationSharedPtr app) { - DCHECK_OR_RETURN(app, false); - auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - return ext.isSubscribedToVehicleInfo(it->second); - }; - - const std::vector<ApplicationSharedPtr>& applications = - application_manager::FindAllApps(application_manager_.applications(), - subscribed_to_ivi_predicate); - - std::vector<ApplicationSharedPtr>::const_iterator app_it = - applications.begin(); - - for (; applications.end() != app_it; ++app_it) { - const ApplicationSharedPtr app = *app_it; - if (!app) { - LOG4CXX_ERROR(logger_, "NULL pointer"); - continue; - } - - appNotification_it = - find(appNotification.begin(), appNotification.end(), app); - if (appNotification_it == appNotification.end()) { - appNotification.push_back(app); - smart_objects::SmartObject msg_param = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_param[it->first] = (*message_)[strings::msg_params][it->first]; - appSO.push_back(msg_param); - } else { - size_t idx = - std::distance(appNotification.begin(), appNotification_it); - appSO[idx][it->first] = (*message_)[strings::msg_params][it->first]; - } + custom_vehicle_data_manager_.CreateMobileMessageParams( + (*message_)[strings::msg_params]); + + const auto& param_names = (*message_)[strings::msg_params].enumerate(); + for (const auto& name : param_names) { + LOG4CXX_DEBUG(logger_, "vehicle_data name: " << name); + auto vehicle_data_value = (*message_)[strings::msg_params][name].asInt(); + application_manager_.IviInfoUpdated(name, vehicle_data_value); + + auto subscribed_to_ivi_predicate = [&name](const ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + return ext.isSubscribedToVehicleInfo(name); + }; + + const auto& applications = application_manager::FindAllApps( + application_manager_.applications(), subscribed_to_ivi_predicate); + for (const auto& app : applications) { + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer"); + continue; + } + notified_app_it = find(notify_apps.begin(), notify_apps.end(), app); + if (notified_app_it == notify_apps.end()) { + notify_apps.push_back(app); + smart_objects::SmartObject msg_param = + smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_param[name] = (*message_)[strings::msg_params][name]; + appSO.push_back(msg_param); + } else { + size_t idx = std::distance(notify_apps.begin(), notified_app_it); + appSO[idx][name] = (*message_)[strings::msg_params][name]; } } } - LOG4CXX_DEBUG( - logger_, - "Number of Notifications to be send: " << appNotification.size()); + LOG4CXX_DEBUG(logger_, + "Number of Notifications to be send: " << notify_apps.size()); - for (size_t idx = 0; idx < appNotification.size(); idx++) { + for (size_t idx = 0; idx < notify_apps.size(); idx++) { LOG4CXX_INFO(logger_, "Send OnVehicleData PRNDL notification to " - << appNotification[idx]->name().c_str() - << " application id " << appNotification[idx]->app_id()); + << notify_apps[idx]->name().c_str() << " application id " + << notify_apps[idx]->app_id()); (*message_)[strings::params][strings::connection_key] = - appNotification[idx]->app_id(); + notify_apps[idx]->app_id(); (*message_)[strings::msg_params] = appSO[idx]; SendNotification(); } } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc index 010cce4c63..c090df7852 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_request.cc @@ -30,13 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include "vehicle_info_plugin/commands/mobile/read_did_request.h" +#include <string> #include "application_manager/application_impl.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/message_helper.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace vehicle_info_plugin { using namespace application_manager; @@ -45,15 +45,12 @@ namespace commands { ReadDIDRequest::ReadDIDRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} ReadDIDRequest::~ReadDIDRequest() {} @@ -131,4 +128,4 @@ void ReadDIDRequest::on_event(const event_engine::Event& event) { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc index 82d49574f0..42e7fc1ba9 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/read_did_response.cc @@ -41,15 +41,12 @@ namespace commands { ReadDIDResponse::ReadDIDResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} ReadDIDResponse::~ReadDIDResponse() {} @@ -61,4 +58,4 @@ void ReadDIDResponse::Run() { } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc index 65f4fde0b2..b125a7de7d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -29,8 +29,10 @@ #include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h" +#include <boost/algorithm/string.hpp> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" @@ -40,15 +42,13 @@ namespace commands { SubscribeVehicleDataRequest::SubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + VehicleInfoCommandParams params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} SubscribeVehicleDataRequest::~SubscribeVehicleDataRequest() {} @@ -73,6 +73,7 @@ void SubscribeVehicleDataRequest::Run() { app, info, result_code, response_params, msg_params, result); if (mobile_apis::Result::INVALID_ENUM != result_code) { + AppendDataTypesToMobileResponse(response_params); SendResponse(result, result_code, info.empty() ? NULL : info.c_str(), @@ -118,35 +119,103 @@ void SubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(hmi_result); + smart_objects::SmartObject converted_msg_params(message[strings::msg_params]); + custom_vehicle_data_manager_.CreateMobileMessageParams(converted_msg_params); + if (is_succeeded) { if (!vi_already_subscribed_by_this_app_.empty()) { result_code = mobile_apis::Result::IGNORED; response_info = "Already subscribed on some provided VehicleData."; } - if (!vi_waiting_for_subscribe_.empty()) { - LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); - VehicleInfoSubscriptions::const_iterator key = - vi_waiting_for_subscribe_.begin(); - for (; key != vi_waiting_for_subscribe_.end(); ++key) { - auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - ext.subscribeToVehicleInfo(*key); + for (const auto& param : converted_msg_params.enumerate()) { + const auto& converted_name = ConvertResponseToRequestName(param); + if (vi_waiting_for_subscribe_.end() == + vi_waiting_for_subscribe_.find(converted_name)) { + LOG4CXX_DEBUG(logger_, "erase " << converted_name); + converted_msg_params.erase(param); } } - } - UnsubscribeFailedSubscriptions(app, message[strings::msg_params]); + if (!SubscribePendingVehicleData(app, converted_msg_params)) { + result_code = mobile_apis::Result::GENERIC_ERROR; + response_info = "Subscription failed for some Vehicle data"; + SendResponse(false, result_code, response_info.c_str()); + return; + } + } if (!vi_already_subscribed_by_another_apps_.empty() || !vi_already_subscribed_by_this_app_.empty()) { - AddAlreadySubscribedVI( - const_cast<smart_objects::SmartObject&>(message[strings::msg_params])); + AddAlreadySubscribedVI(converted_msg_params); } + AppendDataTypesToMobileResponse(converted_msg_params); SendResponse(is_succeeded, result_code, response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); + &converted_msg_params); +} + +void SubscribeVehicleDataRequest::AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const { + using namespace smart_objects; + + std::string oem_vehicle_data_type_str; + EnumConversionHelper<VehicleDataType>::EnumToString( + VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, &oem_vehicle_data_type_str); + + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + for (const auto& item : msg_params.enumerate()) { + const auto& rpc_spec_vehicle_data_item = rpc_spec_vehicle_data.find(item); + if (rpc_spec_vehicle_data.end() == rpc_spec_vehicle_data_item) { + msg_params[item][strings::data_type] = oem_vehicle_data_type_str; + msg_params[item][strings::oem_custom_data_type] = + custom_vehicle_data_manager_.GetVehicleDataItemType(item); + } else { + msg_params[item][strings::data_type] = rpc_spec_vehicle_data_item->second; + } + } +} + +bool SubscribeVehicleDataRequest::CheckSubscriptionStatus( + std::string vi_name, const smart_objects::SmartObject& msg_params) { + const auto subscribed_items = msg_params.enumerate(); + if (subscribed_items.end() == subscribed_items.find(vi_name)) { + LOG4CXX_WARN(logger_, + vi_name << " is waiting to be subscribed, but missing in " + "vehicle response."); + return false; + } + + auto res_code = msg_params[vi_name][strings::result_code].asInt(); + if (hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS != res_code && + hmi_apis::Common_VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED != + res_code) { + LOG4CXX_WARN(logger_, + "Subscription to " << vi_name << " for " << connection_key() + << " failed."); + return false; + } + return true; +} + +bool SubscribeVehicleDataRequest::SubscribePendingVehicleData( + ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) { + LOG4CXX_DEBUG(logger_, "Subscribing to all pending VehicleData"); + + for (const auto& vi_name : vi_waiting_for_subscribe_) { + const bool is_subscription_successful = CheckSubscriptionStatus( + ConvertRequestToResponseName(vi_name), msg_params); + + if (is_subscription_successful) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + ext.subscribeToVehicleInfo(vi_name); + vi_waiting_for_subscribe_.erase(vi_name); + } + } + + return vi_waiting_for_subscribe_.empty(); } bool SubscribeVehicleDataRequest::Init() { @@ -158,76 +227,33 @@ void SubscribeVehicleDataRequest::AddAlreadySubscribedVI( smart_objects::SmartObject& msg_params) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - auto vi_to_string = - [](const mobile_apis::VehicleDataType::eType vehicle_data) { - for (auto& vi_str_to_int_pair : MessageHelper::vehicle_data()) { - if (vehicle_data == vi_str_to_int_pair.second) { - return vi_str_to_int_pair.first; - } - } - return std::string(); - }; - VehicleInfoSubscriptions::const_iterator it_same_app = - vi_already_subscribed_by_this_app_.begin(); - for (; vi_already_subscribed_by_this_app_.end() != it_same_app; - ++it_same_app) { - msg_params[vi_to_string(*it_same_app)][strings::result_code] = + for (const auto& item : vi_already_subscribed_by_this_app_) { + msg_params[item][strings::result_code] = VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; - msg_params[vi_to_string(*it_same_app)][strings::data_type] = *it_same_app; } - VehicleInfoSubscriptions::const_iterator it_another_app = - vi_already_subscribed_by_another_apps_.begin(); - for (; vi_already_subscribed_by_another_apps_.end() != it_another_app; - ++it_another_app) { - msg_params[vi_to_string(*it_another_app)][strings::result_code] = + for (const auto& item : vi_already_subscribed_by_another_apps_) { + msg_params[item][strings::result_code] = VehicleDataResultCode::VDRC_SUCCESS; - msg_params[vi_to_string(*it_another_app)][strings::data_type] = - *it_another_app; - } -} - -void SubscribeVehicleDataRequest::UnsubscribeFailedSubscriptions( - ApplicationSharedPtr app, - const smart_objects::SmartObject& msg_params) const { - LOG4CXX_AUTO_TRACE(logger_); - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - - for (; vehicle_data.end() != it; ++it) { - if (msg_params.keyExists(it->first)) { - if (msg_params[it->first][strings::result_code].asInt() != - hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS) { - LOG4CXX_DEBUG(logger_, - "Subscription for VehicleDataType " - << it->first - << " is unsuccessfull. " - "Unsubscribing app with connection key " - << connection_key() << " from it."); - VehicleInfoAppExtension::ExtractVIExtension(*app) - .unsubscribeFromVehicleInfo(it->second); - } - } } } struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) + std::string vehicle_info_; + SubscribedToIVIPredicate(std::string vehicle_info) : vehicle_info_(vehicle_info) {} bool operator()(const ApplicationSharedPtr app) const { DCHECK_OR_RETURN(app, false); auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - return ext.isSubscribedToVehicleInfo( - static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_)); + return ext.isSubscribedToVehicleInfo(vehicle_info_); } }; bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor( - const uint32_t param_id) const { + const std::string& param_name) const { LOG4CXX_AUTO_TRACE(logger_); - SubscribedToIVIPredicate finder(param_id); + SubscribedToIVIPredicate finder(param_name); DataAccessor<ApplicationSet> accessor = application_manager_.applications(); ApplicationSetConstIt it = std::find_if( accessor.GetData().begin(), accessor.GetData().end(), finder); @@ -241,93 +267,101 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( smart_objects::SmartObject& out_response_params, smart_objects::SmartObject& out_request_params, bool& out_result) { - // counter for items to subscribe - VehicleInfoSubscriptions::size_type items_to_subscribe = 0; - // counter for subscribed items by application - uint32_t subscribed_items = 0; + const bool is_interface_not_available = + (HmiInterfaces::STATE_NOT_AVAILABLE == + application_manager_.hmi_interfaces().GetInterfaceState( + HmiInterfaces::HMI_INTERFACE_VehicleInfo)); + + VehicleInfoSubscriptions::size_type subscribed_items = 0; + + auto app_already_subscribed = + [this, &out_response_params]( + const std::string& key_name, + const mobile_apis::VehicleDataType::eType vd_type) { + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " is subscribed already for VehicleData: " << key_name); + vi_already_subscribed_by_this_app_.insert(key_name); + out_response_params[key_name][strings::data_type] = vd_type; + out_response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; + }; - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); + auto another_app_subscribed = + [this, &out_response_params, &subscribed_items]( + const std::string& key_name, + const mobile_apis::VehicleDataType::eType vd_type, + vehicle_info_plugin::VehicleInfoAppExtension& ext) { + LOG4CXX_DEBUG(logger_, + "There are apps subscribed already for " + "VehicleDataType: " + << key_name); + + if (!ext.subscribeToVehicleInfo(key_name)) { + LOG4CXX_ERROR( + logger_, "Unable to subscribe for VehicleDataType: " << key_name); + return; + } + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " have been subscribed for VehicleDataType: " << key_name); + vi_already_subscribed_by_another_apps_.insert(key_name); + out_response_params[key_name][strings::data_type] = vd_type; + out_response_params[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; + ++subscribed_items; + }; - HmiInterfaces::InterfaceState interface_state = - application_manager_.hmi_interfaces().GetInterfaceState( - HmiInterfaces::HMI_INTERFACE_VehicleInfo); + auto first_subscription = [this, &out_request_params, &subscribed_items]( + const std::string& vi_name) { + out_request_params[vi_name] = (*message_)[strings::msg_params][vi_name]; - const bool is_interface_not_available = - interface_state == HmiInterfaces::STATE_NOT_AVAILABLE; - - for (; vehicle_data.end() != it; ++it) { - const std::string& key_name = it->first; - if ((*message_)[strings::msg_params].keyExists(key_name)) { - const bool is_key_enabled = - (*message_)[strings::msg_params][key_name].asBool(); - if (is_key_enabled) { - ++items_to_subscribe; - } - if (!is_interface_not_available && is_key_enabled) { - mobile_apis::VehicleDataType::eType key_type = it->second; - const auto is_subscribed = - VehicleInfoAppExtension::ExtractVIExtension(*app) - .isSubscribedToVehicleInfo(key_type); - if (is_subscribed) { - LOG4CXX_DEBUG(logger_, - "App with connection key " - << connection_key() - << " is subscribed already for VehicleDataType: " - << key_type); - ++subscribed_items; - vi_already_subscribed_by_this_app_.insert(key_type); - out_response_params[key_name][strings::data_type] = key_type; - out_response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_DATA_ALREADY_SUBSCRIBED; - continue; - } + vi_waiting_for_subscribe_.insert(vi_name); + LOG4CXX_DEBUG( + logger_, + "App with connection key " + << connection_key() + << " will be subscribed for VehicleDataType: " << vi_name); + ++subscribed_items; + return true; + }; - if (IsSomeoneSubscribedFor(key_type)) { - LOG4CXX_DEBUG(logger_, - "There are apps subscribed already for " - "VehicleDataType: " - << key_type); - auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - - if (!ext.subscribeToVehicleInfo(key_type)) { - LOG4CXX_ERROR( - logger_, - "Unable to subscribe for VehicleDataType: " << key_type); - continue; - } - LOG4CXX_DEBUG( - logger_, - "App with connection key " - << connection_key() - << " have been subscribed for VehicleDataType: " << key_type); - ++subscribed_items; - vi_already_subscribed_by_another_apps_.insert(key_type); - out_response_params[key_name][strings::data_type] = key_type; - out_response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; - continue; - } + auto rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - out_request_params[key_name] = is_key_enabled; + VehicleInfoSubscriptions::size_type items_to_subscribe = 0; + auto item_names = (*message_)[strings::msg_params].enumerate(); + if (!is_interface_not_available) { + for (const auto& name : item_names) { + auto enabled = (*message_)[strings::msg_params][name].asBool(); + if (!enabled) { + continue; + } - if (is_key_enabled) { - vi_waiting_for_subscribe_.insert(key_type); - LOG4CXX_DEBUG( - logger_, - "App with connection key " - << connection_key() - << " will be subscribed for VehicleDataType: " << key_type); - ++subscribed_items; - } + auto vehicle_data = rpc_spec_vehicle_data.find(name); + auto vehicle_data_type = + (vehicle_data == rpc_spec_vehicle_data.end()) + ? VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA + : vehicle_data->second; + if (ext.isSubscribedToVehicleInfo(name)) { + app_already_subscribed(name, vehicle_data_type); + } else if (IsSomeoneSubscribedFor(name)) { + another_app_subscribed(name, vehicle_data_type, ext); + } else if (!first_subscription(name)) { + continue; } + + ++items_to_subscribe; } } const bool is_everything_already_subscribed = - items_to_subscribe == - vi_already_subscribed_by_another_apps_.size() + - vi_already_subscribed_by_this_app_.size(); + items_to_subscribe == vi_already_subscribed_by_another_apps_.size() + + vi_already_subscribed_by_this_app_.size(); if (0 == items_to_subscribe) { if (HasDisallowedParams()) { @@ -337,12 +371,14 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( out_info = "No data in the request"; } out_result = false; + return; } if (0 == subscribed_items && !is_interface_not_available) { out_result_code = mobile_apis::Result::IGNORED; out_info = "Already subscribed on provided VehicleData."; out_result = false; + return; } if (is_everything_already_subscribed) { @@ -353,8 +389,35 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( out_info = "Already subscribed on some provided VehicleData."; } out_result = true; + return; } } +const std::string& SubscribeVehicleDataRequest::ConvertResponseToRequestName( + const std::string& name) { + static std::map<std::string, std::string> parameter_name_conversion_map = { + {strings::cluster_modes, strings::cluster_mode_status}}; + const auto converted_it = parameter_name_conversion_map.find(name); + auto result = parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; + return parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; +} + +const std::string& SubscribeVehicleDataRequest::ConvertRequestToResponseName( + const std::string& name) { + static std::map<std::string, std::string> parameter_name_conversion_map = { + {strings::cluster_mode_status, strings::cluster_modes}}; + const auto converted_it = parameter_name_conversion_map.find(name); + auto result = parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; + return parameter_name_conversion_map.end() == converted_it + ? name + : converted_it->second; +} + } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc index 2bea839320..8330176af6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_response.cc @@ -32,8 +32,8 @@ */ #include "vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h" -#include "application_manager/rpc_service.h" #include "application_manager/application_impl.h" +#include "application_manager/rpc_service.h" #include "interfaces/MOBILE_API.h" namespace vehicle_info_plugin { @@ -42,15 +42,12 @@ namespace commands { SubscribeVehicleDataResponse::SubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} SubscribeVehicleDataResponse::~SubscribeVehicleDataResponse() {} @@ -60,4 +57,4 @@ void SubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc index d0152ea0c3..32d63f0c35 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_request.cc @@ -36,9 +36,10 @@ #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/smart_object_keys.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" #include "utils/helpers.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" @@ -48,15 +49,13 @@ namespace commands { UnsubscribeVehicleDataRequest::UnsubscribeVehicleDataRequest( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , custom_vehicle_data_manager_(params.custom_vehicle_data_manager_) {} UnsubscribeVehicleDataRequest::~UnsubscribeVehicleDataRequest() {} @@ -74,67 +73,64 @@ void UnsubscribeVehicleDataRequest::Run() { int32_t items_to_unsubscribe = 0; int32_t unsubscribed_items = 0; - const VehicleData& vehicle_data = MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.begin(); - smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject response_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); + response_params_ = smart_objects::SmartObject(smart_objects::SmartType_Map); + + auto rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + std::set<std::string> custom_vehicle_data; + + auto app_not_subscribed_response = [this](const std::string& key_name) { + LOG4CXX_DEBUG(logger_, + "App with connection key " + << connection_key() + << " is not subscribed for VehicleData: " << key_name); + vi_already_unsubscribed_by_this_app_.insert(key_name); + response_params_[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; + }; + + auto other_app_subscribed_response = [this](const std::string& key_name) { + LOG4CXX_DEBUG(logger_, + "There are apps still subscribed for " + "VehicleDataType: " + << key_name); + vi_still_subscribed_by_another_apps_.insert(key_name); + response_params_[key_name][strings::result_code] = + mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; + }; + + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + + const auto& param_names = (*message_)[strings::msg_params].enumerate(); + for (const auto& name : param_names) { + const bool enabled = (*message_)[strings::msg_params][name].asBool(); + if (!enabled) { + continue; + } - for (; vehicle_data.end() != it; ++it) { - const std::string& key_name = it->first; - if ((*message_)[strings::msg_params].keyExists(key_name)) { - bool is_key_enabled = (*message_)[strings::msg_params][key_name].asBool(); - if (is_key_enabled) { - ++items_to_unsubscribe; - - mobile_apis::VehicleDataType::eType key_type = it->second; - const auto is_subscribed = - VehicleInfoAppExtension::ExtractVIExtension(*app) - .isSubscribedToVehicleInfo(key_type); - if (!is_subscribed) { - ++unsubscribed_items; - vi_already_unsubscribed_by_this_app_.insert(key_type); - response_params[key_name][strings::data_type] = key_type; - response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; - continue; - } - - if (!VehicleInfoAppExtension::ExtractVIExtension(*app) - .unsubscribeFromVehicleInfo(it->second)) { - LOG4CXX_ERROR(logger_, - "Unable to unsubscribe from " - "VehicleDataType: " - << key_type); - continue; - } - - LOG4CXX_DEBUG(logger_, - "Unsubscribed app with connection key " - << connection_key() - << " from VehicleDataType: " << key_type); - - ++unsubscribed_items; - - if (IsSomeoneSubscribedFor(key_type)) { - LOG4CXX_DEBUG(logger_, - "There are another apps still subscribed for " - "VehicleDataType: " - << key_type); - - vi_still_subscribed_by_another_apps_.insert(key_type); - response_params[key_name][strings::data_type] = key_type; - response_params[key_name][strings::result_code] = - mobile_apis::VehicleDataResultCode::VDRC_SUCCESS; - continue; - } - - msg_params[key_name] = is_key_enabled; - } + ++items_to_unsubscribe; + + if (!(ext.isSubscribedToVehicleInfo(name))) { + app_not_subscribed_response(name); + continue; } + + LOG4CXX_DEBUG(logger_, + "Unsubscribed app with connection key " + << connection_key() << " from VehicleDataType: " << name); + + ++unsubscribed_items; + + if (IsSomeoneSubscribedFor(name)) { + other_app_subscribed_response(name); + ext.unsubscribeFromVehicleInfo(name); + continue; + } + + vi_waiting_for_unsubscribe_.insert(name); + msg_params[name] = true; } bool is_everything_already_unsubscribed = @@ -142,6 +138,8 @@ void UnsubscribeVehicleDataRequest::Run() { vi_still_subscribed_by_another_apps_.size() + vi_already_unsubscribed_by_this_app_.size(); + AppendDataTypesToMobileResponse(response_params_); + if (0 == items_to_unsubscribe) { if (HasDisallowedParams()) { SendResponse(false, mobile_apis::Result::DISALLOWED); @@ -156,7 +154,7 @@ void UnsubscribeVehicleDataRequest::Run() { SendResponse(false, mobile_apis::Result::IGNORED, "Was not subscribed on any VehicleData.", - &response_params); + &response_params_); return; } @@ -165,9 +163,9 @@ void UnsubscribeVehicleDataRequest::Run() { SendResponse(false, mobile_apis::Result::IGNORED, "Some provided VehicleData was not subscribed.", - &response_params); + &response_params_); } else { - SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params); + SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params_); } return; } @@ -203,36 +201,56 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) { message[strings::params][hmi_response::code].asInt()); std::string response_info; GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( + bool result = PrepareResultForMobileResponse( hmi_result, HmiInterfaces::HMI_INTERFACE_VehicleInfo); + auto hmi_response_msg_params = message[strings::msg_params]; + mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(hmi_result); + custom_vehicle_data_manager_.CreateMobileMessageParams( + hmi_response_msg_params); + + if (!vi_still_subscribed_by_another_apps_.empty() || + !vi_already_unsubscribed_by_this_app_.empty()) { + AddAlreadyUnsubscribedVI(hmi_response_msg_params); + } + if (result) { if (vi_already_unsubscribed_by_this_app_.size()) { result_code = mobile_apis::Result::IGNORED; response_info = "Some provided VehicleData was not subscribed."; } - } - if (!vi_still_subscribed_by_another_apps_.empty() || - !vi_already_unsubscribed_by_this_app_.empty()) { - AddAlreadyUnsubscribedVI( - const_cast<smart_objects::SmartObject&>(message[strings::msg_params])); - } + for (const auto& param : hmi_response_msg_params.enumerate()) { + const auto converted_param = ConvertResponseToRequestName(param); + if (vi_waiting_for_unsubscribe_.end() == + vi_waiting_for_unsubscribe_.find(converted_param)) { + hmi_response_msg_params.erase(param); + } + } - if (result) { - SetAllowedToTerminate(false); + if (!UnsubscribePendingVehicleData(app, hmi_response_msg_params)) { + result = false; + result_code = mobile_apis::Result::GENERIC_ERROR; + response_info = "Unsubscription failed for some Vehicle data"; + hmi_response_msg_params = smart_objects::SmartObject(); + } } - SendResponse(result, - result_code, - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); - if (result) { - application_manager_.TerminateRequest( - connection_key(), correlation_id(), function_id()); + + AppendDataTypesToMobileResponse(hmi_response_msg_params); + for (const auto& key : hmi_response_msg_params.enumerate()) { + response_params_[key] = hmi_response_msg_params[key]; } + + SendResponse( + result, + result_code, + response_info.empty() ? NULL : response_info.c_str(), + smart_objects::SmartType::SmartType_Null == response_params_.getType() + ? NULL + : &response_params_); } bool UnsubscribeVehicleDataRequest::Init() { @@ -240,25 +258,23 @@ bool UnsubscribeVehicleDataRequest::Init() { return true; } -struct SubscribedToIVIPredicate { - int32_t vehicle_info_; - SubscribedToIVIPredicate(int32_t vehicle_info) - : vehicle_info_(vehicle_info) {} - bool operator()(const ApplicationSharedPtr app) const { +bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor( + const std::string& param_name) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto conn_key = connection_key(); + auto subscribed_to_ivi = [¶m_name, + &conn_key](const ApplicationSharedPtr app) { DCHECK_OR_RETURN(app, false); + if (conn_key == app->app_id()) { + return false; + } auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - return ext.isSubscribedToVehicleInfo( - static_cast<mobile_apis::VehicleDataType::eType>(vehicle_info_)); - } -}; + return (ext.isSubscribedToVehicleInfo(param_name)); + }; -bool UnsubscribeVehicleDataRequest::IsSomeoneSubscribedFor( - const uint32_t param_id) const { - LOG4CXX_AUTO_TRACE(logger_); - SubscribedToIVIPredicate finder(param_id); DataAccessor<ApplicationSet> accessor = application_manager_.applications(); ApplicationSetConstIt it = std::find_if( - accessor.GetData().begin(), accessor.GetData().end(), finder); + accessor.GetData().begin(), accessor.GetData().end(), subscribed_to_ivi); return it != accessor.GetData().end(); } @@ -266,22 +282,94 @@ void UnsubscribeVehicleDataRequest::AddAlreadyUnsubscribedVI( smart_objects::SmartObject& response) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - VehicleInfoSubscriptions::const_iterator it_same_app = - vi_already_unsubscribed_by_this_app_.begin(); - for (; vi_already_unsubscribed_by_this_app_.end() != it_same_app; - ++it_same_app) { - response[*it_same_app][strings::result_code] = + + for (const auto& item : vi_already_unsubscribed_by_this_app_) { + response[item][strings::result_code] = VehicleDataResultCode::VDRC_DATA_NOT_SUBSCRIBED; } - VehicleInfoSubscriptions::const_iterator it_another_app = - vi_still_subscribed_by_another_apps_.begin(); - for (; vi_still_subscribed_by_another_apps_.end() != it_another_app; - ++it_another_app) { - response[*it_another_app][strings::result_code] = - VehicleDataResultCode::VDRC_SUCCESS; + for (const auto& item : vi_still_subscribed_by_another_apps_) { + response[item][strings::result_code] = VehicleDataResultCode::VDRC_SUCCESS; + } +} + +bool UnsubscribeVehicleDataRequest::CheckSubscriptionStatus( + std::string key, const smart_objects::SmartObject& msg_params) { + const auto unsubscribed_items = msg_params.enumerate(); + if (unsubscribed_items.end() == unsubscribed_items.find(key)) { + LOG4CXX_WARN(logger_, + key << " is waiting to be unsubscribed, but missing in " + "vehicle response."); + return false; + } + + auto res_code = msg_params[key][strings::result_code].asInt(); + if (hmi_apis::Common_VehicleDataResultCode::VDRC_SUCCESS != res_code) { + LOG4CXX_WARN(logger_, + "Unubscribing from " << key << " for " << connection_key() + << " failed."); + return false; + } + return true; +} + +bool UnsubscribeVehicleDataRequest::UnsubscribePendingVehicleData( + ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) { + LOG4CXX_DEBUG(logger_, "Unsubscribing from all pending VehicleData"); + + for (const auto& vi_name : vi_waiting_for_unsubscribe_) { + const auto converted_item = ConvertRequestToResponseName(vi_name); + const bool is_unsubscription_successful = + CheckSubscriptionStatus(converted_item, msg_params); + if (is_unsubscription_successful) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + ext.unsubscribeFromVehicleInfo(vi_name); + vi_waiting_for_unsubscribe_.erase(vi_name); + } + } + return vi_waiting_for_unsubscribe_.empty(); +} + +const std::string& UnsubscribeVehicleDataRequest::ConvertRequestToResponseName( + const std::string& name) { + static std::map<std::string, std::string> parameter_name_converion_map = { + {strings::cluster_mode_status, strings::cluster_modes}}; + const auto converted_it = parameter_name_converion_map.find(name); + return parameter_name_converion_map.end() == converted_it + ? name + : converted_it->second; +} + +const std::string& UnsubscribeVehicleDataRequest::ConvertResponseToRequestName( + const std::string& name) { + static std::map<std::string, std::string> parameter_name_converion_map = { + {strings::cluster_modes, strings::cluster_mode_status}}; + const auto converted_it = parameter_name_converion_map.find(name); + return parameter_name_converion_map.end() == converted_it + ? name + : converted_it->second; +} + +void UnsubscribeVehicleDataRequest::AppendDataTypesToMobileResponse( + smart_objects::SmartObject& msg_params) const { + using namespace smart_objects; + + std::string oem_vehicle_data_type_str; + EnumConversionHelper<VehicleDataType>::EnumToString( + VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, &oem_vehicle_data_type_str); + + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + for (const auto& item : msg_params.enumerate()) { + const auto& rpc_spec_vehicle_data_item = rpc_spec_vehicle_data.find(item); + if (rpc_spec_vehicle_data.end() == rpc_spec_vehicle_data_item) { + msg_params[item][strings::data_type] = oem_vehicle_data_type_str; + msg_params[item][strings::oem_custom_data_type] = + custom_vehicle_data_manager_.GetVehicleDataItemType(item); + } else { + msg_params[item][strings::data_type] = rpc_spec_vehicle_data_item->second; + } } } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc index 5f79785784..352239c331 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/unsubscribe_vehicle_data_response.cc @@ -40,15 +40,12 @@ namespace commands { UnsubscribeVehicleDataResponse::UnsubscribeVehicleDataResponse( const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + const VehicleInfoCommandParams& params) : CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} UnsubscribeVehicleDataResponse::~UnsubscribeVehicleDataResponse() {} @@ -67,4 +64,4 @@ void UnsubscribeVehicleDataResponse::Run() { } } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc new file mode 100644 index 0000000000..9df6d922aa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc @@ -0,0 +1,575 @@ +/** + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h" +#include <strings.h> +#include <limits> +#include "policy/policy_table/types.h" +#include "vehicle_info_plugin/vehicle_data_item_schema.h" + +#include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" +#include "application_manager/policies/custom_vehicle_data_provider.h" +#include "interfaces/MOBILE_API_schema.h" +#include "policy/policy_table/policy_enum_schema_factory.h" +#include "smart_objects/enum_schema_item.h" +#include "utils/helpers.h" +#include "utils/optional.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") + +namespace vehicle_info_plugin { + +template <typename T, typename U> +U GetOptional(const rpc::Optional<T>& optional, U def_val) { + return optional.is_initialized() ? static_cast<U>(*optional) : def_val; +} + +enum SearchMethod { RECURSIVE = 0, NON_RECURSIVE }; + +CustomVehicleDataManagerImpl::CustomVehicleDataManagerImpl( + policy::VehicleDataItemProvider& vehicle_data_provider, + application_manager::rpc_service::RPCService& rpc_service) + : vehicle_data_provider_(vehicle_data_provider) + , rpc_service_(rpc_service) {} + +std::string CustomVehicleDataManagerImpl::GetVehicleDataItemType( + const std::string& vehicle_data_item_name) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto& schema = FindSchemaByNameNonRecursive(vehicle_data_item_name); + + return schema.is_initialized() ? std::string(schema->type) + : vehicle_data_item_name; +} + +bool CustomVehicleDataManagerImpl::IsValidCustomVehicleDataName( + const std::string& name) const { + const auto& schema = FindSchemaByNameNonRecursive(name); + return schema.is_initialized(); +} + +bool CustomVehicleDataManagerImpl::IsRemovedCustomVehicleDataName( + const std::string& name) const { + const auto& schema = FindRemovedSchemaByNameNonRecursive(name); + return schema.is_initialized(); +} + +void CustomVehicleDataManagerImpl::CreateMobileMessageParams( + smart_objects::SmartObject& msg_params) { + using namespace application_manager; + LOG4CXX_AUTO_TRACE(logger_); + + typedef std::function<smart_objects::SmartObject( + const smart_objects::SmartObject& input_params, + SearchMethod search_method)> + MobileMsgConstructor; + + MobileMsgConstructor fill_mobile_msg = + [this, &fill_mobile_msg]( + const smart_objects::SmartObject& input_params, + SearchMethod search_method) -> smart_objects::SmartObject { + smart_objects::SmartObject out_params; + + const auto& items = input_params.enumerate(); + for (const auto& key : items) { + auto schema = search_method == SearchMethod::RECURSIVE + ? FindSchemaByKeyRecursive(key) + : FindSchemaByKeyNonRecursive(key); + if (!schema.is_initialized()) { + LOG4CXX_DEBUG(logger_, "Schema for: " << key << " cannot be found"); + continue; + } + + const auto& item_name = schema->name; + if (policy_table::VehicleDataItem::kStruct == std::string(schema->type)) { + auto& input_param = input_params[key]; + if (*schema->array && + input_param.getType() == smart_objects::SmartType_Array) { + for (size_t i = 0; i < input_param.length(); i++) { + const auto param = + fill_mobile_msg(input_param[i], SearchMethod::RECURSIVE); + out_params[item_name][i] = param; + } + continue; + } else { + const auto param = + fill_mobile_msg(input_param, SearchMethod::RECURSIVE); + if (!param.empty()) { + out_params[item_name] = param; + continue; + } + } + } + + out_params[item_name] = input_params[key]; + } + + return out_params; + }; + + const auto& rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + const auto& item_names = msg_params.enumerate(); + smart_objects::SmartObject params_to_convert; + + for (const auto& item_key : item_names) { + const auto& found_it = rpc_spec_vehicle_data.find(item_key); + if (found_it == rpc_spec_vehicle_data.end()) { + params_to_convert[item_key] = msg_params[item_key]; + msg_params.erase(item_key); + } + } + + const auto& mobile_msg_params = + fill_mobile_msg(params_to_convert, SearchMethod::NON_RECURSIVE); + for (const auto& name : mobile_msg_params.enumerate()) { + msg_params[name] = mobile_msg_params[name]; + } +} + +smart_objects::SmartObject CustomVehicleDataManagerImpl::CreateHMIMessageParams( + const std::set<std::string>& item_names) { + typedef std::function<smart_objects::SmartObject( + const policy_table::VehicleDataItem&)> + ParamsConstructor; + + auto fill_param = [](ParamsConstructor& constructor, + const policy_table::VehicleDataItem& param, + smart_objects::SmartObject* out_params) { + DCHECK_OR_RETURN_VOID(out_params) + const auto param_key = std::string(param.key); + const auto param_type = std::string(param.type); + if (policy_table::VehicleDataItem::kStruct == param_type) { + (*out_params)[param_key] = constructor(param); + } else { + (*out_params)[param_key] = true; + } + }; + + ParamsConstructor fill_hmi_params = + [&fill_hmi_params, + fill_param](const policy_table::VehicleDataItem& item) { + smart_objects::SmartObject out_params; + DCHECK(policy_table::VehicleDataItem::kStruct == + std::string(item.type)); + for (auto& param : *(item.params)) { + fill_param(fill_hmi_params, param, &out_params); + } + return out_params; + }; + + smart_objects::SmartObject out_params(smart_objects::SmartType_Map); + for (const auto& name : item_names) { + auto schema = FindSchemaByNameNonRecursive(name); + if (schema.is_initialized()) { + fill_param(fill_hmi_params, *schema, &out_params); + continue; + } + + auto removed_schema = FindRemovedSchemaByNameNonRecursive(name); + if (removed_schema.is_initialized()) { + fill_param(fill_hmi_params, *removed_schema, &out_params); + } + } + + return out_params; +} + +template <typename Comparer> +const OptionalDataItem FindSchema( + const std::vector<policy_table::VehicleDataItem>& oem_items, + SearchMethod search_method, + Comparer comparer) { + LOG4CXX_AUTO_TRACE(logger_); + + std::vector<policy_table::VehicleDataItem> items; + for (const auto& item : oem_items) { + if (comparer(item)) { + items.push_back(item); + } + if (search_method == SearchMethod::RECURSIVE && + policy_table::VehicleDataItem::kStruct == std::string(item.type)) { + auto found_in_params = + FindSchema(*(item.params), search_method, comparer); + if (found_in_params.is_initialized()) { + items.push_back(*found_in_params); + } + } + } + std::sort(items.begin(), + items.end(), + [](const policy_table::VehicleDataItem& left, + const policy_table::VehicleDataItem& right) { + if (!right.since.is_initialized()) { + return false; + } + if (!left.since.is_initialized()) { + return true; + } + const std::string l = *left.since; + const std::string r = *right.since; + return std::stof(l.c_str()) > std::stof(r.c_str()); + }); + + if (!items.empty()) { + return OptionalDataItem(*items.begin()); + } + + return OptionalDataItem(); +} + +void CustomVehicleDataManagerImpl::UpdateVehicleDataItems() { + using namespace ns_smart_device_link::ns_smart_objects; + using namespace policy_table; + + enum class SMemberType { + SMEMBER_MOBILE, + SMEMBER_HMI, + SMEMBER_BOOL_MOBILE, + SMEMBER_BOOL_HMI, + SMEMBER_VDR_MOBILE, + SMEMBER_VDR_HMI + }; + + auto get_custom_vdi = [this]() + -> std::vector<rpc::policy_table_interface_base::VehicleDataItem> { + using namespace rpc::policy_table_interface_base; + std::vector<VehicleDataItem> custom_vehicle_data_items; + auto vehicle_data_items = vehicle_data_provider_.GetVehicleDataItems(); + for (const auto& item : vehicle_data_items) { + policy_table::Parameter parameter_enum; + if (!policy_table::EnumFromJsonString(item.name, ¶meter_enum)) { + custom_vehicle_data_items.push_back(item); + } + } + return custom_vehicle_data_items; + }; + + auto vehicle_data_items = get_custom_vdi(); + + auto get_ischema_item = [](const VehicleDataItem& item, + SMemberType type, + std::vector<SMember> history = {}) -> SMember { + switch (type) { + case SMemberType::SMEMBER_BOOL_MOBILE: { + auto member_schema = + CBoolSchemaItem::create(TSchemaItemParameter<bool>()); + return SMember( + member_schema, + false, // root level items should not be mandatory + item.since.is_initialized() ? std::string(*item.since) : "", + item.until.is_initialized() ? std::string(*item.until) : "", + bool(*item.deprecated), + bool(*item.removed), + history); + } + case SMemberType::SMEMBER_VDR_MOBILE: { + // valid since struct_schema_items is not used in + // InitStructSchemaItem_VehicleDataResult + mobile_apis::MOBILE_API::TStructsSchemaItems mobile_struct_schema_items; + auto member_schema = + mobile_apis::MOBILE_API::InitStructSchemaItem_VehicleDataResult( + mobile_struct_schema_items); + return SMember( + member_schema, + false, // root level items should not be mandatory + item.since.is_initialized() ? std::string(*item.since) : "", + item.until.is_initialized() ? std::string(*item.until) : "", + bool(*item.deprecated), + bool(*item.removed), + history); + } + case SMemberType::SMEMBER_MOBILE: { + TSchemaItemParameter<VehicleDataItem> tschema_item(item); + auto member_schema = VehicleDataItemSchema::create( + tschema_item, VehicleDataItemSchema::SchemaType::MOBILE); + return SMember( + member_schema, + false, // root level items should not be mandatory + item.since.is_initialized() ? std::string(*item.since) : "", + item.until.is_initialized() ? std::string(*item.until) : "", + bool(*item.deprecated), + bool(*item.removed), + history); + } + case SMemberType::SMEMBER_BOOL_HMI: { + auto member_schema = + CBoolSchemaItem::create(TSchemaItemParameter<bool>()); + return SMember(member_schema, + false // root level items should not be mandatory + ); + } + case SMemberType::SMEMBER_VDR_HMI: { + // valid since struct_schema_items is not used in + // InitStructSchemaItem_Common_VehicleDataResult + hmi_apis::HMI_API::TStructsSchemaItems hmi_struct_schema_items; + auto member_schema = + hmi_apis::HMI_API::InitStructSchemaItem_Common_VehicleDataResult( + hmi_struct_schema_items); + return SMember( + member_schema, false // root level items should not be mandatory + ); + } + case SMemberType::SMEMBER_HMI: { + TSchemaItemParameter<VehicleDataItem> tschema_item(item); + auto member_schema = VehicleDataItemSchema::create( + tschema_item, VehicleDataItemSchema::SchemaType::HMI); + return SMember( + member_schema, false // root level items should not be mandatory + ); + } + default: { + auto member_schema = CAlwaysFalseSchemaItem::create(); + return SMember(member_schema, false); + } + } + }; + + auto get_vehicle_data_history = + [&vehicle_data_items](std::string name) -> std::vector<VehicleDataItem> { + std::vector<VehicleDataItem> result; + std::copy_if(vehicle_data_items.begin(), + vehicle_data_items.end(), + std::back_inserter(result), + [&name](VehicleDataItem& item) { return item.name == name; }); + + std::sort(result.begin(), + result.end(), + [](const policy_table::VehicleDataItem& left, + const policy_table::VehicleDataItem& right) { + if (!right.since.is_initialized()) { + return false; + } + if (!left.since.is_initialized()) { + return true; + } + const std::string l = *left.since; + const std::string r = *right.since; + return std::stof(l.c_str()) > std::stof(r.c_str()); + }); + + return result; + }; + + auto get_member_with_history = [&get_ischema_item]( + std::vector<VehicleDataItem> items, + SMemberType type) -> SMember { + std::vector<SMember> history = {}; + std::vector<SMemberType> types{SMemberType::SMEMBER_MOBILE, + SMemberType::SMEMBER_VDR_MOBILE, + SMemberType::SMEMBER_BOOL_MOBILE}; + if (helpers::in_range(types, type) && items.size() > 1) { + auto history_iterator = items.begin() + 1; + for (; history_iterator < items.end(); ++history_iterator) { + const auto& item = (*history_iterator); + history.push_back(get_ischema_item(item, type)); + } + } + + auto latest_item = (*items.begin()); + return get_ischema_item(latest_item, type, history); + }; + + CustomVehicleDataManagerImpl::RPCParams mobile_params; + CustomVehicleDataManagerImpl::RPCParams hmi_params; + + std::set<std::string> vehicle_data_names; + for (const auto& item : vehicle_data_items) { + vehicle_data_names.insert(item.name); + } + + for (const auto& name : vehicle_data_names) { + auto vehicle_data_history = get_vehicle_data_history(name); + const auto& vdi = vehicle_data_history.begin(); + + SMember member_bool_hmi = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_BOOL_HMI); + SMember member_bool_mobile = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_BOOL_MOBILE); + + SMember member_vdr_hmi = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_VDR_HMI); + SMember member_vdr_mobile = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_VDR_MOBILE); + SMember member_hmi = + get_member_with_history(vehicle_data_history, SMemberType::SMEMBER_HMI); + SMember member_mobile = get_member_with_history( + vehicle_data_history, SMemberType::SMEMBER_MOBILE); + + mobile_params.addBoolParam( + std::pair<std::string, SMember>(vdi->name, member_bool_mobile)); + mobile_params.addVDRParam( + std::pair<std::string, SMember>(vdi->name, member_vdr_mobile)); + mobile_params.addParam( + std::pair<std::string, SMember>(vdi->name, member_mobile)); + + hmi_params.addBoolParam( + std::pair<std::string, SMember>(vdi->key, member_bool_hmi)); + hmi_params.addVDRParam( + std::pair<std::string, SMember>(vdi->key, member_vdr_hmi)); + hmi_params.addParam(std::pair<std::string, SMember>(vdi->key, member_hmi)); + } + + std::vector<mobile_apis::FunctionID::eType> mobile_subscribe_functions{ + mobile_apis::FunctionID::SubscribeVehicleDataID, + mobile_apis::FunctionID::UnsubscribeVehicleDataID}; + + for (const auto& function_id : mobile_subscribe_functions) { + rpc_service_.UpdateMobileRPCParams(function_id, + mobile_apis::messageType::request, + mobile_params.getBoolParams()); + rpc_service_.UpdateMobileRPCParams(function_id, + mobile_apis::messageType::response, + mobile_params.getVDRParams()); + } + + std::vector<hmi_apis::FunctionID::eType> hmi_subscribe_functions{ + hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData}; + + for (const auto& function_id : hmi_subscribe_functions) { + rpc_service_.UpdateHMIRPCParams(function_id, + hmi_apis::messageType::request, + hmi_params.getBoolParams()); + rpc_service_.UpdateHMIRPCParams(function_id, + hmi_apis::messageType::response, + hmi_params.getVDRParams()); + } + + rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::GetVehicleDataID, + mobile_apis::messageType::request, + mobile_params.getBoolParams()); + + rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::GetVehicleDataID, + mobile_apis::messageType::response, + mobile_params.getParams()); + + rpc_service_.UpdateMobileRPCParams(mobile_apis::FunctionID::OnVehicleDataID, + mobile_apis::messageType::notification, + mobile_params.getParams()); + + rpc_service_.UpdateHMIRPCParams( + hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + hmi_apis::messageType::request, + hmi_params.getBoolParams()); + + rpc_service_.UpdateHMIRPCParams( + hmi_apis::FunctionID::VehicleInfo_GetVehicleData, + hmi_apis::messageType::response, + hmi_params.getParams()); + + rpc_service_.UpdateHMIRPCParams( + hmi_apis::FunctionID::VehicleInfo_OnVehicleData, + hmi_apis::messageType::notification, + hmi_params.getParams()); +} + +void CustomVehicleDataManagerImpl::OnPolicyEvent( + plugin_manager::PolicyEvent policy_event) { + using namespace plugin_manager; + LOG4CXX_AUTO_TRACE(logger_); + + switch (policy_event) { + case kApplicationPolicyUpdated: + UpdateVehicleDataItems(); + break; + case kApplicationsDisabled: + default: + return; + } +} + +const OptionalDataItem +CustomVehicleDataManagerImpl::FindSchemaByNameNonRecursive( + const std::string& name) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) { + return (name == std::string(item.name)); + }; + + return FindSchema(oem_items, SearchMethod::NON_RECURSIVE, compare_by_name); +} + +const OptionalDataItem +CustomVehicleDataManagerImpl::FindRemovedSchemaByNameNonRecursive( + const std::string& name) const { + LOG4CXX_AUTO_TRACE(logger_); + + const auto& removed_oem_items = + vehicle_data_provider_.GetRemovedVehicleDataItems(); + auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) { + return (name == std::string(item.name)); + }; + + return FindSchema( + removed_oem_items, SearchMethod::NON_RECURSIVE, compare_by_name); +} + +const OptionalDataItem CustomVehicleDataManagerImpl::FindSchemaByNameRecursive( + const std::string& name) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_name = [&name](const policy_table::VehicleDataItem& item) { + return (name == std::string(item.name)); + }; + + return FindSchema(oem_items, SearchMethod::RECURSIVE, compare_by_name); +} + +const OptionalDataItem +CustomVehicleDataManagerImpl::FindSchemaByKeyNonRecursive( + const std::string& key) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_key = [&key](const policy_table::VehicleDataItem& item) { + return (key == std::string(item.key)); + }; + + return FindSchema(oem_items, SearchMethod::NON_RECURSIVE, compare_by_key); +} + +const OptionalDataItem CustomVehicleDataManagerImpl::FindSchemaByKeyRecursive( + const std::string& key) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto& oem_items = vehicle_data_provider_.GetVehicleDataItems(); + auto compare_by_key = [&key](const policy_table::VehicleDataItem& item) { + return (key == std::string(item.key)); + }; + + return FindSchema(oem_items, SearchMethod::RECURSIVE, compare_by_key); +} + +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc new file mode 100644 index 0000000000..750da9fa6e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_data_item_schema.cc @@ -0,0 +1,188 @@ +#include "vehicle_info_plugin/vehicle_data_item_schema.h" +#include <limits> + +namespace vehicle_info_plugin { + +#ifdef ENABLE_LOG +CREATE_LOGGERPTR_LOCAL(vehicle_data_logger, "VehicleDataItemSchema"); +#endif // ENABLE_LOG + +VehicleDataItemSchema::VehicleDataItemSchema(PolicyDataItem& policy_item, + SchemaType schema_type) { + policy_table::VehicleDataItem policy_data_item; + policy_item.getValue(policy_data_item); + + auto get_object_schema = [&policy_data_item, + &schema_type]() -> decltype(so_schema_item_) { + smart_objects::Members members; + auto object_schema = smart_objects::CObjectSchemaItem::create(members); + + for (auto& e : *policy_data_item.params) { + auto schema_item = PolicyDataItem(e); + smart_objects::SMember member(create(schema_item, schema_type), + bool(e.mandatory), + std::string(*e.since), + std::string(*e.until), + bool(*e.deprecated), + bool(*e.removed)); + std::string name; + switch (schema_type) { + case VehicleDataItemSchema::SchemaType::HMI: + name = e.key; + break; + case VehicleDataItemSchema::SchemaType::MOBILE: + default: + name = e.name; + break; + } + object_schema->AddMemberSchemaItem(name, member); + } + + return object_schema; + }; + + auto get_schema = [&policy_data_item, + &get_object_schema, + &schema_type, + this]() -> decltype(so_schema_item_) { + // Check if policy item has POD type + if (isPODType(policy_data_item.type)) { + return GetPODTypeSchema(policy_data_item, schema_type); + } + + // Check if policy item has Struct type + if (policy_data_item.type == policy_table::VehicleDataItem::kStruct) { + return get_object_schema(); + } + + // Check if policy item has Enum type + auto enum_schema = getEnumSchema(policy_data_item.type); + if (enum_schema != nullptr) { + return enum_schema; + } + + // If an unknown type is present in the policy table, it is assumed that it + // is a future enum type. Since normal validation cannot be performed on + // this value, it is treated as a raw string instead + policy_data_item.type = "String"; + + return GetPODTypeSchema(policy_data_item, schema_type); + }; + + if (*policy_data_item.array) { + so_schema_item_ = smart_objects::CArraySchemaItem::create( + get_schema(), + policy_data_item.minsize.is_initialized() + ? smart_objects::TSchemaItemParameter<size_t>( + *policy_data_item.minsize) + : smart_objects::TSchemaItemParameter<size_t>(), + policy_data_item.maxsize.is_initialized() + ? smart_objects::TSchemaItemParameter<size_t>( + *policy_data_item.maxsize) + : smart_objects::TSchemaItemParameter<size_t>()); + } else { + so_schema_item_ = get_schema(); + } +} + +VehicleDataItemSchemaPtr VehicleDataItemSchema::create( + PolicyDataItem& policy_item, SchemaType schema_type) { + return VehicleDataItemSchemaPtr( + new VehicleDataItemSchema(policy_item, schema_type)); +} + +smart_objects::errors::eType +vehicle_info_plugin::VehicleDataItemSchema::validate( + const smart_objects::SmartObject& Object, + rpc::ValidationReport* report__, + const utils::SemanticVersion& MessageVersion, + const bool allow_unknown_enums) { + if (!so_schema_item_) { + std::string validation_info = + "Invalid type: " + + smart_objects::SmartObject::typeToString(Object.getType()); + report__->set_validation_info(validation_info); + return smart_objects::errors::eType::ERROR; + } + + return so_schema_item_->validate( + Object, report__, MessageVersion, allow_unknown_enums); +} + +smart_objects::ISchemaItemPtr VehicleDataItemSchema::GetPODTypeSchema( + const policy_table::VehicleDataItem& policy_item, SchemaType schema_type) { + using IntSchemaItem = smart_objects::TNumberSchemaItem<int64_t>; + using IntItemParam = smart_objects::TSchemaItemParameter<int64_t>; + using FloatSchemaItem = smart_objects::TNumberSchemaItem<double>; + using FloatItemParam = smart_objects::TSchemaItemParameter<double>; + using StringSchemaItem = smart_objects::CStringSchemaItem; + using StringItemParam = smart_objects::TSchemaItemParameter<size_t>; + using BoolSchemaItem = smart_objects::CBoolSchemaItem; + using BoolItemParam = smart_objects::TSchemaItemParameter<bool>; + + if (policy_item.type == policy_table::VehicleDataItem::kInteger) { + return IntSchemaItem::create(policy_item.minvalue.is_initialized() + ? IntItemParam(*policy_item.minvalue) + : IntItemParam(), + policy_item.maxvalue.is_initialized() + ? IntItemParam(*policy_item.maxvalue) + : IntItemParam()); + } + if (policy_item.type == policy_table::VehicleDataItem::kFloat || + policy_item.type == policy_table::VehicleDataItem::kDouble) { + return FloatSchemaItem::create( + policy_item.minvalue.is_initialized() + ? FloatItemParam(double(*policy_item.minvalue)) + : FloatItemParam(), + policy_item.maxvalue.is_initialized() + ? FloatItemParam(double(*policy_item.maxvalue)) + : FloatItemParam()); + } + if (policy_item.type == policy_table::VehicleDataItem::kString) { + return StringSchemaItem::create( + StringItemParam(policy_item.minlength.is_initialized() + ? *policy_item.minlength + : 0), + policy_item.maxlength.is_initialized() + ? StringItemParam(*policy_item.maxlength) + : StringItemParam()); + } + if (policy_item.type == policy_table::VehicleDataItem::kBoolean) { + return BoolSchemaItem::create(BoolItemParam(true)); + } + + std::string error_msg = std::string("Invalid POD type provided: ") + + std::string(policy_item.type); + LOG4CXX_ERROR(vehicle_data_logger, error_msg.c_str()); + return nullptr; +} + +const bool VehicleDataItemSchema::isPODType( + const std::string& type_name) const { + return std::find(policy_table::VehicleDataItem::kPODTypes.begin(), + policy_table::VehicleDataItem::kPODTypes.end(), + type_name) != policy_table::VehicleDataItem::kPODTypes.end(); +} + +smart_objects::ISchemaItemPtr VehicleDataItemSchema::getEnumSchema( + const std::string& type_name) const { + auto enum_schema = policy_table::EnumSchemaItemFactory::Get(type_name); + if (!enum_schema) { + LOG4CXX_ERROR(vehicle_data_logger, "NULL pointer: " << type_name); + } + return enum_schema; +} + +void VehicleDataItemSchema::applySchema( + smart_objects::SmartObject& Object, + const bool remove_unknown_parameters, + const utils::SemanticVersion& MessageVersion) { + so_schema_item_->applySchema( + Object, remove_unknown_parameters, MessageVersion); +} + +void VehicleDataItemSchema::unapplySchema( + smart_objects::SmartObject& Object, const bool remove_unknown_parameters) { + so_schema_item_->unapplySchema(Object, remove_unknown_parameters); +} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc index 3b1d411841..149299d3bb 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_app_extension.cc @@ -53,13 +53,13 @@ VehicleInfoAppExtension::~VehicleInfoAppExtension() { } bool VehicleInfoAppExtension::subscribeToVehicleInfo( - const VehicleDataType vehicle_data) { + const std::string& vehicle_data) { LOG4CXX_DEBUG(logger_, vehicle_data); return subscribed_data_.insert(vehicle_data).second; } bool VehicleInfoAppExtension::unsubscribeFromVehicleInfo( - const VehicleDataType vehicle_data) { + const std::string& vehicle_data) { LOG4CXX_DEBUG(logger_, vehicle_data); auto it = subscribed_data_.find(vehicle_data); if (it != subscribed_data_.end()) { @@ -75,7 +75,7 @@ void VehicleInfoAppExtension::unsubscribeFromVehicleInfo() { } bool VehicleInfoAppExtension::isSubscribedToVehicleInfo( - const VehicleDataType vehicle_data) const { + const std::string& vehicle_data) const { LOG4CXX_DEBUG(logger_, vehicle_data); return subscribed_data_.find(vehicle_data) != subscribed_data_.end(); } @@ -91,7 +91,7 @@ void VehicleInfoAppExtension::SaveResumptionData( smart_objects::SmartObject(smart_objects::SmartType_Array); int i = 0; for (const auto& subscription : subscribed_data_) { - resumption_data[application_vehicle_info][i] = subscription; + resumption_data[application_vehicle_info][i++] = subscription; } } @@ -99,13 +99,12 @@ void VehicleInfoAppExtension::ProcessResumption( const smart_objects::SmartObject& resumption_data) { const char* application_vehicle_info = "vehicleInfo"; if (resumption_data.keyExists(application_vehicle_info)) { - const smart_objects::SmartObject& subscriptions_ivi = - resumption_data[application_vehicle_info]; - for (size_t i = 0; i < subscriptions_ivi.length(); ++i) { - mobile_apis::VehicleDataType::eType ivi = - static_cast<mobile_apis::VehicleDataType::eType>( - (resumption_data[i]).asInt()); - subscribeToVehicleInfo(ivi); + const auto* subscriptions_ivi = + resumption_data[application_vehicle_info].asArray(); + if (subscriptions_ivi) { + for (const auto& ivi : (*subscriptions_ivi)) { + subscribeToVehicleInfo(ivi.asString()); + } } plugin_.ProcessResumptionSubscription(app_, *this); } @@ -122,4 +121,4 @@ VehicleInfoAppExtension& VehicleInfoAppExtension::ExtractVIExtension( DCHECK(vi_app_extension); return *vi_app_extension; } -} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc index 0c6e0a07b1..52ee9f476d 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_command_factory.cc @@ -36,15 +36,27 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { +namespace app_mngr = application_manager; +namespace commands = application_manager::commands; + VehicleInfoCommandFactory::VehicleInfoCommandFactory( app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : hmi_command_factory_(new VehicleInfoHmiCommandFactory( - application_manager, rpc_service, hmi_capabilities, policy_handler)) - , mob_command_factory_(new VehicleInfoMobileCommandFactory( - application_manager, rpc_service, hmi_capabilities, policy_handler)) { + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager) + : hmi_command_factory_( + new VehicleInfoHmiCommandFactory(application_manager, + rpc_service, + hmi_capabilities, + policy_handler, + custom_vehicle_data_manager)) + , mob_command_factory_( + new VehicleInfoMobileCommandFactory(application_manager, + rpc_service, + hmi_capabilities, + policy_handler, + custom_vehicle_data_manager)) { LOG4CXX_AUTO_TRACE(logger_); } @@ -69,4 +81,4 @@ bool VehicleInfoCommandFactory::IsAbleToProcess( ? hmi_command_factory_->IsAbleToProcess(function_id, source) : mob_command_factory_->IsAbleToProcess(function_id, source); } -} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc index 9311cea6d7..e8d852b612 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc @@ -41,6 +41,8 @@ #include "vehicle_info_plugin/commands/hmi/vi_get_dtcs_response.h" #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_request.h" #include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_data_response.h" +#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h" +#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h" #include "vehicle_info_plugin/commands/hmi/vi_is_ready_request.h" #include "vehicle_info_plugin/commands/hmi/vi_is_ready_response.h" #include "vehicle_info_plugin/commands/hmi/vi_read_did_request.h" @@ -49,23 +51,81 @@ #include "vehicle_info_plugin/commands/hmi/vi_subscribe_vehicle_data_response.h" #include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h" #include "vehicle_info_plugin/commands/hmi/vi_unsubscribe_vehicle_data_response.h" -#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_request.h" -#include "vehicle_info_plugin/commands/hmi/vi_get_vehicle_type_response.h" CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { namespace strings = app_mngr::strings; +template <typename VehicleInfoCommandType> +class VehicleInfoCommandCreator : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) + : params_(params) {} + + private: + bool CanBeCreated() const override { + return true; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + application_manager::CommandSharedPtr command( + new VehicleInfoCommandType(message, params_)); + return command; + } + + VehicleInfoCommandParams params_; +}; + +struct VehicleInfoInvalidCommand {}; + +template <> +class VehicleInfoCommandCreator<VehicleInfoInvalidCommand> + : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { + UNUSED(params); + } + + private: + bool CanBeCreated() const override { + return false; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + UNUSED(message); + return application_manager::CommandSharedPtr(); + } +}; + +struct VehicleInfoCommandCreatorFactory { + VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params) + : params_(params) {} + + template <typename VehicleInfoCommandType> + application_manager::CommandCreator& GetCreator() { + LOG4CXX_AUTO_TRACE(logger_); + static VehicleInfoCommandCreator<VehicleInfoCommandType> res(params_); + return res; + } + const VehicleInfoCommandParams params_; +}; + VehicleInfoHmiCommandFactory::VehicleInfoHmiCommandFactory( application_manager::ApplicationManager& application_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager) : application_manager_(application_manager) , rpc_service_(rpc_service) , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) { + , policy_handler_(policy_handler) + , custom_vehicle_data_manager_(custom_vehicle_data_manager) { LOG4CXX_AUTO_TRACE(logger_); } @@ -107,9 +167,12 @@ bool VehicleInfoHmiCommandFactory::IsAbleToProcess( app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator( const int32_t function_id, const int32_t message_type) const { - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); - + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); switch (function_id) { case hmi_apis::FunctionID::VehicleInfo_GetVehicleType: return hmi_apis::messageType::request == message_type @@ -150,7 +213,7 @@ app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator( : factory.GetCreator<commands::VIDiagnosticMessageResponse>(); default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); - return factory.GetCreator<app_mngr::InvalidCommand>(); + return factory.GetCreator<VehicleInfoInvalidCommand>(); } } -} +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc index 41ecd451dd..c3c8d9c8d7 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc @@ -34,6 +34,9 @@ #include "application_manager/message.h" #include "interfaces/MOBILE_API.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" + +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" #include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" #include "vehicle_info_plugin/commands/mobile/diagnostic_message_response.h" @@ -54,21 +57,83 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace vehicle_info_plugin { namespace strings = app_mngr::strings; +template <typename VehicleInfoCommandType> +class VehicleInfoCommandCreator : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) + : params_(params) {} + + private: + bool CanBeCreated() const override { + return true; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + application_manager::CommandSharedPtr command( + new VehicleInfoCommandType(message, params_)); + return command; + } + + VehicleInfoCommandParams params_; +}; + +struct VehicleInfoInvalidCommand {}; + +template <> +class VehicleInfoCommandCreator<VehicleInfoInvalidCommand> + : public application_manager::CommandCreator { + public: + VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { + UNUSED(params); + } + + private: + bool CanBeCreated() const override { + return false; + } + + application_manager::CommandSharedPtr create( + const application_manager::commands::MessageSharedPtr& message) + const override { + UNUSED(message); + return application_manager::CommandSharedPtr(); + } +}; + +struct VehicleInfoCommandCreatorFactory { + VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params) + : params_(params) {} + + template <typename VehicleInfoCommandType> + application_manager::CommandCreator& GetCreator() { + LOG4CXX_AUTO_TRACE(logger_); + static VehicleInfoCommandCreator<VehicleInfoCommandType> res(params_); + return res; + } + const VehicleInfoCommandParams params_; +}; + VehicleInfoMobileCommandFactory::VehicleInfoMobileCommandFactory( application_manager::ApplicationManager& application_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + CustomVehicleDataManager& custom_vehicle_data_manager) : application_manager_(application_manager) , rpc_service_(rpc_service) , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) { + , policy_handler_(policy_handler) + , custom_vehicle_data_manager_(custom_vehicle_data_manager) { LOG4CXX_AUTO_TRACE(logger_); } app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) { + UNUSED(source); + const mobile_apis::FunctionID::eType function_id = static_cast<mobile_apis::FunctionID::eType>( (*message)[strings::params][strings::function_id].asInt()); @@ -105,8 +170,12 @@ bool VehicleInfoMobileCommandFactory::IsAbleToProcess( app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator( const mobile_apis::FunctionID::eType id, const mobile_apis::messageType::eType message_type) const { - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); switch (id) { case mobile_apis::FunctionID::GetVehicleDataID: { return mobile_apis::messageType::request == message_type @@ -141,21 +210,25 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_command_creator( } default: {} } - return factory.GetCreator<app_mngr::InvalidCommand>(); + return factory.GetCreator<VehicleInfoInvalidCommand>(); } app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_notification_creator( const mobile_apis::FunctionID::eType id) const { - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); switch (id) { case mobile_apis::FunctionID::OnVehicleDataID: { return factory.GetCreator<commands::OnVehicleDataNotification>(); } default: {} } - return factory.GetCreator<app_mngr::InvalidCommand>(); + return factory.GetCreator<VehicleInfoInvalidCommand>(); } app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory( @@ -183,8 +256,12 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::get_creator_factory( } default: {} } - auto factory = app_mngr::CommandCreatorFactory( - application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); - return factory.GetCreator<app_mngr::InvalidCommand>(); -} + VehicleInfoCommandParams params = {application_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + custom_vehicle_data_manager_}; + auto factory = VehicleInfoCommandCreatorFactory(params); + return factory.GetCreator<VehicleInfoInvalidCommand>(); } +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc index c9e9839929..40da7501c1 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_plugin.cc @@ -31,18 +31,20 @@ */ #include "vehicle_info_plugin/vehicle_info_plugin.h" -#include "vehicle_info_plugin/vehicle_info_command_factory.h" -#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "application_manager/message_helper.h" #include "application_manager/plugin_manager/plugin_keys.h" +#include "application_manager/rpc_handler.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/message_helper.h" -#include "application_manager/message_helper.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_command_factory.h" namespace vehicle_info_plugin { CREATE_LOGGERPTR_GLOBAL(logger_, "VehicleInfoPlugin") namespace strings = application_manager::strings; namespace plugins = application_manager::plugin_manager; +namespace commands = application_manager::commands; VehicleInfoPlugin::VehicleInfoPlugin() : application_manager_(nullptr) {} @@ -50,10 +52,18 @@ bool VehicleInfoPlugin::Init( application_manager::ApplicationManager& app_manager, application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) { + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) { + UNUSED(last_state); application_manager_ = &app_manager; + custom_vehicle_data_manager_.reset( + new CustomVehicleDataManagerImpl(policy_handler, rpc_service)); command_factory_.reset(new vehicle_info_plugin::VehicleInfoCommandFactory( - app_manager, rpc_service, hmi_capabilities, policy_handler)); + app_manager, + rpc_service, + hmi_capabilities, + policy_handler, + *(custom_vehicle_data_manager_.get()))); return true; } @@ -70,7 +80,10 @@ app_mngr::CommandFactory& VehicleInfoPlugin::GetCommandFactory() { return *command_factory_; } -void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) {} +void VehicleInfoPlugin::OnPolicyEvent(plugins::PolicyEvent event) { + UnsubscribeFromRemovedVDItems(); + custom_vehicle_data_manager_->OnPolicyEvent(event); +} void VehicleInfoPlugin::OnApplicationEvent( plugins::ApplicationEvent event, @@ -78,11 +91,49 @@ void VehicleInfoPlugin::OnApplicationEvent( if (plugins::ApplicationEvent::kApplicationRegistered == event) { application->AddExtension( std::make_shared<VehicleInfoAppExtension>(*this, *application)); - } else if (plugins::ApplicationEvent::kDeleteApplicationData == event) { + } else if ((plugins::ApplicationEvent::kDeleteApplicationData == event) || + (plugins::ApplicationEvent::kApplicationUnregistered == event)) { DeleteSubscriptions(application); } } +void VehicleInfoPlugin::UnsubscribeFromRemovedVDItems() { + typedef std::vector<std::string> StringsVector; + + auto get_items_to_unsubscribe = [this]() -> StringsVector { + StringsVector output_items_list; + auto applications = application_manager_->applications(); + for (auto& app : applications.GetData()) { + auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); + auto subscription_names = ext.Subscriptions(); + for (auto& subscription_name : subscription_names) { + if (custom_vehicle_data_manager_->IsRemovedCustomVehicleDataName( + subscription_name)) { + ext.unsubscribeFromVehicleInfo(subscription_name); + if (!helpers::in_range(output_items_list, subscription_name)) { + LOG4CXX_DEBUG(logger_, + "Vehicle data item " + << subscription_name + << " has been removed by policy"); + output_items_list.push_back(subscription_name); + } + } + } + } + return output_items_list; + }; + + const StringsVector items_to_unsubscribe = get_items_to_unsubscribe(); + + if (items_to_unsubscribe.empty()) { + LOG4CXX_DEBUG(logger_, "There is no data to unsubscribe"); + return; + } + + auto message = GetUnsubscribeIVIRequest(items_to_unsubscribe); + application_manager_->GetRPCService().ManageHMICommand(message); +} + void VehicleInfoPlugin::ProcessResumptionSubscription( application_manager::Application& app, VehicleInfoAppExtension& ext) { LOG4CXX_AUTO_TRACE(logger_); @@ -90,13 +141,15 @@ void VehicleInfoPlugin::ProcessResumptionSubscription( smart_objects::SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = app.app_id(); const auto& subscriptions = ext.Subscriptions(); - for (auto& ivi_data : application_manager::MessageHelper::vehicle_data()) { - mobile_apis::VehicleDataType::eType type_id = ivi_data.second; - if (subscriptions.end() != subscriptions.find(type_id)) { - std::string key_name = ivi_data.first; - msg_params[key_name] = true; - } + if (subscriptions.empty()) { + LOG4CXX_DEBUG(logger_, "No vehicle data to subscribe. Exiting"); + return; } + + for (const auto& item : subscriptions) { + msg_params[item] = true; + } + smart_objects::SmartObjectSPtr request = application_manager::MessageHelper::CreateModuleInfoSO( hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, @@ -106,38 +159,56 @@ void VehicleInfoPlugin::ProcessResumptionSubscription( } application_manager::ApplicationSharedPtr FindAppSubscribedToIVI( - mobile_apis::VehicleDataType::eType ivi_data, + const std::string& ivi_name, application_manager::ApplicationManager& app_mngr) { auto applications = app_mngr.applications(); for (auto& app : applications.GetData()) { auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); - if (ext.isSubscribedToVehicleInfo(ivi_data)) { + if (ext.isSubscribedToVehicleInfo(ivi_name)) { return app; } } return application_manager::ApplicationSharedPtr(); } -smart_objects::SmartObjectSPtr GetUnsubscribeIVIRequest( - int32_t ivi_id, application_manager::ApplicationManager& app_mngr) { +smart_objects::SmartObjectSPtr VehicleInfoPlugin::GetUnsubscribeIVIRequest( + const std::vector<std::string>& ivi_names) { + LOG4CXX_AUTO_TRACE(logger_); using namespace smart_objects; - auto find_ivi_name = [ivi_id]() { + auto msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + + auto find_ivi_name = [](const std::string& ivi_name) { for (auto item : application_manager::MessageHelper::vehicle_data()) { - if (ivi_id == item.second) { + if (ivi_name == item.first) { return item.first; } } return std::string(); }; - std::string key_name = find_ivi_name(); - DCHECK_OR_RETURN(!key_name.empty(), smart_objects::SmartObjectSPtr()); - auto msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params[key_name] = true; + + for (const auto& ivi_name : ivi_names) { + // try to find the name in vehicle data types + std::string key_name = find_ivi_name(ivi_name); + + if (key_name.empty()) { + // the name hasn't been found in vehicle data types + if (custom_vehicle_data_manager_->IsValidCustomVehicleDataName( + ivi_name) || + custom_vehicle_data_manager_->IsRemovedCustomVehicleDataName( + ivi_name)) { + key_name = ivi_name; + } + } + + DCHECK_OR_RETURN(!key_name.empty(), smart_objects::SmartObjectSPtr()); + msg_params[key_name] = true; + } auto message = application_manager::MessageHelper::CreateMessageForHMI( - hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); + hmi_apis::messageType::request, + application_manager_->GetNextHMICorrelationID()); DCHECK(message); SmartObject& object = *message; @@ -152,18 +223,31 @@ void VehicleInfoPlugin::DeleteSubscriptions( application_manager::ApplicationSharedPtr app) { auto& ext = VehicleInfoAppExtension::ExtractVIExtension(*app); auto subscriptions = ext.Subscriptions(); + std::vector<std::string> ivi_to_unsubscribe; for (auto& ivi : subscriptions) { ext.unsubscribeFromVehicleInfo(ivi); auto still_subscribed_app = FindAppSubscribedToIVI(ivi, *application_manager_); if (!still_subscribed_app) { - auto message = GetUnsubscribeIVIRequest(ivi, *application_manager_); - application_manager_->GetRPCService().ManageHMICommand(message); + ivi_to_unsubscribe.push_back(ivi); } } + + if (!ivi_to_unsubscribe.empty()) { + auto message = GetUnsubscribeIVIRequest(ivi_to_unsubscribe); + application_manager_->GetRPCService().ManageHMICommand(message); + } } -} +} // namespace vehicle_info_plugin -extern "C" application_manager::plugin_manager::RPCPlugin* Create() { +extern "C" __attribute__((visibility("default"))) +application_manager::plugin_manager::RPCPlugin* +Create() { return new vehicle_info_plugin::VehicleInfoPlugin(); } + +extern "C" __attribute__((visibility("default"))) void Delete( + application_manager::plugin_manager::RPCPlugin* data) { + delete data; + DELETE_THREAD_LOGGER(vehicle_info_plugin::logger_); +} diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt index 3ea4a50a8a..95d49f9a20 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt @@ -31,21 +31,26 @@ include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) include_directories( + include ${GMOCK_INCLUDE_DIRECTORY} ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include - ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/ + ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands ${COMPONENTS_DIR}/application_manager/test/include/ -) - - + ${COMPONENTS_DIR}/include/test/application_manager/ + ) set(COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) file(GLOB SOURCES ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc ${COMPONENTS_DIR}/application_manager/test/mock_application_helper.cc ${COMPONENTS_DIR}/application_manager/src/smart_object_keys.cc + ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/types.cc + ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/validation.cc + ${COMPONENTS_DIR}/${POLICY_PATH}/src/policy_table/enums.cc ${COMMANDS_TEST_DIR}/hmi/* ${COMMANDS_TEST_DIR}/mobile/* + ${CMAKE_CURRENT_SOURCE_DIR}/custom_vehicle_data_manager_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/vehicle_data_item_schema_test.cc ${COMPONENTS_DIR}/application_manager/src/message.cc ${COMPONENTS_DIR}/application_manager/src/event_engine/* ) @@ -58,6 +63,8 @@ set(LIBRARIES MOBILE_API connectionHandler vehicle_info_plugin + SmartObjects + formatters jsoncpp ) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc new file mode 100644 index 0000000000..6bc956f65f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_request_test.cc @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/vi_get_vehicle_data_request.h" + +#include "gtest/gtest.h" + +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vi_get_vehicle_data_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +using vehicle_info_plugin::commands::VIGetVehicleDataRequest; + +namespace { +const std::string kMobileParam = "mobile_param"; +const std::string kHMIParam = "hmi_param"; +} // namespace + +class VIGetVehicleDataRequestTest + : public VICommandRequestTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P(EqualMsgParams, msg_params, "") { + using namespace app_mngr; + auto message = static_cast<smart_objects::SmartObject>(*arg); + if (!message.keyExists(strings::msg_params)) { + return false; + } + + return msg_params == message[strings::msg_params]; +} + +TEST_F(VIGetVehicleDataRequestTest, Run_Success) { + using namespace app_mngr; + auto command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::rpm] = true; + (*command_msg)[strings::msg_params][kMobileParam] = true; + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + std::string oem_vehicle_data_type_str; + smart_objects::EnumConversionHelper<mobile_apis::VehicleDataType::eType>:: + EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, + &oem_vehicle_data_type_str); + + smart_objects::SmartObject hmi_params; + hmi_params[kHMIParam] = smart_objects::SmartType_Map; + hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(hmi_params)); + + smart_objects::SmartObject hmi_request_msg; + hmi_request_msg[strings::rpm] = + (*command_msg)[strings::msg_params][strings::rpm]; + hmi_request_msg[kHMIParam] = hmi_params[kHMIParam]; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(EqualMsgParams(hmi_request_msg))); + + auto command = CreateCommandVI<VIGetVehicleDataRequest>(command_msg); + command->Run(); +} + +} // namespace vi_get_vehicle_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc index 0508f0cdd6..45bc748df4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc @@ -36,17 +36,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/application.h" +#include "application_manager/event_engine/event.h" #include "application_manager/message_helper.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/event_engine/event.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" #include "hmi/vi_get_vehicle_data_response.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" namespace test { namespace components { @@ -61,9 +61,9 @@ namespace am = ::application_manager; namespace strings = ::application_manager::strings; namespace hmi_response = am::hmi_response; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::VIGetVehicleDataResponse; using am::event_engine::Event; using test::components::event_engine_test::MockEventDispatcher; +using vehicle_info_plugin::commands::VIGetVehicleDataResponse; typedef std::shared_ptr<VIGetVehicleDataResponse> VIGetVehicleDataResponsePtr; @@ -74,7 +74,7 @@ const std::string kStrNumber = "123"; } // namespace class VIGetVehicleDataResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; + : public VICommandsTest<CommandsTestMocks::kIsNice> {}; TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); @@ -84,7 +84,7 @@ TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) { hmi_apis::messageType::response; VIGetVehicleDataResponsePtr command( - CreateCommand<VIGetVehicleDataResponse>(command_msg)); + CreateCommandVI<VIGetVehicleDataResponse>(command_msg)); am::event_engine::Event event( hmi_apis::FunctionID::VehicleInfo_GetVehicleData); @@ -132,7 +132,7 @@ TEST_F(VIGetVehicleDataResponseTest, ErrorResponse_SUCCESS) { (*command_msg)[strings::params][strings::protocol_version]; VIGetVehicleDataResponsePtr command( - CreateCommand<VIGetVehicleDataResponse>(command_msg)); + CreateCommandVI<VIGetVehicleDataResponse>(command_msg)); am::event_engine::Event event( hmi_apis::FunctionID::VehicleInfo_GetVehicleData); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc index 679d9d0e58..c083bf4d60 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_is_ready_request_test.cc @@ -34,16 +34,16 @@ #include "gtest/gtest.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/event_engine/event.h" #include "application_manager/hmi_interfaces.h" -#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_hmi_interface.h" #include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" namespace test { namespace components { @@ -52,19 +52,19 @@ namespace hmi_commands_test { namespace vi_is_ready_request { using ::testing::_; -using ::testing::ReturnRef; using ::testing::Return; +using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::VIIsReadyRequest; using am::event_engine::Event; +using vehicle_info_plugin::commands::VIIsReadyRequest; typedef std::shared_ptr<VIIsReadyRequest> VIIsReadyRequestPtr; class VIIsReadyRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { + : public VICommandRequestTest<CommandsTestMocks::kIsNice> { public: - VIIsReadyRequestTest() : command_(CreateCommand<VIIsReadyRequest>()) {} + VIIsReadyRequestTest() : command_(CreateCommandVI<VIIsReadyRequest>()) {} void SetUpExpectations(bool is_vi_cooperating_available, bool is_send_message_to_hmi, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc new file mode 100644 index 0000000000..fbaabfed06 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_subscribe_vehicle_data_request_test.cc @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/vi_subscribe_vehicle_data_request.h" + +#include "gtest/gtest.h" + +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vi_subscribe_vehicle_data_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +using vehicle_info_plugin::commands::VISubscribeVehicleDataRequest; + +namespace { +const std::string kMobileParam = "mobile_param"; +const std::string kHMIParam = "hmi_param"; +} // namespace + +class VISubscribeVehicleDataRequestTest + : public VICommandRequestTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P(EqualMsgParams, msg_params, "") { + using namespace app_mngr; + auto message = static_cast<smart_objects::SmartObject>(*arg); + if (!message.keyExists(strings::msg_params)) { + return false; + } + + return msg_params == message[strings::msg_params]; +} + +TEST_F(VISubscribeVehicleDataRequestTest, Run_Success) { + using namespace app_mngr; + auto command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::rpm] = true; + (*command_msg)[strings::msg_params][kMobileParam] = true; + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + std::string oem_vehicle_data_type_str; + smart_objects::EnumConversionHelper<mobile_apis::VehicleDataType::eType>:: + EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, + &oem_vehicle_data_type_str); + + smart_objects::SmartObject hmi_params; + hmi_params[kHMIParam] = smart_objects::SmartType_Map; + hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(hmi_params)); + + smart_objects::SmartObject hmi_request_msg; + hmi_request_msg[strings::rpm] = + (*command_msg)[strings::msg_params][strings::rpm]; + hmi_request_msg[kHMIParam] = hmi_params[kHMIParam]; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(EqualMsgParams(hmi_request_msg))); + + auto command = CreateCommandVI<VISubscribeVehicleDataRequest>(command_msg); + command->Run(); +} + +} // namespace vi_subscribe_vehicle_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc new file mode 100644 index 0000000000..2ce04aa21a --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/hmi/vi_unsubscribe_vehicle_data_request_test.cc @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/vi_unsubscribe_vehicle_data_request.h" + +#include "gtest/gtest.h" + +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" + +namespace test { +namespace components { +namespace commands_test { +namespace hmi_commands_test { +namespace vi_unsubscribe_vehicle_data_request { + +using ::testing::_; +using ::testing::Return; +using ::testing::ReturnRef; + +using vehicle_info_plugin::commands::VIUnsubscribeVehicleDataRequest; + +namespace { +const std::string kMobileParam = "mobile_param"; +const std::string kHMIParam = "hmi_param"; +} // namespace + +class VIUnsubscribeVehicleDataRequestTest + : public VICommandRequestTest<CommandsTestMocks::kIsNice> {}; + +MATCHER_P(EqualMsgParams, msg_params, "") { + using namespace app_mngr; + auto message = static_cast<smart_objects::SmartObject>(*arg); + if (!message.keyExists(strings::msg_params)) { + return false; + } + + return msg_params == message[strings::msg_params]; +} + +TEST_F(VIUnsubscribeVehicleDataRequestTest, Run_Success) { + using namespace app_mngr; + auto command_msg = CreateMessage(smart_objects::SmartType_Map); + (*command_msg)[strings::msg_params][strings::rpm] = true; + (*command_msg)[strings::msg_params][kMobileParam] = true; + + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + std::string oem_vehicle_data_type_str; + smart_objects::EnumConversionHelper<mobile_apis::VehicleDataType::eType>:: + EnumToString(mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA, + &oem_vehicle_data_type_str); + + smart_objects::SmartObject hmi_params; + hmi_params[kHMIParam] = smart_objects::SmartType_Map; + hmi_params[kHMIParam][strings::data_type] = oem_vehicle_data_type_str; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(hmi_params)); + + smart_objects::SmartObject hmi_request_msg; + hmi_request_msg[strings::rpm] = true; + hmi_request_msg[kHMIParam] = true; + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(EqualMsgParams(hmi_request_msg))); + + auto command = CreateCommandVI<VIUnsubscribeVehicleDataRequest>(command_msg); + command->Run(); +} + +} // namespace vi_unsubscribe_vehicle_data_request +} // namespace hmi_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc index b27a306a5c..afafd1c6c6 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/diagnostic_message_request_test.cc @@ -36,17 +36,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" #include "application_manager/event_engine/event.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" #include "vehicle_info_plugin/commands/mobile/diagnostic_message_request.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" namespace test { namespace components { @@ -59,8 +59,8 @@ using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::DiagnosticMessageRequest; using am::event_engine::Event; +using vehicle_info_plugin::commands::DiagnosticMessageRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr<DiagnosticMessageRequest> DiagnosticMessageRequestPtr; @@ -71,7 +71,7 @@ const uint32_t kDiagnosticMode = 5u; } // namespace class DiagnosticMessageRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + : public VICommandRequestTest<CommandsTestMocks::kIsNice> {}; TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); @@ -79,7 +79,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { kConnectionKey; DiagnosticMessageRequestPtr command( - CreateCommand<DiagnosticMessageRequest>(command_msg)); + CreateCommandVI<DiagnosticMessageRequest>(command_msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(ApplicationSharedPtr())); @@ -100,7 +100,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_NotSupportedDiagnosticMode_UNSUCCESS) { kConnectionKey; DiagnosticMessageRequestPtr command( - CreateCommand<DiagnosticMessageRequest>(command_msg)); + CreateCommandVI<DiagnosticMessageRequest>(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -127,7 +127,7 @@ TEST_F(DiagnosticMessageRequestTest, Run_SUCCESS) { kConnectionKey; DiagnosticMessageRequestPtr command( - CreateCommand<DiagnosticMessageRequest>(command_msg)); + CreateCommandVI<DiagnosticMessageRequest>(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -154,7 +154,7 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_UNSUCCESS) { Event event(hmi_apis::FunctionID::INVALID_ENUM); DiagnosticMessageRequestPtr command( - CreateCommand<DiagnosticMessageRequest>()); + CreateCommandVI<DiagnosticMessageRequest>()); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); @@ -171,7 +171,7 @@ TEST_F(DiagnosticMessageRequestTest, OnEvent_SUCCESS) { event.set_smart_object(*event_message); DiagnosticMessageRequestPtr command( - CreateCommand<DiagnosticMessageRequest>()); + CreateCommandVI<DiagnosticMessageRequest>()); EXPECT_CALL( mock_rpc_service_, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc index 981d649a94..e4613feb83 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_dtcs_request_test.cc @@ -36,17 +36,16 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_application.h" #include "application_manager/event_engine/event.h" -#include "mobile/get_dtcs_request.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "mobile/get_dtcs_request.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" namespace test { namespace components { @@ -57,23 +56,23 @@ namespace get_dtcs_request { using ::testing::_; using ::testing::Return; namespace am = ::application_manager; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::GetDTCsRequest; using am::event_engine::Event; -using am::MockMessageHelper; using testing::Mock; +using vehicle_info_plugin::commands::GetDTCsRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr<GetDTCsRequest> GetDTCsRequestPtr; class GetDTCsRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { + : public VICommandRequestTest<CommandsTestMocks::kIsNice> { public: - GetDTCsRequestTest() : CommandRequestTest<CommandsTestMocks::kIsNice>() {} + GetDTCsRequestTest() : VICommandRequestTest<CommandsTestMocks::kIsNice>() {} }; TEST_F(GetDTCsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { - GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>()); + GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>()); EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -93,7 +92,7 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; - GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>(command_msg)); + GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -107,7 +106,7 @@ TEST_F(GetDTCsRequestTest, Run_SUCCESS) { } TEST_F(GetDTCsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { - GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>()); + GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>()); Event event(hmi_apis::FunctionID::INVALID_ENUM); @@ -132,7 +131,7 @@ TEST_F(GetDTCsRequestTest, OnEvent_SUCCESS) { MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); - GetDTCsRequestPtr command(CreateCommand<GetDTCsRequest>()); + GetDTCsRequestPtr command(CreateCommandVI<GetDTCsRequest>()); command->on_event(event); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc index cb78e44904..d27e332601 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_request_test.cc @@ -36,17 +36,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" +#include "application_manager/event_engine/event.h" #include "application_manager/message_helper.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/event_engine/event.h" -#include "mobile/get_vehicle_data_request.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "mobile/get_vehicle_data_request.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" namespace test { namespace components { @@ -59,8 +59,8 @@ using ::testing::Return; using ::testing::ReturnRef; namespace am = ::application_manager; using am::commands::MessageSharedPtr; -using vehicle_info_plugin::commands::GetVehicleDataRequest; using am::event_engine::Event; +using vehicle_info_plugin::commands::GetVehicleDataRequest; namespace mobile_result = mobile_apis::Result; typedef std::shared_ptr<GetVehicleDataRequest> GetVehicleDataRequestPtr; @@ -70,20 +70,14 @@ const uint32_t kConnectionKey = 2u; } // namespace class GetVehicleDataRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + : public VICommandRequestTest<CommandsTestMocks::kIsNice> {}; class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest { public: - UnwrappedGetVehicleDataRequest(const MessageSharedPtr& message, - am::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : GetVehicleDataRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + UnwrappedGetVehicleDataRequest( + const MessageSharedPtr& message, + const vehicle_info_plugin::VehicleInfoCommandParams& params) + : GetVehicleDataRequest(message, params) {} policy::RPCParams& get_disallowed_params() { return removed_parameters_permissions_.disallowed_params; @@ -93,7 +87,7 @@ class UnwrappedGetVehicleDataRequest : public GetVehicleDataRequest { }; TEST_F(GetVehicleDataRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { - GetVehicleDataRequestPtr command(CreateCommand<GetVehicleDataRequest>()); + GetVehicleDataRequestPtr command(CreateCommandVI<GetVehicleDataRequest>()); EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -115,7 +109,7 @@ TEST_F(GetVehicleDataRequestTest, Run_TooHighFrequency_UNSUCCESS) { kConnectionKey; GetVehicleDataRequestPtr command( - CreateCommand<GetVehicleDataRequest>(command_msg)); + CreateCommandVI<GetVehicleDataRequest>(command_msg)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -138,14 +132,17 @@ TEST_F(GetVehicleDataRequestTest, Run_EmptyMsgParams_UNSUCCESS) { kConnectionKey; GetVehicleDataRequestPtr command( - CreateCommand<GetVehicleDataRequest>(command_msg)); + CreateCommandVI<GetVehicleDataRequest>(command_msg)); const am::VehicleData kEmptyVehicleData; - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(kEmptyVehicleData)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(kEmptyVehicleData)); + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); MockAppPtr app(CreateMockApp()); - EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); + ON_CALL(app_mngr_, application(kConnectionKey)).WillByDefault(Return(app)); EXPECT_CALL( mock_rpc_service_, @@ -161,11 +158,15 @@ TEST_F(GetVehicleDataRequestTest, kConnectionKey; std::shared_ptr<UnwrappedGetVehicleDataRequest> command( - CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg)); + CreateCommandVI<UnwrappedGetVehicleDataRequest>(command_msg)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); const am::VehicleData kEmptyVehicleData; - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillRepeatedly(ReturnRef(kEmptyVehicleData)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(kEmptyVehicleData)); policy::RPCParams& disallowed_params = command->get_disallowed_params(); disallowed_params.insert("test_param"); @@ -189,13 +190,13 @@ TEST_F(GetVehicleDataRequestTest, Run_SUCCESS) { (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; GetVehicleDataRequestPtr command( - CreateCommand<GetVehicleDataRequest>(command_msg)); + CreateCommandVI<GetVehicleDataRequest>(command_msg)); am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type( kMsgParamKey, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); MockAppPtr app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)).WillOnce(Return(app)); @@ -215,7 +216,7 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { kConnectionKey; std::shared_ptr<UnwrappedGetVehicleDataRequest> command( - CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg)); + CreateCommandVI<UnwrappedGetVehicleDataRequest>(command_msg)); Event event(hmi_apis::FunctionID::INVALID_ENUM); @@ -228,14 +229,18 @@ TEST_F(GetVehicleDataRequestTest, OnEvent_DataNotAvailable_SUCCESS) { const hmi_apis::Common_Result::eType hmi_response_code = hmi_apis::Common_Result::DATA_NOT_AVAILABLE; const mobile_result::eType mobile_response_code = - mobile_result::DATA_NOT_AVAILABLE; + mobile_result::VEHICLE_DATA_NOT_AVAILABLE; + + am::VehicleData vehicle_data; + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; std::shared_ptr<UnwrappedGetVehicleDataRequest> command( - CreateCommand<UnwrappedGetVehicleDataRequest>(command_msg)); + CreateCommandVI<UnwrappedGetVehicleDataRequest>(command_msg)); MessageSharedPtr event_msg(CreateMessage(smart_objects::SmartType_Map)); (*event_msg)[am::strings::params][am::hmi_response::code] = hmi_response_code; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc new file mode 100644 index 0000000000..ad7a14ce40 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/get_vehicle_data_response_test.cc @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gtest/gtest.h" + +#include "application_manager/commands/commands_test.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" + +#include "mobile/get_vehicle_data_response.h" +#include "smart_objects/smart_object.h" + +namespace test { +namespace components { +namespace commands_test { +namespace mobile_commands_test { +namespace get_vehicle_data_response { + +namespace am = ::application_manager; +using am::commands::MessageSharedPtr; +using vehicle_info_plugin::commands::GetVehicleDataResponse; + +typedef std::shared_ptr<GetVehicleDataResponse> GetVehicleDataResponsePtr; + +class GetVehicleDataResponseTest + : public VICommandsTest<CommandsTestMocks::kIsNice> {}; + +TEST_F(GetVehicleDataResponseTest, GetVehicleDataResponse_SUCCESS) { + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); + GetVehicleDataResponsePtr command( + CreateCommandVI<GetVehicleDataResponse>(message)); + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + command->Run(); +} + +} // namespace get_vehicle_data_response +} // namespace mobile_commands_test +} // namespace commands_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc index 1e8a289637..82eb19c45f 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/on_vehicle_data_notification_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Ford Motor Company + * Copyright (c) 2019, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,21 +30,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <stdint.h> -#include <vector> -#include <map> +#include <strings.h> #include "gtest/gtest.h" #include "mobile/on_vehicle_data_notification.h" -#include "utils/custom_string.h" -#include "smart_objects/smart_object.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/commands_test.h" #include "application_manager/message_helper.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/custom_string.h" #include "utils/helpers.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" +#include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_plugin.h" namespace test { namespace components { @@ -62,49 +63,75 @@ using am::commands::MessageSharedPtr; using vehicle_info_plugin::commands::OnVehicleDataNotification; typedef std::shared_ptr<OnVehicleDataNotification> NotificationPtr; +typedef std::shared_ptr<vehicle_info_plugin::VehicleInfoAppExtension> + VehicleInfoAppExtensionPtr; +typedef DataAccessor<application_manager::ApplicationSet> ApplicationSetDA; namespace { const uint32_t kAppId = 1u; +const utils::custom_string::CustomString kAppName("test_app"); } // namespace class OnVehicleDataNotificationTest - : public CommandsTest<CommandsTestMocks::kIsNice> { + : public VICommandsTest<CommandsTestMocks::kIsNice> { public: - OnVehicleDataNotificationTest() - : command_msg_(CreateMessage(smart_objects::SmartType_Map)) - , command_(CreateCommand<OnVehicleDataNotification>(command_msg_)) {} + OnVehicleDataNotificationTest() : mock_app_(CreateMockApp()) {} + + protected: + void SetUp() OVERRIDE { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, name()).WillByDefault(ReturnRef(kAppName)); - MessageSharedPtr command_msg_; - NotificationPtr command_; + ON_CALL(mock_message_helper_, PrintSmartObject(_)) + .WillByDefault(Return(false)); + } + MockAppPtr mock_app_; }; -MATCHER_P2(CheckMessageData, key, value, "") { - const bool kIsMobileProtocolTypeCorrect = - (*arg)[am::strings::params][am::strings::protocol_type].asInt() == - am::commands::CommandImpl::mobile_protocol_type_; - - const bool kIsProtocolVersionCorrect = - (*arg)[am::strings::params][am::strings::protocol_version].asInt() == - am::commands::CommandImpl::protocol_version_; - - const bool kIsNotificationCorrect = - (*arg)[am::strings::params][am::strings::message_type].asInt() == - am::MessageType::kNotification; - - const bool kIsConnectionKeyCorrect = - (*arg)[am::strings::params][am::strings::connection_key].asUInt() == - kAppId; - - const bool kAreMsgParamsCorrect = - (*arg)[am::strings::msg_params][key].asInt() == value; - - using namespace helpers; - return Compare<bool, EQ, ALL>(true, - kIsMobileProtocolTypeCorrect, - kIsProtocolVersionCorrect, - kIsNotificationCorrect, - kIsConnectionKeyCorrect, - kAreMsgParamsCorrect); +MATCHER_P(SmartObjectCheck, checker, "") { + return checker(arg); +} + +TEST_F(OnVehicleDataNotificationTest, OnVehicleDataNotification_SUCCESS) { + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type( + am::strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS)); + vehicle_data.insert(am::VehicleData::value_type( + am::strings::speed, mobile_apis::VehicleDataType::VEHICLEDATA_SPEED)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + application_manager::ApplicationSet apps; + apps.insert(mock_app_); + std::shared_ptr<sync_primitives::Lock> apps_lock = + std::make_shared<sync_primitives::Lock>(); + ApplicationSetDA apps_da(apps, apps_lock); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da)); + + vehicle_info_plugin::VehicleInfoPlugin vi_plugin; + VehicleInfoAppExtensionPtr vi_app_extention_ptr = + std::make_shared<vehicle_info_plugin::VehicleInfoAppExtension>( + vi_plugin, *mock_app_); + vi_app_extention_ptr->subscribeToVehicleInfo("gps"); + vi_app_extention_ptr->subscribeToVehicleInfo("speed"); + ON_CALL(*mock_app_, + QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension:: + VehicleInfoAppExtensionUID)) + .WillByDefault(Return(vi_app_extention_ptr)); + + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); + smart_objects::SmartObject gps_data; + gps_data[am::strings::longitude_degrees] = 1.0; + gps_data[am::strings::latitude_degrees] = 1.0; + gps_data[am::strings::shifted] = true; + + (*message)[am::strings::msg_params][am::strings::gps] = gps_data; + (*message)[am::strings::msg_params][am::strings::speed] = 0; + + NotificationPtr command(CreateCommandVI<OnVehicleDataNotification>(message)); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message, _)); + + command->Run(); } } // namespace on_vehicle_data_notification diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc index c0a07fb57c..372d562965 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/read_did_request_test.cc @@ -35,18 +35,17 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/event_engine/event.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" #include "vehicle_info_plugin/commands/mobile/read_did_request.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" namespace test { namespace components { @@ -59,16 +58,16 @@ using ::testing::DoAll; using ::testing::Return; using ::testing::SaveArg; namespace am = ::application_manager; -using vehicle_info_plugin::commands::ReadDIDRequest; using am::commands::MessageSharedPtr; using am::event_engine::Event; +using vehicle_info_plugin::commands::ReadDIDRequest; class ReadDIDRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; + : public VICommandRequestTest<CommandsTestMocks::kIsNice> {}; TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) { Event event(Event::EventID::INVALID_ENUM); - std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>()); + std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>()); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); command->on_event(event); } @@ -76,7 +75,7 @@ TEST_F(ReadDIDRequestTest, OnEvent_WrongEventId_UNSUCCESS) { TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) { Event event(Event::EventID::VehicleInfo_ReadDID); - std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>()); + std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>()); const hmi_apis::Common_Result::eType hmi_response_code = hmi_apis::Common_Result::SUCCESS; @@ -98,7 +97,7 @@ TEST_F(ReadDIDRequestTest, OnEvent_SUCCESS) { } TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) { - std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>()); + std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>()); ON_CALL(app_mngr_, application(_)) .WillByDefault(Return(std::shared_ptr<am::Application>())); @@ -111,7 +110,7 @@ TEST_F(ReadDIDRequestTest, Run_AppNotRegistered_UNSUCCESS) { } TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) { - std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>()); + std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>()); MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); @@ -127,7 +126,7 @@ TEST_F(ReadDIDRequestTest, Run_CommandLimitsExceeded_UNSUCCESS) { TEST_F(ReadDIDRequestTest, Run_EmptyDidLocation_UNSUCCESS) { MockAppPtr app(CreateMockApp()); - std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>()); + std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); @@ -144,7 +143,7 @@ TEST_F(ReadDIDRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); (*msg)[am::strings::msg_params][am::strings::did_location]["SomeData"] = 0; - std::shared_ptr<ReadDIDRequest> command(CreateCommand<ReadDIDRequest>(msg)); + std::shared_ptr<ReadDIDRequest> command(CreateCommandVI<ReadDIDRequest>(msg)); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc index 165c7694b1..3a200ff282 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_request_test.cc @@ -39,8 +39,12 @@ #include "application_manager/mock_application_manager.h" #include "application_manager/mock_message_helper.h" #include "mobile/unsubscribe_vehicle_data_request.h" -#include "vehicle_info_plugin/vehicle_info_plugin.h" +#include "resumption/mock_last_state.h" +#include "vehicle_info_plugin/commands/vi_command_request_test.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" +#include "vehicle_info_plugin/vehicle_info_plugin.h" + +#include "application_manager/mock_rpc_handler.h" namespace test { namespace components { @@ -53,8 +57,8 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; -using vehicle_info_plugin::commands::UnsubscribeVehicleDataRequest; using am::commands::MessageSharedPtr; +using vehicle_info_plugin::commands::UnsubscribeVehicleDataRequest; typedef std::shared_ptr<UnsubscribeVehicleDataRequest> CommandPtr; @@ -63,10 +67,11 @@ const uint32_t kConnectionKey = 1u; const std::string kMsgParamKey = "test_key"; const mobile_apis::VehicleDataType::eType kVehicleType = mobile_apis::VehicleDataType::VEHICLEDATA_SPEED; +const std::string kVehicleTypeStr = am::strings::speed; } // namespace class UnsubscribeVehicleRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { + : public VICommandRequestTest<CommandsTestMocks::kIsNice> { public: UnsubscribeVehicleRequestTest() : mock_app_(CreateMockApp()) @@ -78,10 +83,14 @@ class UnsubscribeVehicleRequestTest protected: void UnsubscribeSuccessfully(); void SetUp() OVERRIDE { + ON_CALL(app_mngr_, GetRPCHandler()) + .WillByDefault(ReturnRef(mock_rpc_handler_)); + vi_plugin_.Init(app_mngr_, mock_rpc_service_, mock_hmi_capabilities_, - mock_policy_handler_); + mock_policy_handler_, + mock_last_state_); ON_CALL(*mock_app_, AddExtension(vi_app_extension_ptr_)); vi_plugin_.OnApplicationEvent(application_manager::plugin_manager:: ApplicationEvent::kApplicationRegistered, @@ -90,16 +99,19 @@ class UnsubscribeVehicleRequestTest QueryInterface(vehicle_info_plugin::VehicleInfoAppExtension:: VehicleInfoAppExtensionUID)) .WillByDefault(Return(vi_app_extension_ptr_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); } MockAppPtr mock_app_; application_manager::AppExtensionPtr vi_app_extension_ptr_; std::shared_ptr<sync_primitives::Lock> app_set_lock_ptr_; vehicle_info_plugin::VehicleInfoPlugin vi_plugin_; + application_manager_test::MockRPCHandler mock_rpc_handler_; + resumption_test::MockLastState mock_last_state_; }; TEST_F(UnsubscribeVehicleRequestTest, Run_AppNotRegistered_UNSUCCESS) { - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>()); + CommandPtr command(CreateCommandVI<UnsubscribeVehicleDataRequest>()); EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -117,11 +129,18 @@ TEST_F(UnsubscribeVehicleRequestTest, (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][am::strings::button_name] = - kVehicleType; + kVehicleTypeStr; am::VehicleData data; - EXPECT_CALL(mock_message_helper_, vehicle_data()).WillOnce(ReturnRef(data)); - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); + EXPECT_CALL(mock_message_helper_, vehicle_data()) + .WillRepeatedly(ReturnRef(data)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); + + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -138,12 +157,15 @@ TEST_F(UnsubscribeVehicleRequestTest, MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; - (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; + (*command_msg)[am::strings::msg_params][kVehicleTypeStr] = true; am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + + smart_objects::SmartObject hmi_custom_params(smart_objects::SmartType_Map); + hmi_custom_params[kVehicleTypeStr] = true; EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -152,17 +174,19 @@ TEST_F(UnsubscribeVehicleRequestTest, ManageHMICommand( HMIResultCodeIs( hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData), - _)).WillOnce(Return(true)); + _)) + .WillOnce(Return(true)); vehicle_info_plugin::VehicleInfoAppExtension* vi_app_extension = dynamic_cast<vehicle_info_plugin::VehicleInfoAppExtension*>( vi_app_extension_ptr_.get()); - ASSERT_TRUE(vi_app_extension->subscribeToVehicleInfo(kVehicleType)); + ASSERT_TRUE(vi_app_extension->subscribeToVehicleInfo(kVehicleTypeStr)); application_manager::ApplicationSet app_set = {mock_app_}; DataAccessor<application_manager::ApplicationSet> accessor(app_set, app_set_lock_ptr_); // Expectations EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); command->Run(); } @@ -170,9 +194,12 @@ TEST_F(UnsubscribeVehicleRequestTest, Run_EmptyVehicleData_INVALID_DATA_SentToMobile) { am::VehicleData vehicle_data; EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + .WillRepeatedly(ReturnRef(vehicle_data)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); - MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -184,17 +211,21 @@ TEST_F(UnsubscribeVehicleRequestTest, (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = false; - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); command->Run(); } TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeFromNotSubscribedBeforeData_UNSUCCESS) { + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); + am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - + .WillRepeatedly(ReturnRef(vehicle_data)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); @@ -206,7 +237,8 @@ TEST_F(UnsubscribeVehicleRequestTest, (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); command->Run(); } @@ -215,15 +247,19 @@ TEST_F(UnsubscribeVehicleRequestTest, Run_UnsubscribeDataDisabled_UNSUCCESS) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); + + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); + am::VehicleData vehicle_data; vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); - - MockAppPtr mock_app(CreateMockApp()); + .WillRepeatedly(ReturnRef(vehicle_data)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); + .WillOnce(Return(mock_app_)); EXPECT_CALL( mock_rpc_service_, @@ -237,7 +273,8 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); am::VehicleData vehicle_data; @@ -245,7 +282,11 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataNotSubscribed_IGNORED) { .WillRepeatedly(Return(mock_app_)); vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); + .WillRepeatedly(ReturnRef(vehicle_data)); + + smart_objects::SmartObject empty_hmi_custom_params; + ON_CALL(mock_custom_vehicle_data_manager_, CreateHMIMessageParams(_)) + .WillByDefault(Return(empty_hmi_custom_params)); EXPECT_CALL( mock_rpc_service_, @@ -275,7 +316,8 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) { (*command_msg)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*command_msg)[am::strings::msg_params][kMsgParamKey] = true; - CommandPtr command(CreateCommand<UnsubscribeVehicleDataRequest>(command_msg)); + CommandPtr command( + CreateCommandVI<UnsubscribeVehicleDataRequest>(command_msg)); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app_)); @@ -288,6 +330,11 @@ TEST_F(UnsubscribeVehicleRequestTest, OnEvent_DataUnsubscribed_SUCCESS) { message[am::strings::msg_params][kMsgParamKey] = true; test_event.set_smart_object(message); + am::VehicleData vehicle_data; + vehicle_data.insert(am::VehicleData::value_type(kMsgParamKey, kVehicleType)); + EXPECT_CALL(mock_message_helper_, vehicle_data()) + .WillRepeatedly(ReturnRef(vehicle_data)); + EXPECT_CALL( mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc index a0d4699de8..7c610c8adb 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/commands/mobile/unsubscribe_vehicle_response_test.cc @@ -30,13 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "mobile/unsubscribe_vehicle_data_response.h" #include <stdint.h> #include <string> +#include "application_manager/mock_application_manager.h" #include "gtest/gtest.h" +#include "mobile/unsubscribe_vehicle_data_response.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_application_manager.h" +#include "vehicle_info_plugin/commands/vi_commands_test.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_factory.h" namespace test { namespace components { @@ -50,12 +52,12 @@ using ::testing::_; using ::testing::NotNull; using ::testing::Types; -using vehicle_info_plugin::commands::UnsubscribeVehicleDataResponse; using commands::MessageSharedPtr; +using vehicle_info_plugin::commands::UnsubscribeVehicleDataResponse; namespace am = ::application_manager; class UnsubscribeVehicleResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; + : public VICommandsTest<CommandsTestMocks::kIsNice> {}; MATCHER_P(ResultCodeIs, result_code, "") { return result_code == @@ -70,7 +72,7 @@ TEST_F(UnsubscribeVehicleResponseTest, (*command_msg)[am::strings::msg_params][am::strings::success] = false; std::shared_ptr<UnsubscribeVehicleDataResponse> command = - CreateCommand<UnsubscribeVehicleDataResponse>(command_msg); + CreateCommandVI<UnsubscribeVehicleDataResponse>(command_msg); EXPECT_CALL( mock_rpc_service_, @@ -84,7 +86,7 @@ TEST_F(UnsubscribeVehicleResponseTest, std::make_shared<SmartObject>(smart_objects::SmartType_Map); (*command_msg)[am::strings::msg_params][am::strings::success] = true; std::shared_ptr<UnsubscribeVehicleDataResponse> command = - CreateCommand<UnsubscribeVehicleDataResponse>(command_msg); + CreateCommandVI<UnsubscribeVehicleDataResponse>(command_msg); EXPECT_CALL( mock_rpc_service_, @@ -102,7 +104,7 @@ TEST_F(UnsubscribeVehicleResponseTest, (*command_msg)[am::strings::msg_params][am::strings::result_code] = result_type; std::shared_ptr<UnsubscribeVehicleDataResponse> command = - CreateCommand<UnsubscribeVehicleDataResponse>(command_msg); + CreateCommandVI<UnsubscribeVehicleDataResponse>(command_msg); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc new file mode 100644 index 0000000000..7d65d989bf --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/custom_vehicle_data_manager_test.cc @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + +#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/policies/mock_custom_vehicle_data_provider.h" +#include "gtest/gtest.h" +#include "test/application_manager/mock_application_manager.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager_impl.h" + +namespace vehicle_info_plugin_test { + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +using application_manager::MockMessageHelper; +namespace { +std::string kName = "rpm"; +std::string kKey = "VD_RPM"; +} // namespace +class CustomVehicleDataManagerTest : public ::testing::Test { + public: + CustomVehicleDataManagerTest() + : mock_message_helper_( + *application_manager::MockMessageHelper::message_helper_mock()) {} + + void SetUp() OVERRIDE {} + + void InitValidationManager(const policy_table::VehicleDataItems& items) { + using vehicle_info_plugin::CustomVehicleDataManagerImpl; + + ON_CALL(mock_custom_vehicle_data_provider_, GetVehicleDataItems()) + .WillByDefault(Return(items)); + ON_CALL(mock_custom_vehicle_data_provider_, GetRemovedVehicleDataItems()) + .WillByDefault(Return(policy_table::VehicleDataItems())); + custom_vd_manager_.reset(new CustomVehicleDataManagerImpl( + mock_custom_vehicle_data_provider_, mock_rpc_service_)); + } + + test::components::application_manager_test::MockApplicationManager + app_manager_mock_; + std::unique_ptr<vehicle_info_plugin::CustomVehicleDataManager> + custom_vd_manager_; + NiceMock<test::components::policy_test::MockCustomVehicleDataProvider> + mock_custom_vehicle_data_provider_; + NiceMock<test::components::application_manager_test::MockRPCService> + mock_rpc_service_; + MockMessageHelper& mock_message_helper_; +}; + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsEmptyItems) { + policy_table::VehicleDataItems schema_items; + InitValidationManager(schema_items); + const std::set<std::string> items; + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(msg_params.empty()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsOnePODItem) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = kName; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(rpm); + InitValidationManager(schema_items); + + const std::set<std::string> items = {kName}; + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 1u); + EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM")); + auto key_value = msg_params["OEM_REF_RPM"]; + EXPECT_TRUE(key_value.asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsSeveralPODItems) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = kName; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + + policy_table::VehicleDataItem speed; + speed.mark_initialized(); + speed.name = "speed"; + speed.type = "float"; + speed.key = "OEM_REF_SPEED"; + speed.mandatory = false; + *speed.array = false; + speed.params->mark_initialized(); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(rpm); + schema_items.push_back(speed); + InitValidationManager(schema_items); + + const std::set<std::string> items = {kName, "speed"}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 2u); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM")); + auto rpm_key_value = msg_params["OEM_REF_RPM"]; + EXPECT_TRUE(rpm_key_value.asBool()); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_SPEED")); + auto speed_key_value = msg_params["OEM_REF_SPEED"]; + EXPECT_TRUE(speed_key_value.asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, + CreateHMIMessageParamsSchemaWithSeveralItemsRequestWithOneItem) { + policy_table::VehicleDataItem rpm; + rpm.mark_initialized(); + rpm.name = kName; + rpm.type = "Integer"; + rpm.key = "OEM_REF_RPM"; + rpm.mandatory = false; + *rpm.array = false; + rpm.params->mark_initialized(); + + policy_table::VehicleDataItem speed; + speed.mark_initialized(); + speed.name = "speed"; + speed.type = "float"; + speed.key = "OEM_REF_SPEED"; + speed.mandatory = false; + *speed.array = false; + speed.params->mark_initialized(); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(rpm); + schema_items.push_back(speed); + InitValidationManager(schema_items); + + const std::set<std::string> items = {kName}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 1u); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_RPM")); + auto rpm_key_value = msg_params["OEM_REF_RPM"]; + EXPECT_TRUE(rpm_key_value.asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsStructType) { + policy_table::VehicleDataItem alss; + alss.mark_initialized(); + alss.name = "ambientLightSensorStatus"; + alss.type = "AmbientLightStatus"; + alss.key = "OEM_REF_AMB_LIGHT"; + alss.mandatory = false; + alss.params->mark_initialized(); + + policy_table::VehicleDataItem lss; + lss.mark_initialized(); + lss.name = "LightSensorStatus"; + lss.type = "Struct"; + lss.key = "OEM_REF_SEN_LIGHT"; + lss.mandatory = false; + lss.params->mark_initialized(); + lss.params->push_back(alss); + + policy_table::VehicleDataItem hbo; + hbo.mark_initialized(); + hbo.name = "highBeamsOn"; + hbo.type = "Boolean"; + hbo.key = "OEM_REF_HIGH_BEAM"; + hbo.mandatory = true; + hbo.params->mark_initialized(); + + policy_table::VehicleDataItem lbo; + lbo.mark_initialized(); + lbo.name = "lowBeamsOn"; + lbo.type = "Boolean"; + lbo.key = "OEM_REF_LOW_BEAM"; + lbo.mandatory = false; + lbo.params->mark_initialized(); + + policy_table::VehicleDataItem hls; + hls.mark_initialized(); + hls.name = "headLampStatus"; + hls.type = "Struct"; + hls.key = "OEM_REF_HLSTATUS"; + hls.mandatory = false; + hls.params->mark_initialized(); + hls.params->push_back(lss); + hls.params->push_back(lbo); + hls.params->push_back(hbo); + + policy_table::VehicleDataItems schema_items; + schema_items.push_back(hls); + InitValidationManager(schema_items); + + const std::set<std::string> items = {"headLampStatus"}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_EQ(msg_params.length(), 1u); + + EXPECT_TRUE(msg_params.keyExists("OEM_REF_HLSTATUS")); + const auto head_lamp_status = msg_params["OEM_REF_HLSTATUS"]; + EXPECT_EQ(head_lamp_status.getType(), smart_objects::SmartType_Map); + + EXPECT_EQ(head_lamp_status.length(), 3u); + + EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_HIGH_BEAM")); + EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_LOW_BEAM")); + EXPECT_TRUE(head_lamp_status.keyExists("OEM_REF_SEN_LIGHT")); + + EXPECT_TRUE(head_lamp_status["OEM_REF_HIGH_BEAM"].asBool()); + EXPECT_TRUE(head_lamp_status["OEM_REF_LOW_BEAM"].asBool()); + auto light_sensor_status = head_lamp_status["OEM_REF_SEN_LIGHT"]; + + EXPECT_EQ(light_sensor_status.length(), 1u); + EXPECT_TRUE(light_sensor_status.keyExists("OEM_REF_AMB_LIGHT")); + EXPECT_TRUE(light_sensor_status["OEM_REF_AMB_LIGHT"].asBool()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateHMIMessageParamsNoSchemaForItem) { + policy_table::VehicleDataItems schema_items; + InitValidationManager(schema_items); + + const std::set<std::string> items = {kName}; + + const auto msg_params = custom_vd_manager_->CreateHMIMessageParams(items); + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(msg_params.empty()); +} + +TEST_F(CustomVehicleDataManagerTest, CreateMobileMessageParamsStruct) { + const application_manager::VehicleData kEmptyVehicleData; + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(kEmptyVehicleData)); + + policy_table::VehicleDataItems schema_items; + + policy_table::VehicleDataItem custom_vd_item11_struct; + custom_vd_item11_struct.mark_initialized(); + custom_vd_item11_struct.name = "custom_vd_item11_struct"; + custom_vd_item11_struct.type = "Struct"; + custom_vd_item11_struct.key = "OEM_REF_STRUCT"; + custom_vd_item11_struct.mandatory = false; + custom_vd_item11_struct.params->mark_initialized(); + + policy_table::VehicleDataItem struct_element_1_int; + struct_element_1_int.mark_initialized(); + struct_element_1_int.name = "struct_element_1_int"; + struct_element_1_int.type = "Integer"; + struct_element_1_int.key = "OEM_REF_STRUCT_1_INT"; + struct_element_1_int.mandatory = false; + struct_element_1_int.params->mark_initialized(); + custom_vd_item11_struct.params->push_back(struct_element_1_int); + schema_items.push_back(custom_vd_item11_struct); + InitValidationManager(schema_items); + + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + msg_params["OEM_REF_STRUCT"] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + auto& oem_ref_struct = msg_params["OEM_REF_STRUCT"]; + oem_ref_struct["OEM_REF_STRUCT_1_INT"] = 100; + custom_vd_manager_->CreateMobileMessageParams(msg_params); + + EXPECT_EQ(msg_params.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(msg_params.keyExists("custom_vd_item11_struct")); + + auto& mobile_response_vd_item_11 = msg_params["custom_vd_item11_struct"]; + EXPECT_EQ(mobile_response_vd_item_11.getType(), smart_objects::SmartType_Map); + EXPECT_TRUE(mobile_response_vd_item_11.keyExists("struct_element_1_int")); + + auto& mobile_response_element1 = + mobile_response_vd_item_11["struct_element_1_int"]; + EXPECT_EQ(mobile_response_element1.getType(), + smart_objects::SmartType_Integer); + EXPECT_EQ(mobile_response_element1.asInt(), 100); +} +} // namespace vehicle_info_plugin_test diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h new file mode 100644 index 0000000000..a6eac01e1c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_command_request_test.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_ + +#include <stdint.h> + +#include "gtest/gtest.h" + +#include "application_manager/commands/command_request_impl.h" +#include "application_manager/commands/command_request_test.h" +#include "application_manager/event_engine/event.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" + +namespace test { +namespace components { +namespace commands_test { + +using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::SaveArg; +namespace am = ::application_manager; +using am::commands::Command; +using am::commands::CommandRequestImpl; +using am::event_engine::Event; + +template <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice> +class VICommandRequestTest : public CommandRequestTest<kIsNice> { + public: + enum { kDefaultTimeout_ = 100 }; + + template <class Command> + std::shared_ptr<Command> CreateCommandVI() { + auto msg = CommandsTest<kIsNice>::CreateMessage(); + return CreateCommandVI<Command>(msg); + } + + template <class Command> + std::shared_ptr<Command> CreateCommandVI(MessageSharedPtr& msg) { + InitCommandVI(kDefaultTimeout_); + vehicle_info_plugin::VehicleInfoCommandParams params = { + CommandsTest<kIsNice>::app_mngr_, + CommandsTest<kIsNice>::mock_rpc_service_, + CommandsTest<kIsNice>::mock_hmi_capabilities_, + CommandsTest<kIsNice>::mock_policy_handler_, + mock_custom_vehicle_data_manager_}; + return std::make_shared<Command>(msg, params); + } + + testing::NiceMock<vehicle_info_plugin::MockCustomVehicleDataManager> + mock_custom_vehicle_data_manager_; + + protected: + VICommandRequestTest() : CommandRequestTest<kIsNice>() {} + + void InitCommandVI(const uint32_t& timeout) { + CommandRequestTest<kIsNice>::InitCommand(kDefaultTimeout_); + } +}; + +} // namespace commands_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VIHICLE_INFO_PLUGIN_COMMANDS_VI_COMMAND_REQUEST_TEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h new file mode 100644 index 0000000000..ae25acea87 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/commands/vi_commands_test.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_ + +#include <stdint.h> +#include "gtest/gtest.h" + +#include "application_manager/commands/command.h" +#include "smart_objects/smart_object.h" + +#include "application_manager/commands/commands_test.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "vehicle_info_plugin/mock_custom_vehicle_data_manager.h" +#include "vehicle_info_plugin/vehicle_info_command_params.h" + +namespace test { +namespace components { +namespace commands_test { + +namespace am = ::application_manager; + +using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +using am::commands::MessageSharedPtr; +using ::smart_objects::SmartObject; + +template <const CommandsTestMocks kIsNice = CommandsTestMocks::kNotNice> +class VICommandsTest : public CommandsTest<kIsNice> { + public: + enum { kDefaultTimeout_ = 100 }; + + template <class Command> + std::shared_ptr<Command> CreateCommandVI() { + auto msg = CommandsTest<kIsNice>::CreateMessage(); + return CreateCommandVI<Command>(msg); + } + + template <class Command> + std::shared_ptr<Command> CreateCommandVI(MessageSharedPtr& msg) { + InitCommandVI(kDefaultTimeout_); + vehicle_info_plugin::VehicleInfoCommandParams params = { + CommandsTest<kIsNice>::app_mngr_, + CommandsTest<kIsNice>::mock_rpc_service_, + CommandsTest<kIsNice>::mock_hmi_capabilities_, + CommandsTest<kIsNice>::mock_policy_handler_, + mock_custom_vehicle_data_manager_}; + return std::make_shared<Command>(msg, params); + } + + testing::NiceMock<vehicle_info_plugin::MockCustomVehicleDataManager> + mock_custom_vehicle_data_manager_; + + protected: + void InitCommandVI(const uint32_t& timeout) { + ON_CALL(CommandsTest<kIsNice>::app_mngr_, get_settings()) + .WillByDefault(ReturnRef(CommandsTest<kIsNice>::app_mngr_settings_)); + ON_CALL(CommandsTest<kIsNice>::app_mngr_settings_, default_timeout()) + .WillByDefault(ReturnRef(timeout)); + } +}; +} // namespace commands_test +} // namespace components +} // namespace test + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VI_COMMAND_TEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h new file mode 100644 index 0000000000..9a7435f980 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/include/vehicle_info_plugin/mock_custom_vehicle_data_manager.h @@ -0,0 +1,26 @@ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_ + +#include "gmock/gmock.h" +#include "vehicle_info_plugin/custom_vehicle_data_manager.h" + +namespace vehicle_info_plugin { +namespace plugin_manager = application_manager::plugin_manager; +class MockCustomVehicleDataManager : public CustomVehicleDataManager { + public: + MOCK_METHOD1( + CreateHMIMessageParams, + smart_objects::SmartObject(const std::set<std::string>& msg_params)); + MOCK_METHOD1(CreateMobileMessageParams, + void(smart_objects::SmartObject& msg_params)); + MOCK_CONST_METHOD1(GetVehicleDataItemType, + std::string(const std::string& vehicle_data_item_name)); + MOCK_METHOD1(OnPolicyEvent, void(plugin_manager::PolicyEvent policy_event)); + MOCK_CONST_METHOD1(IsValidCustomVehicleDataName, + bool(const std::string& name)); + MOCK_CONST_METHOD1(IsRemovedCustomVehicleDataName, + bool(const std::string& name)); +}; + +} // namespace vehicle_info_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_TEST_INCLUDE_VEHICLE_INFO_PLUGIN_MOCK_CUSTOM_VEHICLE_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc new file mode 100644 index 0000000000..2443310409 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/vehicle_data_item_schema_test.cc @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + +#include "vehicle_info_plugin/vehicle_data_item_schema.h" +#include <limits> +#include <set> +#include <type_traits> +#include "formatters/formatter_json_rpc.h" +#include "formatters/generic_json_formatter.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "interfaces/HMI_API.h" +#include "smart_objects/smart_object.h" + +namespace vehicle_info_plugin_test { +using namespace vehicle_info_plugin; +using namespace rpc; +namespace smart_objects = ns_smart_device_link::ns_smart_objects; +namespace policy_table = rpc::policy_table_interface_base; + +using namespace ns_smart_device_link::ns_json_handler::strings; +using namespace hmi_apis; + +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; + +using ErrorCode = smart_objects::errors::eType; + +namespace { +const int kInvalidValue = std::numeric_limits<int32_t>::max(); +const int kDefaultInteger = 20; +const double kDefaultFloat = 10.05; +const bool kDefaultBoolean = true; +const std::string kDefaultString = "string value"; +const std::string kVehicleDataKey = "key"; +} // namespace + +typedef Common_ComponentVolumeStatus::eType TestEnumType; + +class VehicleDataItemSchemaTest : public ::testing::Test { + public: + /* + * @brief + * Specifies whether user wants to generate valid value of SmartObject or not. + */ + enum class SetValidItemValue { NO = 0, YES = 1 }; + + /* + * @brief + * VehicleDataTestObject struct combines schema and data structures for test + * object. + */ + struct VehicleDataTestObject { + VehicleDataTestObject(const int& key_number) { + schema.mark_initialized(); + schema.params->mark_initialized(); + schema.mandatory = true; + *schema.array = false; + // default value bounds + *schema.minvalue = 10; + *schema.maxvalue = 100; + // default string length + *schema.minlength = 5; + *schema.maxlength = 30; + // default array length + *schema.minsize = 5; + *schema.maxsize = 30; + // generate schema unique key + schema.key = kVehicleDataKey + std::to_string(key_number); + } + + policy_table::VehicleDataItem schema; + smart_objects::SmartObject data; + }; + + public: + VehicleDataItemSchemaTest() : key_number_(1) { + test_enum_.insert(TestEnumType::CVS_UNKNOWN); + test_enum_.insert(TestEnumType::CVS_NORMAL); + test_enum_.insert(TestEnumType::CVS_LOW); + test_enum_.insert(TestEnumType::CVS_FAULT); + test_enum_.insert(TestEnumType::CVS_ALERT); + test_enum_.insert(TestEnumType::CVS_NOT_SUPPORTED); + } + + void assertSmartObjectSize(const size_t& expected_size, + const size_t& actual_size) { + ASSERT_EQ(expected_size, actual_size); + } + + std::vector<VehicleDataTestObject> generatePODObjects( + const SetValidItemValue& set_valid_item) { + std::vector<VehicleDataTestObject> generated_objects; + VehicleDataTestObject custom_object(key_number_++); + + // Integer item + custom_object.schema.type = policy_table::VehicleDataItem::kInteger; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultInteger; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + // Float item + custom_object.schema.type = policy_table::VehicleDataItem::kFloat; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultFloat; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + // String item + custom_object.schema.type = policy_table::VehicleDataItem::kString; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultString; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + // Boolean item + custom_object.schema.type = policy_table::VehicleDataItem::kBoolean; + if (set_valid_item == SetValidItemValue::YES) { + custom_object.data = kDefaultBoolean; + } else { + custom_object.data = kInvalidValue; + } + generated_objects.push_back(custom_object); + + return generated_objects; + } + + VehicleDataTestObject generateTestObject( + const SetValidItemValue& set_valid_item) { + // Enum parameter + VehicleDataTestObject enum_object(key_number_++); + enum_object.schema.type = "ComponentVolumeStatus"; + enum_object.data = (set_valid_item == SetValidItemValue::YES) + ? TestEnumType::CVS_LOW + : kInvalidValue; + + // Integer parameter + VehicleDataTestObject int_object(key_number_++); + int_object.schema.type = policy_table::VehicleDataItem::kInteger; + int_object.data = (set_valid_item == SetValidItemValue::YES) + ? kDefaultInteger + : kInvalidValue; + + // Main object + VehicleDataTestObject main_object(key_number_++); + main_object.schema.type = policy_table::VehicleDataItem::kStruct; + *main_object.schema.params = std::vector<policy_table::VehicleDataItem>{ + enum_object.schema, int_object.schema}; + main_object.data[enum_object.schema.key] = enum_object.data; + main_object.data[int_object.schema.key] = int_object.data; + + assertSmartObjectSize(2u, main_object.data.length()); + return main_object; + } + + VehicleDataTestObject generateRecursiveTestObject( + const SetValidItemValue& set_valid_item) { + // Float item + VehicleDataTestObject float_object(key_number_++); + float_object.schema.type = policy_table::VehicleDataItem::kFloat; + if (set_valid_item == SetValidItemValue::YES) { + float_object.data = kDefaultFloat; + } else { + float_object.data = kInvalidValue; + } + + // String item + VehicleDataTestObject string_object(key_number_++); + string_object.schema.type = policy_table::VehicleDataItem::kString; + if (set_valid_item == SetValidItemValue::YES) { + string_object.data = kDefaultString; + } else { + string_object.data = kInvalidValue; + } + + // Sub Object + VehicleDataTestObject sub_object = generateTestObject(set_valid_item); + + // Main Object + VehicleDataTestObject main_object(key_number_++); + main_object.schema.type = policy_table::VehicleDataItem::kStruct; + *main_object.schema.params = std::vector<policy_table::VehicleDataItem>{ + float_object.schema, string_object.schema, sub_object.schema}; + main_object.data[float_object.schema.key] = float_object.data; + main_object.data[string_object.schema.key] = string_object.data; + main_object.data[sub_object.schema.key] = sub_object.data; + + assertSmartObjectSize(3u, main_object.data.length()); + return main_object; + } + + protected: + std::set<TestEnumType> test_enum_; + int key_number_; +}; + +TEST_F(VehicleDataItemSchemaTest, ValidatePOD_SUCCESS) { + rpc::ValidationReport report("RPC"); + auto valid_pod_objects = generatePODObjects(SetValidItemValue::YES); + + for (auto& object : valid_pod_objects) { + auto test_param = PolicyDataItem(object.schema); + auto result = VehicleDataItemSchema::create( + test_param, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); + } +} + +TEST_F(VehicleDataItemSchemaTest, ValidatePOD_FAIL) { + rpc::ValidationReport report("RPC"); + std::vector<VehicleDataTestObject> valid_pod_objects = + generatePODObjects(SetValidItemValue::NO); + + for (auto& object : valid_pod_objects) { + auto test_param = PolicyDataItem(object.schema); + auto result = VehicleDataItemSchema::create( + test_param, VehicleDataItemSchema::SchemaType::MOBILE); + EXPECT_NE(ErrorCode::OK, result->validate(object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); + } +} + +TEST_F(VehicleDataItemSchemaTest, ValidateEnum_SUCCESS) { + rpc::ValidationReport report("RPC"); + + VehicleDataTestObject test_enum_object(key_number_++); + test_enum_object.schema.type = "ComponentVolumeStatus"; + test_enum_object.data = TestEnumType::CVS_NORMAL; + + auto test_schema = PolicyDataItem(test_enum_object.schema); + + for (auto& enum_value : test_enum_) { + test_enum_object.data = enum_value; + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(test_enum_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); + } +} + +TEST_F(VehicleDataItemSchemaTest, ValidateEnum_FAIL) { + rpc::ValidationReport report("RPC"); + + VehicleDataTestObject test_enum_object(key_number_++); + test_enum_object.schema.type = "ComponentVolumeStatus"; + test_enum_object.data = kInvalidValue; + + auto test_schema = PolicyDataItem(test_enum_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OUT_OF_RANGE, + result->validate(test_enum_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateObject_SUCCESS) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_object = + generateTestObject(SetValidItemValue::YES); + auto test_schema = PolicyDataItem(complex_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(complex_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateObject_FAIL) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_object = + generateTestObject(SetValidItemValue::NO); + auto test_schema = PolicyDataItem(complex_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_NE(ErrorCode::OK, result->validate(complex_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateRecursiveObject_SUCCESS) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_recursive_object = + generateRecursiveTestObject(SetValidItemValue::YES); + auto test_schema = PolicyDataItem(complex_recursive_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, + result->validate(complex_recursive_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateRecursiveObject_FAIL) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject complex_recursive_object = + generateRecursiveTestObject(SetValidItemValue::NO); + auto test_schema = PolicyDataItem(complex_recursive_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_NE(ErrorCode::OK, + result->validate(complex_recursive_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateArray_SUCCESS) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject array_object(key_number_++); + *array_object.schema.array = true; + array_object.schema.type = policy_table::VehicleDataItem::kInteger; + array_object.data = + smart_objects::SmartObject(smart_objects::SmartType_Array); + array_object.data.asArray()->push_back(smart_objects::SmartObject(10)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(20)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(30)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(40)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(50)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(60)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(70)); + + auto test_schema = PolicyDataItem(array_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_EQ(ErrorCode::OK, result->validate(array_object.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateArray_FAIL) { + rpc::ValidationReport report("RPC"); + VehicleDataTestObject array_object(key_number_++); + *array_object.schema.array = true; + array_object.schema.type = policy_table::VehicleDataItem::kInteger; + array_object.data = + smart_objects::SmartObject(smart_objects::SmartType_Array); + array_object.data.asArray()->push_back(smart_objects::SmartObject(10)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(20)); + array_object.data.asArray()->push_back(smart_objects::SmartObject(30)); + + auto test_schema = PolicyDataItem(array_object.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + EXPECT_NE(ErrorCode::OK, result->validate(array_object.data, &report)); + EXPECT_NE(std::string(""), rpc::PrettyFormat(report)); +} + +TEST_F(VehicleDataItemSchemaTest, ValidateUnknownType) { + rpc::ValidationReport report("RPC"); + + VehicleDataTestObject test_object_with_invalid_type(key_number_++); + // Set invalid name of type + test_object_with_invalid_type.schema.type = "omponentolumetatus"; + test_object_with_invalid_type.data = TestEnumType::CVS_NORMAL; + + auto test_schema = PolicyDataItem(test_object_with_invalid_type.schema); + auto result = VehicleDataItemSchema::create( + test_schema, VehicleDataItemSchema::SchemaType::HMI); + test_object_with_invalid_type.data = "CVS_NORMAL"; + EXPECT_EQ(ErrorCode::OK, + result->validate(test_object_with_invalid_type.data, &report)); + EXPECT_EQ(std::string(""), rpc::PrettyFormat(report)); +} + +} // namespace vehicle_info_plugin_test diff --git a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc index 8df3d436bd..691f8d3259 100644 --- a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc +++ b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc @@ -29,14 +29,14 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include <iterator> +#include "application_manager/app_launch/app_launch_ctrl_impl.h" #include <algorithm> +#include <iterator> #include <utility> #include <vector> -#include "application_manager/app_launch/app_launch_ctrl_impl.h" +#include "application_manager/application.h" #include "application_manager/resumption/resume_ctrl.h" #include "connection_handler/connection_handler.h" -#include "application_manager/application.h" #include "utils/timer_task_impl.h" namespace app_launch { diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc index 22d2790183..a931b96fa1 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc @@ -29,14 +29,14 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <unistd.h> +#include <string> #include "application_manager/app_launch/app_launch_data_db.h" -#include "application_manager/application_manager.h" #include "application_manager/app_launch/app_launch_sql_queries.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" namespace app_launch { CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch") @@ -332,9 +332,9 @@ uint32_t AppLaunchDataDB::GetCurentNumberOfAppData() const { "Values of ignition off counts were updated successfully"); number_of_app_data = query.GetInteger(result_query); - LOG4CXX_DEBUG(logger_, - "Total cout saved mobile applications is " - << number_of_app_data); + LOG4CXX_DEBUG( + logger_, + "Total cout saved mobile applications is " << number_of_app_data); } else { LOG4CXX_WARN(logger_, "Failed execute query 'kGetNumberOfApplicationData'. Reson: " @@ -392,4 +392,4 @@ utils::dbms::SQLDatabase* AppLaunchDataDB::db() const { #endif // __QNX__ } -} // namespace resumption +} // namespace app_launch diff --git a/src/components/application_manager/src/app_launch/app_launch_data_json.cc b/src/components/application_manager/src/app_launch/app_launch_data_json.cc index d3e3b7d445..984997e424 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_json.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_json.cc @@ -29,13 +29,13 @@ * 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/app_launch/app_launch_data_json.h" +#include <algorithm> #include "application_manager/smart_object_keys.h" #include "smart_objects/smart_object.h" -#include "utils/date_time.h" #include "json/json.h" +#include "utils/date_time.h" namespace app_launch { @@ -277,4 +277,4 @@ bool AppLaunchDataJson::Persist() { return true; } -} // app_launch +} // namespace app_launch diff --git a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc index cc4765e6c9..7a9402d35e 100644 --- a/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc +++ b/src/components/application_manager/src/app_launch/app_launch_sql_queries.cc @@ -75,4 +75,4 @@ const std::string kRefreshApplicationDataSessionTime = "SET `last_session` = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')" "WHERE `deviceMac` = ? AND appID = ? AND bundleID = ?;"; -} // namespace resumption +} // namespace app_launch 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 f3851482c1..993a57364e 100644 --- a/src/components/application_manager/src/app_launch/apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/apps_launcher.cc @@ -1,8 +1,8 @@ -#include <algorithm> #include "application_manager/app_launch/apps_launcher.h" +#include <algorithm> -#include "utils/timer_task_impl.h" #include <iostream> +#include "utils/timer_task_impl.h" namespace app_launch { struct LauncherGenerator { diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc index a4468d87bc..9a7a6658fe 100644 --- a/src/components/application_manager/src/app_launch/device_apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc @@ -1,15 +1,15 @@ +#include <algorithm> #include <string> #include <vector> -#include <algorithm> -#include "application_manager/app_launch/device_apps_launcher.h" #include "application_manager/app_launch/app_launch_data.h" #include "application_manager/app_launch/apps_launcher.h" +#include "application_manager/app_launch/device_apps_launcher.h" #include "application_manager/resumption/resume_ctrl.h" +#include <iostream> #include "utils/timer.h" #include "utils/timer_task_impl.h" -#include <iostream> namespace app_launch { CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch") @@ -58,9 +58,9 @@ class Launcher { device_launcher_.settings().wait_time_between_apps(), timer::kSingleShot); } else { - LOG4CXX_DEBUG(logger_, - "All Apps on " << apps_on_device_->first - << " postponed launched"); + LOG4CXX_DEBUG( + logger_, + "All Apps on " << apps_on_device_->first << " postponed launched"); device_launcher_.StopLaunchingAppsOnDevice(apps_on_device_->first); } } diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index bab8147d9f..afcc7ae1dd 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -72,10 +72,44 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( std::string service_type = manifest[strings::service_type].asString(); - if (FindServiceByProvider(connection_key, service_type)) { - LOG4CXX_WARN(logger_, - "Service already exists for this provider, rejecting"); - return smart_objects::SmartObject(); + AppService* found_service = + FindServiceByProvider(connection_key, service_type); + if (found_service) { + // Check if there is a different existing service with the same updated + // name. + if (manifest.keyExists(strings::service_name)) { + auto service_by_name = + FindServiceByName(manifest[strings::service_name].asString()); + if (service_by_name) { + auto service_by_name_id = + service_by_name->record[strings::service_id].asString(); + auto found_service_id = + found_service->record[strings::service_id].asString(); + if (service_by_name_id != found_service_id) { + LOG4CXX_WARN(logger_, + "A service already exists with this name, rejecting"); + return smart_objects::SmartObject(); + } + } + } + LOG4CXX_WARN(logger_, "Service already exists for this provider, updating"); + published_services_lock_.Acquire(); + found_service->record[strings::service_manifest] = manifest; + found_service->record[strings::service_published] = true; + smart_objects::SmartObject updated_service_record = found_service->record; + published_services_lock_.Release(); + + smart_objects::SmartObject msg_params; + msg_params[strings::system_capability][strings::system_capability_type] = + mobile_apis::SystemCapabilityType::APP_SERVICES; + + AppServiceUpdated(updated_service_record, + mobile_apis::ServiceUpdateReason::MANIFEST_UPDATE, + msg_params); + + MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + + return updated_service_record; } if (manifest.keyExists(strings::service_name) && @@ -131,10 +165,16 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); - // Activate the new service if it is the default for its service type, or if - // no service is active of its service type + // Activate the new service if it is the default for its service type, if + // no service is active of its service type, or it is a mobile app in full. AppService* active_service = ActiveServiceForType(service_type); - if (!active_service || app_service.default_service) { + ApplicationSharedPtr app = NULL; + if (mobile_service && connection_key) { + app = app_manager_.application(connection_key); + } + + if (!active_service || app_service.default_service || + (app && app->IsFullscreen())) { ActivateAppService(service_id); } @@ -163,7 +203,9 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { // Activate embedded service, if available auto embedded_service = EmbeddedServiceForType( record[strings::service_manifest][strings::service_type].asString()); - if (embedded_service) { + if (embedded_service && + (embedded_service->record[strings::service_id].asString() != + service_id)) { embedded_service->record[strings::service_active] = true; AppServiceUpdated(embedded_service->record, mobile_apis::ServiceUpdateReason::ACTIVATED, @@ -181,13 +223,21 @@ bool AppServiceManager::UnpublishAppService(const std::string service_id) { void AppServiceManager::UnpublishServices(const uint32_t connection_key) { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Unpublishing all app services: " << connection_key); - sync_primitives::AutoLock lock(published_services_lock_); - for (auto it = published_services_.begin(); it != published_services_.end(); - ++it) { - if (it->second.connection_key == connection_key) { - UnpublishAppService(it->first); + + std::list<std::string> app_published_services; + { + sync_primitives::AutoLock lock(published_services_lock_); + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.connection_key == connection_key) { + app_published_services.push_back(it->first); + } } } + + for (auto& service_id : app_published_services) { + UnpublishAppService(service_id); + } } void AppServiceManager::OnAppActivated(ApplicationConstSharedPtr app) { diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index 0636748977..2bef887901 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -173,19 +173,16 @@ InitialApplicationDataImpl::perform_interaction_layout() const { } DynamicApplicationDataImpl::DynamicApplicationDataImpl() - : help_prompt_(NULL) - , timeout_prompt_(NULL) - , vr_help_title_(NULL) - , vr_help_(NULL) + : help_prompt_(nullptr) + , timeout_prompt_(nullptr) + , vr_help_title_(nullptr) + , vr_help_(nullptr) , tbt_state_(mobile_api::TBTState::INVALID_ENUM) - , show_command_(NULL) - , keyboard_props_(NULL) - , menu_title_(NULL) - , menu_icon_(NULL) - , tbt_show_command_(NULL) - , day_color_scheme_(NULL) - , night_color_scheme_(NULL) - , display_layout_("") + , show_command_(nullptr) + , keyboard_props_(nullptr) + , menu_title_(nullptr) + , menu_icon_(nullptr) + , tbt_show_command_(nullptr) , commands_() , commands_lock_ptr_(std::make_shared<sync_primitives::RecursiveLock>()) , sub_menu_() @@ -195,9 +192,12 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , performinteraction_choice_set_map_() , performinteraction_choice_set_lock_ptr_( std::make_shared<sync_primitives::RecursiveLock>()) + , window_params_map_() + , window_params_map_lock_ptr_(std::make_shared<sync_primitives::Lock>()) , is_perform_interaction_active_(false) , is_reset_global_properties_active_(false) - , perform_interaction_mode_(-1) {} + , perform_interaction_mode_(-1) + , display_capabilities_builder_(*this) {} DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { if (help_prompt_) { @@ -230,16 +230,6 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { tbt_show_command_ = NULL; } - if (day_color_scheme_) { - delete day_color_scheme_; - day_color_scheme_ = NULL; - } - - if (night_color_scheme_) { - delete night_color_scheme_; - night_color_scheme_ = NULL; - } - for (CommandsMap::iterator command_it = commands_.begin(); commands_.end() != command_it; ++command_it) { @@ -265,6 +255,8 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { performinteraction_choice_set_map_[it->first].clear(); } performinteraction_choice_set_map_.clear(); + + window_params_map_.clear(); } const smart_objects::SmartObject* DynamicApplicationDataImpl::help_prompt() @@ -316,18 +308,93 @@ const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() return menu_icon_; } -const smart_objects::SmartObject* DynamicApplicationDataImpl::day_color_scheme() +smart_objects::SmartObject DynamicApplicationDataImpl::day_color_scheme() const { - return day_color_scheme_; + using namespace mobile_apis::PredefinedWindows; + auto default_window_it = window_templates_.find(DEFAULT_WINDOW); + + if (window_templates_.end() != default_window_it) { + const smart_objects::SmartObject template_config = + default_window_it->second; + if (template_config.keyExists(strings::day_color_scheme)) { + return template_config[strings::day_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); } -const smart_objects::SmartObject* -DynamicApplicationDataImpl::night_color_scheme() const { - return night_color_scheme_; +smart_objects::SmartObject DynamicApplicationDataImpl::night_color_scheme() + const { + using namespace mobile_apis::PredefinedWindows; + auto default_window_it = window_templates_.find(DEFAULT_WINDOW); + + if (window_templates_.end() != default_window_it) { + const smart_objects::SmartObject template_config = + default_window_it->second; + if (template_config.keyExists(strings::night_color_scheme)) { + return template_config[strings::night_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); +} + +std::string DynamicApplicationDataImpl::display_layout() const { + using namespace mobile_apis::PredefinedWindows; + auto default_window_it = window_templates_.find(DEFAULT_WINDOW); + + if (window_templates_.end() != default_window_it) { + smart_objects::SmartObject template_config = default_window_it->second; + if (template_config.keyExists(strings::template_layout)) { + return template_config[strings::template_layout].asString(); + } + } + + return std::string(); } -const std::string& DynamicApplicationDataImpl::display_layout() const { - return display_layout_; +smart_objects::SmartObjectSPtr +DynamicApplicationDataImpl::display_capabilities() const { + return display_capabilities_; +} + +smart_objects::SmartObjectSPtr DynamicApplicationDataImpl::display_capabilities( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto result_display_caps = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Array); + const auto window_caps = + (*display_capabilities_)[0][strings::window_capabilities].asArray(); + if (!window_caps) { + LOG4CXX_WARN(logger_, "Current window capabilities are empty"); + // SDL still needs to retreive display capabilities + return display_capabilities_; + } + auto find_res = + std::find_if(window_caps->begin(), + window_caps->end(), + [&window_id](const smart_objects::SmartObject& element) { + if (window_id == element[strings::window_id].asInt()) { + return true; + } + + return false; + }); + + DCHECK(find_res != window_caps->end()); + const auto disp_caps_keys = (*display_capabilities_)[0].enumerate(); + for (const auto& key : disp_caps_keys) { + if (strings::window_capabilities == key) { + continue; + } + (*result_display_caps)[0][key] = (*display_capabilities_)[0][key]; + } + + (*result_display_caps)[0][strings::window_capabilities][0] = *find_res; + + return result_display_caps; } void DynamicApplicationDataImpl::load_global_properties( @@ -447,24 +514,198 @@ void DynamicApplicationDataImpl::set_menu_icon( void DynamicApplicationDataImpl::set_day_color_scheme( const smart_objects::SmartObject& color_scheme) { - if (day_color_scheme_) { - delete day_color_scheme_; + using namespace mobile_apis::PredefinedWindows; + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[DEFAULT_WINDOW][strings::day_color_scheme] = color_scheme; +} + +void DynamicApplicationDataImpl::set_night_color_scheme( + const smart_objects::SmartObject& color_scheme) { + using namespace mobile_apis::PredefinedWindows; + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[DEFAULT_WINDOW][strings::night_color_scheme] = color_scheme; +} + +void DynamicApplicationDataImpl::set_display_layout(const std::string& layout) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis::PredefinedWindows; + smart_objects::SmartObject template_config(smart_objects::SmartType_Map); + template_config[strings::template_layout] = layout; + window_templates_[DEFAULT_WINDOW] = template_config; +} + +void DynamicApplicationDataImpl::set_display_capabilities( + const smart_objects::SmartObject& display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + const auto& incoming_window_capabilities = + display_capabilities[0][strings::window_capabilities]; + + smart_objects::SmartObject tmp_window_capabilities; + if (display_capabilities_) { + tmp_window_capabilities = + (*display_capabilities_)[0][strings::window_capabilities]; } - day_color_scheme_ = new smart_objects::SmartObject(color_scheme); + display_capabilities_.reset( + new smart_objects::SmartObject(display_capabilities)); + + auto has_window_id = [&tmp_window_capabilities](const WindowID window_id) { + const auto tmp_window_capabilities_arr = tmp_window_capabilities.asArray(); + if (!tmp_window_capabilities_arr) { + return false; + } + + for (auto element : *tmp_window_capabilities_arr) { + if (element.keyExists(strings::window_id)) { + if (window_id == element[strings::window_id].asInt()) + return true; + } else if (window_id == 0) { + return true; + } + } + + return false; + }; + + for (uint32_t i = 0; i < incoming_window_capabilities.length(); ++i) { + const auto window_id = + incoming_window_capabilities[i][strings::window_id].asInt(); + if (!has_window_id(window_id)) { + tmp_window_capabilities[tmp_window_capabilities.length()] = + incoming_window_capabilities[i]; + } + } + + (*display_capabilities_)[0][strings::window_capabilities] = + tmp_window_capabilities; +} + +void DynamicApplicationDataImpl::remove_window_capability( + const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + + auto window_capabilities = + (*display_capabilities_)[0][strings::window_capabilities].asArray(); + DCHECK_OR_RETURN_VOID(window_capabilities); + + for (auto it = window_capabilities->begin(); it != window_capabilities->end(); + ++it) { + const auto cur_window_id = (*it).keyExists(strings::window_id) + ? (*it)[strings::window_id].asInt() + : 0; + if (window_id == cur_window_id) { + window_capabilities->erase(it); + return; + } + } + + LOG4CXX_WARN( + logger_, + "No window id " << window_id << " found in display capabilities"); +} + +bool DynamicApplicationDataImpl::menu_layout_supported( + const mobile_apis::MenuLayout::eType layout) const { + if (!display_capabilities_) + return false; + + const auto tmp_window_capabilities_arr = + (*display_capabilities_)[0][strings::window_capabilities].asArray(); + + if (!tmp_window_capabilities_arr) + return false; + + for (auto element : *tmp_window_capabilities_arr) { + if ((!element.keyExists(strings::window_id) || + element[strings::window_id].asInt() == 0) && + element.keyExists(strings::menu_layouts_available)) { + for (uint32_t i = 0; + i < element[strings::menu_layouts_available].length(); + ++i) { + if (static_cast<mobile_apis::MenuLayout::eType>( + element[strings::menu_layouts_available][i].asUInt()) == + layout) { + return true; + } + } + } + } + + return false; +} + +void DynamicApplicationDataImpl::set_window_layout(const WindowID window_id, + const std::string& layout) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject template_config(smart_objects::SmartType_Map); + + template_config[strings::template_layout] = layout; + window_templates_[window_id] = template_config; +} + +void DynamicApplicationDataImpl::set_day_color_scheme( + const WindowID window_id, const smart_objects::SmartObject& color_scheme) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[window_id][strings::day_color_scheme] = color_scheme; } void DynamicApplicationDataImpl::set_night_color_scheme( - const smart_objects::SmartObject& color_scheme) { - if (night_color_scheme_) { - delete night_color_scheme_; + const WindowID window_id, const smart_objects::SmartObject& color_scheme) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(color_scheme.getType() == smart_objects::SmartType_Map); + window_templates_[window_id][strings::night_color_scheme] = color_scheme; +} + +std::string DynamicApplicationDataImpl::window_layout( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + AppWindowsTemplates::const_iterator window_template_it = + window_templates_.find(window_id); + + if (window_templates_.end() != window_template_it) { + const smart_objects::SmartObject template_config = + window_template_it->second; + if (template_config.keyExists(strings::template_layout)) { + return template_config[strings::template_layout].asString(); + } } - night_color_scheme_ = new smart_objects::SmartObject(color_scheme); + return std::string(); } -void DynamicApplicationDataImpl::set_display_layout(const std::string& layout) { - display_layout_ = layout; +smart_objects::SmartObject DynamicApplicationDataImpl::day_color_scheme( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + AppWindowsTemplates::const_iterator window_template_it = + window_templates_.find(window_id); + + if (window_templates_.end() != window_template_it) { + const smart_objects::SmartObject template_config = + window_template_it->second; + if (template_config.keyExists(strings::day_color_scheme)) { + return template_config[strings::day_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); +} + +smart_objects::SmartObject DynamicApplicationDataImpl::night_color_scheme( + const WindowID window_id) const { + LOG4CXX_AUTO_TRACE(logger_); + AppWindowsTemplates::const_iterator window_template_it = + window_templates_.find(window_id); + + if (window_templates_.end() != window_template_it) { + const smart_objects::SmartObject template_config = + window_template_it->second; + if (template_config.keyExists(strings::night_color_scheme)) { + return template_config[strings::night_color_scheme]; + } + } + + return smart_objects::SmartObject(smart_objects::SmartType::SmartType_Null); } void DynamicApplicationDataImpl::SetGlobalProperties( @@ -555,6 +796,33 @@ bool DynamicApplicationDataImpl::IsSubMenuNameAlreadyExist( return false; } +DataAccessor<WindowParamsMap> +DynamicApplicationDataImpl::window_optional_params_map() const { + return DataAccessor<WindowParamsMap>(window_params_map_, + window_params_map_lock_ptr_); +} + +void DynamicApplicationDataImpl::SetWindowInfo( + const WindowID window_id, const smart_objects::SmartObject& window_info) { + LOG4CXX_AUTO_TRACE(logger_); + const auto it = window_params_map_.find(window_id); + if (window_params_map_.end() == it) { + window_params_map_[window_id] = + std::make_shared<smart_objects::SmartObject>(window_info); + } +} + +DisplayCapabilitiesBuilder& +DynamicApplicationDataImpl::display_capabilities_builder() { + LOG4CXX_AUTO_TRACE(logger_); + return display_capabilities_builder_; +} + +void DynamicApplicationDataImpl::RemoveWindowInfo(const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + window_params_map_.erase(window_id); +} + void DynamicApplicationDataImpl::AddChoiceSet( uint32_t choice_set_id, const smart_objects::SmartObject& choice_set) { sync_primitives::AutoLock lock(choice_set_map_lock_ptr_); diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 615d3c72cd..2b328ae9a1 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -31,21 +31,21 @@ */ #include "application_manager/application_impl.h" -#include <string> #include <strings.h> -#include "application_manager/message_helper.h" -#include "protocol_handler/protocol_handler.h" +#include <string> #include "application_manager/application_manager.h" +#include "application_manager/message_helper.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" +#include "protocol_handler/protocol_handler.h" #include "utils/file_system.h" -#include "utils/logger.h" #include "utils/gen_hash.h" +#include "utils/logger.h" -#include "utils/timer_task_impl.h" #include "application_manager/policies/policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl.h" #include "transport_manager/common.h" +#include "utils/timer_task_impl.h" namespace { @@ -113,6 +113,7 @@ ApplicationImpl::ApplicationImpl( , video_streaming_suspended_(true) , audio_streaming_suspended_(true) , is_app_allowed_(true) + , is_app_data_resumption_allowed_(false) , has_been_activated_(false) , tts_properties_in_none_(false) , tts_properties_in_full_(false) @@ -187,7 +188,8 @@ void ApplicationImpl::CloseActiveMessage() { } bool ApplicationImpl::IsFullscreen() const { - return mobile_api::HMILevel::HMI_FULL == hmi_level(); + return mobile_api::HMILevel::HMI_FULL == + hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); } bool ApplicationImpl::is_audio() const { @@ -265,19 +267,21 @@ bool ApplicationImpl::IsVideoApplication() const { return is_video_app; } -void ApplicationImpl::SetRegularState(HmiStatePtr state) { +void ApplicationImpl::SetRegularState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); - state_.AddState(state); + state_.AddState(window_id, state); } -void ApplicationImpl::RemovePostponedState() { +void ApplicationImpl::RemovePostponedState(const WindowID window_id) { LOG4CXX_AUTO_TRACE(logger_); - state_.RemoveState(HmiState::STATE_ID_POSTPONED); + state_.RemoveState(window_id, HmiState::STATE_ID_POSTPONED); } -void ApplicationImpl::SetPostponedState(HmiStatePtr state) { +void ApplicationImpl::SetPostponedState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); - state_.AddState(state); + state_.AddState(window_id, state); } void ApplicationImpl::set_mobile_projection_enabled(bool option) { @@ -297,22 +301,56 @@ struct StateIDComparator { } }; -void ApplicationImpl::AddHMIState(HmiStatePtr state) { +void ApplicationImpl::AddHMIState(const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); - state_.AddState(state); + state_.AddState(window_id, state); } -void ApplicationImpl::RemoveHMIState(HmiState::StateID state_id) { +void ApplicationImpl::RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) { LOG4CXX_AUTO_TRACE(logger_); - state_.RemoveState(state_id); + state_.RemoveState(window_id, state_id); +} + +const HmiStatePtr ApplicationImpl::CurrentHmiState( + const WindowID window_id) const { + return state_.GetState(window_id, HmiState::STATE_ID_CURRENT); } -const HmiStatePtr ApplicationImpl::CurrentHmiState() const { - return state_.GetState(HmiState::STATE_ID_CURRENT); +const HmiStatePtr ApplicationImpl::RegularHmiState( + const WindowID window_id) const { + return state_.GetState(window_id, HmiState::STATE_ID_REGULAR); } -const HmiStatePtr ApplicationImpl::RegularHmiState() const { - return state_.GetState(HmiState::STATE_ID_REGULAR); +WindowNames ApplicationImpl::GetWindowNames() const { + LOG4CXX_DEBUG(logger_, + "Collecting window names for application " << app_id()); + + WindowNames window_names; + std::string stringified_window_names; + + sync_primitives::AutoLock auto_lock(window_params_map_lock_ptr_); + for (const auto& window_info_item : window_params_map_) { + const auto window_name = + (*window_info_item.second)[strings::window_name].asString(); + window_names.push_back(window_name); + stringified_window_names += + (stringified_window_names.empty() ? "" : ",") + window_name; + } + + LOG4CXX_DEBUG(logger_, + "Existing window names: [" + stringified_window_names + "]"); + return window_names; +} + +WindowIds ApplicationImpl::GetWindowIds() const { + LOG4CXX_DEBUG(logger_, "Collecting window IDs for application " << app_id()); + return state_.GetWindowIds(); +} + +bool ApplicationImpl::WindowIdExists(const WindowID window_id) const { + const WindowIds window_ids = GetWindowIds(); + return helpers::in_range(window_ids, window_id); } bool ApplicationImpl::IsAllowedToChangeAudioSource() const { @@ -322,8 +360,9 @@ bool ApplicationImpl::IsAllowedToChangeAudioSource() const { return false; } -const HmiStatePtr ApplicationImpl::PostponedHmiState() const { - return state_.GetState(HmiState::STATE_ID_POSTPONED); +const HmiStatePtr ApplicationImpl::PostponedHmiState( + const WindowID window_id) const { + return state_.GetState(window_id, HmiState::STATE_ID_POSTPONED); } const smart_objects::SmartObject* ApplicationImpl::active_message() const { @@ -354,9 +393,10 @@ bool ApplicationImpl::is_media_application() const { return is_media_; } -const mobile_api::HMILevel::eType ApplicationImpl::hmi_level() const { +const mobile_api::HMILevel::eType ApplicationImpl::hmi_level( + const WindowID window_id) const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = CurrentHmiState(window_id); return hmi_state ? hmi_state->hmi_level() : HMILevel::INVALID_ENUM; } @@ -380,9 +420,10 @@ const uint32_t ApplicationImpl::list_files_in_none_count() const { return list_files_in_none_count_; } -const mobile_api::SystemContext::eType ApplicationImpl::system_context() const { +const mobile_api::SystemContext::eType ApplicationImpl::system_context( + const WindowID window_id) const { using namespace mobile_apis; - const HmiStatePtr hmi_state = CurrentHmiState(); + const HmiStatePtr hmi_state = CurrentHmiState(window_id); return hmi_state ? hmi_state->system_context() : SystemContext::INVALID_ENUM; ; } @@ -593,7 +634,7 @@ void ApplicationImpl::SuspendStreaming( } void ApplicationImpl::WakeUpStreaming( - protocol_handler::ServiceType service_type) { + protocol_handler::ServiceType service_type, uint32_t timer_len) { using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); @@ -609,8 +650,9 @@ void ApplicationImpl::WakeUpStreaming( ServiceType::kMobileNav, true, application_manager_); video_streaming_suspended_ = false; } - video_stream_suspend_timer_.Start(video_stream_suspend_timeout_, - timer::kPeriodic); + video_stream_suspend_timer_.Start( + timer_len == 0 ? video_stream_suspend_timeout_ : timer_len, + timer::kPeriodic); } else if (ServiceType::kAudio == service_type) { sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { @@ -619,8 +661,9 @@ void ApplicationImpl::WakeUpStreaming( ServiceType::kAudio, true, application_manager_); audio_streaming_suspended_ = false; } - audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_, - timer::kPeriodic); + audio_stream_suspend_timer_.Start( + timer_len == 0 ? audio_stream_suspend_timeout_ : timer_len, + timer::kPeriodic); } } @@ -680,6 +723,14 @@ void ApplicationImpl::set_app_allowed(const bool allowed) { is_app_allowed_ = allowed; } +bool ApplicationImpl::is_app_data_resumption_allowed() const { + return is_app_data_resumption_allowed_; +} + +void ApplicationImpl::set_app_data_resumption_allowance(const bool allowed) { + is_app_data_resumption_allowed_ = allowed; +} + void ApplicationImpl::set_secondary_device( connection_handler::DeviceHandle secondary_device) { secondary_device_id_ = secondary_device; @@ -849,8 +900,9 @@ bool ApplicationImpl::AreCommandLimitsExceeded( "Time Info: " << "\n Current: " << date_time::getSecs(current) << "\n Limit: (" << date_time::getSecs(limit.first) - << "," << limit.second << ")" - "\n frequency_restrictions: (" + << "," << limit.second + << ")" + "\n frequency_restrictions: (" << frequency_restrictions.first << "," << frequency_restrictions.second << ")"); if (date_time::getSecs(current) < @@ -929,8 +981,10 @@ bool ApplicationImpl::is_application_data_changed() const { return is_application_data_changed_; } -void ApplicationImpl::SetInitialState(HmiStatePtr state) { - state_.InitState(state); +void ApplicationImpl::SetInitialState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) { + state_.InitState(window_id, window_name, state); } void ApplicationImpl::set_is_application_data_changed( @@ -1073,21 +1127,58 @@ void ApplicationImpl::SubscribeToSoftButtons( cmd_softbuttonid_[cmd_id] = softbuttons_id; } } else { - cmd_softbuttonid_[cmd_id] = softbuttons_id; + auto& soft_button_ids = cmd_softbuttonid_[cmd_id]; + for (auto& softbutton_item : softbuttons_id) { + soft_button_ids.insert(softbutton_item); + } } } +struct FindSoftButtonId { + uint32_t soft_button_id_; + + FindSoftButtonId(const uint32_t soft_button_id) + : soft_button_id_(soft_button_id) {} + + bool operator()(const std::pair<uint32_t, WindowID>& element) { + return soft_button_id_ == element.first; + } +}; + bool ApplicationImpl::IsSubscribedToSoftButton(const uint32_t softbutton_id) { + LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); CommandSoftButtonID::iterator it = cmd_softbuttonid_.begin(); for (; it != cmd_softbuttonid_.end(); ++it) { - if ((it->second).find(softbutton_id) != (it->second).end()) { + const auto& soft_button_ids = (*it).second; + FindSoftButtonId finder(softbutton_id); + const auto find_res = + std::find_if(soft_button_ids.begin(), soft_button_ids.end(), finder); + if ((soft_button_ids.end() != find_res)) { return true; } } return false; } +WindowID ApplicationImpl::GetSoftButtonWindowID(const uint32_t softbutton_id) { + LOG4CXX_AUTO_TRACE(logger_); + + sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); + CommandSoftButtonID::iterator it = cmd_softbuttonid_.begin(); + for (; it != cmd_softbuttonid_.end(); ++it) { + const auto& soft_button_ids = (*it).second; + FindSoftButtonId finder(softbutton_id); + const auto find_res = + std::find_if(soft_button_ids.begin(), soft_button_ids.end(), finder); + if ((soft_button_ids.end() != find_res)) { + return find_res->second; + } + } + + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + void ApplicationImpl::UnsubscribeFromSoftButtons(int32_t cmd_id) { sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); CommandSoftButtonID::iterator it = cmd_softbuttonid_.find(cmd_id); @@ -1097,8 +1188,9 @@ void ApplicationImpl::UnsubscribeFromSoftButtons(int32_t cmd_id) { } void ApplicationImpl::set_system_context( + const WindowID window_id, const mobile_api::SystemContext::eType& system_context) { - const HmiStatePtr hmi_state = CurrentHmiState(); + HmiStatePtr hmi_state = CurrentHmiState(window_id); hmi_state->set_system_context(system_context); } @@ -1111,13 +1203,20 @@ void ApplicationImpl::set_audio_streaming_state( " for non-media application to different from NOT_AUDIBLE"); return; } - CurrentHmiState()->set_audio_streaming_state(state); + + // According to proposal SDL-0216 audio streaming state should + // be applied for all windows to keep consistency + HmiStates hmi_states = state_.GetStates(HmiState::STATE_ID_CURRENT); + for (const auto& hmi_state : hmi_states) { + hmi_state->set_audio_streaming_state(state); + } } void ApplicationImpl::set_hmi_level( + const WindowID window_id, const mobile_api::HMILevel::eType& new_hmi_level) { using namespace mobile_apis; - const HMILevel::eType current_hmi_level = hmi_level(); + const HMILevel::eType current_hmi_level = hmi_level(window_id); if (HMILevel::HMI_NONE != current_hmi_level && HMILevel::HMI_NONE == new_hmi_level) { put_file_in_none_count_ = 0; @@ -1126,7 +1225,8 @@ void ApplicationImpl::set_hmi_level( } ApplicationSharedPtr app = application_manager_.application(app_id()); DCHECK_OR_RETURN_VOID(app) - application_manager_.state_controller().SetRegularState(app, new_hmi_level); + application_manager_.state_controller().SetRegularState( + app, window_id, new_hmi_level); LOG4CXX_INFO(logger_, "hmi_level = " << new_hmi_level); usage_report_.RecordHmiStateChanged(new_hmi_level); } @@ -1152,9 +1252,9 @@ bool ApplicationImpl::AddExtension(AppExtensionPtr extension) { bool ApplicationImpl::RemoveExtension(AppExtensionUID uid) { auto it = std::find_if( - extensions_.begin(), - extensions_.end(), - [uid](AppExtensionPtr extension) { return extension->uid() == uid; }); + extensions_.begin(), extensions_.end(), [uid](AppExtensionPtr extension) { + return extension->uid() == uid; + }); return it != extensions_.end(); } @@ -1215,6 +1315,15 @@ void ApplicationImpl::set_cloud_app_certificate( certificate_ = certificate; } +void ApplicationImpl::set_user_location( + const smart_objects::SmartObject& user_location) { + user_location_ = user_location; +} + +const smart_objects::SmartObject& ApplicationImpl::get_user_location() const { + return user_location_; +} + void ApplicationImpl::PushMobileMessage( smart_objects::SmartObjectSPtr mobile_message) { sync_primitives::AutoLock lock(mobile_message_lock_); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index a071edbbfc..8044e8b6cd 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -32,48 +32,49 @@ #include <stdlib.h> // for rand() +#include <bson_object.h> #include <climits> -#include <string> #include <fstream> +#include <string> #include <utility> -#include <bson_object.h> +#include "application_manager/app_launch/app_launch_ctrl_impl.h" +#include "application_manager/app_launch/app_launch_data_db.h" +#include "application_manager/app_launch/app_launch_data_json.h" #include "application_manager/application_manager_impl.h" +#include "application_manager/command_holder_impl.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/command_notification_impl.h" +#include "application_manager/helpers/application_helper.h" +#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/rpc_service_impl.h" -#include "application_manager/rpc_handler_impl.h" #include "application_manager/mobile_message_handler.h" +#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/resumption/resume_ctrl_impl.h" -#include "application_manager/app_launch/app_launch_ctrl_impl.h" -#include "application_manager/app_launch/app_launch_data_db.h" -#include "application_manager/app_launch/app_launch_data_json.h" -#include "application_manager/helpers/application_helper.h" -#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" -#include "protocol_handler/protocol_handler.h" -#include "hmi_message_handler/hmi_message_handler.h" -#include "application_manager/command_holder_impl.h" +#include "application_manager/rpc_handler_impl.h" +#include "application_manager/rpc_protection_manager_impl.h" +#include "application_manager/rpc_service_impl.h" #include "connection_handler/connection_handler_impl.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" +#include "hmi_message_handler/hmi_message_handler.h" #include "protocol/bson_object_keys.h" +#include "protocol_handler/protocol_handler.h" -#include "utils/threads/thread.h" -#include "utils/file_system.h" -#include "utils/helpers.h" -#include "utils/timer_task_impl.h" -#include "smart_objects/enum_schema_item.h" -#include "interfaces/HMI_API_schema.h" +#include <time.h> +#include <boost/filesystem.hpp> #include "application_manager/application_impl.h" +#include "interfaces/HMI_API_schema.h" #include "media_manager/media_manager.h" #include "policy/usage_statistics/counter.h" +#include "smart_objects/enum_schema_item.h" #include "utils/custom_string.h" -#include <time.h> -#include <boost/filesystem.hpp> +#include "utils/file_system.h" +#include "utils/helpers.h" +#include "utils/threads/thread.h" +#include "utils/timer_task_impl.h" namespace { int get_rand_from_range(uint32_t from = 0, int to = RAND_MAX) { @@ -121,17 +122,26 @@ bool device_id_comparator(const std::string& device_id, } /** - * @brief policy_app_id_comparator is predicate to compare policy application - * ids - * @param policy_app_id Policy id of application - * @param app Application pointer - * @return True if policy id of application matches to policy id passed + * @brief PolicyAppIdComparator is struct predicate to compare policy + * application ids & device + * @param device_handle of application + * @param id of application + * @return True if policy id & device_handle of application matches to policy id + * & device_handle passed */ -bool policy_app_id_comparator(const std::string& policy_app_id, - ApplicationSharedPtr app) { - DCHECK_OR_RETURN(app, false); - return app->policy_app_id() == policy_app_id; -} +struct PolicyAppIdComparator { + PolicyAppIdComparator(const 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: + const connection_handler::DeviceHandle& device_handle_; + const std::string& policy_app_id_; +}; uint32_t ApplicationManagerImpl::mobile_corelation_id_ = 0; uint32_t ApplicationManagerImpl::corelation_id_ = 0; @@ -149,6 +159,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( , applications_list_lock_ptr_( std::make_shared<sync_primitives::RecursiveLock>()) , apps_to_register_list_lock_ptr_(std::make_shared<sync_primitives::Lock>()) + , reregister_wait_list_lock_ptr_(std::make_shared<sync_primitives::Lock>()) , audio_pass_thru_active_(false) , audio_pass_thru_app_id_(0) , driver_distraction_state_(hmi_apis::Common_DriverDistractionState::DD_OFF) @@ -198,13 +209,20 @@ ApplicationManagerImpl::ApplicationManagerImpl( const uint32_t timeout_ms = 10000u; clearing_timer->Start(timeout_ms, timer::kSingleShot); timer_pool_.push_back(clearing_timer); - rpc_handler_.reset(new rpc_handler::RPCHandlerImpl(*this)); + rpc_handler_.reset(new rpc_handler::RPCHandlerImpl( + *this, hmi_so_factory(), mobile_so_factory())); commands_holder_.reset(new CommandHolderImpl(*this)); + std::shared_ptr<RPCProtectionManager> rpc_protection_manager = + std::make_shared<RPCProtectionManagerImpl>(*policy_handler_); + policy_handler_->add_listener(rpc_protection_manager.get()); rpc_service_.reset(new rpc_service::RPCServiceImpl(*this, request_ctrl_, protocol_handler_, hmi_handler_, - *commands_holder_)); + *commands_holder_, + rpc_protection_manager, + hmi_so_factory(), + mobile_so_factory())); } ApplicationManagerImpl::~ApplicationManagerImpl() { @@ -249,6 +267,13 @@ ApplicationManagerImpl::pending_applications() const { return accessor; } +DataAccessor<ReregisterWaitList> +ApplicationManagerImpl::reregister_applications() const { + DataAccessor<ReregisterWaitList> accessor(reregister_wait_list_, + reregister_wait_list_lock_ptr_); + return accessor; +} + ApplicationSharedPtr ApplicationManagerImpl::application( uint32_t app_id) const { AppIdPredicate finder(app_id); @@ -284,6 +309,14 @@ ApplicationSharedPtr ApplicationManagerImpl::pending_application_by_policy_id( return FindPendingApp(accessor, finder); } +ApplicationSharedPtr +ApplicationManagerImpl::reregister_application_by_policy_id( + const std::string& policy_app_id) const { + PolicyAppIdPredicate finder(policy_app_id); + DataAccessor<ReregisterWaitList> accessor = reregister_applications(); + return FindReregisterApp(accessor, finder); +} + bool ActiveAppPredicate(const ApplicationSharedPtr app) { return app ? app->IsFullscreen() : false; } @@ -295,7 +328,9 @@ ApplicationSharedPtr ApplicationManagerImpl::active_application() const { } bool LimitedAppPredicate(const ApplicationSharedPtr app) { - return app ? app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED : false; + return app ? app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED + : false; } ApplicationSharedPtr ApplicationManagerImpl::get_limited_media_application() @@ -306,7 +341,8 @@ ApplicationSharedPtr ApplicationManagerImpl::get_limited_media_application() bool LimitedNaviAppPredicate(const ApplicationSharedPtr app) { return app ? (app->is_navi() && - app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED) : false; } @@ -318,7 +354,8 @@ ApplicationSharedPtr ApplicationManagerImpl::get_limited_navi_application() bool LimitedVoiceAppPredicate(const ApplicationSharedPtr app) { return app ? (app->is_voice_communication_supported() && - app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED) : false; } @@ -340,7 +377,8 @@ ApplicationManagerImpl::applications_with_navi() { bool LimitedMobileProjectionPredicate(const ApplicationSharedPtr app) { return app ? (app->mobile_projection_enabled() && - app->hmi_level() == mobile_api::HMILevel::HMI_LIMITED) + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW) == + mobile_api::HMILevel::HMI_LIMITED) : false; } @@ -381,16 +419,12 @@ struct IsApplication { connection_handler::DeviceHandle device_handle_; const std::string& policy_app_id_; }; -void ApplicationManagerImpl::IviInfoUpdated( - mobile_apis::VehicleDataType::eType vehicle_info, int value) { +void ApplicationManagerImpl::IviInfoUpdated(const std::string& vehicle_info, + int value) { // Notify Policy Manager if available about info it's interested in, // i.e. odometer etc - switch (vehicle_info) { - case mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER: - GetPolicyHandler().KmsChanged(value); - break; - default: - break; + if (strings::odometer == vehicle_info) { + GetPolicyHandler().KmsChanged(value); } } @@ -565,12 +599,16 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( HmiStatePtr initial_state = CreateRegularState(std::shared_ptr<Application>(application), + mobile_apis::WindowType::MAIN, mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, mobile_apis::VideoStreamingState::INVALID_ENUM, mobile_api::SystemContext::SYSCTXT_MAIN); - application->SetInitialState(initial_state); + application->SetInitialState( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + std::string(), // should not be tracked for main window + initial_state); application->set_folder_name(policy_app_id + "_" + application->mac_address()); @@ -595,11 +633,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( Version version; int32_t min_version = message[strings::msg_params][strings::sync_msg_version] - [strings::minor_version].asInt(); + [strings::minor_version] + .asInt(); version.min_supported_api_version = static_cast<APIVersion>(min_version); int32_t max_version = message[strings::msg_params][strings::sync_msg_version] - [strings::major_version].asInt(); + [strings::major_version] + .asInt(); version.max_supported_api_version = static_cast<APIVersion>(max_version); application->set_version(version); @@ -724,18 +764,15 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { LOG4CXX_DEBUG(logger_, "Activating application with id:" << app->app_id()); - // remove from resumption if app was activated by user + // Remove from resumption if app was activated by user resume_controller().OnAppActivated(app); + // Activate any app services published by the app GetAppServiceManager().OnAppActivated(app); - const HMILevel::eType hmi_level = HMILevel::HMI_FULL; - const AudioStreamingState::eType audio_state = - app->IsAudioApplication() ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE; - const VideoStreamingState::eType video_state = - app->IsVideoApplication() ? VideoStreamingState::STREAMABLE - : VideoStreamingState::NOT_STREAMABLE; - state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, false); + + // Activate main window in state controller + state_ctrl_.ActivateDefaultWindow(app); + return true; } @@ -1061,9 +1098,9 @@ void ApplicationManagerImpl::RefreshCloudAppInformation() { ApplicationSet::iterator it = std::find_if( apps_to_register_.begin(), apps_to_register_.end(), finder); if (it == apps_to_register_.end()) { - LOG4CXX_DEBUG(logger_, - "Unable to find app to remove (" << policy_app_id - << "), skipping"); + LOG4CXX_DEBUG( + logger_, + "Unable to find app to remove (" << policy_app_id << "), skipping"); continue; } app = *it; @@ -1303,11 +1340,13 @@ void ApplicationManagerImpl::SetAllAppsAllowed(const bool allowed) { HmiStatePtr ApplicationManagerImpl::CreateRegularState( std::shared_ptr<Application> app, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::VideoStreamingState::eType video_state, - mobile_apis::SystemContext::eType system_context) const { + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, + const mobile_apis::SystemContext::eType system_context) const { HmiStatePtr state(new HmiState(app, *this)); + state->set_window_type(window_type); state->set_hmi_level(hmi_level); state->set_audio_streaming_state(audio_state); state->set_video_streaming_state(video_state); @@ -1531,7 +1570,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( { // During sending of UpdateDeviceList this lock is acquired also so making // it scoped - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); for (auto i = reregister_wait_list_.begin(); reregister_wait_list_.end() != i; ++i) { @@ -1571,7 +1610,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingFinish( const std::string& device_uid) { LOG4CXX_AUTO_TRACE(logger_); UNUSED(device_uid); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); const bool unexpected_disonnect = true; const bool is_resuming = true; @@ -1629,7 +1668,8 @@ mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel( if (GetPolicyHandler().PolicyEnabled()) { const std::string policy_app_id = application->policy_app_id(); std::string default_hmi_string = ""; - if (GetPolicyHandler().GetDefaultHmi(policy_app_id, &default_hmi_string)) { + if (GetPolicyHandler().GetDefaultHmi( + application->mac_address(), policy_app_id, &default_hmi_string)) { if ("BACKGROUND" == default_hmi_string) { default_hmi = HMILevel::HMI_BACKGROUND; } else if ("FULL" == default_hmi_string) { @@ -1887,21 +1927,21 @@ void ApplicationManagerImpl::OnServiceStartedCallback( using namespace helpers; using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "ServiceType = " << type << ". Session = " << std::hex - << session_key); + LOG4CXX_DEBUG( + logger_, + "ServiceType = " << type << ". Session = " << std::hex << session_key); std::vector<std::string> empty; - if (type == kRpc) { + if (kRpc == type) { 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."); + LOG4CXX_WARN( + logger_, + "The application with id:" << session_key << " doesn't exists."); connection_handler().NotifyServiceStartedResult(session_key, false, empty); return; } @@ -1919,6 +1959,7 @@ void ApplicationManagerImpl::OnServiceStartedCallback( } else { LOG4CXX_WARN(logger_, "Refuse unknown service"); } + connection_handler().NotifyServiceStartedResult(session_key, false, empty); } @@ -1941,7 +1982,7 @@ void ApplicationManagerImpl::OnServiceEndedCallback( return; } - if (IsAppInReconnectMode(app->policy_app_id())) { + if (IsAppInReconnectMode(app->device(), app->policy_app_id())) { LOG4CXX_DEBUG(logger_, "Application is in reconnection list and won't be closed."); return; @@ -2001,6 +2042,79 @@ void ApplicationManagerImpl::OnServiceEndedCallback( } } +void ApplicationManagerImpl::ProcessServiceStatusUpdate( + const uint32_t connection_key, + hmi_apis::Common_ServiceType::eType service_type, + hmi_apis::Common_ServiceEvent::eType service_event, + utils::Optional<hmi_apis::Common_ServiceStatusUpdateReason::eType> + service_update_reason) { + LOG4CXX_AUTO_TRACE(logger_); + + LOG4CXX_DEBUG(logger_, + "Processing status update with connection key: " + << connection_key << " service type: " << service_type + << " service_event " << service_event + << " service_update_reason " << service_update_reason); + + const auto app = application(connection_key); + + const uint32_t app_id = app ? app->app_id() : 0u; + + auto reason = service_update_reason + ? *service_update_reason + : hmi_apis::Common_ServiceStatusUpdateReason::INVALID_ENUM; + + auto notification = MessageHelper::CreateOnServiceUpdateNotification( + service_type, service_event, reason, app_id); + + rpc_service_->ManageHMICommand(notification); + + if (hmi_apis::Common_ServiceEvent::REQUEST_REJECTED == service_event && + HandleRejectedServiceStatus(app, service_type)) { + state_ctrl_.SetRegularState(app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + true); + } +} + +bool ApplicationManagerImpl::HandleRejectedServiceStatus( + ApplicationSharedPtr app, + const hmi_apis::Common_ServiceType::eType service_type) { + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_WARN(logger_, "Received invalid app"); + return false; + } + + switch (service_type) { + case hmi_apis::Common_ServiceType::VIDEO: + case hmi_apis::Common_ServiceType::AUDIO: { + { + sync_primitives::AutoLock lock(navi_service_status_lock_); + auto app_services = navi_service_status_.find(app->app_id()); + if (navi_service_status_.end() != app_services) { + navi_service_status_.erase(app_services); + } + } + LOG4CXX_DEBUG(logger_, + "The start of service" + << service_type << " for appID: " << app + << " is failed. Service info has been removed"); + return true; + } + case hmi_apis::Common_ServiceType::RPC: { + connection_handler().SendEndService(app->app_id(), + protocol_handler::ServiceType::kRpc); + LOG4CXX_DEBUG(logger_, "RPC service for appID: " << app << " is stopped"); + return true; + } + default: + LOG4CXX_DEBUG(logger_, "Unknown service type: " << service_type); + return false; + } +} + void ApplicationManagerImpl::OnSecondaryTransportStartedCallback( const connection_handler::DeviceHandle device_handle, const int32_t session_key) { @@ -2061,9 +2175,9 @@ void ApplicationManagerImpl::OnSecondaryTransportEndedCallback( connection_handler::DeviceHandle device_handle = app->secondary_device(); if (device_handle == 0) { - LOG4CXX_WARN(logger_, - "Secondary transport of app " << session_key - << " is not found"); + LOG4CXX_WARN( + logger_, + "Secondary transport of app " << session_key << " is not found"); return; } @@ -2093,7 +2207,12 @@ bool ApplicationManagerImpl::OnHandshakeDone( using namespace helpers; ApplicationSharedPtr app = application(connection_key); - DCHECK_OR_RETURN(app, false); + if (!app) { + LOG4CXX_WARN(logger_, + "Application for connection key: " << connection_key + << " was not found"); + return false; + } if (Compare<SSLContext::HandshakeResult, EQ, ONE>( result, SSLContext::Handshake_Result_CertExpired, @@ -2105,8 +2224,14 @@ bool ApplicationManagerImpl::OnHandshakeDone( } return false; } +#ifdef ENABLE_SECURITY +bool ApplicationManagerImpl::OnPTUFailed() { + LOG4CXX_AUTO_TRACE(logger_); + return false; +} +#endif // ENABLE_SECURITY -bool ApplicationManagerImpl::OnHandshakeFailed() { +bool ApplicationManagerImpl::OnGetSystemTimeFailed() { LOG4CXX_AUTO_TRACE(logger_); return false; } @@ -2194,7 +2319,7 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, media_manager::MediaManager* media_manager) { LOG4CXX_TRACE(logger_, "Init application manager"); plugin_manager_.reset(new plugin_manager::RPCPluginManagerImpl( - *this, *rpc_service_, *hmi_capabilities_, *policy_handler_)); + *this, *rpc_service_, *hmi_capabilities_, *policy_handler_, last_state)); if (!plugin_manager_->LoadPlugins(get_settings().plugins_folder())) { LOG4CXX_ERROR(logger_, "Plugins are not loaded"); return false; @@ -2257,6 +2382,13 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, app_service_manager_.reset( new application_manager::AppServiceManager(*this, last_state)); + + auto on_app_policy_updated = [](plugin_manager::RPCPlugin& plugin) { + plugin.OnPolicyEvent(plugin_manager::kApplicationPolicyUpdated); + }; + + plugin_manager_->ForEachPlugin(on_app_policy_updated); + return true; } @@ -2280,6 +2412,8 @@ bool ApplicationManagerImpl::Stop() { LOG4CXX_DEBUG(logger_, "Unloading policy library."); GetPolicyHandler().UnloadPolicyLibrary(); + rpc_service_->Stop(); + return true; } @@ -2488,8 +2622,24 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, } const std::string policy_app_id(app_data[json::appId].asString()); - ApplicationSharedPtr registered_app = - application_by_policy_id(policy_app_id); + + connection_handler::DeviceHandle device_handle; + if (-1 == connection_handler().get_session_observer().GetDataOnSessionKey( + connection_key, nullptr, nullptr, &device_handle)) { + LOG4CXX_ERROR(logger_, + "Failed to create application: no connection info."); + continue; + } + + std::string device_id; + if (-1 == connection_handler().get_session_observer().GetDataOnDeviceID( + device_handle, nullptr, nullptr, &device_id)) { + LOG4CXX_ERROR(logger_, + "Failed to create application: no connection info."); + continue; + } + + ApplicationSharedPtr registered_app = application(device_id, policy_app_id); if (registered_app) { LOG4CXX_DEBUG(logger_, "Application with the same id: " @@ -2528,23 +2678,9 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, const std::string app_icon_dir(settings_.app_icons_folder()); const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); - connection_handler::DeviceHandle device_id = 0; - - if (-1 == - connection_handler().get_session_observer().GetDataOnSessionKey( - connection_key, NULL, NULL, &device_id)) { - LOG4CXX_ERROR(logger_, - "Failed to create application: no connection info."); - continue; - } - - std::string device_mac; - connection_handler().get_session_observer().GetDataOnDeviceID( - device_id, NULL, NULL, &device_mac, NULL); - const uint32_t hmi_app_id = - resume_controller().IsApplicationSaved(policy_app_id, device_mac) - ? resume_controller().GetHMIApplicationID(policy_app_id, device_mac) + resume_controller().IsApplicationSaved(policy_app_id, device_id) + ? resume_controller().GetHMIApplicationID(policy_app_id, device_id) : GenerateNewHMIAppID(); // AppId = 0 because this is query_app(provided by hmi for download, but not @@ -2552,8 +2688,8 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, ApplicationSharedPtr app( new ApplicationImpl(0, policy_app_id, - device_mac, device_id, + device_handle, appName, GetPolicyHandler().GetStatisticManager(), *this)); @@ -2871,9 +3007,9 @@ void ApplicationManagerImpl::RemoveAppsWaitingForRegistration( apps_to_register_.begin(), apps_to_register_.end(), device_finder); while (apps_to_register_.end() != it_app) { - LOG4CXX_DEBUG(logger_, - "Waiting app: " << (*it_app)->name().c_str() - << " is removed."); + LOG4CXX_DEBUG( + logger_, + "Waiting app: " << (*it_app)->name().c_str() << " is removed."); apps_to_register_.erase(it_app); it_app = std::find_if( apps_to_register_.begin(), apps_to_register_.end(), device_finder); @@ -3019,6 +3155,9 @@ void ApplicationManagerImpl::UnregisterApplication( MessageHelper::SendOnAppUnregNotificationToHMI( app_to_remove, is_unexpected_disconnect, *this); request_ctrl_.terminateAppRequests(app_id); + if (applications_.empty()) { + policy_handler_->StopRetrySequence(); + } return; } @@ -3029,6 +3168,7 @@ void ApplicationManagerImpl::OnAppUnauthorized(const uint32_t& app_id) { mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( const ApplicationSharedPtr app, + const WindowID window_id, const std::string& function_id, const RPCParams& rpc_params, CommandParametersPermissions* params_permissions) { @@ -3041,7 +3181,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( DCHECK(app); policy::CheckPermissionResult result; - GetPolicyHandler().CheckPermissions(app, function_id, rpc_params, result); + GetPolicyHandler().CheckPermissions( + app, window_id, function_id, rpc_params, result); if (NULL != params_permissions) { params_permissions->allowed_params = result.list_of_allowed_params; @@ -3049,7 +3190,9 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( params_permissions->undefined_params = result.list_of_undefined_params; } - if (app->hmi_level() == mobile_apis::HMILevel::HMI_NONE && + // Record statistics for default window only + if (app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) == + mobile_apis::HMILevel::HMI_NONE && function_id != MessageHelper::StringifiedFunctionID( mobile_apis::FunctionID::UnregisterAppInterfaceID)) { if (result.hmi_level_permitted != policy::kRpcAllowed) { @@ -3060,7 +3203,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( #ifdef ENABLE_LOG const std::string log_msg = "Application: " + app->policy_app_id() + ", RPC: " + function_id + - ", HMI status: " + MessageHelper::StringifiedHMILevel(app->hmi_level()); + ", window_id: " + std::to_string(window_id) + ", HMI status: " + + MessageHelper::StringifiedHMILevel(app->hmi_level(window_id)); #endif // ENABLE_LOG if (result.hmi_level_permitted != policy::kRpcAllowed) { LOG4CXX_WARN(logger_, "Request is blocked by policies. " << log_msg); @@ -3104,10 +3248,10 @@ bool ApplicationManagerImpl::IsLowVoltage() const { void ApplicationManagerImpl::OnWakeUp() { LOG4CXX_AUTO_TRACE(logger_); - is_low_voltage_ = false; resume_ctrl_->SaveWakeUpTime(); resume_ctrl_->StartSavePersistentDataTimer(); request_ctrl_.OnWakeUp(); + is_low_voltage_ = false; } std::string ApplicationManagerImpl::GetHashedAppID( @@ -3133,7 +3277,10 @@ bool ApplicationManagerImpl::HMILevelAllowsStreaming( LOG4CXX_WARN(logger_, "An application is not registered."); return false; } - return Compare<eType, EQ, ONE>(app->hmi_level(), HMI_FULL, HMI_LIMITED); + return Compare<eType, EQ, ONE>( + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW), + HMI_FULL, + HMI_LIMITED); } bool ApplicationManagerImpl::CanAppStream( @@ -3263,6 +3410,7 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) { connection_handler().SendEndService(app_id, ServiceType::kAudio); app->StopStreamingForce(ServiceType::kAudio); } + DisallowStreaming(app_id); navi_app_to_stop_.push_back(app_id); @@ -3297,14 +3445,16 @@ void ApplicationManagerImpl::ProcessPostponedMessages(const uint32_t app_id) { } MobileMessageQueue messages; app->SwapMobileMessageQueue(messages); - auto push_allowed_messages = [this, &app]( - smart_objects::SmartObjectSPtr message) { + auto push_allowed_messages = [this, + &app](smart_objects::SmartObjectSPtr message) { const std::string function_id = MessageHelper::StringifiedFunctionID( static_cast<mobile_apis::FunctionID::eType>( (*message)[strings::params][strings::function_id].asUInt())); + const WindowID window_id = MessageHelper::ExtractWindowIdFromSmartObject( + (*message)[strings::msg_params]); const RPCParams params; const mobile_apis::Result::eType check_result = - CheckPolicyPermissions(app, function_id, params); + CheckPolicyPermissions(app, window_id, function_id, params); if (mobile_api::Result::SUCCESS == check_result) { rpc_service_->ManageMobileCommand(message, commands::Command::SOURCE_SDL); } else { @@ -3359,39 +3509,6 @@ void ApplicationManagerImpl::ProcessApp(const uint32_t app_id, } } -void ApplicationManagerImpl::SendHMIStatusNotification( - const std::shared_ptr<Application> app) { - LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(app); - smart_objects::SmartObjectSPtr notification = - std::make_shared<smart_objects::SmartObject>(); - 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>(app->app_id()); - - message[strings::msg_params][strings::hmi_level] = - static_cast<int32_t>(app->hmi_level()); - - message[strings::msg_params][strings::audio_streaming_state] = - static_cast<int32_t>(app->audio_streaming_state()); - - message[strings::msg_params][strings::video_streaming_state] = - static_cast<int32_t>(app->video_streaming_state()); - - message[strings::msg_params][strings::system_context] = - static_cast<int32_t>(app->system_context()); - - rpc_service_->ManageMobileCommand(notification, - commands::Command::SOURCE_SDL); -} - void ApplicationManagerImpl::ClearTimerPool() { LOG4CXX_AUTO_TRACE(logger_); @@ -3513,14 +3630,14 @@ bool ApplicationManagerImpl::IsApplicationForbidden( } bool ApplicationManagerImpl::IsAppInReconnectMode( + const connection_handler::DeviceHandle& device_id, const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); return reregister_wait_list_.end() != std::find_if(reregister_wait_list_.begin(), reregister_wait_list_.end(), - std::bind1st(std::ptr_fun(&policy_app_id_comparator), - policy_app_id)); + PolicyAppIdComparator(device_id, policy_app_id)); } policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice( @@ -3822,13 +3939,18 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( if (flag_diffirence_app_hmi_type) { (*it)->set_app_types(transform_app_hmi_types); (*it)->ChangeSupportingAppHMIType(); - if ((*it)->hmi_level() == mobile_api::HMILevel::HMI_BACKGROUND) { + const mobile_apis::HMILevel::eType app_hmi_level = + (*it)->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); + if (app_hmi_level == mobile_api::HMILevel::HMI_BACKGROUND) { MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); - } else if (((*it)->hmi_level() == mobile_api::HMILevel::HMI_FULL) || - ((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) { + } else if ((app_hmi_level == mobile_api::HMILevel::HMI_FULL) || + (app_hmi_level == mobile_api::HMILevel::HMI_LIMITED)) { MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); state_controller().SetRegularState( - *it, mobile_apis::HMILevel::HMI_BACKGROUND, true); + *it, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_BACKGROUND, + true); } } } @@ -3844,11 +3966,11 @@ void ApplicationManagerImpl::EraseAppFromReconnectionList( } const auto policy_app_id = app->policy_app_id(); - sync_primitives::AutoLock lock(reregister_wait_list_lock_); - auto app_it = std::find_if( - reregister_wait_list_.begin(), - reregister_wait_list_.end(), - std::bind1st(std::ptr_fun(&policy_app_id_comparator), policy_app_id)); + sync_primitives::AutoLock lock(reregister_wait_list_lock_ptr_); + auto app_it = + std::find_if(reregister_wait_list_.begin(), + reregister_wait_list_.end(), + PolicyAppIdComparator(app->device(), policy_app_id)); if (reregister_wait_list_.end() != app_it) { reregister_wait_list_.erase(app_it); } @@ -3880,6 +4002,7 @@ void ApplicationManagerImpl::ProcessReconnection( void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { LOG4CXX_AUTO_TRACE(logger_); if (!ptu_result) { + protocol_handler_->ProcessFailedPTU(); return; } @@ -3898,6 +4021,25 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { plugin_manager_->ForEachPlugin(on_app_policy_updated); } +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) +void ApplicationManagerImpl::OnCertDecryptFinished(const bool decrypt_result) { + LOG4CXX_AUTO_TRACE(logger_); + if (!decrypt_result) { + protocol_handler_->ProcessFailedCertDecrypt(); + } +} + +bool ApplicationManagerImpl::OnCertDecryptFailed() { + LOG4CXX_AUTO_TRACE(logger_); + return false; +} +#endif + +void ApplicationManagerImpl::OnPTUTimeoutExceeded() { + LOG4CXX_AUTO_TRACE(logger_); + protocol_handler_->ProcessFailedPTU(); +} + void ApplicationManagerImpl::SendDriverDistractionState( ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); @@ -3906,30 +4048,72 @@ void ApplicationManagerImpl::SendDriverDistractionState( LOG4CXX_WARN(logger_, "DriverDistractionState is INVALID_ENUM"); return; } - smart_objects::SmartObjectSPtr on_driver_distraction = - std::make_shared<smart_objects::SmartObject>(); - (*on_driver_distraction)[strings::params][strings::message_type] = - static_cast<int32_t>(application_manager::MessageType::kNotification); - (*on_driver_distraction)[strings::params][strings::function_id] = - mobile_api::FunctionID::OnDriverDistractionID; - (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = - driver_distraction_state(); - (*on_driver_distraction)[strings::params][strings::connection_key] = - application->app_id(); + auto create_notification = [application, this]() { + auto notification = std::make_shared<smart_objects::SmartObject>(); + auto& msg_params = (*notification)[strings::msg_params]; + auto& params = (*notification)[strings::params]; + + params[strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + params[strings::function_id] = + static_cast<int32_t>(mobile_apis::FunctionID::OnDriverDistractionID); + msg_params[mobile_notification::state] = driver_distraction_state(); + const auto lock_screen_dismissal = + policy_handler_->LockScreenDismissalEnabledState(); + + if (lock_screen_dismissal && + hmi_apis::Common_DriverDistractionState::DD_ON == + driver_distraction_state()) { + bool dismissal_enabled = *lock_screen_dismissal; + if (dismissal_enabled) { + const auto language = + MessageHelper::MobileLanguageToString(application->ui_language()); + + const auto warning_message = + policy_handler_->LockScreenDismissalWarningMessage(language); + // Only allow lock screen dismissal if a warning message is available + if (warning_message && !warning_message->empty()) { + msg_params[mobile_notification::lock_screen_dismissal_warning] = + *warning_message; + } else { + dismissal_enabled = false; + } + } + msg_params[mobile_notification::lock_screen_dismissal_enabled] = + dismissal_enabled; + } + + params[strings::connection_key] = application->app_id(); + return notification; + }; - const std::string function_id = MessageHelper::StringifiedFunctionID( - static_cast<mobile_apis::FunctionID::eType>( - (*on_driver_distraction)[strings::params][strings::function_id] - .asUInt())); const RPCParams params; + const std::string function_id = MessageHelper::StringifiedFunctionID( + mobile_api::FunctionID::OnDriverDistractionID); const mobile_apis::Result::eType check_result = - CheckPolicyPermissions(application, function_id, params); + CheckPolicyPermissions(application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + function_id, + params); if (mobile_api::Result::SUCCESS == check_result) { - rpc_service_->ManageMobileCommand(on_driver_distraction, + rpc_service_->ManageMobileCommand(create_notification(), commands::Command::SOURCE_SDL); } else { - application->PushMobileMessage(on_driver_distraction); + MobileMessageQueue messages; + application->SwapMobileMessageQueue(messages); + messages.erase( + std::remove_if( + messages.begin(), + messages.end(), + [](smart_objects::SmartObjectSPtr message) { + return (*message)[strings::params][strings::function_id] + .asUInt() == + mobile_apis::FunctionID::OnDriverDistractionID; + }), + messages.end()); + application->SwapMobileMessageQueue(messages); + application->PushMobileMessage(create_notification()); } } @@ -4016,9 +4200,9 @@ bool ApplicationManagerImpl::InitDirectory( LOG4CXX_WARN(logger_, directory_type << " directory doesn't exist."); // if storage directory doesn't exist try to create it if (!file_system::CreateDirectoryRecursively(path)) { - LOG4CXX_ERROR(logger_, - "Unable to create " << directory_type << " directory " - << path); + LOG4CXX_ERROR( + logger_, + "Unable to create " << directory_type << " directory " << path); return false; } LOG4CXX_DEBUG(logger_, @@ -4033,9 +4217,9 @@ bool ApplicationManagerImpl::IsReadWriteAllowed(const std::string& path, const std::string directory_type = DirectoryTypeToString(type); if (!(file_system::IsWritingAllowed(path) && file_system::IsReadingAllowed(path))) { - LOG4CXX_ERROR(logger_, - directory_type - << " directory doesn't have read/write permissions."); + LOG4CXX_ERROR( + logger_, + directory_type << " directory doesn't have read/write permissions."); return false; } @@ -4202,16 +4386,11 @@ bool ApplicationManagerImpl::IsSOStructValid( const smart_objects::SmartObject& display_capabilities) { smart_objects::SmartObject display_capabilities_so = display_capabilities; if (hmi_so_factory().AttachSchema(struct_id, display_capabilities_so)) { - if (display_capabilities_so.isValid()) { - return true; - } else { - return false; - } - } else { - LOG4CXX_ERROR(logger_, "Could not find struct id: " << struct_id); - return false; + return display_capabilities_so.isValid(); } - return true; + + LOG4CXX_ERROR(logger_, "Could not find struct id: " << struct_id); + return false; } #ifdef BUILD_TESTS @@ -4294,9 +4473,10 @@ void ApplicationManagerImpl::ChangeAppsHMILevel( LOG4CXX_ERROR(logger_, "There is no app with id: " << app_id); return; } - const mobile_apis::HMILevel::eType old_level = app->hmi_level(); + const mobile_apis::HMILevel::eType old_level = + app->hmi_level(mobile_api::PredefinedWindows::DEFAULT_WINDOW); if (old_level != level) { - app->set_hmi_level(level); + app->set_hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, level); OnHMILevelChanged(app_id, old_level, level); } else { LOG4CXX_WARN(logger_, "Redundant changing HMI level: " << level); diff --git a/src/components/application_manager/src/application_state.cc b/src/components/application_manager/src/application_state.cc index 3f775ee4e2..6ed784424a 100644 --- a/src/components/application_manager/src/application_state.cc +++ b/src/components/application_manager/src/application_state.cc @@ -31,7 +31,10 @@ */ #include "application_manager/application_state.h" + #include <algorithm> +#include <string> + #include "utils/logger.h" #include "utils/macro.h" @@ -45,7 +48,7 @@ struct StateIDComparator { return cur->state_id() == state_id_; } }; -} +} // namespace namespace application_manager { @@ -53,193 +56,293 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") ApplicationState::ApplicationState() {} -void ApplicationState::InitState(HmiStatePtr state) { +void ApplicationState::InitState(const WindowID window_id, + const std::string& window_name, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - hmi_states_.clear(); - hmi_states_.push_back(state); + LOG4CXX_DEBUG(logger_, + "Initing state " << state << " for window " << window_id + << " with name " << window_name); + { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& states = hmi_states_map_[window_id]; + states.push_back(state); + } } -void ApplicationState::AddState(HmiStatePtr state) { +void ApplicationState::AddState(const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); switch (state->state_id()) { case HmiState::StateID::STATE_ID_REGULAR: - SetRegularState(state); + SetRegularState(window_id, state); return; case HmiState::StateID::STATE_ID_POSTPONED: - SetPostponedState(state); + SetPostponedState(window_id, state); return; case HmiState::StateID::STATE_ID_CURRENT: - LOG4CXX_ERROR(logger_, "State of type '" << state << "' can't be added."); + LOG4CXX_ERROR(logger_, + "State of type '" << state << "' can't be added for window " + << window_id); return; default: - AddHMIState(state); + AddHMIState(window_id, state); break; } return; } -void ApplicationState::RemoveState(HmiState::StateID state) { +void ApplicationState::RemoveState(const WindowID window_id, + HmiState::StateID state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); switch (state) { case HmiState::StateID::STATE_ID_CURRENT: case HmiState::StateID::STATE_ID_REGULAR: - LOG4CXX_ERROR(logger_, - "State of type '" << state << "'can't be removed."); + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id) { + LOG4CXX_ERROR(logger_, + "State of type '" << state + << "' can't be removed for window " + << window_id); + return; + } + + RemoveWindowHMIStates(window_id); break; case HmiState::StateID::STATE_ID_POSTPONED: - RemovePostponedState(); + RemovePostponedState(window_id); break; default: - RemoveHMIState(state); + RemoveHMIState(window_id, state); break; } } -HmiStatePtr ApplicationState::GetState(HmiState::StateID state_id) const { +HmiStatePtr ApplicationState::GetState(const WindowID window_id, + HmiState::StateID state_id) const { switch (state_id) { case HmiState::StateID::STATE_ID_REGULAR: - LOG4CXX_DEBUG(logger_, "Getting regular state."); - return RegularHmiState(); + LOG4CXX_DEBUG(logger_, "Getting regular state for window " << window_id); + return RegularHmiState(window_id); case HmiState::StateID::STATE_ID_POSTPONED: - LOG4CXX_DEBUG(logger_, "Getting postponed state."); - return PostponedHmiState(); + LOG4CXX_DEBUG(logger_, + "Getting postponed state for window " << window_id); + return PostponedHmiState(window_id); default: - LOG4CXX_DEBUG(logger_, "Getting current state."); - return CurrentHmiState(); + LOG4CXX_DEBUG(logger_, "Getting current state for window " << window_id); + return CurrentHmiState(window_id); } } -void ApplicationState::AddHMIState(HmiStatePtr state) { +HmiStates ApplicationState::GetStates(const HmiState::StateID state_id) const { + LOG4CXX_DEBUG(logger_, "Collecting all states of type " << state_id); + + HmiStates hmi_states; + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + for (const auto& hmi_state_pair : hmi_states_map_) { + hmi_states.push_back(GetState(hmi_state_pair.first, state_id)); + } + + return hmi_states; +} + +WindowIds ApplicationState::GetWindowIds() const { + LOG4CXX_DEBUG(logger_, "Collecting available window ID's"); + + WindowIds window_ids; + std::string stringified_window_ids; + + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + for (const auto& hmi_state_pair : hmi_states_map_) { + window_ids.push_back(hmi_state_pair.first); + stringified_window_ids += (stringified_window_ids.empty() ? "" : ", ") + + std::to_string(hmi_state_pair.first); + } + + LOG4CXX_DEBUG(logger_, + "Existing window IDs: [" + stringified_window_ids + "]"); + return window_ids; +} + +void ApplicationState::AddHMIState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - HmiStates::iterator it = std::find_if(hmi_states_.begin(), - hmi_states_.end(), + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + HmiStates::iterator it = std::find_if(hmi_states.begin(), + hmi_states.end(), StateIDComparator(state->state_id())); - if (hmi_states_.end() != it) { - LOG4CXX_WARN( - logger_, - "Hmi state with ID " - << state->state_id() - << "has been already applied to this application. Ignoring"); + if (hmi_states.end() != it) { + LOG4CXX_WARN(logger_, + "Hmi state with ID " << state->state_id() + << "has been already applied for window " + << window_id + << " of this application. Ignoring"); return; } - hmi_states_.push_back(state); + hmi_states.push_back(state); } -void ApplicationState::RemoveHMIState(HmiState::StateID state_id) { +void ApplicationState::RemoveHMIState(const WindowID window_id, + HmiState::StateID state_id) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; HmiStates::iterator it = std::find_if( - hmi_states_.begin(), hmi_states_.end(), StateIDComparator(state_id)); - if (it == hmi_states_.end()) { - LOG4CXX_ERROR(logger_, "Unsuccesful remove HmiState: " << state_id); + hmi_states.begin(), hmi_states.end(), StateIDComparator(state_id)); + if (hmi_states.end() == it) { + LOG4CXX_ERROR(logger_, + "Unsuccesful remove HmiState: " << state_id << " for window " + << window_id); return; } // unable to remove regular state - DCHECK_OR_RETURN_VOID(it != hmi_states_.begin()); + DCHECK_OR_RETURN_VOID(hmi_states.begin() != it); HmiStates::iterator next = it; HmiStates::iterator prev = it; next++; prev--; - if (next != hmi_states_.end()) { + + if (next != hmi_states.end()) { HmiStatePtr next_state = *next; HmiStatePtr prev_state = *prev; next_state->set_parent(prev_state); } - hmi_states_.erase(it); + + hmi_states.erase(it); } -void ApplicationState::RemovePostponedState() { +void ApplicationState::RemoveWindowHMIStates(const WindowID window_id) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); + DCHECK_OR_RETURN_VOID(mobile_apis::PredefinedWindows::DEFAULT_WINDOW != + window_id); + + LOG4CXX_DEBUG(logger_, + "Removing HMI states for window with id #" << window_id); + { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + hmi_states_map_.erase(window_id); + } +} + +void ApplicationState::RemovePostponedState(const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + DCHECK_OR_RETURN_VOID(!hmi_states.empty()); StateIDComparator finder(HmiState::StateID::STATE_ID_POSTPONED); HmiStates::iterator postponed_state = - std::find_if(hmi_states_.begin(), hmi_states_.end(), finder); + std::find_if(hmi_states.begin(), hmi_states.end(), finder); - if (hmi_states_.end() == postponed_state) { - LOG4CXX_ERROR(logger_, "No postponed state is set for app."); + if (hmi_states.end() == postponed_state) { + LOG4CXX_ERROR(logger_, + "No postponed state is set for window " << window_id); return; } - hmi_states_.erase(postponed_state); + + hmi_states.erase(postponed_state); } -void ApplicationState::SetRegularState(HmiStatePtr state) { +void ApplicationState::SetRegularState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::StateID::STATE_ID_REGULAR); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + DCHECK_OR_RETURN_VOID(!hmi_states.empty()); - HmiStatePtr front_state = hmi_states_.front(); + HmiStatePtr front_state = hmi_states.front(); HmiState::StateID front_state_id = front_state->state_id(); if (HmiState::StateID::STATE_ID_POSTPONED == front_state_id) { // Drop postponed state - hmi_states_.erase(hmi_states_.begin()); + hmi_states.erase(hmi_states.begin()); } // Drop regular state - hmi_states_.erase(hmi_states_.begin()); + hmi_states.erase(hmi_states.begin()); - if (!hmi_states_.empty()) { - HmiStatePtr front_state = hmi_states_.front(); + if (!hmi_states.empty()) { + HmiStatePtr front_state = hmi_states.front(); front_state->set_parent(state); } - hmi_states_.insert(hmi_states_.begin(), state); + + // Insert new regular state + hmi_states.insert(hmi_states.begin(), state); if (HmiState::StateID::STATE_ID_POSTPONED == front_state_id) { - hmi_states_.insert(hmi_states_.begin(), front_state); + // Restore postponed state if it was before + hmi_states.insert(hmi_states.begin(), front_state); } } -void ApplicationState::SetPostponedState(HmiStatePtr state) { +void ApplicationState::SetPostponedState(const WindowID window_id, + HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::StateID::STATE_ID_POSTPONED); - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); - HmiStatePtr front_state = hmi_states_.front(); + + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + HmiStates& hmi_states = hmi_states_map_[window_id]; + DCHECK_OR_RETURN_VOID(!hmi_states.empty()); + HmiStatePtr front_state = hmi_states.front(); if (front_state->state_id() == HmiState::StateID::STATE_ID_POSTPONED) { - hmi_states_.erase(hmi_states_.begin()); + hmi_states.erase(hmi_states.begin()); } - hmi_states_.insert(hmi_states_.begin(), state); + + hmi_states.insert(hmi_states.begin(), state); } -HmiStatePtr ApplicationState::CurrentHmiState() const { - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN(!hmi_states_.empty(), HmiStatePtr()); - HmiStatePtr back_state = hmi_states_.back(); +HmiStatePtr ApplicationState::CurrentHmiState(const WindowID window_id) const { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + auto it_states = hmi_states_map_.find(window_id); + DCHECK_OR_RETURN(it_states != hmi_states_map_.end(), HmiStatePtr()); + + const HmiStates& hmi_states = it_states->second; + DCHECK_OR_RETURN(!hmi_states.empty(), HmiStatePtr()); + + HmiStatePtr back_state = hmi_states.back(); DCHECK_OR_RETURN( back_state->state_id() != HmiState::StateID::STATE_ID_POSTPONED, HmiStatePtr()); + return back_state; } -HmiStatePtr ApplicationState::RegularHmiState() const { - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN(!hmi_states_.empty(), HmiStatePtr()); - HmiStates::const_iterator front_itr = hmi_states_.begin(); +HmiStatePtr ApplicationState::RegularHmiState(const WindowID window_id) const { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + auto it_states = hmi_states_map_.find(window_id); + DCHECK_OR_RETURN(it_states != hmi_states_map_.end(), HmiStatePtr()); + + const HmiStates& hmi_states = it_states->second; + DCHECK_OR_RETURN(!hmi_states.empty(), HmiStatePtr()); + + HmiStates::const_iterator front_itr = hmi_states.begin(); if ((*front_itr)->state_id() == HmiState::StateID::STATE_ID_POSTPONED) { ++front_itr; } + return *front_itr; } -HmiStatePtr ApplicationState::PostponedHmiState() const { - sync_primitives::AutoLock auto_lock(hmi_states_lock_); - DCHECK_OR_RETURN(!hmi_states_.empty(), HmiStatePtr()); - HmiStatePtr front_state = hmi_states_.front(); +HmiStatePtr ApplicationState::PostponedHmiState( + const WindowID window_id) const { + sync_primitives::AutoLock auto_lock(hmi_states_map_lock_); + auto it_states = hmi_states_map_.find(window_id); + DCHECK_OR_RETURN(it_states != hmi_states_map_.end(), HmiStatePtr()); + + const HmiStates& hmi_states = it_states->second; + DCHECK_OR_RETURN(!hmi_states.empty(), HmiStatePtr()); + + HmiStatePtr front_state = hmi_states.front(); return front_state->state_id() == HmiState::StateID::STATE_ID_POSTPONED ? front_state : HmiStatePtr(); diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index ea74e78f4e..1c336ac64f 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -43,20 +43,23 @@ CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager) void CommandHolderImpl::Suspend( ApplicationSharedPtr application, CommandType type, + commands::Command::CommandSource source, std::shared_ptr<smart_objects::SmartObject> command) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " << application->policy_app_id()); - sync_primitives::AutoLock lock(commands_lock_); + AppCommandInfo info = {command, source}; + + sync_primitives::AutoLock lock(commands_lock_); if (CommandType::kHmiCommand == type) { - app_hmi_commands_[application].push_back(command); + app_hmi_commands_[application].push_back(info); LOG4CXX_DEBUG(logger_, "Suspended HMI command(s): " << app_hmi_commands_.size()); } else { - app_mobile_commands_[application].push_back(command); + app_mobile_commands_[application].push_back(info); LOG4CXX_DEBUG( logger_, "Suspended mobile command(s): " << app_mobile_commands_.size()); @@ -113,8 +116,10 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { "Resuming HMI command(s): " << app_hmi_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id(); - app_manager_.GetRPCService().ManageHMICommand(cmd); + (*cmd.command_ptr_)[strings::msg_params][strings::app_id] = + application->hmi_app_id(); + app_manager_.GetRPCService().ManageHMICommand(cmd.command_ptr_, + cmd.command_source_); } app_hmi_commands_.erase(app_commands); @@ -132,11 +137,12 @@ void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { "Resuming mobile command(s): " << app_mobile_commands_.size()); for (auto cmd : app_commands->second) { - (*cmd)[strings::params][strings::connection_key] = application->app_id(); - app_manager_.GetRPCService().ManageMobileCommand( - cmd, commands::Command::CommandSource::SOURCE_MOBILE); + (*cmd.command_ptr_)[strings::params][strings::connection_key] = + application->app_id(); + app_manager_.GetRPCService().ManageMobileCommand(cmd.command_ptr_, + cmd.command_source_); } app_mobile_commands_.erase(app_commands); } -} // application_manager +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 04fabfb2ec..8875895cb7 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2014, Ford Motor Company All rights reserved. @@ -43,7 +43,7 @@ struct AppExtensionPredicate { return app ? (app->QueryInterface(uid).use_count() != 0) : false; } }; -} +} // namespace namespace commands { @@ -96,6 +96,15 @@ int32_t CommandImpl::function_id() const { return (*message_)[strings::params][strings::function_id].asInt(); } +WindowID CommandImpl::window_id() const { + if ((*message_).keyExists(strings::msg_params)) { + if ((*message_)[strings::msg_params].keyExists(strings::window_id)) { + return (*message_)[strings::msg_params][strings::window_id].asInt(); + } + } + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + uint32_t CommandImpl::connection_key() const { return (*message_)[strings::params][strings::connection_key].asUInt(); } diff --git a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc index 26b43856f7..bd4fa58c8f 100644 --- a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc @@ -32,8 +32,8 @@ #include "application_manager/commands/command_notification_from_mobile_impl.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" namespace application_manager { diff --git a/src/components/application_manager/src/commands/command_notification_impl.cc b/src/components/application_manager/src/commands/command_notification_impl.cc index 70df95986b..cc2606ab6f 100644 --- a/src/components/application_manager/src/commands/command_notification_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_impl.cc @@ -32,8 +32,8 @@ #include "application_manager/commands/command_notification_impl.h" #include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" #include "application_manager/message_helper.h" +#include "application_manager/rpc_service.h" 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 f67fde22a0..257ccfd9c3 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -112,7 +112,8 @@ const std::string CreateInfoForUnsupportedResult( } } -bool CheckResultCode(const ResponseInfo& first, const ResponseInfo& second) { +bool CommandRequestImpl::CheckResult(const ResponseInfo& first, + const ResponseInfo& second) const { if (first.is_ok && second.is_unsupported_resource) { return true; } @@ -144,19 +145,21 @@ struct DisallowedParamsInserter { : response_(response), code_(code) {} bool operator()(const std::string& param) { - const VehicleData& vehicle_data = - application_manager::MessageHelper::vehicle_data(); - VehicleData::const_iterator it = vehicle_data.find(param); - if (vehicle_data.end() != it) { - smart_objects::SmartObjectSPtr disallowed_param = - std::make_shared<smart_objects::SmartObject>( - smart_objects::SmartType_Map); - (*disallowed_param)[strings::data_type] = (*it).second; - (*disallowed_param)[strings::result_code] = code_; - response_[strings::msg_params][param.c_str()] = *disallowed_param; - return true; - } - return false; + smart_objects::SmartObjectSPtr disallowed_param = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + + auto rpc_spec_vehicle_data = MessageHelper::vehicle_data(); + auto vehicle_data = rpc_spec_vehicle_data.find(param); + auto vehicle_data_type = + vehicle_data == rpc_spec_vehicle_data.end() + ? mobile_apis::VehicleDataType::VEHICLEDATA_OEM_CUSTOM_DATA + : vehicle_data->second; + + (*disallowed_param)[strings::data_type] = vehicle_data_type; + (*disallowed_param)[strings::result_code] = code_; + response_[strings::msg_params][param.c_str()] = *disallowed_param; + return true; } private: @@ -186,13 +189,7 @@ ResponseInfo::ResponseInfo(const hmi_apis::Common_Result::eType result, interface_state = application_manager.hmi_interfaces().GetInterfaceState(hmi_interface); - is_ok = Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED); + is_ok = CommandRequestImpl::IsHMIResultSuccess(result_code); is_not_used = hmi_apis::Common_Result::INVALID_ENUM == result_code; @@ -306,9 +303,9 @@ void CommandRequestImpl::SendResponse( } // Add disallowed parameters and info from request back to response with - // appropriate - // reasons (VehicleData result codes) - if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) { + // appropriate reasons (VehicleData result codes) + if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED && + result_code != mobile_apis::Result::INVALID_DATA) { const mobile_apis::FunctionID::eType& id = static_cast<mobile_apis::FunctionID::eType>(function_id()); if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) || @@ -725,12 +722,17 @@ bool CommandRequestImpl::CheckAllowedParameters() { } mobile_apis::Result::eType check_result = - application_manager_.CheckPolicyPermissions( - app, - MessageHelper::StringifiedFunctionID( - static_cast<mobile_api::FunctionID::eType>(function_id())), - params, - ¶meters_permissions_); + mobile_apis::Result::eType::INVALID_ID; + const auto current_window_id = window_id(); + if (app->WindowIdExists(current_window_id)) { + check_result = application_manager_.CheckPolicyPermissions( + app, + current_window_id, + MessageHelper::StringifiedFunctionID( + static_cast<mobile_api::FunctionID::eType>(function_id())), + params, + ¶meters_permissions_); + } // Check, if RPC is allowed by policy if (mobile_apis::Result::SUCCESS != check_result) { @@ -799,49 +801,28 @@ void CommandRequestImpl::RemoveDisallowedParameters() { smart_objects::SmartObject& params = (*message_)[strings::msg_params]; - // Remove from request all disallowed parameters - RPCParams::const_iterator it_disallowed = - parameters_permissions_.disallowed_params.begin(); - RPCParams::const_iterator it_disallowed_end = - parameters_permissions_.disallowed_params.end(); - for (; it_disallowed != it_disallowed_end; ++it_disallowed) { - if (params.keyExists(*it_disallowed)) { - const std::string key = *it_disallowed; + for (const auto& key : params.enumerate()) { + if (parameters_permissions_.disallowed_params.end() != + parameters_permissions_.disallowed_params.find(key)) { + // Remove from request all disallowed parameters params.erase(key); removed_parameters_permissions_.disallowed_params.insert(key); LOG4CXX_INFO(logger_, "Following parameter is disallowed by user: " << key); } - } - // Remove from request all undefined yet parameters - RPCParams::const_iterator it_undefined = - parameters_permissions_.undefined_params.begin(); - RPCParams::const_iterator it_undefined_end = - parameters_permissions_.undefined_params.end(); - for (; it_undefined != it_undefined_end; ++it_undefined) { - if (params.keyExists(*it_undefined)) { - const std::string key = *it_undefined; + else if (removed_parameters_permissions_.undefined_params.end() != + removed_parameters_permissions_.undefined_params.find(key)) { + // Remove from request all undefined yet parameters params.erase(key); removed_parameters_permissions_.undefined_params.insert(key); LOG4CXX_INFO(logger_, "Following parameter is disallowed by policy: " << key); } - } - // Remove from request all parameters missed in allowed - const VehicleData& vehicle_data = - application_manager::MessageHelper::vehicle_data(); - - VehicleData::const_iterator it_vehicle_data = vehicle_data.begin(); - VehicleData::const_iterator it_vehicle_data_end = vehicle_data.end(); - for (; it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) { - const std::string key = it_vehicle_data->first; - if (params.keyExists(key) && - parameters_permissions_.allowed_params.end() == - std::find(parameters_permissions_.allowed_params.begin(), - parameters_permissions_.allowed_params.end(), - key)) { + else if (parameters_permissions_.allowed_params.end() == + parameters_permissions_.allowed_params.find(key)) { + // Remove from request all parameters missed in allowed params.erase(key); removed_parameters_permissions_.undefined_params.insert(key); LOG4CXX_INFO(logger_, @@ -910,7 +891,7 @@ bool CommandRequestImpl::HasDisallowedParams() const { } bool CommandRequestImpl::IsMobileResultSuccess( - mobile_apis::Result::eType result_code) const { + const mobile_apis::Result::eType result_code) { LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; return Compare<mobile_apis::Result::eType, EQ, ONE>( @@ -922,18 +903,24 @@ bool CommandRequestImpl::IsMobileResultSuccess( mobile_apis::Result::SAVED); } +bool CommandRequestImpl::IsHMIResultSuccess( + const hmi_apis::Common_Result::eType result_code) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + return Compare<hmi_apis::Common_Result::eType, EQ, ONE>( + result_code, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS, + hmi_apis::Common_Result::WRONG_LANGUAGE, + hmi_apis::Common_Result::RETRY, + hmi_apis::Common_Result::SAVED); +} + bool CommandRequestImpl::PrepareResultForMobileResponse( hmi_apis::Common_Result::eType result_code, HmiInterfaces::InterfaceID interface) const { LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; - if (Compare<hmi_apis::Common_Result::eType, EQ, ONE>( - result_code, - hmi_apis::Common_Result::SUCCESS, - hmi_apis::Common_Result::WARNINGS, - hmi_apis::Common_Result::WRONG_LANGUAGE, - hmi_apis::Common_Result::RETRY, - hmi_apis::Common_Result::SAVED)) { + if (IsHMIResultSuccess(result_code)) { return true; } @@ -949,8 +936,8 @@ bool CommandRequestImpl::PrepareResultForMobileResponse( bool CommandRequestImpl::PrepareResultForMobileResponse( ResponseInfo& out_first, ResponseInfo& out_second) const { LOG4CXX_AUTO_TRACE(logger_); - bool result = CheckResultCode(out_first, out_second) || - CheckResultCode(out_second, out_first); + bool result = + CheckResult(out_first, out_second) || CheckResult(out_second, out_first); return result; } diff --git a/src/components/application_manager/src/commands/request_from_hmi.cc b/src/components/application_manager/src/commands/request_from_hmi.cc index 873d9a844f..576287286f 100644 --- a/src/components/application_manager/src/commands/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/request_from_hmi.cc @@ -199,7 +199,7 @@ void RequestFromHMI::SendProviderRequest( if (hmi_destination) { LOG4CXX_DEBUG(logger_, "Sending Request to HMI Provider"); application_manager_.IncreaseForwardedRequestTimeout( - application_manager::request_controller::RequestInfo::HmiConnectoinKey, + application_manager::request_controller::RequestInfo::HmiConnectionKey, correlation_id()); SendHMIRequest(hmi_function_id, &(*msg)[strings::msg_params], use_events); return; @@ -217,7 +217,7 @@ void RequestFromHMI::SendProviderRequest( LOG4CXX_DEBUG(logger_, "Sending Request to Mobile Provider"); application_manager_.IncreaseForwardedRequestTimeout( - application_manager::request_controller::RequestInfo::HmiConnectoinKey, + application_manager::request_controller::RequestInfo::HmiConnectionKey, correlation_id()); SendMobileRequest( mobile_function_id, app, &(*msg)[strings::msg_params], use_events); diff --git a/src/components/application_manager/src/display_capabilities_builder.cc b/src/components/application_manager/src/display_capabilities_builder.cc new file mode 100644 index 0000000000..8234128280 --- /dev/null +++ b/src/components/application_manager/src/display_capabilities_builder.cc @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/display_capabilities_builder.h" +#include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +namespace application_manager { + +CREATE_LOGGERPTR_GLOBAL(logger_, "DisplayCapabilitiesBuilder") + +const WindowID kDefaultWindowID = 0; + +DisplayCapabilitiesBuilder::DisplayCapabilitiesBuilder(Application& application) + : owner_(application) { + LOG4CXX_AUTO_TRACE(logger_); +} + +void DisplayCapabilitiesBuilder::InitBuilder( + DisplayCapabilitiesBuilder::ResumeCallback resume_callback, + const smart_objects::SmartObject& windows_info) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(display_capabilities_lock_); + resume_callback_ = resume_callback; + window_ids_to_resume_.insert(kDefaultWindowID); + for (size_t i = 0; i < windows_info.length(); ++i) { + auto window_id = windows_info[i][strings::window_id].asInt(); + LOG4CXX_DEBUG(logger_, + "Inserting " << window_id << " to waiting container"); + window_ids_to_resume_.insert(window_id); + } +} + +void DisplayCapabilitiesBuilder::UpdateDisplayCapabilities( + const smart_objects::SmartObject& incoming_display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace smart_objects; + sync_primitives::AutoLock lock(display_capabilities_lock_); + + if (!display_capabilities_) { + display_capabilities_ = std::make_shared<SmartObject>(SmartType_Array); + } + + // As per v6.0, only single display is supported + auto cur_window_caps = + (*display_capabilities_)[0][strings::window_capabilities]; + + const auto& inc_window_caps = + incoming_display_capabilities[0][strings::window_capabilities]; + + for (size_t i = 0; i < inc_window_caps.length(); ++i) { + const WindowID window_id = + inc_window_caps[i].keyExists(strings::window_id) + ? inc_window_caps[i][strings::window_id].asInt() + : kDefaultWindowID; + if (window_ids_to_resume_.end() != window_ids_to_resume_.find(window_id)) { + cur_window_caps[cur_window_caps.length()] = inc_window_caps[i]; + LOG4CXX_DEBUG(logger_, "Stop waiting for: " << window_id); + window_ids_to_resume_.erase(window_id); + } + } + + *display_capabilities_ = incoming_display_capabilities; + (*display_capabilities_)[0][strings::window_capabilities] = cur_window_caps; + + if (window_ids_to_resume_.empty()) { + LOG4CXX_TRACE(logger_, "Invoking resume callback"); + resume_callback_(owner_, *display_capabilities_); + display_capabilities_.reset(); + } +} // namespace application_manager + +const smart_objects::SmartObjectSPtr +DisplayCapabilitiesBuilder::display_capabilities() const { + LOG4CXX_AUTO_TRACE(logger_); + return display_capabilities_; +} + +void DisplayCapabilitiesBuilder::ResetDisplayCapabilities() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(display_capabilities_lock_); + display_capabilities_.reset(); +} + +void DisplayCapabilitiesBuilder::StopWaitingForWindow( + const WindowID window_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(display_capabilities_lock_); + LOG4CXX_DEBUG(logger_, + "Window id " << window_id << " will be erased due to failure"); + window_ids_to_resume_.erase(window_id); + if (window_ids_to_resume_.empty()) { + LOG4CXX_TRACE(logger_, + window_id << " was the last window pending resumption. " + "Invoking resume callback"); + resume_callback_(owner_, *display_capabilities_); + display_capabilities_.reset(); + } +} +} // 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 3f3cfae1d3..30b1b83e79 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 @@ -31,9 +31,9 @@ */ #include "application_manager/event_engine/event_dispatcher_impl.h" -#include "interfaces/HMI_API.h" -#include "application_manager/event_engine/event_observer.h" #include <algorithm> +#include "application_manager/event_engine/event_observer.h" +#include "interfaces/HMI_API.h" namespace application_manager { namespace event_engine { @@ -137,8 +137,9 @@ void EventDispatcherImpl::raise_mobile_event(const MobileEvent& event) { } if (mobile_apis::messageType::response == event.smart_object_type()) { - mobile_observers_ = mobile_observers_event_ - [event.id()][event.smart_object_correlation_id()]; + mobile_observers_ = + mobile_observers_event_[event.id()] + [event.smart_object_correlation_id()]; } } diff --git a/src/components/application_manager/src/event_engine/event_observer.cc b/src/components/application_manager/src/event_engine/event_observer.cc index fc252d3125..e17203f2f2 100644 --- a/src/components/application_manager/src/event_engine/event_observer.cc +++ b/src/components/application_manager/src/event_engine/event_observer.cc @@ -57,10 +57,6 @@ void EventObserver::unsubscribe_from_event(const Event::EventID& event_id) { event_dispatcher_.remove_observer(event_id, *this); } -void EventObserver::unsubscribe_from_all_events() { - event_dispatcher_.remove_observer(*this); -} - void EventObserver::unsubscribe_from_all_hmi_events() { event_dispatcher_.remove_observer(*this); } diff --git a/src/components/application_manager/src/help_prompt_manager_impl.cc b/src/components/application_manager/src/help_prompt_manager_impl.cc index 016e09635b..ec883e5fc2 100644 --- a/src/components/application_manager/src/help_prompt_manager_impl.cc +++ b/src/components/application_manager/src/help_prompt_manager_impl.cc @@ -28,7 +28,7 @@ * 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/help_prompt_manager_impl.h" @@ -90,9 +90,9 @@ bool HelpPromptManagerImpl::AddCommand( const bool limit_exceeded = kLimitCommand <= GetCommandsCount(vr_commands_.end()); - LOG4CXX_DEBUG(logger_, - "Will be added first command from array " - << strings::vr_commands); + LOG4CXX_DEBUG( + logger_, + "Will be added first command from array " << strings::vr_commands); smart_objects::SmartObjectSPtr vr_item = std::make_shared<smart_objects::SmartObject>(commands.asArray()->front()); diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 59f1c6caf2..fc86eb5e62 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -1,9 +1,9 @@ -#include <vector> -#include <string> #include "application_manager/helpers/application_helper.h" +#include <string> +#include <vector> #include "application_manager/message_helper.h" -#include "utils/logger.h" #include "utils/file_system.h" +#include "utils/logger.h" namespace { using namespace application_manager; diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 060eaf011c..6f95e43545 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -32,16 +32,16 @@ #include <map> -#include "utils/logger.h" -#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/application_manager.h" -#include "smart_objects/smart_object.h" +#include "application_manager/hmi_capabilities_impl.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" #include "config_profile/profile.h" #include "formatters/CFormatterJsonBase.h" #include "interfaces/HMI_API.h" +#include "smart_objects/smart_object.h" #include "utils/file_system.h" +#include "utils/logger.h" namespace application_manager { namespace formatters = ns_smart_device_link::ns_json_handler::formatters; @@ -135,6 +135,46 @@ void InitCapabilities() { hmi_apis::Common_ButtonName::CUSTOM_BUTTON)); button_enum_name.insert(std::make_pair(std::string("SEARCH"), hmi_apis::Common_ButtonName::SEARCH)); + button_enum_name.insert( + std::make_pair(std::string("NAV_CENTER_LOCATION"), + hmi_apis::Common_ButtonName::NAV_CENTER_LOCATION)); + button_enum_name.insert(std::make_pair( + std::string("NAV_ZOOM_IN"), hmi_apis::Common_ButtonName::NAV_ZOOM_IN)); + button_enum_name.insert(std::make_pair( + std::string("NAV_ZOOM_OUT"), hmi_apis::Common_ButtonName::NAV_ZOOM_OUT)); + button_enum_name.insert(std::make_pair( + std::string("NAV_PAN_UP"), hmi_apis::Common_ButtonName::NAV_PAN_UP)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_UP_RIGHT"), + hmi_apis::Common_ButtonName::NAV_PAN_UP_RIGHT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_RIGHT"), + hmi_apis::Common_ButtonName::NAV_PAN_RIGHT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_DOWN_RIGHT"), + hmi_apis::Common_ButtonName::NAV_PAN_DOWN_RIGHT)); + button_enum_name.insert(std::make_pair( + std::string("NAV_PAN_DOWN"), hmi_apis::Common_ButtonName::NAV_PAN_DOWN)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_DOWN_LEFT"), + hmi_apis::Common_ButtonName::NAV_PAN_DOWN_LEFT)); + button_enum_name.insert(std::make_pair( + std::string("NAV_PAN_LEFT"), hmi_apis::Common_ButtonName::NAV_PAN_LEFT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_PAN_UP_LEFT"), + hmi_apis::Common_ButtonName::NAV_PAN_UP_LEFT)); + button_enum_name.insert( + std::make_pair(std::string("NAV_TILT_TOGGLE"), + hmi_apis::Common_ButtonName::NAV_TILT_TOGGLE)); + button_enum_name.insert( + std::make_pair(std::string("NAV_ROTATE_CLOCKWISE"), + hmi_apis::Common_ButtonName::NAV_ROTATE_CLOCKWISE)); + button_enum_name.insert( + std::make_pair(std::string("NAV_ROTATE_COUNTERCLOCKWISE"), + hmi_apis::Common_ButtonName::NAV_ROTATE_COUNTERCLOCKWISE)); + button_enum_name.insert( + std::make_pair(std::string("NAV_HEADING_TOGGLE"), + hmi_apis::Common_ButtonName::NAV_HEADING_TOGGLE)); text_fields_enum_name.insert(std::make_pair( std::string("mainField1"), hmi_apis::Common_TextFieldName::mainField1)); @@ -337,6 +377,8 @@ void InitCapabilities() { std::make_pair(std::string("MFD5"), hmi_apis::Common_DisplayType::MFD5)); display_type_enum.insert(std::make_pair( std::string("GEN3_8_INCH"), hmi_apis::Common_DisplayType::GEN3_8_INCH)); + display_type_enum.insert(std::make_pair( + std::string("SDL_GENERIC"), hmi_apis::Common_DisplayType::SDL_GENERIC)); character_set_enum.insert(std::make_pair( std::string("TYPE2SET"), hmi_apis::Common_CharacterSet::TYPE2SET)); @@ -405,6 +447,7 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr) , phone_capability_(NULL) , video_streaming_capability_(NULL) , rc_capability_(NULL) + , seat_location_capability_(NULL) , app_mngr_(app_mngr) , hmi_language_handler_(app_mngr) { InitCapabilities(); @@ -568,6 +611,12 @@ void HMICapabilitiesImpl::set_display_capabilities( } } +void HMICapabilitiesImpl::set_system_display_capabilities( + const smart_objects::SmartObject& display_capabilities) { + system_display_capabilities_.reset( + new smart_objects::SmartObject(display_capabilities)); +} + void HMICapabilitiesImpl::set_hmi_zone_capabilities( const smart_objects::SmartObject& hmi_zone_capabilities) { if (hmi_zone_capabilities_) { @@ -703,6 +752,15 @@ void HMICapabilitiesImpl::set_rc_capability( rc_capability_ = new smart_objects::SmartObject(rc_capability); } +void HMICapabilitiesImpl::set_seat_location_capability( + const smart_objects::SmartObject& seat_location_capability) { + if (seat_location_capability_) { + delete seat_location_capability_; + } + seat_location_capability_ = + new smart_objects::SmartObject(seat_location_capability); +} + void HMICapabilitiesImpl::Init(resumption::LastState* last_state) { hmi_language_handler_.Init(last_state); if (false == load_capabilities_from_file()) { @@ -758,6 +816,11 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities() return display_capabilities_; } +const smart_objects::SmartObjectSPtr +HMICapabilitiesImpl::system_display_capabilities() const { + return system_display_capabilities_; +} + const smart_objects::SmartObject* HMICapabilitiesImpl::hmi_zone_capabilities() const { return hmi_zone_capabilities_; @@ -845,6 +908,11 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::rc_capability() const { return rc_capability_; } +const smart_objects::SmartObject* +HMICapabilitiesImpl::seat_location_capability() const { + return seat_location_capability_; +} + bool HMICapabilitiesImpl::load_capabilities_from_file() { std::string json_string; std::string file_name = app_mngr_.get_settings().hmi_capabilities_file_name(); @@ -914,7 +982,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { hmi_apis::Common_TextFieldName::eType>::const_iterator it_text_field_name = text_fields_enum_name.find( display_capabilities_so[hmi_response::text_fields][i] - [strings::name].asString()); + [strings::name] + .asString()); display_capabilities_so[hmi_response::text_fields][i].erase( strings::name); if (text_fields_enum_name.end() != it_text_field_name) { @@ -1025,25 +1094,16 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { if (check_existing_json_member(ui, "audioPassThruCapabilities")) { Json::Value audio_capabilities = ui.get("audioPassThruCapabilities", ""); - smart_objects::SmartObject audio_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Array); - audio_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Map); - if (check_existing_json_member(audio_capabilities, "samplingRate")) { - audio_capabilities_so["samplingRate"] = - sampling_rate_enum.find(audio_capabilities.get("samplingRate", "") - .asString())->second; - } - if (check_existing_json_member(audio_capabilities, "bitsPerSample")) { - audio_capabilities_so["bitsPerSample"] = - bit_per_sample_enum.find(audio_capabilities.get("bitsPerSample", - "").asString()) - ->second; - } - if (check_existing_json_member(audio_capabilities, "audioType")) { - audio_capabilities_so["audioType"] = - audio_type_enum.find(audio_capabilities.get("audioType", "") - .asString())->second; + smart_objects::SmartObject audio_capabilities_so( + smart_objects::SmartType_Array); + if (audio_capabilities.type() == Json::arrayValue) { + for (uint32_t i = 0; i < audio_capabilities.size(); i++) { + convert_audio_capability_to_obj(audio_capabilities[i], + audio_capabilities_so[i]); + } + } else if (audio_capabilities.type() == Json::objectValue) { + convert_audio_capability_to_obj(audio_capabilities, + audio_capabilities_so[0]); } set_audio_pass_thru_capabilities(audio_capabilities_so); } @@ -1052,23 +1112,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { Json::Value pcm_capabilities = ui.get("pcmStreamCapabilities", ""); smart_objects::SmartObject pcm_capabilities_so = smart_objects::SmartObject(smart_objects::SmartType_Map); - - if (check_existing_json_member(pcm_capabilities, "samplingRate")) { - pcm_capabilities_so["samplingRate"] = - sampling_rate_enum.find(pcm_capabilities.get("samplingRate", "") - .asString())->second; - } - if (check_existing_json_member(pcm_capabilities, "bitsPerSample")) { - pcm_capabilities_so["bitsPerSample"] = - bit_per_sample_enum.find(pcm_capabilities.get("bitsPerSample", "") - .asString())->second; - } - if (check_existing_json_member(pcm_capabilities, "audioType")) { - pcm_capabilities_so["audioType"] = - audio_type_enum.find(pcm_capabilities.get("audioType", "") - .asString())->second; - } - + convert_audio_capability_to_obj(pcm_capabilities, pcm_capabilities_so); set_pcm_stream_capabilities(pcm_capabilities_so); } @@ -1089,6 +1133,7 @@ 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, @@ -1191,6 +1236,15 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() { set_rc_supported(true); } } + if (check_existing_json_member(system_capabilities, + "seatLocationCapability")) { + Json::Value seat_location_capability = + system_capabilities.get("seatLocationCapability", ""); + smart_objects::SmartObject seat_location_capability_so; + formatters::CFormatterJsonBase::jsonValueToObj( + seat_location_capability, seat_location_capability_so); + set_seat_location_capability(seat_location_capability_so); + } } } // UI end @@ -1325,6 +1379,27 @@ void HMICapabilitiesImpl::convert_json_languages_to_obj( } } +void HMICapabilitiesImpl::convert_audio_capability_to_obj( + const Json::Value& capability, + smart_objects::SmartObject& output_so) const { + if (check_existing_json_member(capability, "samplingRate")) { + output_so[strings::sampling_rate] = + sampling_rate_enum.find(capability.get("samplingRate", "").asString()) + ->second; + } + if (check_existing_json_member(capability, "bitsPerSample")) { + output_so[strings::bits_per_sample] = + bit_per_sample_enum + .find(capability.get("bitsPerSample", "").asString()) + ->second; + } + if (check_existing_json_member(capability, "audioType")) { + output_so[strings::audio_type] = + audio_type_enum.find(capability.get("audioType", "").asString()) + ->second; + } +} + HMILanguageHandler& HMICapabilitiesImpl::get_hmi_language_handler() { return hmi_language_handler_; } diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 9aff403e09..0c33ea4b11 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -103,8 +103,12 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[BasicCommunication_OnEventChanged] = HmiInterfaces::HMI_INTERFACE_BasicCommunication; + convert_map[BasicCommunication_OnServiceUpdate] = + HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[BasicCommunication_GetFilePath] = HmiInterfaces::HMI_INTERFACE_BasicCommunication; + convert_map[BasicCommunication_CloseApplication] = + HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[VR_IsReady] = HmiInterfaces::HMI_INTERFACE_VR; convert_map[VR_Started] = HmiInterfaces::HMI_INTERFACE_VR; convert_map[VR_Stopped] = HmiInterfaces::HMI_INTERFACE_VR; @@ -135,12 +139,16 @@ generate_function_to_interface_convert_map() { convert_map[UI_DeleteCommand] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_AddSubMenu] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_DeleteSubMenu] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_ShowAppMenu] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_CreateWindow] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_DeleteWindow] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_PerformInteraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetMediaClockTimer] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnCommand] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnSystemContext] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_UI; + convert_map[UI_CancelInteraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_ChangeRegistration] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnLanguageChange] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_GetSupportedLanguages] = HmiInterfaces::HMI_INTERFACE_UI; @@ -148,7 +156,6 @@ generate_function_to_interface_convert_map() { convert_map[UI_OnDriverDistraction] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetAppIcon] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_SetDisplayLayout] = HmiInterfaces::HMI_INTERFACE_UI; - convert_map[UI_ShowCustomForm] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnKeyboardInput] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_OnTouchEvent] = HmiInterfaces::HMI_INTERFACE_UI; convert_map[UI_Slider] = HmiInterfaces::HMI_INTERFACE_UI; @@ -219,7 +226,6 @@ generate_function_to_interface_convert_map() { convert_map[SDL_OnStatusUpdate] = HmiInterfaces::HMI_INTERFACE_SDL; convert_map[SDL_OnSystemError] = HmiInterfaces::HMI_INTERFACE_SDL; convert_map[SDL_AddStatisticsInfo] = HmiInterfaces::HMI_INTERFACE_SDL; - convert_map[SDL_GetURLS] = HmiInterfaces::HMI_INTERFACE_SDL; convert_map[RC_IsReady] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[Buttons_ButtonPress] = HmiInterfaces::HMI_INTERFACE_RC; @@ -229,8 +235,11 @@ generate_function_to_interface_convert_map() { HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_OnInteriorVehicleData] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[RC_OnRemoteControlSettings] = HmiInterfaces::HMI_INTERFACE_RC; + convert_map[RC_SetGlobalProperties] = HmiInterfaces::HMI_INTERFACE_RC; convert_map[AppService_PublishAppService] = HmiInterfaces::HMI_INTERFACE_AppService; + convert_map[AppService_UnpublishAppService] = + HmiInterfaces::HMI_INTERFACE_AppService; convert_map[AppService_GetAppServiceData] = HmiInterfaces::HMI_INTERFACE_AppService; convert_map[AppService_PerformAppServiceInteraction] = diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index 647df242df..e206633ae2 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -28,16 +28,16 @@ * 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/hmi_language_handler.h" #include "application_manager/application_manager.h" +#include "application_manager/hmi_capabilities.h" #include "application_manager/message_helper.h" #include "application_manager/rpc_service.h" -#include "application_manager/hmi_capabilities.h" -#include "utils/helpers.h" #include "resumption/last_state.h" #include "smart_objects/smart_object.h" +#include "utils/helpers.h" static const std::string LanguagesKey = "Languages"; static const std::string UIKey = "UI"; @@ -78,9 +78,9 @@ void HMILanguageHandler::set_language_for( LOG4CXX_WARN(logger_, "Unknown interface has been passed " << interface); return; } - LOG4CXX_DEBUG(logger_, - "Setting language " << language << " for interface " - << interface); + LOG4CXX_DEBUG( + logger_, + "Setting language " << language << " for interface " << interface); Json::Value& dictionary = last_state_->get_dictionary(); dictionary[LanguagesKey][key] = language; return; @@ -273,8 +273,9 @@ void HMILanguageHandler::VerifyWithPersistedLanguages() { LOG4CXX_INFO(logger_, "Application with app_id " - << app->app_id() << " will be unregistered because of " - "HMI language(s) mismatch."); + << app->app_id() + << " will be unregistered because of " + "HMI language(s) mismatch."); CheckApplication(std::make_pair(app->app_id(), false)); } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index e220988f0e..844d0254cf 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -32,9 +32,9 @@ */ #include "application_manager/hmi_state.h" -#include <ostream> #include <boost/assign.hpp> #include <boost/bimap.hpp> +#include <ostream> #include "application_manager/application_manager.h" #include "utils/helpers.h" @@ -48,6 +48,7 @@ HmiState::HmiState(std::shared_ptr<Application> app, : hmi_app_id_(app->hmi_app_id()) , state_id_(state_id) , app_mngr_(app_mngr) + , window_type_(mobile_apis::WindowType::INVALID_ENUM) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) @@ -60,6 +61,7 @@ HmiState::HmiState(std::shared_ptr<Application> app, : hmi_app_id_(app->hmi_app_id()) , state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) + , window_type_(mobile_apis::WindowType::INVALID_ENUM) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) @@ -96,6 +98,15 @@ bool HmiState::is_mobile_projection_app() const { return app ? app->mobile_projection_enabled() : false; } +mobile_apis::WindowType::eType HmiState::window_type() const { + return window_type_; +} + +void HmiState::set_window_type( + const mobile_apis::WindowType::eType window_type) { + window_type_ = window_type; +} + mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state() const { using namespace mobile_apis; @@ -173,17 +184,25 @@ PhoneCallHmiState::PhoneCallHmiState(std::shared_ptr<Application> app, mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { using namespace helpers; using namespace mobile_apis; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + if (Compare<HMILevel::eType, EQ, ONE>(parent()->hmi_level(), HMILevel::HMI_BACKGROUND, HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + if (is_navi_app() || is_mobile_projection_app()) { return HMILevel::HMI_LIMITED; } + if (!is_media_app()) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -198,6 +217,11 @@ DeactivateHMI::DeactivateHMI(std::shared_ptr<Application> app, mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { using namespace helpers; using namespace mobile_apis; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + if (Compare<HMILevel::eType, EQ, ONE>(parent()->hmi_level(), HMILevel::HMI_BACKGROUND, HMILevel::HMI_NONE)) { @@ -215,14 +239,19 @@ AudioSource::AudioSource(std::shared_ptr<Application> app, } mobile_apis::HMILevel::eType AudioSource::hmi_level() const { + using namespace mobile_apis; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + // Checking for NONE is necessary to avoid issue during // calculation of HMI level during setting default HMI level - if (keep_context_ || - mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { + if (keep_context_ || HMILevel::HMI_NONE == parent()->hmi_level()) { return parent()->hmi_level(); } - return mobile_apis::HMILevel::HMI_BACKGROUND; + return HMILevel::HMI_BACKGROUND; } EmbeddedNavi::EmbeddedNavi(std::shared_ptr<Application> app, @@ -232,11 +261,17 @@ EmbeddedNavi::EmbeddedNavi(std::shared_ptr<Application> app, mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { using namespace mobile_apis; using namespace helpers; + + if (WindowType::WIDGET == window_type()) { + return parent()->hmi_level(); + } + if (Compare<HMILevel::eType, EQ, ONE>(parent()->hmi_level(), HMILevel::HMI_BACKGROUND, HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -278,7 +313,8 @@ std::ostream& operator<<(std::ostream& os, const HmiState& src) { } else { os << "(none)"; } - os << ", hmi app id:" << src.hmi_app_id_ << ", state:" << src.state_id() + os << ", hmi app id:" << src.hmi_app_id_ + << ", window_type:" << src.window_type_ << ", state:" << src.state_id() << ", hmi_level:" << src.hmi_level() << ", audio:" << src.audio_streaming_state() << ", video:" << src.video_streaming_state() diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc index 332d68adbf..b75428780d 100644 --- a/src/components/application_manager/src/message.cc +++ b/src/components/application_manager/src/message.cc @@ -36,7 +36,7 @@ namespace { bool BinaryDataPredicate(uint8_t i, uint8_t j) { return (i == j); } -} +} // namespace namespace application_manager { @@ -64,8 +64,8 @@ Message::Message(protocol_handler::MessagePriority priority) , binary_data_(NULL) , data_size_(0) , payload_size_(0) - , version_( - protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) {} + , version_(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) + , is_message_encrypted_(false) {} Message::Message(const Message& message) : function_id_(0) @@ -76,8 +76,8 @@ Message::Message(const Message& message) , binary_data_(NULL) , data_size_(0) , payload_size_(0) - , version_( - protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) { + , version_(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN) + , is_message_encrypted_(false) { *this = message; } @@ -142,6 +142,10 @@ int32_t Message::connection_key() const { return connection_key_; } +bool Message::is_message_encrypted() const { + return is_message_encrypted_; +} + MessageType Message::type() const { return type_; } @@ -228,6 +232,10 @@ void Message::set_payload_size(size_t payload_size) { payload_size_ = payload_size; } +void Message::set_message_encryption(const bool protection) { + is_message_encrypted_ = protection; +} + bool Message::is_sufficient_version( protocol_handler::MajorProtocolVersion minVersion, protocol_handler::MajorProtocolVersion version) { 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 0e44a53c6f..fb0c9f15bf 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -39,13 +39,13 @@ #include <inttypes.h> #undef __STDC_FORMAT_MACROS -#include <set> -#include <string> #include <strings.h> #include <algorithm> -#include <utility> -#include <map> #include <functional> +#include <map> +#include <set> +#include <string> +#include <utility> #include "application_manager/application.h" #include "application_manager/application_manager.h" @@ -55,18 +55,18 @@ #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/rpc_service.h" #include "connection_handler/connection_handler_impl.h" -#include "transport_manager/common.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/enum_schema_item.h" +#include "transport_manager/common.h" #include "utils/file_system.h" -#include "utils/macro.h" #include "utils/logger.h" +#include "utils/macro.h" -#include "formatters/formatter_json_rpc.h" -#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/CFormatterJsonBase.h" #include "formatters/CFormatterJsonSDLRPCv1.h" +#include "formatters/CFormatterJsonSDLRPCv2.h" +#include "formatters/formatter_json_rpc.h" #include "json/json.h" -#include "formatters/CFormatterJsonBase.h" CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") @@ -162,71 +162,84 @@ struct ExternalConsentStatusAppender } // namespace -std::pair<std::string, - mobile_apis::VehicleDataType::eType> kVehicleDataInitializer[] = { - std::make_pair(strings::gps, mobile_apis::VehicleDataType::VEHICLEDATA_GPS), - std::make_pair(strings::speed, - mobile_apis::VehicleDataType::VEHICLEDATA_SPEED), - std::make_pair(strings::rpm, mobile_apis::VehicleDataType::VEHICLEDATA_RPM), - std::make_pair(strings::fuel_level, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL), - std::make_pair(strings::fuel_level_state, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), - std::make_pair(strings::instant_fuel_consumption, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), - std::make_pair(strings::fuel_range, - mobile_apis::VehicleDataType::VEHICLEDATA_FUELRANGE), - std::make_pair(strings::cloud_app_vehicle_id, - mobile_apis::VehicleDataType::VEHICLEDATA_CLOUDAPPVEHICLEID), - std::make_pair(strings::external_temp, - mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), - std::make_pair(strings::turn_signal, - mobile_apis::VehicleDataType::VEHICLEDATA_TURNSIGNAL), - std::make_pair(strings::vin, mobile_apis::VehicleDataType::VEHICLEDATA_VIN), - std::make_pair(strings::prndl, - mobile_apis::VehicleDataType::VEHICLEDATA_PRNDL), - std::make_pair(strings::tire_pressure, - mobile_apis::VehicleDataType::VEHICLEDATA_TIREPRESSURE), - std::make_pair(strings::odometer, - mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER), - std::make_pair(strings::belt_status, - mobile_apis::VehicleDataType::VEHICLEDATA_BELTSTATUS), - std::make_pair( - strings::electronic_park_brake_status, - mobile_apis::VehicleDataType::VEHICLEDATA_ELECTRONICPARKBRAKESTATUS), - std::make_pair(strings::body_information, - mobile_apis::VehicleDataType::VEHICLEDATA_BODYINFO), - std::make_pair(strings::device_status, - mobile_apis::VehicleDataType::VEHICLEDATA_DEVICESTATUS), - std::make_pair(strings::driver_braking, - mobile_apis::VehicleDataType::VEHICLEDATA_BRAKING), - std::make_pair(strings::wiper_status, - mobile_apis::VehicleDataType::VEHICLEDATA_WIPERSTATUS), - std::make_pair(strings::head_lamp_status, - mobile_apis::VehicleDataType::VEHICLEDATA_HEADLAMPSTATUS), - std::make_pair(strings::e_call_info, - mobile_apis::VehicleDataType::VEHICLEDATA_ECALLINFO), - std::make_pair(strings::airbag_status, - mobile_apis::VehicleDataType::VEHICLEDATA_AIRBAGSTATUS), - std::make_pair(strings::emergency_event, - mobile_apis::VehicleDataType::VEHICLEDATA_EMERGENCYEVENT), - std::make_pair(strings::cluster_mode_status, - mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), - std::make_pair(strings::my_key, - mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY), - /* - NOT DEFINED in mobile API - std::make_pair(strings::gps, - BATTVOLTAGE), - */ - std::make_pair(strings::engine_torque, - mobile_apis::VehicleDataType::VEHICLEDATA_ENGINETORQUE), - std::make_pair(strings::acc_pedal_pos, - mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), - std::make_pair(strings::steering_wheel_angle, - mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), - std::make_pair(strings::engine_oil_life, - mobile_apis::VehicleDataType::VEHICLEDATA_ENGINEOILLIFE)}; +std::pair<std::string, mobile_apis::VehicleDataType::eType> + kVehicleDataInitializer[] = { + std::make_pair(strings::gps, + mobile_apis::VehicleDataType::VEHICLEDATA_GPS), + std::make_pair(strings::speed, + mobile_apis::VehicleDataType::VEHICLEDATA_SPEED), + std::make_pair(strings::rpm, + mobile_apis::VehicleDataType::VEHICLEDATA_RPM), + std::make_pair(strings::fuel_level, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL), + std::make_pair( + strings::fuel_level_state, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), + std::make_pair( + strings::instant_fuel_consumption, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), + std::make_pair(strings::fuel_range, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELRANGE), + std::make_pair( + strings::cloud_app_vehicle_id, + mobile_apis::VehicleDataType::VEHICLEDATA_CLOUDAPPVEHICLEID), + std::make_pair(strings::external_temp, + mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), + std::make_pair(strings::turn_signal, + mobile_apis::VehicleDataType::VEHICLEDATA_TURNSIGNAL), + std::make_pair(strings::vin, + mobile_apis::VehicleDataType::VEHICLEDATA_VIN), + std::make_pair(strings::prndl, + mobile_apis::VehicleDataType::VEHICLEDATA_PRNDL), + std::make_pair(strings::tire_pressure, + mobile_apis::VehicleDataType::VEHICLEDATA_TIREPRESSURE), + std::make_pair(strings::odometer, + mobile_apis::VehicleDataType::VEHICLEDATA_ODOMETER), + std::make_pair(strings::belt_status, + mobile_apis::VehicleDataType::VEHICLEDATA_BELTSTATUS), + std::make_pair(strings::electronic_park_brake_status, + mobile_apis::VehicleDataType:: + VEHICLEDATA_ELECTRONICPARKBRAKESTATUS), + std::make_pair(strings::body_information, + mobile_apis::VehicleDataType::VEHICLEDATA_BODYINFO), + std::make_pair(strings::device_status, + mobile_apis::VehicleDataType::VEHICLEDATA_DEVICESTATUS), + std::make_pair(strings::driver_braking, + mobile_apis::VehicleDataType::VEHICLEDATA_BRAKING), + std::make_pair(strings::wiper_status, + mobile_apis::VehicleDataType::VEHICLEDATA_WIPERSTATUS), + std::make_pair( + strings::head_lamp_status, + mobile_apis::VehicleDataType::VEHICLEDATA_HEADLAMPSTATUS), + std::make_pair(strings::e_call_info, + mobile_apis::VehicleDataType::VEHICLEDATA_ECALLINFO), + std::make_pair(strings::airbag_status, + mobile_apis::VehicleDataType::VEHICLEDATA_AIRBAGSTATUS), + std::make_pair( + strings::emergency_event, + mobile_apis::VehicleDataType::VEHICLEDATA_EMERGENCYEVENT), + std::make_pair( + strings::cluster_mode_status, + mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), + std::make_pair( + strings::cluster_modes, + mobile_apis::VehicleDataType::VEHICLEDATA_CLUSTERMODESTATUS), + std::make_pair(strings::my_key, + mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY), + /* + NOT DEFINED in mobile API + std::make_pair(strings::gps, + BATTVOLTAGE), + */ + std::make_pair(strings::engine_torque, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINETORQUE), + std::make_pair(strings::acc_pedal_pos, + mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), + std::make_pair(strings::steering_wheel_angle, + mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), + std::make_pair( + strings::engine_oil_life, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINEOILLIFE)}; const VehicleData MessageHelper::vehicle_data_( kVehicleDataInitializer, @@ -322,6 +335,15 @@ std::string MessageHelper::CommonLanguageToString( return std::string(); } +std::string MessageHelper::MobileLanguageToString( + mobile_apis::Language::eType language) { + using namespace ns_smart_device_link::ns_smart_objects; + const char* str = 0; + EnumConversionHelper<mobile_apis::Language::eType>::EnumToCString(language, + &str); + return str ? str : std::string(); +} + smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( hmi_apis::messageType::eType message_type, const uint32_t correlation_id) { using namespace smart_objects; @@ -338,6 +360,33 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( return message; } +smart_objects::SmartObjectSPtr +MessageHelper::CreateDisplayCapabilityUpdateToMobile( + const smart_objects::SmartObject& display_capabilities, Application& app) { + LOG4CXX_AUTO_TRACE(logger_); + auto message = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + + (*message)[strings::params][strings::message_type] = + MessageType::kNotification; + (*message)[strings::params][strings::function_id] = + mobile_apis::FunctionID::OnSystemCapabilityUpdatedID; + (*message)[strings::params][strings::connection_key] = app.app_id(); + (*message)[strings::params][strings::protocol_type] = + commands::CommandImpl::mobile_protocol_type_; + (*message)[strings::params][strings::protocol_version] = + commands::CommandImpl::protocol_version_; + + smart_objects::SmartObject system_capability(smart_objects::SmartType_Map); + system_capability[strings::system_capability_type] = + static_cast<int32_t>(mobile_apis::SystemCapabilityType::DISPLAYS); + system_capability[strings::display_capabilities] = display_capabilities; + (*message)[strings::msg_params][strings::system_capability] = + system_capability; + + return message; +} + void MessageHelper::BroadcastCapabilityUpdate( smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); @@ -359,7 +408,8 @@ void MessageHelper::BroadcastCapabilityUpdate( hmi_apis::FunctionID::BasicCommunication_OnSystemCapabilityUpdated; smart_objects::SmartObjectSPtr hmi_notification = std::make_shared<smart_objects::SmartObject>(message); - app_mngr.GetRPCService().ManageHMICommand(hmi_notification); + app_mngr.GetRPCService().ManageHMICommand( + hmi_notification, commands::Command::CommandSource::SOURCE_SDL_TO_HMI); } smart_objects::SmartObject MessageHelper::CreateAppServiceCapabilities( @@ -613,15 +663,16 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, msg_params = *MessageHelper::CreateAppVrHelp(application); msg_params[hmi_request::menu_title] = ""; - smart_objects::SmartObject key_board_properties = + smart_objects::SmartObject keyboard_properties = smart_objects::SmartObject(smart_objects::SmartType_Map); - key_board_properties[strings::language] = + keyboard_properties[strings::language] = static_cast<int32_t>(hmi_apis::Common_Language::EN_US); - key_board_properties[hmi_request::keyboard_layout] = + keyboard_properties[hmi_request::keyboard_layout] = static_cast<int32_t>(hmi_apis::Common_KeyboardLayout::QWERTY); - key_board_properties[hmi_request::auto_complete_text] = ""; - msg_params[hmi_request::keyboard_properties] = key_board_properties; + keyboard_properties[hmi_request::auto_complete_list] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + msg_params[hmi_request::keyboard_properties] = keyboard_properties; msg_params[strings::app_id] = application->app_id(); @@ -751,7 +802,8 @@ hmi_apis::Common_Result::eType MessageHelper::MobileToHMIResult( } void MessageHelper::SendHMIStatusNotification( - const Application& application_impl, + ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr notification = @@ -769,16 +821,21 @@ void MessageHelper::SendHMIStatusNotification( static_cast<int32_t>(application_manager::MessageType::kNotification); message[strings::params][strings::connection_key] = - static_cast<int32_t>(application_impl.app_id()); + static_cast<int32_t>(application->app_id()); + + message[strings::msg_params][strings::window_id] = window_id; message[strings::msg_params][strings::hmi_level] = - static_cast<int32_t>(application_impl.hmi_level()); + static_cast<int32_t>(application->hmi_level(window_id)); message[strings::msg_params][strings::audio_streaming_state] = - static_cast<int32_t>(application_impl.audio_streaming_state()); + static_cast<int32_t>(application->audio_streaming_state()); + + message[strings::msg_params][strings::video_streaming_state] = + static_cast<int32_t>(application->video_streaming_state()); message[strings::msg_params][strings::system_context] = - static_cast<int32_t>(application_impl.system_context()); + static_cast<int32_t>(application->system_context(window_id)); application_manager.GetRPCService().ManageMobileCommand( notification, commands::Command::SOURCE_SDL); @@ -1130,12 +1187,11 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( auto& help_prompt_manager = const_cast<Application*>(app.get())->help_prompt_manager(); - const bool can_send_ui = helpers::Compare<HelpPromptManager::SendingType, - helpers::EQ, - helpers::ONE>( - help_prompt_manager.GetSendingType(), - HelpPromptManager::SendingType::kSendVRHelp, - HelpPromptManager::SendingType::kSendBoth); + const bool can_send_ui = helpers:: + Compare<HelpPromptManager::SendingType, helpers::EQ, helpers::ONE>( + help_prompt_manager.GetSendingType(), + HelpPromptManager::SendingType::kSendVRHelp, + HelpPromptManager::SendingType::kSendBoth); // UI global properties @@ -1173,12 +1229,11 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( requests.push_back(ui_global_properties); } - const bool can_send_vr = helpers::Compare<HelpPromptManager::SendingType, - helpers::EQ, - helpers::ONE>( - help_prompt_manager.GetSendingType(), - HelpPromptManager::SendingType::kSendHelpPrompt, - HelpPromptManager::SendingType::kSendBoth); + const bool can_send_vr = helpers:: + Compare<HelpPromptManager::SendingType, helpers::EQ, helpers::ONE>( + help_prompt_manager.GetSendingType(), + HelpPromptManager::SendingType::kSendHelpPrompt, + HelpPromptManager::SendingType::kSendBoth); // TTS global properties if (can_send_vr && (app->help_prompt() || app->timeout_prompt())) { @@ -1539,6 +1594,67 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI( return vr_command; } +smart_objects::SmartObjectSPtr MessageHelper::CreateUICreateWindowRequestToHMI( + ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& window_info) { + LOG4CXX_AUTO_TRACE(logger_); + auto ui_request = CreateMessageForHMI(hmi_apis::messageType::request, + app_mngr.GetNextHMICorrelationID()); + + (*ui_request)[strings::params][strings::function_id] = + static_cast<int>(hmi_apis::FunctionID::UI_CreateWindow); + + (*ui_request)[strings::correlation_id] = + (*ui_request)[strings::params][strings::correlation_id]; + (*ui_request)[strings::function_id] = + (*ui_request)[strings::params][strings::function_id]; + + smart_objects::SmartObject msg_params( + smart_objects::SmartObject(smart_objects::SmartType_Map)); + + msg_params[strings::window_id] = window_info[strings::window_id].asInt(); + msg_params[strings::window_type] = window_info[strings::window_type].asInt(); + msg_params[strings::window_name] = + window_info[strings::window_name].asString(); + + if (window_info.keyExists(strings::associated_service_type)) { + msg_params[strings::associated_service_type] = + window_info[strings::associated_service_type].asString(); + } + if (window_info.keyExists(strings::duplicate_updates_from_window_id)) { + msg_params[strings::duplicate_updates_from_window_id] = + window_info[strings::duplicate_updates_from_window_id].asInt(); + } + + msg_params[strings::app_id] = application->hmi_app_id(); + + (*ui_request)[strings::msg_params] = msg_params; + + return ui_request; +} + +smart_objects::SmartObjectList MessageHelper::CreateUICreateWindowRequestsToHMI( + application_manager::ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& windows_info) { + smart_objects::SmartObjectList requests; + DCHECK_OR_RETURN(application, requests); + + for (size_t i = 0; i < windows_info.length(); ++i) { + const auto& info = windows_info[i]; + + const auto ui_request = + CreateUICreateWindowRequestToHMI(application, app_mngr, info); + + DCHECK_OR_RETURN(ui_request, requests); + + requests.push_back(ui_request); + } + + return requests; +} + bool MessageHelper::CreateDeviceInfo( connection_handler::DeviceHandle device_handle, const protocol_handler::SessionObserver& session_observer, @@ -1591,8 +1707,8 @@ bool MessageHelper::CreateHMIApplicationStruct( const smart_objects::SmartObject* app_types = app->app_types(); const smart_objects::SmartObject* ngn_media_screen_name = app->ngn_media_screen_name(); - const smart_objects::SmartObject* day_color_scheme = app->day_color_scheme(); - const smart_objects::SmartObject* night_color_scheme = + const smart_objects::SmartObject day_color_scheme = app->day_color_scheme(); + const smart_objects::SmartObject night_color_scheme = app->night_color_scheme(); message = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -1630,7 +1746,8 @@ bool MessageHelper::CreateHMIApplicationStruct( const policy::RequestType::State app_request_types_state = policy_handler.GetAppRequestTypeState(policy_app_id); if (policy::RequestType::State::AVAILABLE == app_request_types_state) { - const auto request_types = policy_handler.GetAppRequestTypes(policy_app_id); + const auto request_types = + policy_handler.GetAppRequestTypes(app->device(), policy_app_id); message[strings::request_type] = SmartObject(smart_objects::SmartType_Array); smart_objects::SmartObject& request_types_array = @@ -1667,12 +1784,12 @@ bool MessageHelper::CreateHMIApplicationStruct( SmartObject(smart_objects::SmartType_Array); } - if (day_color_scheme) { - message[strings::day_color_scheme] = *day_color_scheme; + if (day_color_scheme.getType() == smart_objects::SmartType_Map) { + message[strings::day_color_scheme] = day_color_scheme; } - if (night_color_scheme) { - message[strings::night_color_scheme] = *night_color_scheme; + if (night_color_scheme.getType() == smart_objects::SmartType_Map) { + message[strings::night_color_scheme] = night_color_scheme; } message[strings::device_info] = @@ -1781,12 +1898,16 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr) { DCHECK_OR_RETURN(app, smart_objects::SmartObjectSPtr()); + if (hmi_apis::Common_HMILevel::NONE == level) { + LOG4CXX_WARN(logger_, + "BC.ActivateApp cannot be used to deactivate an application"); + return NULL; + } const uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); smart_objects::SmartObjectSPtr message = @@ -1823,6 +1944,23 @@ smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( return message; } +smart_objects::SmartObjectSPtr MessageHelper::GetBCCloseApplicationRequestToHMI( + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { + DCHECK_OR_RETURN(app, smart_objects::SmartObjectSPtr()); + + const uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); + smart_objects::SmartObjectSPtr message = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_CloseApplication; + (*message)[strings::params][strings::message_type] = MessageType::kRequest; + (*message)[strings::params][strings::correlation_id] = correlation_id; + (*message)[strings::msg_params][strings::app_id] = app->app_id(); + + return message; +} + void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_WARN(logger_, "SendOnResumeAudioSourceToHMI app_id: " << app_id); @@ -2099,6 +2237,34 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse( return std::make_shared<smart_objects::SmartObject>(response_data); } +smart_objects::SmartObjectSPtr MessageHelper::CreateOnServiceUpdateNotification( + const hmi_apis::Common_ServiceType::eType service_type, + const hmi_apis::Common_ServiceEvent::eType service_event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType + service_update_reason, + const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + auto notification = MessageHelper::CreateHMINotification( + hmi_apis::FunctionID::BasicCommunication_OnServiceUpdate); + + (*notification)[strings::msg_params][hmi_notification::service_type] = + service_type; + (*notification)[strings::msg_params][hmi_notification::service_event] = + service_event; + + if (0 != app_id) { + (*notification)[strings::msg_params][strings::app_id] = app_id; + } + + if (hmi_apis::Common_ServiceStatusUpdateReason::INVALID_ENUM != + service_update_reason) { + (*notification)[strings::msg_params][hmi_notification::reason] = + service_update_reason; + } + + return notification; +} + void MessageHelper::SendNaviSetVideoConfig( int32_t app_id, ApplicationManager& app_mngr, @@ -2295,6 +2461,14 @@ void MessageHelper::SendPolicySnapshotNotification( const std::string& url, ApplicationManager& app_mngr) { smart_objects::SmartObject content(smart_objects::SmartType_Map); + const auto request_type = +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + mobile_apis::RequestType::PROPRIETARY; +#else + mobile_apis::RequestType::HTTP; +#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE + + content[strings::msg_params][strings::request_type] = request_type; if (!url.empty()) { content[strings::msg_params][strings::url] = @@ -2305,13 +2479,6 @@ void MessageHelper::SendPolicySnapshotNotification( content[strings::params][strings::binary_data] = smart_objects::SmartObject(policy_data); -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) - content[strings::msg_params][strings::request_type] = - mobile_apis::RequestType::PROPRIETARY; -#else - content[strings::msg_params][strings::request_type] = - mobile_apis::RequestType::HTTP; -#endif // PROPRIETARY || EXTERNAL_PROPRIETARY_MODE SendSystemRequestNotification(connection_key, content, app_mngr); } @@ -2393,7 +2560,8 @@ void MessageHelper::SendQueryApps(const uint32_t connection_key, void MessageHelper::SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr) { + ApplicationManager& app_mngr, + const policy::EncryptionRequired encryprion_required) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject content(smart_objects::SmartType_Map); @@ -2410,8 +2578,10 @@ void MessageHelper::SendOnPermissionsChangeNotification( content[strings::msg_params] = smart_objects::SmartObject(smart_objects::SmartType_Map); - // content[strings::msg_params][strings::app_id] = connection_key; - + if (encryprion_required.is_initialized()) { + content[strings::msg_params][strings::require_encryption] = + static_cast<bool>(*encryprion_required); + } content[strings::msg_params]["permissionItem"] = smart_objects::SmartObject(smart_objects::SmartType_Array); @@ -2421,6 +2591,41 @@ void MessageHelper::SendOnPermissionsChangeNotification( policy::Permissions::const_iterator it_permissions = permissions.begin(); policy::Permissions::const_iterator it_permissions_end = permissions.end(); + using policy::EncryptionRequired; + auto permission_item_encryption_flag_state = + [](const EncryptionRequired& app_flag, + const EncryptionRequired& groups_flag) -> EncryptionRequired { + enum EncryptionFlagState { TRUE, FALSE, MISSING }; + auto enum_from_optional_bool = [](const EncryptionRequired& flag) { + if (!flag.is_initialized()) { + return MISSING; + } + return *flag ? TRUE : FALSE; + }; + + typedef std::pair<EncryptionFlagState, EncryptionFlagState> + EnctyptionStatePair; + typedef std::map<EnctyptionStatePair, EncryptionRequired> + PermissionItemEncryptionTable; + static PermissionItemEncryptionTable encryption_state_table = { + {{TRUE, TRUE}, EncryptionRequired(true)}, + {{TRUE, FALSE}, EncryptionRequired()}, + {{TRUE, MISSING}, EncryptionRequired()}, + {{FALSE, TRUE}, EncryptionRequired()}, + {{FALSE, FALSE}, EncryptionRequired()}, + {{FALSE, MISSING}, EncryptionRequired()}, + {{MISSING, TRUE}, EncryptionRequired(true)}, + {{MISSING, FALSE}, EncryptionRequired()}, + {{MISSING, MISSING}, EncryptionRequired()}, + }; + const auto app_flag_state = enum_from_optional_bool(app_flag); + const auto groups_flag_state = enum_from_optional_bool(groups_flag); + auto it = encryption_state_table.find( + EnctyptionStatePair(app_flag_state, groups_flag_state)); + DCHECK_OR_RETURN(it != encryption_state_table.end(), EncryptionRequired()); + return it->second; + }; + for (size_t index_pi = 0; it_permissions != it_permissions_end; ++it_permissions, ++index_pi) { permissions_item_array[index_pi] = @@ -2429,9 +2634,14 @@ void MessageHelper::SendOnPermissionsChangeNotification( smart_objects::SmartObject& permission_item = permissions_item_array[index_pi]; - // Filling the rpcName of PermissionItem permission_item["rpcName"] = (*it_permissions).first; const policy::RpcPermissions& rpc_permissions = (*it_permissions).second; + auto item_require_encryption = permission_item_encryption_flag_state( + encryprion_required, rpc_permissions.require_encryption); + if (item_require_encryption.is_initialized()) { + const bool require_encryption = *item_require_encryption; + permission_item[strings::require_encryption] = require_encryption; + } // Creating SO for hmiPermissions permission_item["hmiPermissions"] = @@ -2930,7 +3140,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( } if ((!request_soft_buttons[i].keyExists(strings::text)) || (!VerifyString( - request_soft_buttons[i][strings::text].asString()))) { + request_soft_buttons[i][strings::text].asString()))) { return Result::INVALID_DATA; } break; @@ -2939,7 +3149,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( if ((!request_soft_buttons[i].keyExists(strings::text)) || ((request_soft_buttons[i][strings::text].length()) && (!VerifyString( - request_soft_buttons[i][strings::text].asString())))) { + request_soft_buttons[i][strings::text].asString())))) { return Result::INVALID_DATA; } @@ -2971,17 +3181,32 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( void MessageHelper::SubscribeApplicationToSoftButton( smart_objects::SmartObject& message_params, ApplicationSharedPtr app, - int32_t function_id) { + int32_t function_id, + const WindowID window_id) { SoftButtonID softbuttons_id; smart_objects::SmartObject& soft_buttons = message_params[strings::soft_buttons]; unsigned int length = soft_buttons.length(); for (unsigned int i = 0; i < length; ++i) { - softbuttons_id.insert(soft_buttons[i][strings::soft_button_id].asUInt()); + const auto button_id = std::make_pair( + soft_buttons[i][strings::soft_button_id].asUInt(), window_id); + softbuttons_id.insert(button_id); } app->SubscribeToSoftButtons(function_id, softbuttons_id); } +void MessageHelper::SubscribeApplicationToSoftButton( + smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id) { + LOG4CXX_AUTO_TRACE(logger_); + SubscribeApplicationToSoftButton( + message_params, + app, + function_id, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW); +} + bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { #ifdef DEBUG Json::Value tmp; @@ -2992,4 +3217,14 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return true; } +WindowID MessageHelper::ExtractWindowIdFromSmartObject( + const smart_objects::SmartObject& s_map) { + if (smart_objects::SmartType_Map == s_map.getType()) { + if (s_map.keyExists(strings::window_id)) { + return s_map[strings::window_id].asInt(); + } + } + return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +} + } // namespace 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 1ee368a212..d3e7c782f7 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -32,12 +32,12 @@ #include <string.h> -#include "utils/macro.h" #include "application_manager/mobile_message_handler.h" -#include "protocol_handler/protocol_payload.h" #include "protocol_handler/protocol_packet.h" +#include "protocol_handler/protocol_payload.h" #include "utils/bitstream.h" #include "utils/logger.h" +#include "utils/macro.h" #include <stdint.h> #include <memory> @@ -48,7 +48,7 @@ const uint8_t kRequest = 0x0; const uint8_t kResponse = 0x1; const uint8_t kNotification = 0x2; const uint8_t kUnknown = 0xF; -} +} // namespace namespace application_manager { using protocol_handler::Extract; @@ -58,7 +58,7 @@ typedef std::map<MessageType, std::string> MessageTypeMap; MessageTypeMap message_types = {std::make_pair(kRequest, "Request"), std::make_pair(kResponse, "Response"), std::make_pair(kNotification, "Notification")}; -} +} // namespace CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") application_manager::Message* @@ -195,6 +195,7 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2( message->protocol_version())); outgoing_message->set_data_size(message->data_size()); outgoing_message->set_payload_size(message->payload_size()); + outgoing_message->set_message_encryption(message->protection_flag()); if (!payload.data.empty()) { const BinaryData binary_payload_data(payload.data); @@ -220,7 +221,8 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV1( new protocol_handler::RawMessage(message->connection_key(), 1, &raw_message[0], - message_string.length() + 1); + message_string.length() + 1, + false); return result; } @@ -298,6 +300,7 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2( message->protocol_version(), &data_for_sending[0], data_for_sending_size, + false, type); return msg_to_protocol_handler; diff --git a/src/components/application_manager/src/plugin_manager/plugin_keys.cc b/src/components/application_manager/src/plugin_manager/plugin_keys.cc index 9eabc67c09..80be2d1389 100644 --- a/src/components/application_manager/src/plugin_manager/plugin_keys.cc +++ b/src/components/application_manager/src/plugin_manager/plugin_keys.cc @@ -8,7 +8,7 @@ const char* vehicle_info_rpc_plugin = "Vehicle Info RPC Plugin"; const char* app_service_rpc_plugin = "App Service RPC Plugin"; const char* rc_rpc_plugin = "RC RPC Plugin"; const char* sdl_rpc_plugin = "SDL RPC Plugin"; -} +} // namespace plugin_names } // namespace plugin_manager } // namespace application_manager
\ No newline at end of file diff --git a/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc b/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc index bbd0011298..0c7ec9838b 100644 --- a/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc +++ b/src/components/application_manager/src/plugin_manager/rpc_plugin_manager_impl.cc @@ -1,6 +1,6 @@ -#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include <dlfcn.h> +#include "application_manager/plugin_manager/rpc_plugin_manager_impl.h" #include "utils/file_system.h" namespace application_manager { @@ -12,11 +12,13 @@ RPCPluginManagerImpl::RPCPluginManagerImpl( ApplicationManager& app_manager, rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) : app_manager_(app_manager) , rpc_service_(rpc_service) , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) {} + , policy_handler_(policy_handler) + , last_state_(last_state) {} bool IsLibraryFile(const std::string& file_path) { size_t pos = file_path.find_last_of("."); @@ -29,32 +31,57 @@ bool IsLibraryFile(const std::string& file_path) { return true; } -RPCPluginPtr LoadPlugin(const std::string& full_plugin_path) { +template <typename T> +T GetFuncFromLib(void* dl_handle, const std::string& function_name) { + T exported_func = + reinterpret_cast<T>(dlsym(dl_handle, function_name.c_str())); + char* error_string = dlerror(); + if (nullptr != error_string) { + LOG4CXX_ERROR(logger_, "Failed to export symbols : " << error_string); + return nullptr; + } + return exported_func; +} + +RPCPluginManagerImpl::RPCPluginPtr RPCPluginManagerImpl::LoadPlugin( + const std::string& full_plugin_path) const { if (!IsLibraryFile(full_plugin_path)) { LOG4CXX_DEBUG(logger_, "Skip loading " << full_plugin_path); - return RPCPluginPtr(); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); } void* plugin_dll = dlopen(full_plugin_path.c_str(), RTLD_LAZY); if (nullptr == plugin_dll) { - LOG4CXX_ERROR(logger_, - "Failed to open dll " << full_plugin_path << " : " - << dlerror()); - return RPCPluginPtr(); + LOG4CXX_ERROR( + logger_, + "Failed to open dll " << full_plugin_path << " : " << dlerror()); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); } typedef RPCPlugin* (*Create)(); - Create create_plugin = reinterpret_cast<Create>(dlsym(plugin_dll, "Create")); - char* error_string = dlerror(); - if (nullptr != error_string) { - LOG4CXX_ERROR(logger_, - "Failed to export dll's " << full_plugin_path - << " symbols : " << error_string); + Create create_plugin = GetFuncFromLib<Create>(plugin_dll, "Create"); + if (!create_plugin) { + LOG4CXX_ERROR(logger_, "No Create function in " << full_plugin_path); + dlclose(plugin_dll); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); + } + + typedef void (*Delete)(RPCPlugin*); + Delete delete_plugin = GetFuncFromLib<Delete>(plugin_dll, "Delete"); + if (!delete_plugin) { + LOG4CXX_ERROR(logger_, "No Delete function in " << full_plugin_path); dlclose(plugin_dll); - return RPCPluginPtr(); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); } + + auto plugin_destroyer = [delete_plugin, plugin_dll](RPCPlugin* plugin) { + LOG4CXX_DEBUG(logger_, "Delete plugin " << plugin->PluginName()); + delete_plugin(plugin); + dlclose(plugin_dll); + return RPCPluginPtr(nullptr, [](RPCPlugin*) {}); + }; RPCPlugin* plugin = create_plugin(); - return RPCPluginPtr(plugin); + return RPCPluginPtr(plugin, plugin_destroyer); } uint32_t RPCPluginManagerImpl::LoadPlugins(const std::string& plugins_path) { @@ -66,11 +93,14 @@ uint32_t RPCPluginManagerImpl::LoadPlugins(const std::string& plugins_path) { if (!plugin) { continue; } - LOG4CXX_DEBUG(logger_, - "Loaded " << plugin->PluginName() << " plugin from " - << full_name); - if (plugin->Init( - app_manager_, rpc_service_, hmi_capabilities_, policy_handler_)) { + LOG4CXX_DEBUG( + logger_, + "Loaded " << plugin->PluginName() << " plugin from " << full_name); + if (plugin->Init(app_manager_, + rpc_service_, + hmi_capabilities_, + policy_handler_, + last_state_)) { loaded_plugins_.push_back(std::move(plugin)); } else { LOG4CXX_ERROR(logger_, @@ -82,10 +112,6 @@ uint32_t RPCPluginManagerImpl::LoadPlugins(const std::string& plugins_path) { return loaded_plugins_.size(); } -std::vector<RPCPluginPtr>& RPCPluginManagerImpl::GetPlugins() { - return loaded_plugins_; -} - utils::Optional<RPCPlugin> RPCPluginManagerImpl::FindPluginToProcess( const int32_t function_id, const commands::Command::CommandSource message_source) { diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc index ea8935c8c5..afe909fee4 100644 --- a/src/components/application_manager/src/policies/policy_event_observer.cc +++ b/src/components/application_manager/src/policies/policy_event_observer.cc @@ -31,10 +31,10 @@ */ #include "application_manager/policies/policy_event_observer.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/policies/policy_handler.h" -#include "utils/date_time.h" +#include "application_manager/smart_object_keys.h" #include "smart_objects/smart_object.h" +#include "utils/date_time.h" namespace policy { using namespace application_manager; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index aeb5a8bd01..09dcb2c7ad 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -30,34 +30,37 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "application_manager/policies/policy_handler.h" -#include <unistd.h> #include <dlfcn.h> +#include <unistd.h> #include <algorithm> -#include <vector> #include <functional> #include <utility> -#include "application_manager/smart_object_keys.h" -#include "application_manager/policies/delegates/app_permission_delegate.h" -#include "policy/status.h" +#include <vector> #include "application_manager/application_manager.h" -#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/delegates/app_permission_delegate.h" #include "application_manager/rpc_service.h" -#include "policy/policy_manager_impl.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/state_controller.h" +#include "application_manager/usage_statistics.h" #include "connection_handler/connection_handler.h" -#include "utils/macro.h" -#include "utils/date_time.h" +#include "interfaces/MOBILE_API.h" #include "json/value.h" #include "json/writer.h" -#include "application_manager/usage_statistics.h" +#include "policy/policy_manager_impl.h" #include "policy/policy_types.h" -#include "interfaces/MOBILE_API.h" +#include "policy/status.h" +#include "smart_objects/enum_schema_item.h" +#include "utils/date_time.h" #include "utils/file_system.h" +#include "utils/macro.h" #include "utils/scope_guard.h" -#include "smart_objects/enum_schema_item.h" -#include "utils/helpers.h" #include "policy/policy_manager.h" +#include "utils/helpers.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +#include "policy/ptu_retry_handler.h" +#endif // EXTERNAL_PROPRIETARY_MODE namespace policy { @@ -107,13 +110,12 @@ const policy::DeviceParams GetDeviceParams( const protocol_handler::SessionObserver& session_observer) { CREATE_LOGGERPTR_LOCAL(logger_, "PolicyHandler"); policy::DeviceParams device_params; - if (-1 == - session_observer.GetDataOnDeviceID( - device_handle, - &device_params.device_name, - NULL, - &device_params.device_mac_address, - &device_params.device_connection_type)) { + if (-1 == session_observer.GetDataOnDeviceID( + device_handle, + &device_params.device_name, + NULL, + &device_params.device_mac_address, + &device_params.device_connection_type)) { LOG4CXX_ERROR(logger_, "Failed to extract information for device " << device_handle); } @@ -127,7 +129,10 @@ struct HMILevelPredicate : level_(level) {} bool operator()(const ApplicationSharedPtr app) const { - return level_ == app->hmi_level() ? true : false; + return level_ == app->hmi_level( + mobile_apis::PredefinedWindows::DEFAULT_WINDOW) + ? true + : false; } private: @@ -166,6 +171,7 @@ struct DeactivateApplication { if (device_id_ == app->device()) { state_ctrl_.SetRegularState( app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, @@ -178,41 +184,6 @@ struct DeactivateApplication { StateController& state_ctrl_; }; -struct SDLAllowedNotification { - SDLAllowedNotification(const connection_handler::DeviceHandle& device_id, - PolicyManager* policy_manager, - StateController& state_controller) - : device_id_(device_id) - , policy_manager_(policy_manager) - , state_controller_(state_controller) {} - - void operator()(const ApplicationSharedPtr& app) { - DCHECK_OR_RETURN_VOID(policy_manager_); - if (device_id_ == app->device()) { - std::string hmi_level = "NONE"; - mobile_apis::HMILevel::eType default_mobile_hmi; - policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level); - if ("BACKGROUND" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND; - } else if ("FULL" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL; - } else if ("LIMITED" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED; - } else if ("NONE" == hmi_level) { - default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE; - } else { - return; - } - state_controller_.SetRegularState(app, default_mobile_hmi, true); - } - } - - private: - connection_handler::DeviceHandle device_id_; - PolicyManager* policy_manager_; - StateController& state_controller_; -}; - /** * @brief Gets from system list of currently registered applications and * create collection of links device-to-application @@ -327,7 +298,6 @@ const std::string PolicyHandler::kLibrary = "libPolicy.so"; PolicyHandler::PolicyHandler(const PolicySettings& settings, ApplicationManager& application_manager) : AsyncRunner("PolicyHandler async runner thread") - , dl_handle_(0) , last_activated_app_id_(0) , statistic_manager_impl_(std::make_shared<StatisticManagerImpl>(this)) , settings_(settings) @@ -335,6 +305,11 @@ PolicyHandler::PolicyHandler(const PolicySettings& settings, PolicyHandler::~PolicyHandler() {} +PolicyEncryptionFlagGetterInterfaceSPtr +PolicyHandler::PolicyEncryptionFlagGetter() const { + return policy_manager_; +} + bool PolicyHandler::PolicyEnabled() const { return get_settings().enable_policy(); } @@ -349,36 +324,46 @@ bool PolicyHandler::LoadPolicyLibrary() { policy_manager_.reset(); return false; } - dl_handle_ = dlopen(kLibrary.c_str(), RTLD_LAZY); - const char* error = dlerror(); - if (!error) { - if (CreateManager()) { - policy_manager_->set_listener(this); - event_observer_ = - std::shared_ptr<PolicyEventObserver>(new PolicyEventObserver( - this, application_manager_.event_dispatcher())); - } - } else { - LOG4CXX_ERROR(logger_, error); + if (CreateManager()) { + policy_manager_->set_listener(this); + event_observer_ = std::shared_ptr<PolicyEventObserver>( + new PolicyEventObserver(this, application_manager_.event_dispatcher())); } return (policy_manager_.use_count() != 0); } bool PolicyHandler::CreateManager() { + void* policy_handle = dlopen(kLibrary.c_str(), RTLD_LAZY); + const char* error = dlerror(); + if (!policy_handle) { + LOG4CXX_ERROR( + logger_, + (error == NULL ? "Unknown error in dlopen while loading policy table" + : error)); + return false; + } + typedef PolicyManager* (*CreateManager)(); typedef void (*DeleteManager)(PolicyManager*); CreateManager create_manager = - reinterpret_cast<CreateManager>(dlsym(dl_handle_, "CreateManager")); + reinterpret_cast<CreateManager>(dlsym(policy_handle, "CreateManager")); DeleteManager delete_manager = - reinterpret_cast<DeleteManager>(dlsym(dl_handle_, "DeleteManager")); + reinterpret_cast<DeleteManager>(dlsym(policy_handle, "DeleteManager")); + auto policy_destroyer = [delete_manager, + policy_handle](PolicyManager* policy_manager) { + LOG4CXX_DEBUG(logger_, "Delete Policy Manager"); + delete_manager(policy_manager); + dlclose(policy_handle); + }; char* error_string = dlerror(); if (NULL == error_string) { policy_manager_ = - std::shared_ptr<PolicyManager>(create_manager(), delete_manager); + std::shared_ptr<PolicyManager>(create_manager(), policy_destroyer); } else { LOG4CXX_WARN(logger_, error_string); + dlclose(policy_handle); } return (policy_manager_.use_count() != 0); } @@ -396,12 +381,31 @@ bool PolicyHandler::InitPolicyTable() { hmi_apis::FunctionID::BasicCommunication_OnReady); std::string preloaded_file = get_settings().preloaded_pt_file(); if (file_system::FileExists(preloaded_file)) { - return policy_manager_->InitPT(preloaded_file, &get_settings()); + const bool pt_inited = + policy_manager_->InitPT(preloaded_file, &get_settings()); + OnPTInited(); + return pt_inited; } LOG4CXX_FATAL(logger_, "The file which contains preloaded PT is not exist"); return false; } +void PolicyHandler::OnPTInited() { + LOG4CXX_AUTO_TRACE(logger_); + + sync_primitives::AutoLock lock(listeners_lock_); + + std::for_each(listeners_.begin(), + listeners_.end(), + std::mem_fun(&PolicyHandlerObserver::OnPTInited)); +} + +void PolicyHandler::StopRetrySequence() { + LOG4CXX_AUTO_TRACE(logger_); + + policy_manager_->StopRetrySequence(); +} + bool PolicyHandler::ResetPolicyTable() { LOG4CXX_TRACE(logger_, "Reset policy table."); POLICY_LIB_CHECK(false); @@ -453,10 +457,20 @@ uint32_t PolicyHandler::GetAppIdForSending() const { logger_, "Number of apps with NONE level: " << apps_with_none_level.size()); + if (apps_with_none_level.empty()) { + LOG4CXX_WARN(logger_, "There is no registered application"); + return 0; + } + return ChooseRandomAppForPolicyUpdate(apps_with_none_level); } #ifdef EXTERNAL_PROPRIETARY_MODE +PTURetryHandler& PolicyHandler::ptu_retry_handler() const { + LOG4CXX_AUTO_TRACE(logger_); + return *policy_manager_; +} + void PolicyHandler::OnAppPermissionConsent( const uint32_t connection_key, const PermissionConsent& permissions, @@ -476,6 +490,7 @@ void PolicyHandler::OnAppPermissionConsent( void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id, const bool is_allowed) { + LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); connection_handler::DeviceHandle device_handle; if (!application_manager_.connection_handler().GetDeviceID(device_id, @@ -506,21 +521,25 @@ void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id, continue; } - policy_manager_->ReactOnUserDevConsentForApp(policy_app_id, is_allowed); + policy_manager_->ReactOnUserDevConsentForApp( + device_handle, policy_app_id, is_allowed); - policy_manager_->SendNotificationOnPermissionsUpdated(policy_app_id); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id, + policy_app_id); } } } void PolicyHandler::SendOnAppPermissionsChanged( - const AppPermissions& permissions, const std::string& policy_app_id) const { + const AppPermissions& permissions, + const std::string& device_id, + const std::string& policy_app_id) const { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "PolicyHandler::SendOnAppPermissionsChanged for " - << policy_app_id); + LOG4CXX_DEBUG( + logger_, + "PolicyHandler::SendOnAppPermissionsChanged for " << policy_app_id); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN(logger_, "No app found for policy app id = " << policy_app_id); return; @@ -554,10 +573,11 @@ struct SmartObjectToInt { }; StatusNotifier PolicyHandler::AddApplication( + const std::string& device_id, const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) { POLICY_LIB_CHECK(std::make_shared<utils::CallNothing>()); - return policy_manager_->AddApplication(application_id, hmi_types); + return policy_manager_->AddApplication(device_id, application_id, hmi_types); } void PolicyHandler::AddDevice(const std::string& device_id, @@ -609,13 +629,9 @@ void PolicyHandler::OnAppPermissionConsentInternal( #endif } } else if (!app_to_device_link_.empty()) { - sync_primitives::AutoLock lock(app_to_device_link_lock_); - std::map<std::string, std::string>::const_iterator it = - app_to_device_link_.begin(); - for (; app_to_device_link_.end() != it; ++it) { - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(it->second); - + const ApplicationSet& accessor = + application_manager_.applications().GetData(); + for (const auto& app : accessor) { // If list of apps sent to HMI for user consents is not the same as // current, // permissions should be set only for coincident to registered apps @@ -626,19 +642,26 @@ void PolicyHandler::OnAppPermissionConsentInternal( continue; } + if (!app->IsRegistered()) { + LOG4CXX_DEBUG(logger_, + "Application " << app->policy_app_id() + << " is not marked as registered."); + continue; + } + DeviceParams device_params = GetDeviceParams( app->device(), application_manager_.connection_handler().get_session_observer()); - if (device_params.device_mac_address != it->first) { + if (device_params.device_mac_address != app->mac_address()) { LOG4CXX_WARN(logger_, "Device_id of application is changed." "Permissions setting skipped."); continue; } - out_permissions.policy_app_id = it->second; - out_permissions.device_id = it->first; + out_permissions.policy_app_id = app->policy_app_id(); + out_permissions.device_id = app->mac_address(); #ifdef EXTERNAL_PROPRIETARY_MODE policy_manager_->SetUserConsentForApp(out_permissions, mode); #else @@ -812,9 +835,9 @@ bool PolicyHandler::IsAppSuitableForPolicyUpdate( LOG4CXX_AUTO_TRACE(logger_); if (!value->IsRegistered()) { - LOG4CXX_DEBUG(logger_, - "Application " << value->app_id() - << " is not marked as registered."); + LOG4CXX_DEBUG( + logger_, + "Application " << value->app_id() << " is not marked as registered."); return false; } @@ -827,9 +850,9 @@ bool PolicyHandler::IsAppSuitableForPolicyUpdate( value->device(), application_manager_.connection_handler().get_session_observer()); - const bool is_device_allowed = (kDeviceAllowed == - policy_manager_->GetUserConsentForDevice( - device_params.device_mac_address)); + const bool is_device_allowed = + (kDeviceAllowed == policy_manager_->GetUserConsentForDevice( + device_params.device_mac_address)); LOG4CXX_DEBUG(logger_, "Is device " << device_params.device_mac_address << " allowed " @@ -862,6 +885,15 @@ void PolicyHandler::OnDeviceSwitching(const std::string& device_id_from, policy_manager_->OnDeviceSwitching(device_id_from, device_id_to); } +void PolicyHandler::OnLockScreenDismissalStateChanged() { + LOG4CXX_AUTO_TRACE(logger_); + const auto accessor = application_manager_.applications(); + const auto apps = accessor.GetData(); + for (auto& app : apps) { + application_manager_.SendDriverDistractionState(app); + } +} + void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); @@ -879,10 +911,15 @@ void PolicyHandler::OnUpdateStatusChanged(const std::string& status) { } std::string PolicyHandler::OnCurrentDeviceIdUpdateRequired( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) { LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + DeviceParams device_params = GetDeviceParams( + device_handle, + application_manager_.connection_handler().get_session_observer()); + + ApplicationSharedPtr app = application_manager_.application( + device_params.device_mac_address, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN(logger_, @@ -890,11 +927,8 @@ std::string PolicyHandler::OnCurrentDeviceIdUpdateRequired( << policy_app_id << "' " "not found within registered applications."); - return ""; + return std::string(); } - DeviceParams device_params = GetDeviceParams( - app->device(), - application_manager_.connection_handler().get_session_observer()); return device_params.device_mac_address; } @@ -936,9 +970,9 @@ void PolicyHandler::OnVehicleDataUpdated( POLICY_LIB_CHECK_VOID(); #ifdef EXTERNAL_PROPRIETARY_MODE if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR(logger_, - "Message does not contains mandatory section " - << strings::msg_params); + LOG4CXX_ERROR( + logger_, + "Message does not contains mandatory section " << strings::msg_params); return; } if (message[strings::msg_params].keyExists(strings::vin)) { @@ -952,14 +986,14 @@ void PolicyHandler::OnVehicleDataUpdated( } void PolicyHandler::OnPendingPermissionChange( - const std::string& policy_app_id) { + const std::string& device_id, const std::string& policy_app_id) { LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "PolicyHandler::OnPendingPermissionChange for " - << policy_app_id); + LOG4CXX_DEBUG( + logger_, + "PolicyHandler::OnPendingPermissionChange for " << policy_app_id); POLICY_LIB_CHECK_VOID(); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN(logger_, "No app found for " << policy_app_id << " policy app id."); @@ -967,7 +1001,7 @@ void PolicyHandler::OnPendingPermissionChange( } AppPermissions permissions = - policy_manager_->GetAppPermissionsChanges(policy_app_id); + policy_manager_->GetAppPermissionsChanges(device_id, policy_app_id); const uint32_t app_id = app->app_id(); @@ -976,6 +1010,7 @@ void PolicyHandler::OnPendingPermissionChange( app_id, permissions, application_manager_); application_manager_.state_controller().SetRegularState( app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, @@ -984,7 +1019,8 @@ void PolicyHandler::OnPendingPermissionChange( return; } - mobile_apis::HMILevel::eType app_hmi_level = app->hmi_level(); + mobile_apis::HMILevel::eType app_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); switch (app_hmi_level) { case mobile_apis::HMILevel::eType::HMI_FULL: @@ -1051,14 +1087,17 @@ bool PolicyHandler::SendMessageToSDK(const BinaryMessage& pt_string, if (mobile_app_id.empty()) { LOG4CXX_WARN(logger_, "Application with connection key '" - << app_id << "'" - " has no application id."); + << app_id + << "'" + " has no application id."); return false; } LOG4CXX_DEBUG(logger_, - "Update url is " << url << " for application " - "with connection key " << app_id); + "Update url is " << url + << " for application " + "with connection key " + << app_id); MessageHelper::SendPolicySnapshotNotification( app_id, pt_string, url, application_manager_); @@ -1070,15 +1109,21 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file, const BinaryMessage& pt_string) { POLICY_LIB_CHECK(false); - bool ret = policy_manager_->LoadPT(file, pt_string); - LOG4CXX_INFO(logger_, "Policy table is saved: " << std::boolalpha << ret); - if (ret) { + const auto load_pt_result = policy_manager_->LoadPT(file, pt_string); + + LOG4CXX_INFO(logger_, "Load policy table result code: " << load_pt_result); + + const bool is_ptu_successful = + load_pt_result == PolicyManager::PtProcessingResult::kSuccess; + OnPTUFinished(is_ptu_successful); + + if (is_ptu_successful) { LOG4CXX_INFO(logger_, "PTU was successful."); policy_manager_->CleanupUnpairedDevices(); - int32_t correlation_id = application_manager_.GetNextHMICorrelationID(); - SetDaysAfterEpoch(); + policy_manager_->OnPTUFinished(load_pt_result); + uint32_t correlation_id = application_manager_.GetNextHMICorrelationID(); event_observer_->subscribe_on_event( hmi_apis::FunctionID::VehicleInfo_GetVehicleData, correlation_id); std::vector<std::string> vehicle_data_args; @@ -1087,9 +1132,10 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file, correlation_id, vehicle_data_args, application_manager_); } else { LOG4CXX_WARN(logger_, "Exchange wasn't successful"); + policy_manager_->OnPTUFinished(load_pt_result); } - OnPTUFinished(ret); - return ret; + + return is_ptu_successful; } bool PolicyHandler::UnloadPolicyLibrary() { @@ -1101,10 +1147,6 @@ bool PolicyHandler::UnloadPolicyLibrary() { if (policy_manager_) { policy_manager_.reset(); } - if (dl_handle_) { - ret = (dlclose(dl_handle_) == 0); - dl_handle_ = 0; - } LOG4CXX_TRACE(logger_, "exit"); return ret; } @@ -1123,7 +1165,8 @@ struct SDLAlowedNotification { if (app->device() == device_id_) { std::string hmi_level; mobile_apis::HMILevel::eType default_mobile_hmi; - policy_manager_->GetDefaultHmi(app->policy_app_id(), &hmi_level); + policy_manager_->GetDefaultHmi( + app->mac_address(), app->policy_app_id(), &hmi_level); if ("BACKGROUND" == hmi_level) { default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND; } else if ("FULL" == hmi_level) { @@ -1135,7 +1178,11 @@ struct SDLAlowedNotification { } else { return; } - state_controller_.SetRegularState(app, default_mobile_hmi, true); + state_controller_.SetRegularState( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + default_mobile_hmi, + true); } } @@ -1173,9 +1220,9 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( policy_manager_->SetUserConsentForDevice(device_id, is_allowed); connection_handler::DeviceHandle device_handle = 0; if (!connection_handler.GetDeviceID(device_id, &device_handle)) { - LOG4CXX_WARN(logger_, - "Device handle with mac " << device_id - << " wasn't found."); + LOG4CXX_WARN( + logger_, + "Device handle with mac " << device_id << " wasn't found."); } #ifdef EXTERNAL_PROPRIETARY_MODE @@ -1244,7 +1291,12 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( : VideoStreamingState::NOT_STREAMABLE; application_manager_.state_controller().SetRegularState( - app, mobile_apis::HMILevel::HMI_FULL, audio_state, video_state, true); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_FULL, + audio_state, + video_state, + true); last_activated_app_id_ = 0; } else { DeactivateApplication deactivate_notification( @@ -1280,7 +1332,8 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, permissions.isSDLAllowed = true; } } else { - permissions = policy_manager_->GetAppPermissionsChanges(policy_app_id); + permissions = policy_manager_->GetAppPermissionsChanges(app->mac_address(), + policy_app_id); #ifdef EXTERNAL_PROPRIETARY_MODE UsageStatistics& usage = app->usage_report(); @@ -1351,31 +1404,33 @@ void PolicyHandler::PTExchangeAtUserRequest(uint32_t correlation_id) { update_status, correlation_id, application_manager_); } -void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, +void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions, const HMILevel& default_hmi) { LOG4CXX_AUTO_TRACE(logger_); - OnPermissionsUpdated(policy_app_id, permissions); + OnPermissionsUpdated(device_id, policy_app_id, permissions); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN( logger_, - "Connection_key not found for application_id:" << policy_app_id); + "Connection_key not found for application_id: " << policy_app_id); return; } // The application currently not running (i.e. in NONE) should change HMI // level to default - mobile_apis::HMILevel::eType current_hmi_level = app->hmi_level(); + mobile_apis::HMILevel::eType current_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); mobile_apis::HMILevel::eType hmi_level = MessageHelper::StringToHMILevel(default_hmi); if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level) { - LOG4CXX_WARN(logger_, - "Couldn't convert default hmi level " << default_hmi - << " to enum."); + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << default_hmi << " to enum."); return; } if (current_hmi_level == hmi_level) { @@ -1391,10 +1446,16 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, if (hmi_level == mobile_apis::HMILevel::HMI_FULL) { application_manager_.state_controller().SetRegularState( - app, hmi_level, true); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + hmi_level, + true); } else { application_manager_.state_controller().SetRegularState( - app, hmi_level, false); + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + hmi_level, + false); } break; } @@ -1407,26 +1468,35 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, } } -void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, +void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, const Permissions& permissions) { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = - application_manager_.application_by_policy_id(policy_app_id); + application_manager_.application(device_id, policy_app_id); if (app.use_count() == 0) { LOG4CXX_WARN( logger_, - "Connection_key not found for application_id:" << policy_app_id); + "Connection_key not found for application_id: " << policy_app_id); return; } + const auto require_encryption = + policy_manager_->GetAppEncryptionRequired(policy_app_id); + MessageHelper::SendOnPermissionsChangeNotification( - app->app_id(), permissions, application_manager_); + app->app_id(), permissions, application_manager_, require_encryption); LOG4CXX_DEBUG(logger_, - "Notification sent for application_id:" + "Notification sent for application_id: " << policy_app_id << " and connection_key " << app->app_id()); } +#ifndef EXTERNAL_PROPRIETARY_MODE +void PolicyHandler::OnPTUTimeOut() { + application_manager_.protocol_handler().ProcessFailedPTU(); +} +#endif bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path) { @@ -1463,7 +1533,8 @@ void PolicyHandler::OnSnapshotCreated( } } #else // EXTERNAL_PROPRIETARY_MODE -void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { +void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string, + const PTUIterationType iteration_type) { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); #ifdef PROPRIETARY_MODE @@ -1472,10 +1543,22 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { LOG4CXX_ERROR(logger_, "Snapshot processing skipped."); return; } - MessageHelper::SendPolicyUpdate(policy_snapshot_full_path, - TimeoutExchangeSec(), - policy_manager_->RetrySequenceDelaysSeconds(), - application_manager_); + + if (PTUIterationType::RetryIteration == iteration_type) { + uint32_t app_id_for_sending = GetAppIdForSending(); + + if (0 != app_id_for_sending) { + MessageHelper::SendPolicySnapshotNotification( + app_id_for_sending, pt_string, std::string(), application_manager_); + } + + } else { + MessageHelper::SendPolicyUpdate( + policy_snapshot_full_path, + TimeoutExchangeSec(), + policy_manager_->RetrySequenceDelaysSeconds(), + application_manager_); + } #else // PROPRIETARY_MODE LOG4CXX_ERROR(logger_, "HTTP policy"); EndpointUrls urls; @@ -1506,12 +1589,13 @@ bool PolicyHandler::GetPriority(const std::string& policy_app_id, void PolicyHandler::CheckPermissions( const application_manager::ApplicationSharedPtr app, + const application_manager::WindowID window_id, const PTString& rpc, const RPCParams& rpc_params, CheckPermissionResult& result) { POLICY_LIB_CHECK_VOID(); const std::string hmi_level = - MessageHelper::StringifiedHMILevel(app->hmi_level()); + MessageHelper::StringifiedHMILevel(app->hmi_level(window_id)); if (hmi_level.empty()) { LOG4CXX_WARN(logger_, "HMI level for " << app->policy_app_id() << " is invalid, rpc " @@ -1525,13 +1609,8 @@ void PolicyHandler::CheckPermissions( "Checking permissions for " << app->policy_app_id() << " in " << hmi_level << " on device " << device_id << " rpc " << rpc); -#ifdef EXTERNAL_PROPRIETARY_MODE - policy_manager_->CheckPermissions( - app->policy_app_id(), hmi_level, rpc, rpc_params, result); -#else // EXTERNAL_PROPRIETARY_MODE policy_manager_->CheckPermissions( device_id, app->policy_app_id(), hmi_level, rpc, rpc_params, result); -#endif // EXTERNAL_PROPRIETARY_MODE } uint32_t PolicyHandler::GetNotificationsNumber( @@ -1546,10 +1625,15 @@ DeviceConsent PolicyHandler::GetUserConsentForDevice( return policy_manager_->GetUserConsentForDevice(device_id); } -bool PolicyHandler::GetDefaultHmi(const std::string& policy_app_id, +Json::Value PolicyHandler::GetPolicyTableData() const { + return policy_manager_->GetPolicyTableData(); +} + +bool PolicyHandler::GetDefaultHmi(const std::string& device_id, + const std::string& policy_app_id, std::string* default_hmi) const { POLICY_LIB_CHECK(false); - return policy_manager_->GetDefaultHmi(policy_app_id, default_hmi); + return policy_manager_->GetDefaultHmi(device_id, policy_app_id, default_hmi); } bool PolicyHandler::GetInitialAppData(const std::string& application_id, @@ -1598,7 +1682,13 @@ uint32_t PolicyHandler::TimeoutExchangeMSec() const { } void PolicyHandler::OnExceededTimeout() { + LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_VOID(); + + std::for_each(listeners_.begin(), + listeners_.end(), + std::mem_fn(&PolicyHandlerObserver::OnPTUTimeoutExceeded)); + policy_manager_->OnExceededTimeout(); } @@ -1607,6 +1697,19 @@ void PolicyHandler::OnSystemReady() { policy_manager_->OnSystemReady(); } +const boost::optional<bool> PolicyHandler::LockScreenDismissalEnabledState() + const { + POLICY_LIB_CHECK(boost::optional<bool>()); + return policy_manager_->LockScreenDismissalEnabledState(); +} + +const boost::optional<std::string> +PolicyHandler::LockScreenDismissalWarningMessage( + const std::string& language) const { + POLICY_LIB_CHECK(boost::optional<std::string>()); + return policy_manager_->LockScreenDismissalWarningMessage(language); +} + void PolicyHandler::PTUpdatedAt(Counters counter, int value) { POLICY_LIB_CHECK_VOID(); policy_manager_->PTUpdatedAt(counter, value); @@ -1673,7 +1776,7 @@ custom_str::CustomString PolicyHandler::GetAppName( if (app.use_count() == 0) { LOG4CXX_WARN( logger_, - "Connection_key not found for application_id:" << policy_app_id); + "Connection_key not found for application_id: " << policy_app_id); return custom_str::CustomString(""); } return app->name(); @@ -1703,9 +1806,9 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { const bool is_written = file_system::Write( file_name, std::vector<uint8_t>(certificate_data.begin(), certificate_data.end())); - LOG4CXX_DEBUG(logger_, - "Saving encrypted certificate data: \"" << certificate_data - << '"'); + LOG4CXX_DEBUG( + logger_, + "Saving encrypted certificate data: \"" << certificate_data << '"'); if (!is_written) { LOG4CXX_ERROR(logger_, "Unable to save encrypted certificate to file " << file_name); @@ -1743,6 +1846,7 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { if (!is_succeeded) { LOG4CXX_ERROR(logger_, "Couldn't delete file " << file_name); + ProcessCertDecryptFailed(); return; } @@ -1752,9 +1856,9 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { "Unable to read certificate from file " << file_name); return; } - LOG4CXX_DEBUG(logger_, - "Loaded decrypted certificate data: \"" << certificate_data - << '"'); + LOG4CXX_DEBUG( + logger_, + "Loaded decrypted certificate data: \"" << certificate_data << '"'); policy_manager_->SetDecryptedCertificate(certificate_data); @@ -1765,6 +1869,18 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated), certificate_data)); } + +void PolicyHandler::ProcessCertDecryptFailed() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(listeners_lock_); + + std::for_each( + listeners_.begin(), + listeners_.end(), + std::bind2nd(std::mem_fn(&PolicyHandlerObserver::OnCertDecryptFinished), + false)); +} + #else // EXTERNAL_PROPRIETARY_MODE void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { LOG4CXX_AUTO_TRACE(logger_); @@ -1910,24 +2026,24 @@ void PolicyHandler::OnSetCloudAppProperties( const smart_objects::SmartObject& message) { POLICY_LIB_CHECK_VOID(); if (!message.keyExists(strings::msg_params)) { - LOG4CXX_ERROR(logger_, - "Message does not contain mandatory section " - << strings::msg_params); + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory section " << strings::msg_params); return; } if (!message[strings::msg_params].keyExists(strings::properties)) { - LOG4CXX_ERROR(logger_, - "Message does not contain app properties " - << strings::msg_params); + LOG4CXX_ERROR( + logger_, + "Message does not contain app properties " << strings::msg_params); return; } const smart_objects::SmartObject& properties = message[strings::msg_params][strings::properties]; if (!properties.keyExists(strings::app_id)) { - LOG4CXX_ERROR(logger_, - "Message does not contain mandatory parameter " - << strings::app_id); + LOG4CXX_ERROR( + logger_, + "Message does not contain mandatory parameter " << strings::app_id); return; } std::string policy_app_id(properties[strings::app_id].asString()); @@ -2089,9 +2205,10 @@ void PolicyHandler::OnAppsSearchCompleted(const bool trigger_ptu) { policy_manager_->OnAppsSearchCompleted(trigger_ptu); } -void PolicyHandler::OnAppRegisteredOnMobile(const std::string& application_id) { +void PolicyHandler::OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) { POLICY_LIB_CHECK_VOID(); - policy_manager_->OnAppRegisteredOnMobile(application_id); + policy_manager_->OnAppRegisteredOnMobile(device_id, application_id); } RequestType::State PolicyHandler::GetAppRequestTypeState( @@ -2107,12 +2224,13 @@ RequestSubType::State PolicyHandler::GetAppRequestSubTypeState( } bool PolicyHandler::IsRequestTypeAllowed( + const transport_manager::DeviceHandle& device_id, const std::string& policy_app_id, mobile_apis::RequestType::eType type) const { POLICY_LIB_CHECK(false); using namespace mobile_apis; - std::string stringified_type = RequestTypeToString(type); + const std::string stringified_type = RequestTypeToString(type); if (stringified_type.empty()) { LOG4CXX_ERROR(logger_, "Unknown request type."); return false; @@ -2135,7 +2253,11 @@ bool PolicyHandler::IsRequestTypeAllowed( case RequestType::State::AVAILABLE: { // If any of request types is available for current application - get them const auto request_types = +#ifdef EXTERNAL_PROPRIETARY_MODE + policy_manager_->GetAppRequestTypes(device_id, policy_app_id); +#else policy_manager_->GetAppRequestTypes(policy_app_id); +#endif return helpers::in_range(request_types, stringified_type); } default: @@ -2181,9 +2303,14 @@ bool PolicyHandler::IsRequestSubTypeAllowed( } const std::vector<std::string> PolicyHandler::GetAppRequestTypes( + const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) const { POLICY_LIB_CHECK(std::vector<std::string>()); +#ifdef EXTERNAL_PROPRIETARY_MODE + return policy_manager_->GetAppRequestTypes(device_handle, policy_app_id); +#else return policy_manager_->GetAppRequestTypes(policy_app_id); +#endif } const std::vector<std::string> PolicyHandler::GetAppRequestSubTypes( @@ -2192,9 +2319,15 @@ const std::vector<std::string> PolicyHandler::GetAppRequestSubTypes( return policy_manager_->GetAppRequestSubTypes(policy_app_id); } -const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const { - POLICY_LIB_CHECK(VehicleInfo()); - return policy_manager_->GetVehicleInfo(); +const std::vector<policy_table::VehicleDataItem> +policy::PolicyHandler::GetVehicleDataItems() const { + POLICY_LIB_CHECK(std::vector<policy_table::VehicleDataItem>()); + return policy_manager_->GetVehicleDataItems(); +} + +std::vector<rpc::policy_table_interface_base::VehicleDataItem> +policy::PolicyHandler::GetRemovedVehicleDataItems() const { + return policy_manager_->GetRemovedVehicleDataItems(); } #ifdef EXTERNAL_PROPRIETARY_MODE @@ -2236,15 +2369,31 @@ bool PolicyHandler::IsUrlAppIdValid(const uint32_t app_idx, const ApplicationSharedPtr app = application_manager_.application_by_policy_id(app_data.app_id); - const bool is_registered = (app && (app->IsRegistered())); - const bool is_default = (app_data.app_id == policy::kDefaultId); - const bool is_empty_urls = app_urls.empty(); + if (policy::kDefaultId == app_data.app_id) { + return true; + } + + if (app_urls.empty()) { + return false; + } - return ((is_registered && !is_empty_urls) || is_default); + const auto devices_ids = GetDevicesIds(app_data.app_id); + LOG4CXX_TRACE(logger_, + "Count devices: " << devices_ids.size() + << " for app_id: " << app_data.app_id); + for (const auto& device_id : devices_ids) { + ApplicationSharedPtr app = + application_manager_.application(device_id, app_data.app_id); + if (app && (app->IsRegistered())) { + return true; + } + } + + return false; } std::vector<std::string> PolicyHandler::GetDevicesIds( - const std::string& policy_app_id) { + const std::string& policy_app_id) const { return application_manager_.devices(policy_app_id); } @@ -2252,7 +2401,8 @@ 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 (app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW) == + 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) { @@ -2264,7 +2414,10 @@ void PolicyHandler::UpdateHMILevel(ApplicationSharedPtr app, // 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_); + MessageHelper::SendHMIStatusNotification( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + application_manager_); } } } @@ -2288,17 +2441,17 @@ void PolicyHandler::OnUpdateHMIStatus(const std::string& device_id, ApplicationSharedPtr app = application_manager_.application(device_id, policy_app_id); if (!app) { - LOG4CXX_WARN(logger_, - "Could not find application: " << device_id << " - " - << policy_app_id); + 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."); + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << hmi_level << " to enum."); return; } @@ -2307,7 +2460,10 @@ void PolicyHandler::OnUpdateHMIStatus(const std::string& device_id, << app->app_id() << " to default hmi level " << level); // Set application hmi level application_manager_.ChangeAppsHMILevel(app->app_id(), level); - MessageHelper::SendHMIStatusNotification(*app, application_manager_); + MessageHelper::SendHMIStatusNotification( + app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + application_manager_); } bool PolicyHandler::GetModuleTypes(const std::string& policy_app_id, @@ -2318,6 +2474,7 @@ bool PolicyHandler::GetModuleTypes(const std::string& policy_app_id, } void PolicyHandler::SetDefaultHmiTypes( + const transport_manager::DeviceHandle& device_handle, const std::string& application_id, const smart_objects::SmartObject* app_types) { LOG4CXX_AUTO_TRACE(logger_); @@ -2330,7 +2487,7 @@ void PolicyHandler::SetDefaultHmiTypes( std::back_inserter(hmi_types), SmartObjectToInt()); } - policy_manager_->SetDefaultHmiTypes(application_id, hmi_types); + policy_manager_->SetDefaultHmiTypes(device_handle, application_id, hmi_types); } bool PolicyHandler::CheckHMIType(const std::string& application_id, @@ -2361,17 +2518,17 @@ void PolicyHandler::OnUpdateHMILevel(const std::string& device_id, ApplicationSharedPtr app = application_manager_.application(device_id, policy_app_id); if (!app) { - LOG4CXX_WARN(logger_, - "Could not find application: " << device_id << " - " - << policy_app_id); + 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."); + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << hmi_level << " to enum."); return; } UpdateHMILevel(app, level); diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 315cf6fdf8..eaebaf4861 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -32,9 +32,9 @@ #include "utils/logger.h" -#include "application_manager/request_controller.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/request_to_hmi.h" +#include "application_manager/request_controller.h" #include "utils/timer_task_impl.h" @@ -126,6 +126,12 @@ RequestController::TResult RequestController::CheckPosibilitytoAdd( return RequestController::TOO_MANY_REQUESTS; } + if (IsLowVoltage()) { + LOG4CXX_ERROR(logger_, + "Impossible to add request due to Low Voltage is active"); + return RequestController::INVALID_DATA; + } + return SUCCESS; } @@ -192,6 +198,13 @@ RequestController::TResult RequestController::addHMIRequest( "Default timeout was set to 0." "RequestController will not track timeout of this request."); } + + if (IsLowVoltage()) { + LOG4CXX_ERROR(logger_, + "Impossible to add request due to Low Voltage is active"); + return RequestController::INVALID_DATA; + } + waiting_for_response_.Add(request_info_ptr); LOG4CXX_DEBUG(logger_, "Waiting for response count:" << waiting_for_response_.Size()); @@ -202,6 +215,11 @@ RequestController::TResult RequestController::addHMIRequest( void RequestController::addNotification(const RequestPtr ptr) { LOG4CXX_AUTO_TRACE(logger_); + if (IsLowVoltage()) { + LOG4CXX_ERROR( + logger_, "Impossible to add notification due to Low Voltage is active"); + return; + } notification_list_.push_back(ptr); } @@ -274,7 +292,7 @@ void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id, void RequestController::OnHMIResponse(const uint32_t correlation_id, const int32_t function_id) { LOG4CXX_AUTO_TRACE(logger_); - TerminateRequest(correlation_id, RequestInfo::HmiConnectoinKey, function_id); + TerminateRequest(correlation_id, RequestInfo::HmiConnectionKey, function_id); } void RequestController::terminateWaitingForExecutionAppRequests( @@ -321,7 +339,7 @@ void RequestController::terminateAppRequests(const uint32_t& app_id) { void RequestController::terminateAllHMIRequests() { LOG4CXX_AUTO_TRACE(logger_); - terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectoinKey); + terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectionKey); } void RequestController::terminateAllMobileRequests() { @@ -430,7 +448,7 @@ void RequestController::TimeoutThread() { const uint32_t experied_app_id = probably_expired->app_id(); probably_expired->request()->onTimeOut(); - if (RequestInfo::HmiConnectoinKey == probably_expired->app_id()) { + if (RequestInfo::HmiConnectionKey == probably_expired->app_id()) { LOG4CXX_DEBUG(logger_, "Erase HMI request: " << probably_expired->requestId()); waiting_for_response_.RemoveRequest(probably_expired); diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index bbcda06b43..4f1e0a8f07 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -42,12 +42,12 @@ namespace request_controller { CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController") -uint32_t RequestInfo::HmiConnectoinKey = 0; +uint32_t RequestInfo::HmiConnectionKey = 0; HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectoinKey; + app_id_ = RequestInfo::HmiConnectionKey; } HMIRequestInfo::HMIRequestInfo(RequestPtr request, @@ -55,7 +55,7 @@ HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, start_time, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectoinKey; + app_id_ = RequestInfo::HmiConnectionKey; } MobileRequestInfo::MobileRequestInfo(RequestPtr request, @@ -252,7 +252,7 @@ uint32_t RequestInfoSet::RemoveByConnectionKey(uint32_t connection_key) { uint32_t RequestInfoSet::RemoveMobileRequests() { LOG4CXX_AUTO_TRACE(logger_); return RemoveRequests(AppIdCompararator(AppIdCompararator::NotEqual, - RequestInfo::HmiConnectoinKey)); + RequestInfo::HmiConnectionKey)); } const size_t RequestInfoSet::Size() { diff --git a/src/components/application_manager/src/request_tracker.cc b/src/components/application_manager/src/request_tracker.cc index c047c82579..052667dc3f 100644 --- a/src/components/application_manager/src/request_tracker.cc +++ b/src/components/application_manager/src/request_tracker.cc @@ -30,10 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "utils/logger.h" -#include "utils/macro.h" #include "application_manager/request_tracker.h" #include "application_manager/message_helper.h" +#include "utils/logger.h" +#include "utils/macro.h" namespace application_manager { 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 6af8826491..0e1840e867 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -30,24 +30,25 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "application_manager/resumption/resume_ctrl_impl.h" +#include "application_manager/display_capabilities_builder.h" -#include <fstream> #include <algorithm> +#include <fstream> #include "application_manager/application_manager.h" #include "application_manager/rpc_service.h" -#include "utils/file_system.h" -#include "connection_handler/connection_handler_impl.h" -#include "application_manager/message_helper.h" -#include "connection_handler/connection.h" #include "application_manager/commands/command_impl.h" -#include "policy/policy_manager_impl.h" +#include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" -#include "utils/helpers.h" #include "application_manager/resumption/resumption_data_db.h" #include "application_manager/resumption/resumption_data_json.h" +#include "application_manager/state_controller.h" +#include "connection_handler/connection.h" +#include "connection_handler/connection_handler_impl.h" +#include "policy/policy_manager_impl.h" +#include "utils/file_system.h" +#include "utils/helpers.h" #include "utils/timer_task_impl.h" @@ -152,14 +153,20 @@ void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) { LOG4CXX_DEBUG(logger_, "Low Voltage state is active"); return; } - LOG4CXX_DEBUG(logger_, - "application with appID " << application->app_id() - << " will be saved"); + LOG4CXX_DEBUG( + logger_, + "application with appID " << application->app_id() << " will be saved"); resumption_storage_->SaveApplication(application); } void ResumeCtrlImpl::on_event(const event_engine::Event& event) { - LOG4CXX_DEBUG(logger_, "Event received" << event.id()); + LOG4CXX_DEBUG(logger_, "Event received: " << event.id()); + + if (hmi_apis::FunctionID::UI_CreateWindow == event.id()) { + LOG4CXX_INFO(logger_, "Received UI_CreateWindow event"); + const auto& response_message = event.smart_object(); + RestoreWidgetsHMIState(response_message); + } } bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { @@ -208,7 +215,12 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { << saved_hmi_level); } - return SetAppHMIState(application, saved_hmi_level, true); + const bool app_hmi_state_is_set = + SetAppHMIState(application, saved_hmi_level, true); + if (app_hmi_state_is_set && + application->is_app_data_resumption_allowed()) { + RestoreAppWidgets(application, saved_app); + } } else { result = false; LOG4CXX_ERROR(logger_, "saved app data corrupted"); @@ -219,6 +231,89 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { return result; } +void ResumeCtrlImpl::RestoreWidgetsHMIState( + const smart_objects::SmartObject& response_message) { + LOG4CXX_AUTO_TRACE(logger_); + const auto correlation_id = + response_message[strings::params][strings::correlation_id].asInt(); + const auto& request = requests_msg_.find(correlation_id); + if (requests_msg_.end() == request) { + LOG4CXX_ERROR(logger_, + "Request UI_CreateWindow for correlation id: " + << correlation_id << " not found"); + return; + } + + const auto& msg_params = (*request->second)[strings::msg_params]; + const auto hmi_app_id = msg_params[strings::app_id].asInt(); + auto application = application_manager_.application_by_hmi_app(hmi_app_id); + if (!application) { + LOG4CXX_ERROR(logger_, + "Application is not registered by hmi id: " << hmi_app_id); + requests_msg_.erase(request); + return; + } + const WindowID window_id = msg_params[strings::window_id].asInt(); + + const auto result_code = static_cast<hmi_apis::Common_Result::eType>( + response_message[strings::params][hmi_response::code].asInt()); + if (hmi_apis::Common_Result::SUCCESS != result_code) { + LOG4CXX_ERROR(logger_, + "UI_CreateWindow for correlation id: " + << correlation_id + << " failed with code: " << result_code); + requests_msg_.erase(request); + auto& builder = application->display_capabilities_builder(); + builder.StopWaitingForWindow(window_id); + return; + } + + smart_objects::SmartObject window_info(smart_objects::SmartType_Map); + auto fill_optional_param = [&window_info, + &msg_params](const std::string& key) { + if (msg_params.keyExists(key)) { + window_info[key] = msg_params[key].asString(); + } + }; + fill_optional_param(strings::associated_service_type); + fill_optional_param(strings::duplicate_updates_from_window_id); + + const auto window_name = msg_params[strings::window_name].asString(); + window_info[strings::window_name] = window_name; + application->SetWindowInfo(window_id, window_info); + + const auto window_type = static_cast<mobile_apis::WindowType::eType>( + msg_params[strings::window_type].asInt()); + // State should be initialized with INVALID_ENUM value to let state controller + // trigger OnHmiStatus notifiation sending + auto initial_state = application_manager_.CreateRegularState( + application, + window_type, + mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_api::SystemContext::INVALID_ENUM); + application->SetInitialState(window_id, window_name, initial_state); + + // Default HMI level for all windows except the main one is always NONE + application_manager_.state_controller().OnAppWindowAdded( + application, window_id, window_type, mobile_apis::HMILevel::HMI_NONE); + + requests_msg_.erase(request); +} + +void ResumeCtrlImpl::ProcessSystemCapabilityUpdated( + Application& app, const smart_objects::SmartObject& display_capabilities) { + LOG4CXX_AUTO_TRACE(logger_); + + auto notification = MessageHelper::CreateDisplayCapabilityUpdateToMobile( + display_capabilities, app); + + application_manager_.GetRPCService().ManageMobileCommand( + notification, commands::Command::SOURCE_SDL); + app.set_is_resuming(false); +} + bool ResumeCtrlImpl::SetupDefaultHMILevel(ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN(application, false); @@ -252,7 +347,9 @@ void ResumeCtrlImpl::ApplicationResumptiOnTimer() { LOG4CXX_ERROR(logger_, "Invalid app_id = " << *it); continue; } - StartAppHmiStateResumption(app); + if (!StartAppHmiStateResumption(app)) { + app->set_is_resuming(false); + } } is_resumption_active_ = false; waiting_for_timer_.clear(); @@ -262,6 +359,7 @@ void ResumeCtrlImpl::ApplicationResumptiOnTimer() { void ResumeCtrlImpl::OnAppActivated(ApplicationSharedPtr application) { if (is_resumption_active_) { RemoveFromResumption(application->app_id()); + application->set_is_resuming(false); } } @@ -291,15 +389,38 @@ bool ResumeCtrlImpl::SetAppHMIState( SetupDefaultHMILevel(application); return false; } - application->set_is_resuming(true); - application_manager_.state_controller().SetRegularState(application, - hmi_level); + + application_manager_.state_controller().SetRegularState( + application, mobile_apis::PredefinedWindows::DEFAULT_WINDOW, hmi_level); LOG4CXX_INFO(logger_, "Application with policy id " << application->policy_app_id() << " got HMI level " << hmi_level); + return true; } +void ResumeCtrlImpl::RestoreAppWidgets( + application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) { + using namespace mobile_apis; + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(application); + if (!saved_app.keyExists(strings::windows_info)) { + LOG4CXX_ERROR(logger_, "windows_info section does not exist"); + return; + } + const auto& windows_info = saved_app[strings::windows_info]; + auto request_list = MessageHelper::CreateUICreateWindowRequestsToHMI( + application, application_manager_, windows_info); + + requests_msg_.clear(); + for (auto& request : request_list) { + requests_msg_.insert(std::make_pair( + (*request)[strings::params][strings::correlation_id].asInt(), request)); + } + ProcessHMIRequests(request_list); +} + bool ResumeCtrlImpl::IsHMIApplicationIdExist(uint32_t hmi_app_id) { LOG4CXX_DEBUG(logger_, "hmi_app_id :" << hmi_app_id); return resumption_storage_->IsHMIApplicationIdExist(hmi_app_id); @@ -399,6 +520,8 @@ bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application, << " hmi_app_id = " << application->hmi_app_id() << " policy_id = " << application->policy_app_id() << " received hash = " << hash); + application->set_is_resuming(true); + if (!application->is_cloud_app()) { // Default HMI Level is already set before resumption in // ApplicationManager::OnApplicationRegistered, and handling low bandwidth @@ -421,17 +544,18 @@ bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application, bool ResumeCtrlImpl::StartResumptionOnlyHMILevel( ApplicationSharedPtr application) { - // sync_primitives::AutoLock lock(resumtion_lock_); LOG4CXX_AUTO_TRACE(logger_); if (!application) { LOG4CXX_WARN(logger_, "Application does not exist."); return false; } + + application->set_is_resuming(true); LOG4CXX_DEBUG(logger_, - "HMI level resumption requested for application id " - << application->app_id() << "with hmi_app_id " - << application->hmi_app_id() << ", policy_app_id " - << application->policy_app_id()); + "HMI level resumption requested for application id: " + << application->app_id() + << " with hmi_app_id: " << application->hmi_app_id() + << ", policy_app_id " << application->policy_app_id()); if (!application->is_cloud_app()) { // Default HMI Level is already set before resumption in // ApplicationManager::OnApplicationRegistered, and handling low bandwidth @@ -444,7 +568,6 @@ bool ResumeCtrlImpl::StartResumptionOnlyHMILevel( bool result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); if (result) { - // sync_primitives::AutoUnlock unlock(lock); AddToResumptionTimerQueue(application->app_id()); } LOG4CXX_INFO(logger_, "StartResumptionOnlyHMILevel::Result = " << result); @@ -473,18 +596,18 @@ void ResumeCtrlImpl::RetryResumption(const uint32_t app_id) { AddToResumptionTimerQueue(app_id); } -void ResumeCtrlImpl::StartAppHmiStateResumption( +bool ResumeCtrlImpl::StartAppHmiStateResumption( ApplicationSharedPtr application) { using namespace date_time; LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN_VOID(application); + DCHECK_OR_RETURN(application, false); smart_objects::SmartObject saved_app; const std::string& device_mac = application->mac_address(); - const bool result = resumption_storage_->GetSavedApplication( + const bool get_saved_app_result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - if (!result) { + if (!get_saved_app_result) { LOG4CXX_ERROR(logger_, "Application was not saved"); - return; + return false; } const bool is_hmi_level_applicable_to_resume = @@ -492,7 +615,7 @@ void ResumeCtrlImpl::StartAppHmiStateResumption( if (!is_hmi_level_applicable_to_resume) { LOG4CXX_DEBUG(logger_, "No applicable HMI level found for resuming"); - return; + return false; } const bool is_resume_allowed_by_low_voltage = @@ -507,18 +630,20 @@ void ResumeCtrlImpl::StartAppHmiStateResumption( if (restore_hmi_level_allowed) { LOG4CXX_INFO(logger_, "Resume application " << application->policy_app_id()); - RestoreAppHMIState(application); + const bool hmi_state_restore_result = RestoreAppHMIState(application); if (mobile_apis::HMILevel::eType::INVALID_ENUM != application->deferred_resumption_hmi_level()) { // the application has not been fully resumed - return; + return false; } RemoveApplicationFromSaved(application); + return hmi_state_restore_result; } else { - LOG4CXX_INFO(logger_, - "Do not need to resume application " - << application->policy_app_id()); + LOG4CXX_INFO( + logger_, + "Do not need to resume application " << application->policy_app_id()); } + return true; } void ResumeCtrlImpl::ResetLaunchTime() { @@ -561,9 +686,14 @@ bool ResumeCtrlImpl::CheckApplicationHash(ApplicationSharedPtr application, "app_id : " << application->app_id() << " hash : " << hash); smart_objects::SmartObject saved_app; const std::string& device_mac = application->mac_address(); - bool result = resumption_storage_->GetSavedApplication( + const bool get_app_result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); - return result ? saved_app[strings::hash_id].asString() == hash : false; + const bool check_result = + get_app_result ? saved_app[strings::hash_id].asString() == hash : false; + if (check_result) { + application->set_app_data_resumption_allowance(true); + } + return check_result; } void ResumeCtrlImpl::SaveDataOnTimer() { @@ -628,6 +758,27 @@ bool ResumeCtrlImpl::RestoreApplicationData(ApplicationSharedPtr application) { return result; } +void ResumeCtrlImpl::StartWaitingForDisplayCapabilitiesUpdate( + app_mngr::ApplicationSharedPtr application) { + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject saved_app(smart_objects::SmartType_Map); + resumption_storage_->GetSavedApplication( + application->policy_app_id(), application->mac_address(), saved_app); + auto resume_callback = + [this](Application& app, + const smart_objects::SmartObject& display_capabilities) -> void { + LOG4CXX_AUTO_TRACE(logger_); + ProcessSystemCapabilityUpdated(app, display_capabilities); + }; + auto& builder = application->display_capabilities_builder(); + + smart_objects::SmartObject windows_info(smart_objects::SmartType_Null); + if (saved_app.keyExists(strings::windows_info)) { + windows_info = saved_app[strings::windows_info]; + } + builder.InitBuilder(resume_callback, windows_info); +} + void ResumeCtrlImpl::AddFiles(ApplicationSharedPtr application, const smart_objects::SmartObject& saved_app) { LOG4CXX_AUTO_TRACE(logger_); @@ -1006,7 +1157,8 @@ bool ResumeCtrlImpl::ProcessHMIRequest(smart_objects::SmartObjectSPtr request, (*request)[strings::correlation_id].asInt(); subscribe_on_event(function_id, hmi_correlation_id); } - if (!application_manager_.GetRPCService().ManageHMICommand(request)) { + if (!application_manager_.GetRPCService().ManageHMICommand( + request, commands::Command::SOURCE_SDL_TO_HMI)) { LOG4CXX_ERROR(logger_, "Unable to send request"); return false; } @@ -1035,8 +1187,9 @@ void ResumeCtrlImpl::AddToResumptionTimerQueue(const uint32_t app_id) { } queue_lock_.Release(); LOG4CXX_DEBUG(logger_, - "Application ID " << app_id << " have been added" - " to resumption queue."); + "Application ID " << app_id + << " have been added" + " to resumption queue."); if (run_resumption) { LOG4CXX_DEBUG(logger_, "Application ID " << app_id << " will be restored by timer"); @@ -1197,4 +1350,4 @@ static mobile_api::HMILevel::eType ConvertHmiLevelString( } } -} // namespce resumption +} // namespace resumption diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 856fb03750..9046fe35ad 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -31,9 +31,9 @@ */ #include "application_manager/resumption/resumption_data.h" -#include "utils/logger.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application_manager_settings.h" +#include "application_manager/smart_object_keys.h" +#include "utils/logger.h" namespace resumption { @@ -198,6 +198,52 @@ smart_objects::SmartObject ResumptionData::GetApplicationFiles( return files; } +smart_objects::SmartObject ResumptionData::GetApplicationWidgetsInfo( + app_mngr::ApplicationConstSharedPtr application) const { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + smart_objects::SmartObject windows_info = + smart_objects::SmartObject(smart_objects::SmartType_Array); + DCHECK_OR_RETURN(application, windows_info); + const auto window_ids = application->GetWindowIds(); + const auto& window_optional_params_map = + application->window_optional_params_map().GetData(); + for (const auto& window_id : window_ids) { + const HmiStatePtr hmi_state = application->CurrentHmiState(window_id); + if (mobile_apis::WindowType::WIDGET != hmi_state->window_type()) { + continue; + } + auto info = CreateWindowInfoSO( + window_id, hmi_state->window_type(), window_optional_params_map); + + windows_info[windows_info.length()] = info; + } + return windows_info; +} + +smart_objects::SmartObject ResumptionData::CreateWindowInfoSO( + const app_mngr::WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const app_mngr::WindowParamsMap& window_optional_params_map) const { + using namespace app_mngr; + LOG4CXX_AUTO_TRACE(logger_); + auto window_info = smart_objects::SmartObject(smart_objects::SmartType_Map); + + window_info[strings::window_id] = window_id; + window_info[strings::window_type] = window_type; + + const auto& it_info = window_optional_params_map.find(window_id); + if (window_optional_params_map.end() != it_info) { + const auto keys = it_info->second->enumerate(); + + for (const auto& key : keys) { + window_info[key] = (*it_info->second)[key]; + } + } + + return window_info; +} + smart_objects::SmartObject ResumptionData::PointerToSmartObj( const smart_objects::SmartObject* ptr) const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 1591ce566a..9188a47bf9 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -29,18 +29,18 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <unistd.h> +#include <string> #include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager_settings.h" +#include "application_manager/message_helper.h" #include "application_manager/resumption/resumption_data_db.h" #include "application_manager/resumption/resumption_sql_queries.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/message_helper.h" -#include "utils/helpers.h" #include "utils/gen_hash.h" +#include "utils/helpers.h" #include "utils/scope_guard.h" -#include "application_manager/application_manager_settings.h" namespace { const std::string kDatabaseName = "resumption"; @@ -2731,7 +2731,8 @@ bool ResumptionDataDB::UpdateApplicationData( utils::dbms::SQLQuery query(db()); const int64_t time_stamp = static_cast<int64_t>(time(NULL)); - const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); + const mobile_apis::HMILevel::eType hmi_level = + application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); if (!query.Prepare(kUpdateApplicationData)) { LOG4CXX_WARN(logger_, @@ -2843,7 +2844,8 @@ ApplicationParams::ApplicationParams(app_mngr::ApplicationSharedPtr application) m_grammar_id = application->get_grammar_id(); m_connection_key = application->app_id(); m_hmi_app_id = application->hmi_app_id(); - m_hmi_level = application->hmi_level(); + m_hmi_level = + application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); m_is_media_application = application->IsAudioApplication(); app_ptr = application; } diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 584fb4e697..5da47d31ce 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -30,14 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/application_manager.h" #include "application_manager/resumption/resumption_data_json.h" -#include "smart_objects/smart_object.h" -#include "json/json.h" -#include "formatters/CFormatterJsonBase.h" +#include "application_manager/application_manager.h" +#include "application_manager/application_manager_settings.h" #include "application_manager/message_helper.h" #include "application_manager/smart_object_keys.h" -#include "application_manager/application_manager_settings.h" +#include "formatters/CFormatterJsonBase.h" +#include "json/json.h" +#include "smart_objects/smart_object.h" namespace resumption { @@ -64,7 +64,8 @@ void ResumptionDataJson::SaveApplication( const uint32_t grammar_id = application->get_grammar_id(); const uint32_t time_stamp = (uint32_t)time(NULL); const std::string device_mac = application->mac_address(); - const mobile_apis::HMILevel::eType hmi_level = application->hmi_level(); + const mobile_apis::HMILevel::eType hmi_level = + application->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); const bool is_subscribed_for_way_points = application_manager_.IsAppSubscribedForWayPoints(application); @@ -99,6 +100,9 @@ void ResumptionDataJson::SaveApplication( formatters::CFormatterJsonBase::objToJsonValue( GetApplicationFiles(application), tmp); json_app[strings::application_files] = tmp; + formatters::CFormatterJsonBase::objToJsonValue( + GetApplicationWidgetsInfo(application), tmp); + json_app[strings::windows_info] = tmp; json_app[strings::time_stamp] = time_stamp; json_app[strings::subscribed_for_way_points] = is_subscribed_for_way_points; @@ -531,4 +535,4 @@ void ResumptionDataJson::Persist() { last_state().SaveStateToFileSystem(); } -} // resumption +} // namespace resumption diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 28b3779dad..695d94628d 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -43,12 +43,14 @@ namespace formatters = ns_smart_device_link::ns_json_handler::formatters; namespace jhs = ns_smart_device_link::ns_json_handler::strings; namespace plugin_names = application_manager::plugin_manager::plugin_names; -RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager) +RPCHandlerImpl::RPCHandlerImpl(ApplicationManager& app_manager, + hmi_apis::HMI_API& hmi_so_factory, + mobile_apis::MOBILE_API& mobile_so_factory) : app_manager_(app_manager) , messages_from_mobile_("AM FromMobile", this) , messages_from_hmi_("AM FromHMI", this) - , hmi_so_factory_(hmi_apis::HMI_API()) - , mobile_so_factory_(mobile_apis::MOBILE_API()) + , hmi_so_factory_(hmi_so_factory) + , mobile_so_factory_(mobile_so_factory) #ifdef TELEMETRY_MONITOR , metric_observer_(NULL) #endif // TELEMETRY_MONITOR @@ -159,23 +161,19 @@ void RPCHandlerImpl::ProcessMessageFromHMI( smart_objects::SmartObjectSPtr smart_object = std::make_shared<smart_objects::SmartObject>(); bool allow_unknown_parameters = false; - if (!smart_object) { - LOG4CXX_ERROR(logger_, "Null pointer"); - return; - } smart_objects::SmartObject converted_result; formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>( message->json_message(), converted_result); + const auto function_id = static_cast<int32_t>( + converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); if (app_manager_.GetRPCService().IsAppServiceRPC( - converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt(), - commands::Command::SOURCE_HMI)) { + function_id, commands::Command::SOURCE_HMI)) { LOG4CXX_DEBUG( logger_, - "Allowing unknown parameters for request function " - << converted_result[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + "Allowing unknown parameters for request function " << function_id); allow_unknown_parameters = true; } @@ -198,6 +196,7 @@ void RPCHandlerImpl::ProcessMessageFromHMI( LOG4CXX_ERROR(logger_, "Received command didn't run successfully"); } } + void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) { LOG4CXX_AUTO_TRACE(logger_); @@ -209,6 +208,10 @@ void RPCHandlerImpl::Handle(const impl::MessageFromMobile message) { LOG4CXX_INFO(logger_, "Application manager is stopping"); return; } + if (app_manager_.IsLowVoltage()) { + LOG4CXX_ERROR(logger_, "Low Voltage is active."); + return; + } ProcessMessageFromMobile(message); } @@ -220,6 +223,11 @@ void RPCHandlerImpl::Handle(const impl::MessageFromHmi message) { LOG4CXX_ERROR(logger_, "Null-pointer message received."); return; } + if (app_manager_.IsLowVoltage()) { + LOG4CXX_ERROR(logger_, "Low Voltage is active."); + return; + } + ProcessMessageFromHMI(message); } @@ -227,6 +235,11 @@ void RPCHandlerImpl::OnMessageReceived( const protocol_handler::RawMessagePtr message) { LOG4CXX_AUTO_TRACE(logger_); + if (app_manager_.IsLowVoltage()) { + LOG4CXX_ERROR(logger_, "Low Voltage is active."); + return; + } + if (!message) { LOG4CXX_ERROR(logger_, "Null-pointer message received."); NOTREACHED(); @@ -415,11 +428,12 @@ bool RPCHandlerImpl::ConvertMessageToSO( utils::SemanticVersion empty_version; if (validate_params && - output.validate(&report, empty_version, allow_unknown_parameters) != - smart_objects::errors::OK) { - LOG4CXX_ERROR(logger_, - "Incorrect parameter from HMI - " - << rpc::PrettyFormat(report)); + smart_objects::errors::OK != + output.validate( + &report, empty_version, allow_unknown_parameters)) { + LOG4CXX_ERROR( + logger_, + "Incorrect parameter from HMI - " << rpc::PrettyFormat(report)); output.erase(strings::msg_params); output[strings::params][hmi_response::code] = @@ -472,6 +486,7 @@ bool RPCHandlerImpl::ConvertMessageToSO( << message.protocol_version() << "."); return false; } + output[strings::params][strings::protection] = message.is_message_encrypted(); LOG4CXX_DEBUG(logger_, "Successfully parsed message into smart object"); return true; @@ -513,6 +528,7 @@ std::shared_ptr<Message> RPCHandlerImpl::ConvertRawMsgToMessage( } else { LOG4CXX_ERROR(logger_, "Received invalid message"); } + return outgoing_message; } @@ -523,5 +539,5 @@ hmi_apis::HMI_API& RPCHandlerImpl::hmi_so_factory() { mobile_apis::MOBILE_API& RPCHandlerImpl::mobile_so_factory() { return mobile_so_factory_; } -} -} +} // namespace rpc_handler +} // namespace application_manager diff --git a/src/components/application_manager/src/rpc_passing_handler.cc b/src/components/application_manager/src/rpc_passing_handler.cc index 32eda4b9e8..7f72632bb1 100644 --- a/src/components/application_manager/src/rpc_passing_handler.cc +++ b/src/components/application_manager/src/rpc_passing_handler.cc @@ -40,6 +40,7 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/rpc_handler.h" #include "application_manager/rpc_passing_handler.h" #include "application_manager/smart_object_keys.h" @@ -108,9 +109,11 @@ bool RPCPassingHandler::ExtractRPCParams( } CommandParametersPermissions parameters_permissions; + const WindowID window_id = + MessageHelper::ExtractWindowIdFromSmartObject(s_map); mobile_apis::Result::eType check_result = app_manager_.CheckPolicyPermissions( - app, function_id_str, params, ¶meters_permissions); + app, window_id, function_id_str, params, ¶meters_permissions); // Check if RPC is allowed by policy (since we are allowing unknown params, // check should pass if only undefined parameters exist) @@ -141,7 +144,7 @@ bool RPCPassingHandler::IsPassthroughAllowed( rpc_message[strings::params][strings::function_id].asInt()); std::string function_id_str = MessageHelper::StringifiedFunctionID(function_id); - PolicyHandlerInterface& policy_handler = app_manager_.GetPolicyHandler(); + auto& policy_handler = app_manager_.GetPolicyHandler(); if (function_id_str.empty()) { // Unknown RPC, just do basic revoked and user consent checks @@ -397,9 +400,9 @@ void RPCPassingHandler::ClearCompletedTimers() { for (auto it = timeout_queue_.begin(); it != timeout_queue_.end();) { TimerSPtr timer = it->first; if (timer->is_completed()) { - LOG4CXX_DEBUG(logger_, - "Removing completed timer for correlation id " - << it->second); + LOG4CXX_DEBUG( + logger_, + "Removing completed timer for correlation id " << it->second); it = timeout_queue_.erase(it); } else { ++it; @@ -415,9 +418,9 @@ void RPCPassingHandler::AddRequestTimer(uint32_t correlation_id) { const uint32_t timeout_ms = app_manager_.get_settings().rpc_pass_through_timeout(); rpc_passing_timer->Start(timeout_ms, timer::kSingleShot); - LOG4CXX_DEBUG(logger_, - "Adding and starting timer for correlation id " - << correlation_id); + LOG4CXX_DEBUG( + logger_, + "Adding and starting timer for correlation id " << correlation_id); sync_primitives::AutoLock lock(timeout_queue_lock_); timeout_queue_.push_back(std::make_pair(rpc_passing_timer, correlation_id)); } diff --git a/src/components/application_manager/src/rpc_protection_manager_impl.cc b/src/components/application_manager/src/rpc_protection_manager_impl.cc new file mode 100644 index 0000000000..4afceb9e5b --- /dev/null +++ b/src/components/application_manager/src/rpc_protection_manager_impl.cc @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/rpc_protection_manager_impl.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + +CREATE_LOGGERPTR_LOCAL(logger_, "RPCProtectionManagerImpl"); + +namespace application_manager { + +namespace rpc_encryption_exceptions { +std::vector<std::string> kExceptionRPCs = {"RegisterAppInterface", + "SystemRequest", + "OnPermissionsChange", + "OnSystemRequest", + "PutFile", + "OnHMIStatus"}; +} + +RPCProtectionManagerImpl::RPCProtectionManagerImpl( + policy::PolicyHandlerInterface& policy_handler) + : policy_handler_(policy_handler) { + LOG4CXX_AUTO_TRACE(logger_); +} + +bool RPCProtectionManagerImpl::CheckPolicyEncryptionFlag( + const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto& policy_encryption_flag_getter = + policy_handler_.PolicyEncryptionFlagGetter(); + if (!policy_encryption_flag_getter) { + LOG4CXX_ERROR(logger_, "Policy Encryption Flag getter is not inited"); + return false; + } + const std::string function_name = + policy_encryption_flag_getter->GetPolicyFunctionName(function_id); + LOG4CXX_DEBUG(logger_, "Function for check is " << function_name); + + if (!is_rpc_service_secure && IsExceptionRPC(function_id)) { + LOG4CXX_WARN(logger_, + "Exception RPC can be sent in an non secure service despite " + "encryption required flag"); + return false; + } + + if (!app) { + LOG4CXX_WARN(logger_, "Received app nullptr"); + return false; + } + + const auto policy_app_id = app->policy_app_id(); + + return IsEncryptionRequiredByPolicy(policy_app_id, function_name); +} + +bool RPCProtectionManagerImpl::IsEncryptionRequiredByPolicy( + const std::string& policy_app_id, const std::string& function_name) const { + LOG4CXX_AUTO_TRACE(logger_); + + auto it = encrypted_rpcs_.find(policy_app_id); + + if (encrypted_rpcs_.end() == it) { + LOG4CXX_WARN( + logger_, + "App specific policies for app: " << policy_app_id << " not found"); + it = encrypted_rpcs_.find(policy_table::kDefaultApp); + return encrypted_rpcs_.end() != it + ? (*it).second.find(function_name) != (*it).second.end() + : false; + } + + return (*it).second.find(function_name) != (*it).second.end(); +} + +bool RPCProtectionManagerImpl::IsInEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) const { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, "correlation_id is " << correlation_id); + + return encryption_needed_cache_.find(std::make_pair( + app_id, correlation_id)) != encryption_needed_cache_.end(); +} + +bool RPCProtectionManagerImpl::IsExceptionRPC( + const uint32_t function_id) const { + using namespace rpc_encryption_exceptions; + const std::string policy_fucntion_id = policy_table::EnumToJsonString( + static_cast<policy_table::FunctionID>(function_id)); + return helpers::in_range(kExceptionRPCs, policy_fucntion_id); +} + +void RPCProtectionManagerImpl::AddToEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(message_needed_encryption_lock_); + + LOG4CXX_DEBUG(logger_, "Adding rpc with correlation id: " << correlation_id); + + encryption_needed_cache_.insert(std::make_pair(app_id, correlation_id)); +} + +void RPCProtectionManagerImpl::RemoveFromEncryptionNeededCache( + const uint32_t app_id, const uint32_t correlation_id) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(message_needed_encryption_lock_); + + LOG4CXX_DEBUG(logger_, + "Removing rpc with correlation id: " << correlation_id); + + encryption_needed_cache_.erase(std::make_pair(app_id, correlation_id)); +} + +void RPCProtectionManagerImpl::OnPTUFinished(const bool ptu_result) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(encrypted_rpcs_lock_); + + if (ptu_result) { + LOG4CXX_TRACE(logger_, + "PTU finished successfully, commencing internal encrypted " + "RPC cache update"); + encrypted_rpcs_.clear(); + SaveEncryptedRPC(); + } else { + LOG4CXX_WARN(logger_, + "PTU was unsuccessful. Keeping internal RPC cache from " + "current snapshot"); + } +} + +void RPCProtectionManagerImpl::SaveEncryptedRPC() { + LOG4CXX_AUTO_TRACE(logger_); + + const auto policy_encryption_flag_getter = + policy_handler_.PolicyEncryptionFlagGetter(); + + const auto policy_policy_app_ids = + policy_encryption_flag_getter->GetApplicationPolicyIDs(); + + for (const auto& app : policy_policy_app_ids) { + LOG4CXX_DEBUG(logger_, "Processing app name: " << app); + + encrypted_rpcs_[app] = GetEncryptedRPCsForApp(app); + } +} + +void RPCProtectionManagerImpl::OnPTInited() { + LOG4CXX_AUTO_TRACE(logger_); + + encrypted_rpcs_.clear(); + + SaveEncryptedRPC(); +} + +RPCProtectionManagerImpl::FunctionNames +RPCProtectionManagerImpl::GetEncryptedRPCsForApp( + const std::string& policy_app_id) { + LOG4CXX_AUTO_TRACE(logger_); + FunctionNames encrypted_rpcs; + + const auto policy_encryption_flag_getter = + policy_handler_.PolicyEncryptionFlagGetter(); + + if (!policy_encryption_flag_getter->AppNeedEncryption(policy_app_id)) { + return encrypted_rpcs; + } + + const auto function_groups = + policy_encryption_flag_getter->GetFunctionalGroupsForApp(policy_app_id); + + auto fill_encrypted_rpcs = [&encrypted_rpcs]( + const std::string& function_name) { + LOG4CXX_DEBUG(logger_, "Adding required encryprion rpc: " << function_name); + encrypted_rpcs.insert(function_name); + }; + + for (const auto& function_group : function_groups) { + if (policy_encryption_flag_getter->FunctionGroupNeedEncryption( + function_group)) { + auto rpcs = policy_encryption_flag_getter->GetRPCsForFunctionGroup( + function_group); + + std::for_each(rpcs.begin(), rpcs.end(), fill_encrypted_rpcs); + } + } + + return encrypted_rpcs; +} + +} // namespace application_manager diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index daa8cb2ac5..79b2cbd752 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -31,8 +31,11 @@ */ #include "application_manager/rpc_service_impl.h" +#include "application_manager/rpc_protection_manager_impl.h" #include "application_manager/app_service_manager.h" +#include "application_manager/command_factory.h" +#include "application_manager/commands/command.h" #include "application_manager/plugin_manager/plugin_keys.h" namespace application_manager { @@ -48,19 +51,68 @@ RPCServiceImpl::RPCServiceImpl( request_controller::RequestController& request_ctrl, protocol_handler::ProtocolHandler* protocol_handler, hmi_message_handler::HMIMessageHandler* hmi_handler, - CommandHolder& commands_holder) + CommandHolder& commands_holder, + RPCProtectionManagerSPtr rpc_protection_manager, + hmi_apis::HMI_API& hmi_so_factory, + mobile_apis::MOBILE_API& mobile_so_factory) : app_manager_(app_manager) , request_ctrl_(request_ctrl) , protocol_handler_(protocol_handler) , hmi_handler_(hmi_handler) + , rpc_protection_manager_(rpc_protection_manager) , commands_holder_(commands_holder) , messages_to_mobile_("AM ToMobile", this) , messages_to_hmi_("AM ToHMI", this) - , hmi_so_factory_(hmi_apis::HMI_API()) - , mobile_so_factory_(mobile_apis::MOBILE_API()) {} + , hmi_so_factory_(hmi_so_factory) + , mobile_so_factory_(mobile_so_factory) {} RPCServiceImpl::~RPCServiceImpl() {} +void RPCServiceImpl::Stop() { + LOG4CXX_AUTO_TRACE(logger_); + + messages_to_mobile_.Shutdown(); + messages_to_hmi_.Shutdown(); +} + +EncryptionFlagCheckResult RPCServiceImpl::IsEncryptionRequired( + const smart_objects::SmartObject& message, + std::shared_ptr<Application> app, + const bool is_rpc_service_secure) const { + LOG4CXX_AUTO_TRACE(logger_); + const auto function_id = + message[strings::params][strings::function_id].asUInt(); + const auto correlation_id = + message[strings::params][strings::correlation_id].asUInt(); + + const auto message_type = + message[strings::params][strings::message_type].asUInt(); + const bool policy_encryption_flag = + rpc_protection_manager_->CheckPolicyEncryptionFlag( + function_id, app, is_rpc_service_secure); + if (MessageType::kRequest == message_type) { + const bool message_protected = + message[strings::params][strings::protection].asBool(); + + if (!message_protected) { + return policy_encryption_flag + ? EncryptionFlagCheckResult::kError_EncryptionNeeded + : EncryptionFlagCheckResult::kSuccess_NotProtected; + } + + // request is encrypted, so we need to encrypt response regardless of + // policy flag + const auto connection_key = + message[strings::params][strings::connection_key].asUInt(); + rpc_protection_manager_->AddToEncryptionNeededCache(connection_key, + correlation_id); + return EncryptionFlagCheckResult::kSuccess_Protected; + } + return policy_encryption_flag + ? EncryptionFlagCheckResult::kSuccess_Protected + : EncryptionFlagCheckResult::kSuccess_NotProtected; +} + bool RPCServiceImpl::ManageMobileCommand( const commands::MessageSharedPtr message, commands::Command::CommandSource source) { @@ -82,9 +134,10 @@ bool RPCServiceImpl::ManageMobileCommand( (*message)[strings::params][strings::connection_key].asUInt()); auto app_ptr = app_manager_.application(connection_key); - if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->policy_app_id())) { + if (app_ptr && app_manager_.IsAppInReconnectMode(app_ptr->device(), + app_ptr->policy_app_id())) { commands_holder_.Suspend( - app_ptr, CommandHolder::CommandType::kMobileCommand, message); + app_ptr, CommandHolder::CommandType::kMobileCommand, source, message); return true; } mobile_apis::FunctionID::eType function_id = @@ -118,6 +171,21 @@ bool RPCServiceImpl::ManageMobileCommand( SendMessageToMobile(response); return false; } +#ifdef ENABLE_SECURITY + if (EncryptionFlagCheckResult::kError_EncryptionNeeded == + IsEncryptionRequired( + *message, + app, + protocol_handler_->IsRPCServiceSecure(connection_key))) { + const auto response = MessageHelper::CreateNegativeResponse( + connection_key, + function_id, + correlation_id, + static_cast<int32_t>(mobile_apis::Result::ENCRYPTION_NEEDED)); + SendMessageToMobile(response); + return false; + } +#endif // ENABLE_SECURITY // Message for "CheckPermission" must be with attached schema mobile_so_factory().attachSchema(*message, false); @@ -176,7 +244,8 @@ bool RPCServiceImpl::ManageMobileCommand( mobile_apis::HMILevel::eType app_hmi_level = mobile_apis::HMILevel::INVALID_ENUM; if (app) { - app_hmi_level = app->hmi_level(); + app_hmi_level = + app->hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW); } // commands will be launched from request_ctrl @@ -296,9 +365,10 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message, (*message)[strings::msg_params][strings::app_id].asUInt(); auto app = app_manager_.application(static_cast<uint32_t>(connection_key)); - if (app && app_manager_.IsAppInReconnectMode(app->policy_app_id())) { + if (app && app_manager_.IsAppInReconnectMode(app->device(), + app->policy_app_id())) { commands_holder_.Suspend( - app, CommandHolder::CommandType::kHmiCommand, message); + app, CommandHolder::CommandType::kHmiCommand, source, message); return true; } } @@ -337,6 +407,7 @@ void RPCServiceImpl::Handle(const impl::MessageToHmi message) { } void RPCServiceImpl::Handle(const impl::MessageToMobile message) { + LOG4CXX_AUTO_TRACE(logger_); if (!protocol_handler_) { LOG4CXX_WARN(logger_, "Protocol Handler is not set; cannot send message to mobile."); @@ -361,7 +432,32 @@ void RPCServiceImpl::Handle(const impl::MessageToMobile message) { } } - protocol_handler_->SendMessageToMobileApp(rawMessage, is_final); + const auto correlation_id = message->correlation_id(); + const auto app_id = message->connection_key(); + + const bool is_service_secure = + protocol_handler_->IsRPCServiceSecure(message->connection_key()); + + const bool needs_encryption = + MessageType::kNotification == message->type() + ? rpc_protection_manager_->CheckPolicyEncryptionFlag( + message->function_id(), + app_manager_.application(app_id), + is_service_secure) + : rpc_protection_manager_->IsInEncryptionNeededCache(app_id, + correlation_id); + + if (needs_encryption && !is_service_secure) { + LOG4CXX_WARN(logger_, + "Unable to send rpc that requires encryption without secure " + "rpc service"); + return; + }; + + protocol_handler_->SendMessageToMobileApp( + rawMessage, needs_encryption, is_final); + rpc_protection_manager_->RemoveFromEncryptionNeededCache(app_id, + correlation_id); LOG4CXX_INFO(logger_, "Message for mobile given away"); if (close_session) { @@ -431,9 +527,9 @@ void RPCServiceImpl::SendMessageToMobile( if (IsAppServiceRPC(function_id, commands::Command::CommandSource::SOURCE_SDL) || rpc_passing) { - LOG4CXX_DEBUG(logger_, - "Allowing unknown parameters for response function " - << function_id); + LOG4CXX_DEBUG( + logger_, + "Allowing unknown parameters for response function " << function_id); allow_unknown_parameters = true; } @@ -451,6 +547,8 @@ void RPCServiceImpl::SendMessageToMobile( LOG4CXX_WARN(logger_, "Can't send msg to Mobile: failed to create string"); return; } + const auto api_function_id = static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asUInt()); smart_objects::SmartObject& msg_to_mobile = *message; // If correlation_id is not present, it is from-HMI message which should be @@ -461,12 +559,11 @@ void RPCServiceImpl::SendMessageToMobile( msg_to_mobile[strings::params][strings::connection_key].asUInt(), msg_to_mobile[strings::params][strings::function_id].asInt()); } else if (app) { - mobile_apis::FunctionID::eType function_id = - static_cast<mobile_apis::FunctionID::eType>( - (*message)[strings::params][strings::function_id].asUInt()); RPCParams params; const smart_objects::SmartObject& s_map = (*message)[strings::msg_params]; + const WindowID window_id = + MessageHelper::ExtractWindowIdFromSmartObject(s_map); if (smart_objects::SmartType_Map == s_map.getType()) { smart_objects::SmartMap::iterator iter = s_map.map_begin(); smart_objects::SmartMap::iterator iter_end = s_map.map_end(); @@ -479,18 +576,20 @@ void RPCServiceImpl::SendMessageToMobile( } } const std::string string_functionID = - MessageHelper::StringifiedFunctionID(function_id); + MessageHelper::StringifiedFunctionID(api_function_id); const mobile_apis::Result::eType check_result = - app_manager_.CheckPolicyPermissions(app, string_functionID, params); + app_manager_.CheckPolicyPermissions( + app, window_id, string_functionID, params); if (mobile_apis::Result::SUCCESS != check_result) { LOG4CXX_WARN(logger_, - "Function \"" << string_functionID << "\" (#" << function_id + "Function \"" << string_functionID << "\" (#" + << api_function_id << ") not allowed by policy"); return; } #ifdef EXTERNAL_PROPRIETARY_MODE - if (function_id == mobile_apis::FunctionID::OnSystemRequestID) { + if (api_function_id == mobile_apis::FunctionID::OnSystemRequestID) { mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType>( (*message)[strings::msg_params][strings::request_type].asUInt()); @@ -514,7 +613,6 @@ void RPCServiceImpl::SendMessageToMobile( void RPCServiceImpl::SendMessageToHMI( const commands::MessageSharedPtr message) { LOG4CXX_AUTO_TRACE(logger_); - if (!message) { LOG4CXX_WARN(logger_, "Null-pointer message received."); NOTREACHED(); @@ -555,7 +653,6 @@ void RPCServiceImpl::SendMessageToHMI( "Cannot send message to HMI: failed to create string"); return; } - messages_to_hmi_.PostMessage(impl::MessageToHmi(message_to_send)); } @@ -707,6 +804,28 @@ bool RPCServiceImpl::ConvertSOtoMessage( return true; } +void RPCServiceImpl::UpdateMobileRPCParams( + const mobile_apis::FunctionID::eType& function_id, + const mobile_apis::messageType::eType& message_type, + const std::map<std::string, SMember>& members) { + mobile_so_factory().ResetFunctionSchema(function_id, message_type); + for (const auto& item : members) { + mobile_so_factory().AddCustomMember( + function_id, message_type, item.first, item.second); + } +} + +void RPCServiceImpl::UpdateHMIRPCParams( + const hmi_apis::FunctionID::eType& function_id, + const hmi_apis::messageType::eType& message_type, + const std::map<std::string, SMember>& members) { + hmi_so_factory().ResetFunctionSchema(function_id, message_type); + for (const auto& item : members) { + hmi_so_factory().AddCustomMember( + function_id, message_type, item.first, item.second); + } +} + hmi_apis::HMI_API& RPCServiceImpl::hmi_so_factory() { return hmi_so_factory_; } diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 48e293a782..fe0f878e6c 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -5,6 +5,8 @@ namespace application_manager { namespace strings { const char* params = "params"; +const char* require_encryption = "requireEncryption"; +const char* protection = "protection"; const char* message_type = "message_type"; const char* correlation_id = "correlation_id"; const char* function_id = "function_id"; @@ -20,6 +22,7 @@ const char* info = "info"; const char* app_id = "appID"; const char* full_app_id = "fullAppID"; const char* bundle_id = "appBundleID"; +const char* window_id = "windowID"; const char* app_info = "appInfo"; const char* app_launch = "app_launch"; const char* app_launch_list = "app_launch_list"; @@ -59,6 +62,7 @@ const char* main_field_1 = "mainField1"; const char* main_field_2 = "mainField2"; const char* main_field_3 = "mainField3"; const char* main_field_4 = "mainField4"; +const char* template_title = "templateTitle"; const char* metadata_tags = "metadataTags"; const char* eta = "eta"; const char* time_to_destination = "timeToDestination"; @@ -77,10 +81,13 @@ const char* menu_icon = "menuIcon"; const char* keyboard_properties = "keyboardProperties"; const char* vr_commands = "vrCommands"; const char* position = "position"; +const char* user_location = "userLocation"; const char* num_ticks = "numTicks"; const char* slider_footer = "sliderFooter"; const char* menu_id = "menuID"; const char* menu_name = "menuName"; +const char* menu_layout = "menuLayout"; +const char* menu_layouts_available = "menuLayoutsAvailable"; const char* interaction_choice_set_id = "interactionChoiceSetID"; const char* interaction_choice_set_id_list = "interactionChoiceSetIDList"; const char* choice_set = "choiceSet"; @@ -96,7 +103,10 @@ const char* initial_prompt = "initialPrompt"; const char* initial_text = "initialText"; const char* duration = "duration"; const char* progress_indicator = "progressIndicator"; +const char* func_id = "functionID"; +const char* cancel_id = "cancelID"; const char* alert_type = "alertType"; +const char* alert_icon = "alertIcon"; const char* play_tone = "playTone"; const char* soft_buttons = "softButtons"; const char* soft_button_id = "softButtonID"; @@ -133,9 +143,17 @@ const char* activate_app_hmi_level = "level"; const char* audio_streaming_state = "audioStreamingState"; const char* video_streaming_state = "videoStreamingState"; const char* system_context = "systemContext"; +const char* window_name = "windowName"; +const char* window_type = "type"; +const char* window_type_supported = "windowTypeSupported"; +const char* maximum_number_of_windows = "maximumNumberOfWindows"; +const char* window_capabilities = "windowCapabilities"; +const char* associated_service_type = "associatedServiceType"; +const char* duplicate_updates_from_window_id = "duplicateUpdatesFromWindowID"; const char* speech_capabilities = "speechCapabilities"; const char* vr_capabilities = "vrCapabilities"; const char* audio_pass_thru_capabilities = "audioPassThruCapabilities"; +const char* audio_pass_thru_capabilities_list = "audioPassThruCapabilitiesList"; const char* pcm_stream_capabilities = "pcmStreamCapabilities"; const char* audio_pass_thru_icon = "audioPassThruIcon"; const char* way_points = "wayPoints"; @@ -146,6 +164,7 @@ const char* navigation_capability = "navigationCapability"; const char* phone_capability = "phoneCapability"; const char* video_streaming_capability = "videoStreamingCapability"; const char* rc_capability = "remoteControlCapability"; +const char* seat_location_capability = "seatLocationCapability"; const char* app_services_capabilities = "appServicesCapabilities"; const char* day_color_scheme = "dayColorScheme"; const char* night_color_scheme = "nightColorScheme"; @@ -156,6 +175,8 @@ const char* red = "red"; const char* green = "green"; const char* blue = "blue"; const char* display_layout = "displayLayout"; +const char* template_configuration = "templateConfiguration"; +const char* template_layout = "template"; const char* icon_resumed = "iconResumed"; const char* nicknames = "nicknames"; const char* enabled = "enabled"; @@ -165,6 +186,11 @@ const char* hybrid_app_preference = "hybridAppPreference"; const char* is_cloud_application = "isCloudApplication"; const char* cloud_connection_status = "cloudConnectionStatus"; const char* endpoint = "endpoint"; +const char* display_capabilities = "displayCapabilities"; +const char* policy_type = "policyType"; +const char* property = "property"; +const char* displays = "displays"; +const char* seat_location = "seatLocation"; // PutFile const char* sync_file_name = "syncFileName"; @@ -183,6 +209,7 @@ const char* is_template = "isTemplate"; const char* image = "image"; const char* type = "type"; const char* system_file = "systemFile"; +const char* is_system_file = "isSystemFile"; const char* offset = "offset"; const char* length = "length"; const char* secondary_image = "secondaryImage"; @@ -221,6 +248,7 @@ const char* key_press_mode = "keypressMode"; // duplicate names from hmi_request const char* limited_character_list = "limitedCharacterList"; const char* auto_complete_text = "autoCompleteText"; +const char* auto_complete_list = "autoCompleteList"; const char* navigation_text = "navigationText"; // vehicle info @@ -252,6 +280,7 @@ const char* e_call_info = "eCallInfo"; const char* airbag_status = "airbagStatus"; const char* emergency_event = "emergencyEvent"; const char* cluster_mode_status = "clusterModeStatus"; +const char* cluster_modes = "clusterModes"; const char* my_key = "myKey"; const char* help_prompt = "helpPrompt"; const char* scroll_message_body = "scrollableMessageBody"; @@ -271,6 +300,7 @@ const char* sdl_version = "sdlVersion"; const char* system_software_version = "systemSoftwareVersion"; const char* priority = "priority"; const char* engine_oil_life = "engineOilLife"; +const char* oem_custom_data_type = "oemCustomDataType"; // app services const char* app_service_manifest = "appServiceManifest"; @@ -289,6 +319,7 @@ const char* service_active = "serviceActive"; const char* app_service_id = "appServiceId"; const char* service_data = "serviceData"; const char* media_service_data = "mediaServiceData"; +const char* media_image = "mediaImage"; const char* weather_service_data = "weatherServiceData"; const char* location = "location"; const char* current_forecast = "currentForecast"; @@ -310,6 +341,10 @@ const char* activate = "activate"; const char* set_as_default = "setAsDefault"; const char* origin_app = "originApp"; +// sis data +const char* station_short_name = "stationShortName"; +const char* station_location = "stationLocation"; + // resuming const char* application_commands = "applicationCommands"; const char* application_submenus = "applicationSubMenus"; @@ -338,8 +373,12 @@ const char* time_stamp = "timeStamp"; const char* manual_text_entry = "manualTextEntry"; const char* image_type_supported = "imageTypeSupported"; const char* unexpected_disconnect = "unexpectedDisconnect"; + +const char* shifted = "shifted"; +const char* altitude = "altitude"; const char* longitude_degrees = "longitudeDegrees"; const char* latitude_degrees = "latitudeDegrees"; + const char* address = "address"; const char* country_name = "countryName"; const char* country_code = "countryCode"; @@ -362,13 +401,14 @@ const char* delivery_mode = "deliveryMode"; const char* audio_streaming_indicator = "audioStreamingIndicator"; +const char* windows_info = "windowsInfo"; + const char* const keyboard_properties_supported = "keyboardPropertiesSupported"; const char* const language_supported = "languageSupported"; const char* const keyboard_layout_supported = "keyboardLayoutSupported"; const char* const keypress_mode_supported = "keypressModeSupported"; const char* const limited_characters_list_supported = "limitedCharactersListSupported"; -const char* const auto_complete_text_supported = "autoCompleteTextSupported"; const char* const send_location_enabled = "sendLocationEnabled"; const char* const get_way_points_enabled = "getWayPointsEnabled"; const char* const entity_type = "entityType"; @@ -389,6 +429,9 @@ 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 diagonal_screen_size = "diagonalScreenSize"; +const char* const pixel_per_inch = "pixelPerInch"; +const char* const scale = "scale"; const char* const haptic_rect_data = "hapticRectData"; const char* const rect = "rect"; const char* const x = "x"; @@ -431,6 +474,8 @@ namespace mobile_notification { const char* state = "state"; const char* syncp_timeout = "Timeout"; const char* syncp_url = "URL"; +const char* lock_screen_dismissal_enabled = "lockScreenDismissalEnabled"; +const char* lock_screen_dismissal_warning = "lockScreenDismissalWarning"; } // namespace mobile_notification namespace hmi_levels { @@ -475,7 +520,7 @@ const char* keyboard_properties = "keyboardProperties"; const char* method_name = "methodName"; const char* keyboard_layout = "keyboardLayout"; const char* limited_character_list = "limitedCharacterList"; -const char* auto_complete_text = "autoCompleteText"; +const char* auto_complete_list = "autoCompleteList"; const char* file = "file"; const char* file_name = "fileName"; const char* retry = "retry"; @@ -536,6 +581,9 @@ const char* policyfile = "policyfile"; const char* is_active = "isActive"; const char* is_deactivated = "isDeactivated"; const char* event_name = "eventName"; +const char* service_type = "serviceType"; +const char* service_event = "serviceEvent"; +const char* reason = "reason"; } // namespace hmi_notification } // namespace application_manager diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index f4852c532c..8368597370 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -32,8 +32,8 @@ #include "application_manager/state_controller_impl.h" #include <tuple> -#include "application_manager/usage_statistics.h" #include "application_manager/rpc_service.h" +#include "application_manager/usage_statistics.h" #include "utils/helpers.h" #include "connection_handler/connection_handler.h" @@ -67,14 +67,16 @@ StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) } void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state, - const bool send_activate_app) { + const bool request_hmi_state_change) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(HmiState::STATE_ID_REGULAR == state->state_id()); - LOG4CXX_DEBUG(logger_, "Set regular state " << *state); + LOG4CXX_DEBUG(logger_, + "Set window #" << window_id << " regular state " << *state); if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || state->audio_streaming_state() == @@ -93,37 +95,44 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, HmiStatePtr resolved_state = ResolveHmiState(app, state); if (!resolved_state) { state->set_state_id(HmiState::STATE_ID_POSTPONED); - app->SetPostponedState(state); + app->SetPostponedState(window_id, state); return; } + LOG4CXX_DEBUG(logger_, "Resolved state: " << *resolved_state); const hmi_apis::Common_HMILevel::eType hmi_level = static_cast<hmi_apis::Common_HMILevel::eType>( resolved_state->hmi_level()); - if (send_activate_app) { - const int64_t corr_id = SendBCActivateApp(app, hmi_level, true); - if (-1 != corr_id) { - subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, - corr_id); - waiting_for_activate_[app->app_id()] = resolved_state; + if (request_hmi_state_change) { + const int64_t result = RequestHMIStateChange(app, hmi_level, true); + if (-1 != result) { + const uint32_t corr_id = static_cast<uint32_t>(result); + subscribe_on_event( + hmi_apis::Common_HMILevel::NONE == hmi_level + ? hmi_apis::FunctionID::BasicCommunication_CloseApplication + : hmi_apis::FunctionID::BasicCommunication_ActivateApp, + corr_id); + waiting_for_response_[app->app_id()] = resolved_state; + app_mngr_.set_application_id(corr_id, app->hmi_app_id()); return; } LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); return; } - ApplyRegularState(app, resolved_state); + ApplyRegularState(app, window_id, resolved_state); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, - const bool send_activate_app) { + const bool request_hmi_state_change) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_regular = app->RegularHmiState(); + HmiStatePtr prev_regular = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -132,16 +141,22 @@ void StateControllerImpl::SetRegularState( hmi_state->set_audio_streaming_state(audio_state); hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_regular->system_context()); - SetRegularState(app, hmi_state, send_activate_app); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, request_hmi_state_change); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, - const bool send_activate_app) { + const bool request_hmi_state_change) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); + + HmiStatePtr prev_regular = app->RegularHmiState(window_id); + DCHECK_OR_RETURN_VOID(prev_regular); + const HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -150,33 +165,43 @@ void StateControllerImpl::SetRegularState( hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); hmi_state->set_video_streaming_state(CalcVideoState(app, hmi_level)); hmi_state->set_system_context(SystemContext::SYSCTXT_MAIN); - SetRegularState(app, hmi_state, send_activate_app); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, request_hmi_state_change); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, - const bool send_activate_app) { + const bool request_hmi_state_change) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); + + HmiStatePtr prev_regular = app->RegularHmiState(window_id); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(system_context); - SetRegularState(app, hmi_state, send_activate_app); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, request_hmi_state_change); } void StateControllerImpl::SetRegularState( - ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) { + ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::HMILevel::eType hmi_level) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr prev_state = app->RegularHmiState(window_id); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); @@ -186,15 +211,16 @@ void StateControllerImpl::SetRegularState( hmi_state->set_system_context(prev_state ? prev_state->system_context() : mobile_apis::SystemContext::SYSCTXT_MAIN); - SetRegularState(app, hmi_state); + SetRegularState(app, window_id, hmi_state); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::SystemContext::eType system_context) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_regular = app->RegularHmiState(); + HmiStatePtr prev_regular = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -205,16 +231,18 @@ void StateControllerImpl::SetRegularState( hmi_state->set_video_streaming_state( CalcVideoState(app, prev_regular->hmi_level())); hmi_state->set_system_context(system_context); - SetRegularState(app, hmi_state, false); + hmi_state->set_window_type(prev_regular->window_type()); + SetRegularState(app, window_id, hmi_state, false); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr prev_state = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -223,18 +251,23 @@ void StateControllerImpl::SetRegularState( hmi_state->set_audio_streaming_state(audio_state); hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_state->system_context()); - SetRegularState(app, hmi_state, false); + hmi_state->set_window_type(prev_state->window_type()); + SetRegularState(app, window_id, hmi_state, false); } void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); - if (mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { - SetRegularState(app, state, true); + + // SDL should send BC.ActivateApp for main window during resumption + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { + SetRegularState(app, window_id, state, true); } else { - SetRegularState(app, state, false); + SetRegularState(app, window_id, state, false); } } @@ -295,7 +328,8 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( return; } - const HmiStatePtr state_to_resolve = app_to_resolve->RegularHmiState(); + const HmiStatePtr state_to_resolve = + app_to_resolve->RegularHmiState(window_id_); DCHECK_OR_RETURN_VOID(state_to_resolve); // If applied HMI state is FULL: @@ -379,22 +413,23 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( std::make_tuple( result_hmi_level, result_audio_state, result_video_state)) { LOG4CXX_DEBUG(logger_, - "Application " - << app_to_resolve->app_id() << " will change state to: " - << "HMI level " << to_resolve_hmi_level << " --> " - << result_hmi_level << ", audio " - << state_to_resolve->audio_streaming_state() << " --> " - << result_audio_state << ", video " - << state_to_resolve->video_streaming_state() << " --> " - << result_video_state); + "Application " << app_to_resolve->app_id() << " window " + << window_id_ << " will change state to: " + << "HMI level " << to_resolve_hmi_level + << " --> " << result_hmi_level << ", audio " + << state_to_resolve->audio_streaming_state() + << " --> " << result_audio_state << ", video " + << state_to_resolve->video_streaming_state() + << " --> " << result_video_state); state_ctrl_->SetupRegularHmiState(app_to_resolve, + window_id_, result_hmi_level, result_audio_state, result_video_state); } else { LOG4CXX_DEBUG(logger_, - "Application " << app_to_resolve->app_id() - << " will NOT change HMI level"); + "Application " << app_to_resolve->app_id() << " window " + << window_id_ << " will NOT change HMI level"); } } @@ -408,6 +443,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN(available_state, HmiStatePtr()); available_state->set_hmi_level(state->hmi_level()); + available_state->set_window_type(state->window_type()); available_state->set_audio_streaming_state(state->audio_streaming_state()); available_state->set_video_streaming_state(state->video_streaming_state()); available_state->set_system_context(state->system_context()); @@ -565,12 +601,14 @@ bool StateControllerImpl::IsStateAvailableForResumption( } void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - LOG4CXX_DEBUG(logger_, "Setup regular state: " << *state); - HmiStatePtr curr_state = app->CurrentHmiState(); + LOG4CXX_DEBUG(logger_, + "Setup window #" << window_id << " regular state: " << *state); + HmiStatePtr curr_state = app->CurrentHmiState(window_id); HmiStatePtr old_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(old_state); @@ -578,28 +616,30 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, old_state->set_audio_streaming_state(curr_state->audio_streaming_state()); old_state->set_video_streaming_state(curr_state->video_streaming_state()); old_state->set_system_context(curr_state->system_context()); - app->SetRegularState(state); + old_state->set_window_type(curr_state->window_type()); + app->SetRegularState(window_id, state); - if (HMILevel::HMI_LIMITED == state->hmi_level() && app->is_resuming()) { + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW == window_id && + HMILevel::HMI_LIMITED == state->hmi_level() && app->is_resuming()) { LOG4CXX_DEBUG(logger_, "Resuming to LIMITED level. " << "Send OnResumeAudioSource notification"); MessageHelper::SendOnResumeAudioSourceToHMI(app->app_id(), app_mngr_); } - app->set_is_resuming(false); - HmiStatePtr new_state = app->CurrentHmiState(); - OnStateChanged(app, old_state, new_state); + HmiStatePtr new_state = app->CurrentHmiState(window_id); + OnStateChanged(app, window_id, old_state, new_state); } void StateControllerImpl::SetupRegularHmiState( ApplicationSharedPtr app, + const WindowID window_id, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr prev_state = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr new_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -608,27 +648,69 @@ void StateControllerImpl::SetupRegularHmiState( new_state->set_audio_streaming_state(audio_state); new_state->set_video_streaming_state(video_state); new_state->set_system_context(prev_state->system_context()); - SetupRegularHmiState(app, new_state); + new_state->set_window_type(prev_state->window_type()); + SetupRegularHmiState(app, window_id, new_state); } void StateControllerImpl::ApplyRegularState(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); LOG4CXX_DEBUG(logger_, - "Applying to app " << app->app_id() << " state " << *state); - SetupRegularHmiState(app, state); + "Applying to app " << app->app_id() << " window #" << window_id + << " state " << *state); + SetupRegularHmiState(app, window_id, state); + + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_DEBUG(logger_, "No need to resolve conflicts for a widget"); + return; + } + LOG4CXX_DEBUG(logger_, "Resolving HMI level conflicts for app " << app->app_id()); - ForEachApplication(HmiLevelConflictResolver(app, state, this)); + ForEachApplication(HmiLevelConflictResolver(app, window_id, state, this)); } + +void StateControllerImpl::UpdateAppWindowsStreamingState( + ApplicationSharedPtr app, HmiStatePtr state) { + LOG4CXX_AUTO_TRACE(logger_); + const auto window_ids = app->GetWindowIds(); + for (auto window_id : window_ids) { + HmiStatePtr window_hmi_state = app->RegularHmiState(window_id); + LOG4CXX_DEBUG( + logger_, "State: " << *state << " window state: " << *window_hmi_state); + if (window_hmi_state->audio_streaming_state() != + state->audio_streaming_state() || + window_hmi_state->video_streaming_state() != + state->video_streaming_state()) { + LOG4CXX_DEBUG(logger_, + "Updating streaming state for window #" << window_id); + + HmiStatePtr new_window_state = + CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(new_window_state); + new_window_state->set_hmi_level(window_hmi_state->hmi_level()); + new_window_state->set_audio_streaming_state( + state->audio_streaming_state()); + new_window_state->set_video_streaming_state( + state->video_streaming_state()); + new_window_state->set_system_context(window_hmi_state->system_context()); + new_window_state->set_window_type(window_hmi_state->window_type()); + app->SetRegularState(window_id, new_window_state); + + MessageHelper::SendHMIStatusNotification(app, window_id, app_mngr_); + } + } +} + void StateControllerImpl::on_event(const event_engine::MobileEvent& event) {} void StateControllerImpl::on_event(const event_engine::Event& event) { - using smart_objects::SmartObject; using event_engine::Event; + using smart_objects::SmartObject; using namespace hmi_apis; namespace FunctionID = hmi_apis::FunctionID; @@ -636,8 +718,9 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { const SmartObject& message = event.smart_object(); const FunctionID::eType id = static_cast<FunctionID::eType>(event.id()); switch (id) { - case FunctionID::BasicCommunication_ActivateApp: { - OnActivateAppResponse(message); + case FunctionID::BasicCommunication_ActivateApp: + case FunctionID::BasicCommunication_CloseApplication: { + OnHMIResponse(message); break; } case FunctionID::BasicCommunication_OnAppActivated: { @@ -725,26 +808,82 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { } } +void StateControllerImpl::ActivateDefaultWindow(ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + + const WindowID window_id = PredefinedWindows::DEFAULT_WINDOW; + const HMILevel::eType hmi_level = HMILevel::HMI_FULL; + const AudioStreamingState::eType audio_state = + app->IsAudioApplication() ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + const VideoStreamingState::eType video_state = + app->IsVideoApplication() ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; + + SetRegularState(app, window_id, hmi_level, audio_state, video_state, false); + + // After main window activation, streaming state should be updated for another + // windows of the app + HmiStatePtr new_state = + app->RegularHmiState(PredefinedWindows::DEFAULT_WINDOW); + UpdateAppWindowsStreamingState(app, new_state); +} + +void StateControllerImpl::ExitDefaultWindow(ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace mobile_apis; + + const WindowID window_id = PredefinedWindows::DEFAULT_WINDOW; + const HMILevel::eType hmi_level = HMILevel::HMI_NONE; + const AudioStreamingState::eType audio_state = + AudioStreamingState::NOT_AUDIBLE; + const VideoStreamingState::eType video_state = + VideoStreamingState::NOT_STREAMABLE; + + SetRegularState(app, window_id, hmi_level, audio_state, video_state, false); + + // After main window exiting, streaming state should be updated for another + // windows of the app + HmiStatePtr new_state = + app->RegularHmiState(PredefinedWindows::DEFAULT_WINDOW); + UpdateAppWindowsStreamingState(app, new_state); +} + void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, + const WindowID window_id, HmiStatePtr old_state, HmiStatePtr new_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(old_state); DCHECK_OR_RETURN_VOID(new_state); - LOG4CXX_DEBUG(logger_, "Old state: " << *old_state); - LOG4CXX_DEBUG(logger_, "New state: " << *new_state); - if (IsStateChanged(*old_state, *new_state)) { - app_mngr_.SendHMIStatusNotification(app); - if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { - app->ResetDataInNone(); - } - app_mngr_.OnHMILevelChanged( - app->app_id(), old_state->hmi_level(), new_state->hmi_level()); - app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); - } else { - LOG4CXX_ERROR(logger_, "State has NOT been changed."); + LOG4CXX_DEBUG(logger_, + "Window #" << window_id << " old state: " << *old_state); + LOG4CXX_DEBUG(logger_, + "Window #" << window_id << " new state: " << *new_state); + + if (!IsStateChanged(*old_state, *new_state)) { + LOG4CXX_DEBUG(logger_, "State has NOT been changed."); + return; + } + + MessageHelper::SendHMIStatusNotification(app, window_id, app_mngr_); + + if (mobile_apis::PredefinedWindows::DEFAULT_WINDOW != window_id) { + LOG4CXX_DEBUG(logger_, + "State was changed not for a main application window. No " + "additional actions required"); + return; } + + if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { + app->ResetDataInNone(); + } + + app_mngr_.OnHMILevelChanged( + app->app_id(), old_state->hmi_level(), new_state->hmi_level()); + app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); } bool StateControllerImpl::IsTempStateActive(HmiState::StateID id) const { @@ -755,6 +894,20 @@ bool StateControllerImpl::IsTempStateActive(HmiState::StateID id) const { void StateControllerImpl::OnApplicationRegistered( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType default_level) { + LOG4CXX_AUTO_TRACE(logger_); + + // After app registration HMI level should be set for DEFAUL_WINDOW only + OnAppWindowAdded(app, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::WindowType::MAIN, + default_level); +} + +void StateControllerImpl::OnAppWindowAdded( + ApplicationSharedPtr app, + const WindowID window_id, + const mobile_apis::WindowType::eType window_type, + const mobile_apis::HMILevel::eType default_level) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; @@ -768,9 +921,10 @@ void StateControllerImpl::OnApplicationRegistered( DCHECK_OR_RETURN_VOID(new_state); DCHECK_OR_RETURN_VOID(new_state->state_id() != HmiState::STATE_ID_REGULAR); - HmiStatePtr old_hmi_state = app->CurrentHmiState(); + HmiStatePtr old_hmi_state = app->CurrentHmiState(window_id); new_state->set_parent(old_hmi_state); - app->AddHMIState(new_state); + new_state->set_window_type(old_hmi_state->window_type()); + app->AddHMIState(window_id, new_state); } } @@ -781,50 +935,57 @@ void StateControllerImpl::OnApplicationRegistered( default_state->set_audio_streaming_state(CalcAudioState(app, default_level)); default_state->set_video_streaming_state(CalcVideoState(app, default_level)); default_state->set_system_context(SystemContext::SYSCTXT_MAIN); + default_state->set_window_type(window_type); - HmiStatePtr initial_state = app->RegularHmiState(); + HmiStatePtr initial_state = app->RegularHmiState(window_id); - app->SetRegularState(default_state); + app->SetRegularState(window_id, default_state); - HmiStatePtr new_state = app->CurrentHmiState(); + HmiStatePtr new_state = app->CurrentHmiState(window_id); - OnStateChanged(app, initial_state, new_state); + OnStateChanged(app, window_id, initial_state, new_state); } -int64_t StateControllerImpl::SendBCActivateApp( +int64_t StateControllerImpl::RequestHMIStateChange( ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr bc_activate_app_request = - MessageHelper::GetBCActivateAppRequestToHMI( - app, - app_mngr_.connection_handler().get_session_observer(), - app_mngr_.GetPolicyHandler(), - level, - send_policy_priority, - app_mngr_); - if (!bc_activate_app_request) { - LOG4CXX_ERROR(logger_, "Unable to create BC.ActivateAppRequest"); + smart_objects::SmartObjectSPtr request = NULL; + if (hmi_apis::Common_HMILevel::NONE == level) { + request = MessageHelper::GetBCCloseApplicationRequestToHMI(app, app_mngr_); + } else { + request = MessageHelper::GetBCActivateAppRequestToHMI( + app, + app_mngr_.GetPolicyHandler(), + level, + send_policy_priority, + app_mngr_); + } + if (!request) { + LOG4CXX_ERROR(logger_, "Unable to create request"); return -1; } - if (!app_mngr_.GetRPCService().ManageHMICommand(bc_activate_app_request)) { - LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateAppRequest"); + if (!app_mngr_.GetRPCService().ManageHMICommand(request)) { + LOG4CXX_ERROR(logger_, "Unable to send request"); return -1; } - const int64_t corr_id = - (*bc_activate_app_request)[strings::params][strings::correlation_id] - .asInt(); - return corr_id; + const uint32_t corr_id = + (*request)[strings::params][strings::correlation_id].asUInt(); + return static_cast<int64_t>(corr_id); } void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); - HmiStatePtr state = app->PostponedHmiState(); - if (state) { - app->RemovePostponedState(); - state->set_state_id(HmiState::STATE_ID_REGULAR); - SetRegularState(app, state); + const WindowIds window_ids = app->GetWindowIds(); + + for (const auto& window_id : window_ids) { + HmiStatePtr state = app->PostponedHmiState(window_id); + if (state) { + app->RemovePostponedState(window_id); + state->set_state_id(HmiState::STATE_ID_REGULAR); + SetRegularState(app, window_id, state); + } } } @@ -852,16 +1013,19 @@ void StateControllerImpl::TempStateStopped(HmiState::StateID ID) { std::mem_fun(&StateControllerImpl::ApplyPostponedStateForApp), this)); } -void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { +void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app, + const WindowID window_id) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - const HmiStatePtr regular = app->RegularHmiState(); + const HmiStatePtr regular = app->RegularHmiState(window_id); DCHECK_OR_RETURN_VOID(regular); HmiStatePtr new_regular = std::make_shared<HmiState>(*regular); - LOG4CXX_DEBUG(logger_, "Current HMI level: '" << app->hmi_level() << "'"); + LOG4CXX_DEBUG(logger_, + "Window #" << window_id << " current HMI level: '" + << app->hmi_level(window_id) << "'"); const bool is_audio_app = app->IsAudioApplication(); const bool is_video_app = app->IsVideoApplication(); @@ -887,23 +1051,25 @@ void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { new_regular->set_video_streaming_state(VideoStreamingState::NOT_STREAMABLE); } - SetRegularState(app, new_regular, false); + SetRegularState(app, window_id, new_regular, false); } -void StateControllerImpl::OnActivateAppResponse( +void StateControllerImpl::OnHMIResponse( const smart_objects::SmartObject& message) { const hmi_apis::Common_Result::eType code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - const int32_t correlation_id = - message[strings::params][strings::correlation_id].asInt(); + const uint32_t correlation_id = + message[strings::params][strings::correlation_id].asUInt(); const uint32_t hmi_app_id = app_mngr_.application_id(correlation_id); ApplicationSharedPtr application = app_mngr_.application_by_hmi_app(hmi_app_id); if (application && hmi_apis::Common_Result::SUCCESS == code) { - HmiStatePtr pending_state = waiting_for_activate_[application->app_id()]; + HmiStatePtr pending_state = waiting_for_response_[application->app_id()]; DCHECK_OR_RETURN_VOID(pending_state); - ApplyRegularState(application, pending_state); + ApplyRegularState(application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + pending_state); } } @@ -919,7 +1085,33 @@ void StateControllerImpl::OnAppActivated( return; } - SetRegularState(app, HMILevel::HMI_FULL, true); + WindowID window_id = mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + if (message[strings::msg_params].keyExists(strings::window_id)) { + window_id = message[strings::msg_params][strings::window_id].asInt(); + } + + const auto window_ids = app->GetWindowIds(); + if (!helpers::in_range(window_ids, window_id)) { + LOG4CXX_ERROR( + logger_, + "Application " << app_id << " does not contain window #" << window_id); + return; + } + + if (PredefinedWindows::DEFAULT_WINDOW != window_id) { + const auto window_hmi_level = app->hmi_level(window_id); + const HMILevel::eType new_hmi_level = HMILevel::HMI_NONE == window_hmi_level + ? HMILevel::HMI_BACKGROUND + : HMILevel::HMI_FULL; + const AudioStreamingState::eType audio_state = app->audio_streaming_state(); + const VideoStreamingState::eType video_state = app->video_streaming_state(); + + SetRegularState( + app, window_id, new_hmi_level, audio_state, video_state, false); + return; + } + + SetRegularState(app, window_id, HMILevel::HMI_FULL, true); } void StateControllerImpl::OnAppDeactivated( @@ -934,13 +1126,39 @@ void StateControllerImpl::OnAppDeactivated( return; } - if (HMILevel::HMI_FULL != app->hmi_level()) { + WindowID window_id = mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + if (message[strings::msg_params].keyExists(strings::window_id)) { + window_id = message[strings::msg_params][strings::window_id].asInt(); + } + + const auto window_ids = app->GetWindowIds(); + if (!helpers::in_range(window_ids, window_id)) { + LOG4CXX_ERROR( + logger_, + "Application " << app_id << " does not contain window #" << window_id); + return; + } + + const auto window_hmi_level = app->hmi_level(window_id); + if (PredefinedWindows::DEFAULT_WINDOW != window_id) { + const HMILevel::eType new_hmi_level = HMILevel::HMI_FULL == window_hmi_level + ? HMILevel::HMI_BACKGROUND + : HMILevel::HMI_NONE; + const AudioStreamingState::eType audio_state = app->audio_streaming_state(); + const VideoStreamingState::eType video_state = app->video_streaming_state(); + + SetRegularState( + app, window_id, new_hmi_level, audio_state, video_state, false); + return; + } + + if (HMILevel::HMI_FULL != window_hmi_level) { return; } // TODO(AOleynik): Need to delete DeactivateReason and modify OnAppDeactivated // when HMI will support that, otherwise won't be testable - DeactivateApp(app); + DeactivateApp(app, window_id); } void StateControllerImpl::OnVideoStreamingStarted( diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc index f5d08a8ebf..deb92d5d81 100644 --- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -82,6 +82,13 @@ void SystemTimeHandlerImpl::DoSubscribe(utils::SystemTimeListener* listener) { system_time_listener_ = listener; } +void SystemTimeHandlerImpl::ResetPendingSystemTimeRequests() { + LOG4CXX_AUTO_TRACE(logger_); + unsubscribe_from_event( + hmi_apis::FunctionID::BasicCommunication_GetSystemTime); + awaiting_get_system_time_ = false; +} + void SystemTimeHandlerImpl::DoUnsubscribe(utils::SystemTimeListener* listener) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(system_time_listener_lock_); @@ -145,6 +152,14 @@ void SystemTimeHandlerImpl::ProcessSystemTimeResponse( const application_manager::event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); + + const auto result = static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS != result) { + system_time_listener_->OnSystemTimeFailed(); + } + const smart_objects::SmartObject& system_time_so = message[strings::msg_params][hmi_response::system_time]; diff --git a/src/components/application_manager/src/usage_statistics.cc b/src/components/application_manager/src/usage_statistics.cc index 1cfccd816e..3f1831f449 100644 --- a/src/components/application_manager/src/usage_statistics.cc +++ b/src/components/application_manager/src/usage_statistics.cc @@ -31,9 +31,9 @@ */ #include "application_manager/usage_statistics.h" -#include "smart_objects/smart_object.h" -#include "smart_objects/enum_schema_item.h" #include "policy/usage_statistics/statistics_manager.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "utils/macro.h" using namespace mobile_apis; diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index 4851a6b37e..f6146f96f9 100755 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -46,6 +46,7 @@ include_directories( ${COMPONENTS_DIR}/security_manager/include/ ${COMPONENTS_DIR}/application_manager/test/include/ ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/ + ${COMPONENTS_DIR}/application_manager/rpc_plugins/vehicle_info_plugin/include/ ${BSON_INCLUDE_DIRECTORY} ) @@ -56,6 +57,7 @@ set(testSources ${AM_TEST_DIR}/request_info_test.cc ${AM_TEST_DIR}/resumption_sql_queries_test.cc ${AM_TEST_DIR}/event_engine_test.cc + ${AM_TEST_DIR}/mobile_event_engine_test.cc ${AM_TEST_DIR}/policy_event_observer_test.cc ${AM_TEST_DIR}/application_impl_test.cc ${AM_TEST_DIR}/hmi_capabilities_test.cc @@ -64,6 +66,7 @@ set(testSources ${AM_TEST_DIR}/usage_statistics_test.cc ${AM_TEST_DIR}/policy_handler_test.cc ${AM_TEST_DIR}/app_service_manager_test.cc + ${AM_TEST_DIR}/rpc_passing_handler_test.cc ${AM_TEST_DIR}/application_manager_impl_test.cc ${AM_TEST_DIR}/application_helper_test.cc ${AM_TEST_DIR}/command_holder_test.cc @@ -86,7 +89,7 @@ set (RequestController_SOURCES set(LIBRARIES Utils ApplicationManager - sdl_rpc_plugin + sdl_rpc_plugin_static jsoncpp Policy connectionHandler @@ -152,6 +155,7 @@ set(ResumptionData_SOURCES file(COPY hmi_capabilities.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY hmi_capabilities_sc1.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY hmi_capabilities_sc2.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY hmi_capabilities_old_apt.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY smartDeviceLink_test.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/resumption) diff --git a/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc b/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc index 3293a8908d..b3bb8dd705 100644 --- a/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc +++ b/src/components/application_manager/test/app_launch/app_launch_ctrl_test.cc @@ -30,16 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" #include <sstream> -#include "utils/macro.h" #include "application_manager/app_launch/app_launch_ctrl_impl.h" #include "application_manager/mock_app_launch_data.h" #include "application_manager/mock_app_launch_settings.h" -#include "application_manager/mock_resume_ctrl.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_resume_ctrl.h" #include "connection_handler/mock_connection_handler.h" +#include "gtest/gtest.h" +#include "utils/macro.h" #include "utils/test_async_waiter.h" @@ -47,14 +47,14 @@ namespace test { namespace components { namespace app_launch_test { +using ::testing::AtLeast; +using ::testing::DoAll; +using ::testing::InSequence; +using ::testing::Invoke; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; using ::testing::Truly; -using ::testing::NiceMock; -using ::testing::Invoke; -using ::testing::AtLeast; -using ::testing::InSequence; -using ::testing::DoAll; namespace ch_test = test::components::connection_handler_test; namespace am_test = test::components::application_manager_test; diff --git a/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc index dc96fcf176..d0f2e21f4c 100644 --- a/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc +++ b/src/components/application_manager/test/app_launch/app_launch_data_db_test.cc @@ -31,18 +31,18 @@ */ #include <algorithm> +#include <memory> #include <sstream> #include <string> -#include <memory> #include "gtest/gtest.h" -#include "utils/macro.h" #include "sql_database.h" #include "sql_query.h" +#include "utils/macro.h" -#include "utils/file_system.h" -#include "application_manager/mock_app_launch_settings.h" #include "application_manager/app_launch/app_launch_data_db.h" #include "application_manager/app_launch/app_launch_sql_queries.h" +#include "application_manager/mock_app_launch_settings.h" +#include "utils/file_system.h" namespace test { namespace components { @@ -51,9 +51,9 @@ namespace app_launch_test { using namespace file_system; using namespace app_launch; -using ::testing::ReturnRef; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; namespace { const std::string kEmptyString = ""; diff --git a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc index 4541970c70..12a375685e 100644 --- a/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc +++ b/src/components/application_manager/test/app_launch/app_launch_data_json_test.cc @@ -30,27 +30,27 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/app_launch/app_launch_data_json.h" #include <algorithm> -#include <sstream> #include <memory> -#include "json/json.h" +#include <sstream> +#include "application_manager/mock_app_launch_settings.h" +#include "application_manager/smart_object_keys.h" #include "gtest/gtest.h" -#include "utils/macro.h" -#include "utils/file_system.h" -#include "utils/date_time.h" +#include "json/json.h" #include "resumption/last_state_impl.h" #include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_app_launch_settings.h" -#include "application_manager/app_launch/app_launch_data_json.h" +#include "utils/date_time.h" +#include "utils/file_system.h" +#include "utils/macro.h" namespace test { namespace components { namespace test_app_launch { using ::testing::_; -using ::testing::Return; using ::testing::NiceMock; +using ::testing::Return; namespace am = application_manager; using namespace Json; @@ -339,6 +339,6 @@ TEST_F(AppLaunchDataJsonTest, SelectMultipleData) { } } -} // namespace app_launch +} // namespace test_app_launch } // namespace components } // namespace test diff --git a/src/components/application_manager/test/app_service_manager_test.cc b/src/components/application_manager/test/app_service_manager_test.cc index 526bbbdb7d..daabdeedf4 100644 --- a/src/components/application_manager/test/app_service_manager_test.cc +++ b/src/components/application_manager/test/app_service_manager_test.cc @@ -60,6 +60,7 @@ const std::string kServiceType = "MEDIA"; const std::string kServiceName = "service_name"; const std::string kServiceId = "service_id"; const std::string kPolicyAppId = "p_app_id"; +const std::string kPolicyAppId2 = "p_app_id2"; const uint32_t kConnectionKey = 43629; const uint32_t kHMIConnectionKey = 0; @@ -83,6 +84,7 @@ class AppServiceManagerTest : public testing::Test { public: AppServiceManagerTest() : mock_app_ptr_(new MockApplication) + , mock_app_ptr2_(new MockApplication) , app_service_manager_(mock_app_manager_, mock_last_state_) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) { @@ -101,10 +103,15 @@ class AppServiceManagerTest : public testing::Test { .WillByDefault(ReturnRef(mock_settings_)); ON_CALL(*mock_app_ptr_, policy_app_id()) .WillByDefault(Return(kPolicyAppId)); + ON_CALL(*mock_app_ptr2_, policy_app_id()) + .WillByDefault(Return(kPolicyAppId2)); ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(dict_)); auto app_ptr = std::static_pointer_cast<am::Application>(mock_app_ptr_); + auto app_ptr2 = std::static_pointer_cast<am::Application>(mock_app_ptr2_); ON_CALL(mock_app_manager_, application(kConnectionKey)) .WillByDefault(Return(app_ptr)); + ON_CALL(mock_app_manager_, application(kConnectionKey + 1)) + .WillByDefault(Return(app_ptr2)); } protected: @@ -134,13 +141,15 @@ class AppServiceManagerTest : public testing::Test { BroadcastCapabilityUpdate( CapabilityUpdateMatcher( mobile_apis::ServiceUpdateReason::PUBLISHED), - _)).WillOnce(Return()); + _)) + .WillOnce(Return()); if (first_run) { EXPECT_CALL(*mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher( mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(Return()); + _)) + .WillOnce(Return()); } bool mobile_service = connection_key != kHMIConnectionKey; return app_service_manager_.PublishAppService( @@ -153,16 +162,17 @@ class AppServiceManagerTest : public testing::Test { mobile_apis::ServiceUpdateReason::eType reason, bool published, bool active) { - smart_objects::SmartObject& services_updated = msg_params - [am::strings::system_capability][am::strings::app_services_capabilities] - [am::strings::app_services]; + smart_objects::SmartObject& services_updated = + msg_params[am::strings::system_capability] + [am::strings::app_services_capabilities] + [am::strings::app_services]; ASSERT_EQ(smart_objects::SmartType_Array, services_updated.getType()); EXPECT_EQ(length, services_updated.length()); for (size_t i = 0; i < services_updated.length(); i++) { smart_objects::SmartObject& service_cap = services_updated[i]; - if (service_id == - service_cap[am::strings::updated_app_service_record] - [am::strings::service_id].asString()) { + if (service_id == service_cap[am::strings::updated_app_service_record] + [am::strings::service_id] + .asString()) { CheckCapability(service_cap, service_id, reason, published, active); return; } @@ -189,6 +199,7 @@ class AppServiceManagerTest : public testing::Test { Json::Value dict_; std::vector<std::string> embedded_services_; std::shared_ptr<MockApplication> mock_app_ptr_; + std::shared_ptr<MockApplication> mock_app_ptr2_; MockApplicationManager mock_app_manager_; resumption_test::MockLastState mock_last_state_; MockApplicationManagerSettings mock_settings_; @@ -208,14 +219,16 @@ TEST_F(AppServiceManagerTest, PublishAppService_Mobile_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); smart_objects::SmartObject syscap_update_activated; EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); auto record = app_service_manager_.PublishAppService(manifest, true, kConnectionKey); @@ -255,14 +268,16 @@ TEST_F(AppServiceManagerTest, PublishAppService_HMI_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::PUBLISHED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_published), Return())); smart_objects::SmartObject syscap_update_activated; EXPECT_CALL( *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); auto record = app_service_manager_.PublishAppService(manifest, false); @@ -297,7 +312,8 @@ TEST_F(AppServiceManagerTest, UnpublishAppService_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::REMOVED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_unpublished), Return())); std::string service_id = record[am::strings::service_id].asString(); EXPECT_TRUE(app_service_manager_.UnpublishAppService(service_id)); @@ -319,7 +335,8 @@ TEST_F(AppServiceManagerTest, ActivateAppService_AlreadyActivated) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).Times(0); + _)) + .Times(0); std::string service_id = record[am::strings::service_id].asString(); EXPECT_TRUE(app_service_manager_.ActivateAppService(service_id)); @@ -337,7 +354,8 @@ TEST_F(AppServiceManagerTest, ActivateAppService_TwoApps_SUCCESS) { *mock_message_helper_, BroadcastCapabilityUpdate( CapabilityUpdateMatcher(mobile_apis::ServiceUpdateReason::ACTIVATED), - _)).WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); + _)) + .WillOnce(DoAll(SaveArg<0>(&syscap_update_activated), Return())); std::string service_id = record[am::strings::service_id].asString(); std::string service_id2 = record2[am::strings::service_id].asString(); diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index 3203839fc2..d9d590a171 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -36,42 +36,42 @@ #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_message_helper.h" -#include "policy/usage_statistics/mock_statistics_manager.h" #include "policy/mock_policy_settings.h" +#include "policy/usage_statistics/mock_statistics_manager.h" #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" -#include "application_manager/usage_statistics.h" #include "application_manager/helpers/application_helper.h" #include "application_manager/smart_object_keys.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/usage_statistics.h" #include "connection_handler/device.h" +#include "interfaces/MOBILE_API.h" #include "smart_objects/smart_object.h" #include "utils/custom_string.h" #include "utils/macro.h" -#include "test/resumption/mock_last_state.h" #include "media_manager/mock_media_manager.h" +#include "test/resumption/mock_last_state.h" namespace { const uint8_t expected_tread_pool_size = 2u; const uint8_t stop_streaming_timeout = 1u; const std::string kDirectoryName = "./test_storage"; const std::vector<std::string> kTimeoutPrompt{"timeoutPrompt"}; -} +} // namespace namespace test { namespace components { namespace application_manager_test { +using resumption_test::MockLastState; +using test::components::media_manager_test::MockMediaManager; using testing::_; using ::testing::Mock; using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using resumption_test::MockLastState; -using test::components::media_manager_test::MockMediaManager; using namespace application_manager; using namespace policy_handler_test; @@ -255,6 +255,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectHMICleanupRequests) { application_manager::DeleteApplicationData(app_impl_, app_manager_impl_); } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc index 437f567538..7b45d387f7 100644 --- a/src/components/application_manager/test/application_impl_test.cc +++ b/src/components/application_manager/test/application_impl_test.cc @@ -35,23 +35,23 @@ #include <stdint.h> #include <iostream> -#include "gtest/gtest.h" #include "application_manager/hmi_state.h" +#include "gtest/gtest.h" #include "utils/file_system.h" -#include "application_manager/mock_message_helper.h" -#include "utils/custom_string.h" +#include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_request_controller_settings.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/state_controller.h" -#include "resumption/last_state.h" -#include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/mock_resume_ctrl.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/state_controller.h" #include "policy/usage_statistics/mock_statistics_manager.h" +#include "resumption/last_state.h" #include "smart_objects/smart_object.h" +#include "utils/custom_string.h" namespace test { namespace components { @@ -63,13 +63,20 @@ using namespace mobile_apis; namespace custom_str = utils::custom_string; using ::testing::_; +using ::testing::AtLeast; using ::testing::Mock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::AtLeast; using usage_statistics_test::MockStatisticsManager; -typedef void (ApplicationImpl::*AddSet)(HmiStatePtr args); +typedef void (ApplicationImpl::*AddSet)(const WindowID window_id, + HmiStatePtr args); + +namespace { +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const std::string kDefaultWindowName = "DefaultName"; +} // namespace class ApplicationImplTest : public ::testing::Test { protected: @@ -91,9 +98,11 @@ class ApplicationImplTest : public ::testing::Test { EXPECT_CALL(mock_application_manager_settings_, app_storage_folder()) .WillRepeatedly(ReturnRef(directory_name)); EXPECT_CALL(mock_application_manager_settings_, - audio_data_stopped_timeout()).WillOnce(Return(0)); + audio_data_stopped_timeout()) + .WillOnce(Return(0)); EXPECT_CALL(mock_application_manager_settings_, - video_data_stopped_timeout()).WillOnce(Return(0)); + video_data_stopped_timeout()) + .WillOnce(Return(0)); app_impl.reset( new ApplicationImpl(app_id, policy_app_id, @@ -104,7 +113,8 @@ class ApplicationImplTest : public ::testing::Test { mock_application_manager_)); HmiStatePtr initial_state = CreateTestHmiState(); - app_impl->SetInitialState(initial_state); + app_impl->SetInitialState( + kDefaultWindowId, kDefaultWindowName, initial_state); } virtual void TearDown() OVERRIDE { @@ -157,12 +167,12 @@ HmiStatePtr ApplicationImplTest::TestAddHmiState(HMILevel::eType hmi_lvl, test_lvl = hmi_lvl; state_id = id_state; HmiStatePtr state = CreateTestHmiState(); - ((app_impl.get())->*hmi_action)(state); + ((app_impl.get())->*hmi_action)(kDefaultWindowId, state); return state; } void ApplicationImplTest::CheckCurrentHMIState() { - HmiStatePtr current_state = app_impl->CurrentHmiState(); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(test_lvl, current_state->hmi_level()); EXPECT_EQ(state_id, current_state->state_id()); } @@ -205,7 +215,7 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetRegularState) { HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); - HmiStatePtr current_state = app_impl->RegularHmiState(); + HmiStatePtr current_state = app_impl->RegularHmiState(kDefaultWindowId); EXPECT_EQ(HMILevel::HMI_FULL, current_state->hmi_level()); EXPECT_EQ(HmiState::STATE_ID_REGULAR, current_state->state_id()); EXPECT_EQ(app_id, app_impl->app_id()); @@ -226,8 +236,8 @@ TEST_F(ApplicationImplTest, AddStates_RemoveLastState) { CheckCurrentHMIState(); // Remove last state - app_impl->RemoveHMIState(state3->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state3->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state2, current_state); EXPECT_EQ(HMILevel::HMI_NONE, current_state->hmi_level()); EXPECT_EQ(HmiState::STATE_ID_VIDEO_STREAMING, current_state->state_id()); @@ -247,8 +257,8 @@ TEST_F(ApplicationImplTest, AddStates_RemoveNotLastNotFirstState) { CheckCurrentHMIState(); // Remove not last state - app_impl->RemoveHMIState(state2->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state2->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state3, current_state); // HMI level is equal to parent hmi_level EXPECT_EQ(HMILevel::HMI_FULL, current_state->hmi_level()); @@ -270,8 +280,8 @@ TEST_F(ApplicationImplTest, AddStates_RemoveFirstState) { CheckCurrentHMIState(); // Remove first added state - app_impl->RemoveHMIState(state1->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state1->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state3, current_state); // Last state does not have a parent EXPECT_EQ(HMILevel::HMI_LIMITED, current_state->hmi_level()); @@ -293,8 +303,8 @@ TEST_F(ApplicationImplTest, SetRegularState_RemoveFirstState) { CheckCurrentHMIState(); // Remove first state - app_impl->RemoveHMIState(state1->state_id()); - HmiStatePtr current_state = app_impl->CurrentHmiState(); + app_impl->RemoveHMIState(kDefaultWindowId, state1->state_id()); + HmiStatePtr current_state = app_impl->CurrentHmiState(kDefaultWindowId); EXPECT_EQ(state3, current_state); // Last state has a parent EXPECT_EQ(HMILevel::HMI_FULL, current_state->hmi_level()); @@ -309,12 +319,12 @@ TEST_F(ApplicationImplTest, SetPostponedState_RemovePostponedState) { &ApplicationImpl::SetPostponedState); // Check that state was setted correctly - HmiStatePtr state2 = app_impl->PostponedHmiState(); + HmiStatePtr state2 = app_impl->PostponedHmiState(kDefaultWindowId); EXPECT_EQ(state1, state2); // Check that state was correctly removed - app_impl->RemovePostponedState(); - state2 = app_impl->PostponedHmiState(); + app_impl->RemovePostponedState(kDefaultWindowId); + state2 = app_impl->PostponedHmiState(kDefaultWindowId); EXPECT_EQ(nullptr, state2); } @@ -325,9 +335,9 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetHmiLvlAudioSystemState) { HmiState::STATE_ID_REGULAR, &ApplicationImpl::SetRegularState); - EXPECT_EQ(test_lvl, app_impl->hmi_level()); + EXPECT_EQ(test_lvl, app_impl->hmi_level(kDefaultWindowId)); EXPECT_EQ(audiostate, app_impl->audio_streaming_state()); - EXPECT_EQ(syst_context, app_impl->system_context()); + EXPECT_EQ(syst_context, app_impl->system_context(kDefaultWindowId)); audiostate = AudioStreamingState::AUDIBLE; syst_context = SystemContext::SYSCTXT_MENU; @@ -335,9 +345,9 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetHmiLvlAudioSystemState) { HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); - EXPECT_EQ(test_lvl, app_impl->hmi_level()); + EXPECT_EQ(test_lvl, app_impl->hmi_level(kDefaultWindowId)); EXPECT_EQ(audiostate, app_impl->audio_streaming_state()); - EXPECT_EQ(syst_context, app_impl->system_context()); + EXPECT_EQ(syst_context, app_impl->system_context(kDefaultWindowId)); } TEST_F(ApplicationImplTest, IsAudioApplication) { @@ -563,7 +573,9 @@ TEST_F(ApplicationImplTest, SubscribeToSoftButton_UnsubscribeFromSoftButton) { SoftButtonID test_button; for (uint i = 0; i < btn_count; i++) { - test_button.insert(i); + test_button.insert(std::make_pair( + i, + static_cast<WindowID>(mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); } app_impl->SubscribeToSoftButtons(FunctionID::ScrollableMessageID, test_button); @@ -666,7 +678,8 @@ TEST_F(ApplicationImplTest, TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) { EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendHashUpdateNotification(app_id, _)).Times(1); + SendHashUpdateNotification(app_id, _)) + .Times(1); resumprion_test::MockResumeCtrl mock_resume_ctrl; EXPECT_CALL(mock_application_manager_, resume_controller()) .WillOnce(ReturnRef(mock_resume_ctrl)); @@ -678,7 +691,8 @@ TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) { TEST_F(ApplicationImplTest, UpdateHash_AppMngrSuspended) { EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendHashUpdateNotification(app_id, _)).Times(0); + SendHashUpdateNotification(app_id, _)) + .Times(0); resumprion_test::MockResumeCtrl mock_resume_ctrl; EXPECT_CALL(mock_application_manager_, resume_controller()) .WillOnce(ReturnRef(mock_resume_ctrl)); @@ -699,7 +713,8 @@ TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingNotApproved) { TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingApproved) { app_impl->set_video_streaming_approved(true); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendNaviSetVideoConfig(app_id, _, _)).Times(0); + SendNaviSetVideoConfig(app_id, _, _)) + .Times(0); smart_objects::SmartObject params; app_impl->SetVideoConfig(protocol_handler::ServiceType::kMobileNav, params); @@ -707,7 +722,8 @@ TEST_F(ApplicationImplTest, SetVideoConfig_MobileNavi_StreamingApproved) { TEST_F(ApplicationImplTest, SetVideoConfig_NotMobileNavi) { EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendNaviSetVideoConfig(app_id, _, _)).Times(0); + SendNaviSetVideoConfig(app_id, _, _)) + .Times(0); smart_objects::SmartObject params; app_impl->SetVideoConfig(protocol_handler::ServiceType::kAudio, params); @@ -732,13 +748,15 @@ TEST_F(ApplicationImplTest, StartStreaming_Audio_StreamingNotApproved) { TEST_F(ApplicationImplTest, StartStreaming_StreamingApproved) { app_impl->set_video_streaming_approved(true); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendNaviStartStream(app_id, _)).Times(0); + SendNaviStartStream(app_id, _)) + .Times(0); app_impl->StartStreaming(protocol_handler::ServiceType::kMobileNav); app_impl->set_audio_streaming_approved(true); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), - SendAudioStartStream(app_id, _)).Times(0); + SendAudioStartStream(app_id, _)) + .Times(0); app_impl->StartStreaming(protocol_handler::ServiceType::kAudio); } diff --git a/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc b/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc index 8ab852779a..939ef98620 100644 --- a/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc +++ b/src/components/application_manager/test/application_manager_impl_mock_hmi_test.cc @@ -33,25 +33,25 @@ #include <memory> #include <string> -#include "gtest/gtest.h" #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" +#include "gtest/gtest.h" #include "utils/custom_string.h" #include "encryption/hashing.h" #include "application_manager/mock_application_manager_settings.h" -#include "application_manager/mock_resumption_data.h" #include "application_manager/mock_command_factory.h" #include "application_manager/mock_request.h" +#include "application_manager/mock_resumption_data.h" +#include "application_manager/mock_rpc_plugin.h" +#include "application_manager/mock_rpc_plugin_manager.h" #include "connection_handler/mock_connection_handler.h" #include "policy/mock_policy_settings.h" #include "policy/usage_statistics/mock_statistics_manager.h" -#include "protocol_handler/mock_session_observer.h" #include "protocol_handler/mock_protocol_handler.h" -#include "application_manager/mock_rpc_plugin_manager.h" -#include "application_manager/mock_rpc_plugin.h" +#include "protocol_handler/mock_session_observer.h" #include "utils/optional.h" namespace test { @@ -63,9 +63,9 @@ namespace am = application_manager; using testing::_; using ::testing::DoAll; using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; using ::testing::SetArgPointee; using namespace application_manager; @@ -269,6 +269,6 @@ TEST_F(ApplicationManagerImplMockHmiTest, Mock::VerifyAndClearExpectations(&mock_command_factory); } -} // application_manager_test +} // namespace application_manager_test } // namespace components } // namespace test 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 83e7717b7c..152d577cda 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -39,12 +39,14 @@ #include "application_manager/application.h" #include "application_manager/application_impl.h" #include "application_manager/application_manager_impl.h" +#include "application_manager/hmi_state.h" +#include "application_manager/mock_app_service_manager.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/mock_app_service_manager.h" #include "application_manager/mock_rpc_plugin_manager.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/mock_state_controller.h" #include "application_manager/policies/mock_policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/test/include/application_manager/mock_message_helper.h" @@ -88,6 +90,9 @@ using ::testing::SaveArg; using ::testing::SetArgPointee; using ::testing::SetArgReferee; +using test::components::application_manager_test::MockStateController; +using test::components::policy_test::MockPolicyHandlerInterface; + using namespace application_manager; // custom action to call a member function with 4 arguments @@ -96,12 +101,21 @@ ACTION_P6(InvokeMemberFuncWithArg4, ptr, memberFunc, a, b, c, d) { } namespace { +const uint32_t kCorrelationID = 54321u; const std::string kDirectoryName = "./test_storage"; const uint32_t kTimeout = 10000u; connection_handler::DeviceHandle kDeviceId = 12345u; const std::string kAppId = "someID"; const uint32_t kConnectionKey = 1232u; const std::string kAppName = "appName"; +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; + +typedef hmi_apis::Common_ServiceStatusUpdateReason::eType + ServiceStatusUpdateReason; +typedef hmi_apis::Common_ServiceType::eType ServiceType; +typedef hmi_apis::Common_ServiceEvent::eType ServiceEvent; +typedef utils::Optional<ServiceStatusUpdateReason> UpdateReasonOptional; #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) // Cloud application params @@ -117,7 +131,20 @@ const bool kEnabled = true; #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT } // namespace -class ApplicationManagerImplTest : public ::testing::Test { +struct ServiceStatus { + ServiceType service_type_; + ServiceEvent service_event_; + UpdateReasonOptional reason_; + + ServiceStatus(ServiceType type, + ServiceEvent event, + UpdateReasonOptional reason) + : service_type_(type), service_event_(event), reason_(reason) {} +}; + +class ApplicationManagerImplTest + : public ::testing::Test, + public ::testing::WithParamInterface<ServiceStatus> { public: ApplicationManagerImplTest() : app_id_(0u) @@ -125,12 +152,14 @@ class ApplicationManagerImplTest : public ::testing::Test { std::make_shared<NiceMock<resumption_test::MockResumptionData> >( mock_app_mngr_)) , mock_rpc_service_(new MockRPCService) - , mock_policy_handler_( - new test::components::policy_test::MockPolicyHandlerInterface) + , mock_policy_handler_(new NiceMock<MockPolicyHandlerInterface>) , mock_app_service_manager_( new MockAppServiceManager(mock_app_mngr_, mock_last_state_)) , mock_message_helper_( application_manager::MockMessageHelper::message_helper_mock()) + , mock_statistics_manager_( + std::make_shared< + NiceMock<usage_statistics_test::MockStatisticsManager> >()) { #ifdef ENABLE_LOG @@ -138,17 +167,35 @@ class ApplicationManagerImplTest : public ::testing::Test { #endif Mock::VerifyAndClearExpectations(mock_message_helper_); } - ~ApplicationManagerImplTest() { + ~ApplicationManagerImplTest() OVERRIDE { Mock::VerifyAndClearExpectations(mock_message_helper_); } protected: void SetUp() OVERRIDE { CreateAppManager(); + ON_CALL(mock_state_ctrl_, + SetRegularState(_, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + mobile_apis::HMILevel::HMI_NONE, + true)); + ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*mock_app_ptr_, device()).WillByDefault(Return(kDeviceId)); + + HmiStatePtr hmi_state(std::make_shared<HmiState>( + mock_app_ptr_, mock_app_mngr_, HmiState::STATE_ID_REGULAR)); + + ON_CALL(*mock_app_ptr_, + RegularHmiState(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(hmi_state)); + ON_CALL(mock_session_observer_, GetDataOnSessionKey(_, _, _, _)) .WillByDefault(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); + ON_CALL(mock_connection_handler_, GetDataOnSessionKey(_, _, _, &kDeviceId)) + .WillByDefault(DoAll(SetArgPointee<3u>(app_id_), Return(0))); ON_CALL(mock_connection_handler_, get_session_observer()) .WillByDefault(ReturnRef(mock_session_observer_)); + app_manager_impl_->SetMockRPCService(mock_rpc_service_); app_manager_impl_->resume_controller().set_resumption_storage( mock_storage_); @@ -160,6 +207,16 @@ class ApplicationManagerImplTest : public ::testing::Test { app_manager_impl_->SetAppServiceManager(mock_app_service_manager_); Json::Value empty; ON_CALL(mock_last_state_, get_dictionary()).WillByDefault(ReturnRef(empty)); + + auto request = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + ON_CALL(*mock_message_helper_, CreateModuleInfoSO(_, _)) + .WillByDefault(Return(request)); + ON_CALL(*mock_message_helper_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map))); + ON_CALL(*mock_policy_handler_, GetStatisticManager()) + .WillByDefault(Return(mock_statistics_manager_)); } void CreateAppManager() { @@ -179,16 +236,35 @@ class ApplicationManagerImplTest : public ::testing::Test { ON_CALL(mock_application_manager_settings_, default_timeout()) .WillByDefault(ReturnRef(kTimeout)); ON_CALL(mock_application_manager_settings_, - application_list_update_timeout()).WillByDefault(Return(kTimeout)); + application_list_update_timeout()) + .WillByDefault(Return(kTimeout)); app_manager_impl_.reset(new am::ApplicationManagerImpl( mock_application_manager_settings_, mock_policy_settings_)); - mock_app_ptr_ = std::shared_ptr<MockApplication>(new MockApplication()); + mock_app_ptr_ = std::shared_ptr<NiceMock<MockApplication> >( + new NiceMock<MockApplication>()); app_manager_impl_->set_protocol_handler(&mock_protocol_handler_); + app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); ASSERT_TRUE(app_manager_impl_.get()); ASSERT_TRUE(mock_app_ptr_.get()); } + application_manager::commands::MessageSharedPtr CreateCloseAppMessage() { + using namespace application_manager; + + smart_objects::SmartObjectSPtr message = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_CloseApplication; + (*message)[strings::params][strings::message_type] = MessageType::kRequest; + (*message)[strings::params][strings::correlation_id] = kCorrelationID; + (*message)[strings::msg_params][strings::app_id] = kAppId; + + return message; + } + void AddMockApplication() { app_manager_impl_->AddMockApplication(mock_app_ptr_); } @@ -228,27 +304,101 @@ class ApplicationManagerImplTest : public ::testing::Test { #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) void AddCloudAppToPendingDeviceMap(); + void CreatePendingApplication(); #endif uint32_t app_id_; NiceMock<policy_test::MockPolicySettings> mock_policy_settings_; std::shared_ptr<NiceMock<resumption_test::MockResumptionData> > mock_storage_; + MockStateController mock_state_ctrl_; MockRPCService* mock_rpc_service_; resumption_test::MockLastState mock_last_state_; NiceMock<con_test::MockConnectionHandler> mock_connection_handler_; NiceMock<protocol_handler_test::MockSessionObserver> mock_session_observer_; NiceMock<MockApplicationManagerSettings> mock_application_manager_settings_; - test::components::policy_test::MockPolicyHandlerInterface* - mock_policy_handler_; + NiceMock<MockPolicyHandlerInterface>* mock_policy_handler_; application_manager_test::MockApplicationManager mock_app_mngr_; std::unique_ptr<am::ApplicationManagerImpl> app_manager_impl_; MockAppServiceManager* mock_app_service_manager_; application_manager::MockMessageHelper* mock_message_helper_; - std::shared_ptr<MockApplication> mock_app_ptr_; + std::shared_ptr<NiceMock<MockApplication> > mock_app_ptr_; NiceMock<protocol_handler_test::MockProtocolHandler> mock_protocol_handler_; + std::shared_ptr<NiceMock<usage_statistics_test::MockStatisticsManager> > + mock_statistics_manager_; }; +INSTANTIATE_TEST_CASE_P( + ProcessServiceStatusUpdate_REQUEST_ACCEPTED, + ApplicationManagerImplTest, + ::testing::Values(ServiceStatus(ServiceType::AUDIO, + ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::VIDEO, + ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::RPC, + ServiceEvent::REQUEST_ACCEPTED, + UpdateReasonOptional::EMPTY))); + +INSTANTIATE_TEST_CASE_P( + ProcessServiceStatusUpdate_REQUEST_RECEIVED, + ApplicationManagerImplTest, + ::testing::Values(ServiceStatus(ServiceType::AUDIO, + ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::VIDEO, + ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::RPC, + ServiceEvent::REQUEST_RECEIVED, + UpdateReasonOptional::EMPTY))); + +INSTANTIATE_TEST_CASE_P( + ProcessServiceStatusUpdate_REQUEST_REJECTED, + ApplicationManagerImplTest, + ::testing::Values(ServiceStatus(ServiceType::AUDIO, + ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::VIDEO, + ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional::EMPTY), + ServiceStatus(ServiceType::RPC, + ServiceEvent::REQUEST_REJECTED, + UpdateReasonOptional::EMPTY))); + +TEST_P(ApplicationManagerImplTest, + ProcessServiceStatusUpdate_SendMessageToHMI) { + smart_objects::SmartObjectSPtr notification_ = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + (*notification_)[strings::msg_params][hmi_notification::service_type] = + GetParam().service_type_; + (*notification_)[strings::msg_params][hmi_notification::service_event] = + GetParam().service_event_; + (*notification_)[strings::msg_params][strings::app_id] = kConnectionKey; + + AddMockApplication(); + + ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kConnectionKey)); + + auto close_message = CreateCloseAppMessage(); + ON_CALL(*mock_message_helper_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(close_message)); + ON_CALL(*mock_message_helper_, CreateOnServiceUpdateNotification(_, _, _, _)) + .WillByDefault(Return(notification_)); + + ON_CALL(*mock_rpc_service_, ManageHMICommand(notification_, _)) + .WillByDefault(Return(true)); + ON_CALL(*mock_rpc_service_, ManageHMICommand(close_message, _)) + .WillByDefault(Return(true)); + + app_manager_impl_->ProcessServiceStatusUpdate(kConnectionKey, + GetParam().service_type_, + GetParam().service_event_, + GetParam().reason_); +} + TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) { using namespace ns_smart_device_link::ns_smart_objects; SmartObject app_data; @@ -382,7 +532,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_VideoServiceStart) { 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -413,7 +563,7 @@ TEST_F(ApplicationManagerImplTest, 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -444,7 +594,7 @@ TEST_F(ApplicationManagerImplTest, 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); bool result = false; @@ -474,7 +624,7 @@ TEST_F(ApplicationManagerImplTest, 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); bool result = false; @@ -558,7 +708,7 @@ TEST_F(ApplicationManagerImplTest, 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -632,7 +782,7 @@ TEST_F(ApplicationManagerImplTest, 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -667,7 +817,7 @@ TEST_F(ApplicationManagerImplTest, OnServiceStartedCallback_AudioServiceStart) { 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -697,7 +847,7 @@ TEST_F(ApplicationManagerImplTest, 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()) + EXPECT_CALL(*mock_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); bool result = false; @@ -818,6 +968,9 @@ TEST_F(ApplicationManagerImplTest, std::shared_ptr<MockApplication> switching_app_ptr = std::make_shared<MockApplication>(); + ON_CALL(*switching_app_ptr, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*switching_app_ptr, device()).WillByDefault(Return(kDeviceId)); + const std::string switching_device_id = "switching"; const std::string switching_device_id_hash = encryption::MakeHash(switching_device_id); @@ -830,7 +983,7 @@ TEST_F(ApplicationManagerImplTest, .WillRepeatedly(Return(policy_app_id_switch)); const auto hmi_level_switching_app = mobile_apis::HMILevel::HMI_FULL; - EXPECT_CALL(*switching_app_ptr, hmi_level()) + EXPECT_CALL(*switching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_switching_app)); std::shared_ptr<MockApplication> nonswitching_app_ptr = @@ -848,7 +1001,7 @@ TEST_F(ApplicationManagerImplTest, .WillRepeatedly(Return(policy_app_id_nonswitch)); const auto hmi_level_nonswitching_app = mobile_apis::HMILevel::HMI_LIMITED; - EXPECT_CALL(*nonswitching_app_ptr, hmi_level()) + EXPECT_CALL(*nonswitching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_nonswitching_app)); // Act @@ -866,15 +1019,18 @@ TEST_F(ApplicationManagerImplTest, .WillOnce(Return(smart_objects::SmartObjectSPtr())); app_manager_impl_->OnDeviceSwitchingStart(switching_device, non_switching_device); - EXPECT_TRUE(app_manager_impl_->IsAppInReconnectMode(policy_app_id_switch)); - EXPECT_FALSE( - app_manager_impl_->IsAppInReconnectMode(policy_app_id_nonswitch)); + EXPECT_TRUE( + app_manager_impl_->IsAppInReconnectMode(kDeviceId, policy_app_id_switch)); + EXPECT_FALSE(app_manager_impl_->IsAppInReconnectMode( + kDeviceId, policy_app_id_nonswitch)); } TEST_F(ApplicationManagerImplTest, OnDeviceSwitchingFinish_ExpectUnregisterAppsInWaitList) { std::shared_ptr<MockApplication> switching_app_ptr = std::make_shared<MockApplication>(); + ON_CALL(*switching_app_ptr, app_id()).WillByDefault(Return(kConnectionKey)); + ON_CALL(*switching_app_ptr, device()).WillByDefault(Return(kDeviceId)); plugin_manager::MockRPCPluginManager* mock_rpc_plugin_manager = new plugin_manager::MockRPCPluginManager; @@ -894,7 +1050,7 @@ TEST_F(ApplicationManagerImplTest, .WillRepeatedly(Return(policy_app_id_switch)); const auto hmi_level_switching_app = mobile_apis::HMILevel::HMI_FULL; - EXPECT_CALL(*switching_app_ptr, hmi_level()) + EXPECT_CALL(*switching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_switching_app)); std::shared_ptr<MockApplication> nonswitching_app_ptr = @@ -911,8 +1067,12 @@ TEST_F(ApplicationManagerImplTest, EXPECT_CALL(*nonswitching_app_ptr, policy_app_id()) .WillRepeatedly(Return(policy_app_id_nonswitch)); + ON_CALL(*nonswitching_app_ptr, protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); + const auto hmi_level_nonswitching_app = mobile_apis::HMILevel::HMI_LIMITED; - EXPECT_CALL(*nonswitching_app_ptr, hmi_level()) + EXPECT_CALL(*nonswitching_app_ptr, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(hmi_level_nonswitching_app)); // Act @@ -931,7 +1091,8 @@ TEST_F(ApplicationManagerImplTest, app_manager_impl_->OnDeviceSwitchingStart(switching_device, non_switching_device); - EXPECT_TRUE(app_manager_impl_->IsAppInReconnectMode(policy_app_id_switch)); + EXPECT_TRUE( + app_manager_impl_->IsAppInReconnectMode(kDeviceId, policy_app_id_switch)); app_manager_impl_->OnDeviceSwitchingFinish(switching_device_id); EXPECT_FALSE( @@ -1010,6 +1171,15 @@ TEST_F(ApplicationManagerImplTest, StartStopAudioPassThru) { } } +TEST_F(ApplicationManagerImplTest, + StopApplicationManager_ExpectStopRPCService) { + EXPECT_CALL(*mock_policy_handler_, UnloadPolicyLibrary()); + + EXPECT_CALL(*mock_rpc_service_, Stop()); + + app_manager_impl_->Stop(); +} + TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) { std::string dummy_file_name; ON_CALL(mock_application_manager_settings_, recording_file_name()) @@ -1157,9 +1327,10 @@ bool ApplicationManagerImplTest::CheckResumptionRequiredTransportAvailableTest( TransportTypeProfileStringFromDeviceHandle(secondary_device_handle)) .WillOnce(Return(secondary_transport_device_string)); } else { - EXPECT_CALL(mock_session_observer_, - TransportTypeProfileStringFromDeviceHandle( - secondary_device_handle)).WillOnce(Return(std::string(""))); + EXPECT_CALL( + mock_session_observer_, + TransportTypeProfileStringFromDeviceHandle(secondary_device_handle)) + .WillOnce(Return(std::string(""))); } return app_manager_impl_->CheckResumptionRequiredTransportAvailable( @@ -1452,7 +1623,6 @@ TEST_F(ApplicationManagerImplTest, #if defined(CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT) void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() { - app_manager_impl_->SetMockPolicyHandler(mock_policy_handler_); std::vector<std::string> enabled_apps{"1234"}; EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) .WillOnce(SetArgReferee<0>(enabled_apps)); @@ -1474,8 +1644,7 @@ void ApplicationManagerImplTest::AddCloudAppToPendingDeviceMap() { app_manager_impl_->RefreshCloudAppInformation(); } -TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { - // Add to pending device map. Calls refresh cloud app +void ApplicationManagerImplTest::CreatePendingApplication() { AddCloudAppToPendingDeviceMap(); // CreatePendingApplication @@ -1505,6 +1674,10 @@ TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { EXPECT_EQ(1u, app_list.size()); } +TEST_F(ApplicationManagerImplTest, CreatePendingApplication) { + CreatePendingApplication(); +} + TEST_F(ApplicationManagerImplTest, SetPendingState) { AddCloudAppToPendingDeviceMap(); AddMockApplication(); @@ -1576,7 +1749,8 @@ TEST_F(ApplicationManagerImplTest, testing::An<connection_handler::DeviceHandle*>())) .WillOnce(DoAll(SetArgPointee<3u>(kDeviceId), Return(0))); EXPECT_CALL(*mock_rpc_service_, - ManageMobileCommand(_, commands::Command::SOURCE_SDL)).Times(0); + ManageMobileCommand(_, commands::Command::SOURCE_SDL)) + .Times(0); smart_objects::SmartObject request_for_registration( smart_objects::SmartType_Map); @@ -1663,6 +1837,61 @@ TEST_F(ApplicationManagerImplTest, app_manager_impl_->RegisterApplication(request_for_registration_ptr); EXPECT_EQ(0, application.use_count()); } + +TEST_F(ApplicationManagerImplTest, PolicyIDByIconUrl_Success) { + std::vector<std::string> enabled_apps{"1234"}; + EXPECT_CALL(*mock_policy_handler_, GetEnabledCloudApps(_)) + .WillOnce(SetArgReferee<0>(enabled_apps)); + EXPECT_CALL(*mock_policy_handler_, GetCloudAppParameters(_, _, _, _, _, _, _)) + .WillOnce(DoAll(SetArgReferee<1>(kEnabled), + SetArgReferee<2>(kEndpoint2), + SetArgReferee<3>(kCertificate), + SetArgReferee<4>(kAuthToken), + SetArgReferee<5>(kTransportType), + SetArgReferee<6>(kHybridAppPreferenceStr), + Return(true))); + + std::vector<std::string> nicknames{"CloudApp"}; + EXPECT_CALL(*mock_policy_handler_, GetInitialAppData(_, _, _)) + .WillOnce(DoAll(SetArgPointee<1>(nicknames), Return(true))); + + const std::string url = "https://www.fakeiconurl.com/icon.png"; + EXPECT_CALL(*mock_policy_handler_, GetIconUrl("1234")) + .WillRepeatedly(Return(url)); + + app_manager_impl_->RefreshCloudAppInformation(); + + std::string result = app_manager_impl_->PolicyIDByIconUrl(url); + EXPECT_EQ(result, "1234"); +} + +TEST_F(ApplicationManagerImplTest, SetIconFileFromSystemRequest_Success) { + CreatePendingApplication(); + Mock::VerifyAndClearExpectations(mock_message_helper_); + + file_system::CreateDirectory(kDirectoryName); + const std::string full_icon_path = kDirectoryName + "/1234"; + ASSERT_TRUE(file_system::CreateFile(full_icon_path)); + + const std::string url = "https://www.fakeiconurl.com/icon.png"; + EXPECT_CALL(*mock_policy_handler_, GetIconUrl("1234")) + .WillRepeatedly(Return(url)); + + smart_objects::SmartObject dummy_object(smart_objects::SmartType_Map); + smart_objects::SmartObjectSPtr sptr = + std::make_shared<smart_objects::SmartObject>(dummy_object); + + EXPECT_CALL(*mock_message_helper_, + CreateModuleInfoSO( + hmi_apis::FunctionID::BasicCommunication_UpdateAppList, _)) + .WillOnce(Return(sptr)); + EXPECT_CALL(*mock_rpc_service_, ManageHMICommand(sptr, _)).Times(1); + EXPECT_CALL(mock_application_manager_settings_, app_icons_folder()) + .WillOnce(ReturnRef(kDirectoryName)); + app_manager_impl_->SetIconFileFromSystemRequest("1234"); + EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true)); +} + #endif // CLOUD_APP_WEBSOCKET_TRANSPORT_SUPPORT } // namespace application_manager_test } // namespace components diff --git a/src/components/application_manager/test/application_state_test.cc b/src/components/application_manager/test/application_state_test.cc index a0bfa2890f..22d111f926 100644 --- a/src/components/application_manager/test/application_state_test.cc +++ b/src/components/application_manager/test/application_state_test.cc @@ -31,15 +31,15 @@ */ #include "application_manager/application_state.h" -#include "gtest/gtest.h" +#include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/hmi_state.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "resumption/last_state.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/state_controller.h" +#include "gtest/gtest.h" +#include "resumption/last_state.h" namespace test { namespace components { @@ -50,6 +50,11 @@ using namespace mobile_apis; typedef HmiState::StateID StateID; namespace { + +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const std::string kDefaultWindowName = "DefaultName"; + std::vector<StateID> GenerateCurrentStates() { std::vector<StateID> states; states.push_back(StateID::STATE_ID_PHONE_CALL); @@ -60,7 +65,7 @@ std::vector<StateID> GenerateCurrentStates() { states.push_back(StateID::STATE_ID_DEACTIVATE_HMI); return states; } -} +} // namespace class ApplicationStateTest : public ::testing::Test { public: @@ -87,8 +92,8 @@ TEST_F(ApplicationStateTest, AddStates_GetCurrentStates) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); - EXPECT_EQ(state, app_state.GetState(current_id)); + app_state.AddState(kDefaultWindowId, state); + EXPECT_EQ(state, app_state.GetState(kDefaultWindowId, current_id)); } } @@ -99,16 +104,16 @@ TEST_F(ApplicationStateTest, AddStates_RemoveStates_GetCurrentState) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); - HmiStatePtr curr_state = app_state.GetState(current_id); + HmiStatePtr curr_state = app_state.GetState(kDefaultWindowId, current_id); ASSERT_EQ(*new_state, curr_state->state_id()); } new_state = added_states_.end() - 1; while (new_state != added_states_.begin()) { - app_state.RemoveState(*new_state); - HmiStatePtr curr_state = app_state.GetState(current_id); + app_state.RemoveState(kDefaultWindowId, *new_state); + HmiStatePtr curr_state = app_state.GetState(kDefaultWindowId, current_id); --new_state; EXPECT_EQ(*new_state, curr_state->state_id()); } @@ -122,19 +127,20 @@ TEST_F(ApplicationStateTest, AddStatesAddPostponedState_GetPostponedState) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); } // Postponed state wasn't added - HmiStatePtr get_postponed_id = app_state.GetState(postponed_id); + HmiStatePtr get_postponed_id = + app_state.GetState(kDefaultWindowId, postponed_id); EXPECT_EQ(nullptr, get_postponed_id); // Add posponed state HmiStatePtr state = std::make_shared<HmiState>( static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Postponed state exists - get_postponed_id = app_state.GetState(postponed_id); + get_postponed_id = app_state.GetState(kDefaultWindowId, postponed_id); EXPECT_EQ(state, get_postponed_id); } @@ -146,7 +152,7 @@ TEST_F(ApplicationStateTest, AddStates_GetRegularState) { app_mngr_, *new_state); state->set_hmi_level(HMILevel::HMI_FULL); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); ++new_state; // Add some other for (; new_state != added_states_.end(); ++new_state) { @@ -154,13 +160,14 @@ TEST_F(ApplicationStateTest, AddStates_GetRegularState) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); state->set_hmi_level(HMILevel::HMI_LIMITED); } // Regular state will be the first added state new_state = added_states_.begin(); - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(*new_state, reg_state->state_id()); EXPECT_EQ(HMILevel::HMI_FULL, reg_state->hmi_level()); } @@ -171,7 +178,7 @@ TEST_F(ApplicationStateTest, AddRegularState_RemoveFirstState_GetRegularState) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); ++new_state; // Add postponed state @@ -179,10 +186,10 @@ TEST_F(ApplicationStateTest, AddRegularState_RemoveFirstState_GetRegularState) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Make sure that the state was added - HmiStatePtr post_state = app_state.GetState(postponed_id); + HmiStatePtr post_state = app_state.GetState(kDefaultWindowId, postponed_id); ASSERT_EQ(state, post_state); for (; new_state != added_states_.end(); ++new_state) { @@ -190,19 +197,20 @@ TEST_F(ApplicationStateTest, AddRegularState_RemoveFirstState_GetRegularState) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, *new_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); } // Regular state will be the first added state new_state = added_states_.begin(); - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); ASSERT_EQ(*new_state, reg_state->state_id()); - app_state.RemoveState(*new_state); + app_state.RemoveState(kDefaultWindowId, *new_state); ++new_state; // Now regular state is the next state except postponed - reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + reg_state = app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(*new_state, reg_state->state_id()); } @@ -213,14 +221,14 @@ TEST_F(ApplicationStateTest, AddRegularState_PreviousStatePostponed) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, first_state); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Add postponed state state = std::make_shared<HmiState>( static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Add new postponed state std::shared_ptr<MockApplication> mock_app_2(new MockApplication); @@ -228,21 +236,22 @@ TEST_F(ApplicationStateTest, AddRegularState_PreviousStatePostponed) { static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Add regular state state = std::make_shared<HmiState>( static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, StateID::STATE_ID_REGULAR); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Postponed state is the first - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_POSTPONED); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_POSTPONED); ASSERT_EQ(postponed_id, reg_state->state_id()); // Regular state is the second one - reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + reg_state = app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(StateID::STATE_ID_REGULAR, reg_state->state_id()); } @@ -253,12 +262,14 @@ TEST_F(ApplicationStateTest, InitState_GetRegularState) { app_mngr_, init_state); - app_state.InitState(state); + app_state.InitState(kDefaultWindowId, kDefaultWindowName, state); - HmiStatePtr reg_state = app_state.GetState(StateID::STATE_ID_REGULAR); + HmiStatePtr reg_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_REGULAR); EXPECT_EQ(state, reg_state); - HmiStatePtr curr_state = app_state.GetState(StateID::STATE_ID_CURRENT); + HmiStatePtr curr_state = + app_state.GetState(kDefaultWindowId, StateID::STATE_ID_CURRENT); EXPECT_EQ(state, curr_state); } @@ -271,23 +282,24 @@ TEST_F(ApplicationStateTest, AddPosponedState_DeletePosponedState) { init_state); state->set_hmi_level(mobile_apis::HMILevel::HMI_FULL); - app_state.InitState(state); + app_state.InitState(kDefaultWindowId, kDefaultWindowName, state); // Add postponed state state = std::make_shared<HmiState>( static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, postponed_id); - app_state.AddState(state); + app_state.AddState(kDefaultWindowId, state); // Make sure that state was added - HmiStatePtr get_postponed_state = app_state.GetState(postponed_id); + HmiStatePtr get_postponed_state = + app_state.GetState(kDefaultWindowId, postponed_id); ASSERT_EQ(state, get_postponed_state); // Remove postponed state - app_state.RemoveState(postponed_id); + app_state.RemoveState(kDefaultWindowId, postponed_id); - get_postponed_state = app_state.GetState(postponed_id); + get_postponed_state = app_state.GetState(kDefaultWindowId, postponed_id); EXPECT_EQ(nullptr, get_postponed_state); } @@ -298,13 +310,13 @@ TEST_F(ApplicationStateTest, static_cast<std::shared_ptr<Application> >(mock_app_), app_mngr_, reg_state); - app_state.InitState(state); + app_state.InitState(kDefaultWindowId, kDefaultWindowName, state); // Try deleting regular state - app_state.RemoveState(reg_state); + app_state.RemoveState(kDefaultWindowId, reg_state); // Get regular state - HmiStatePtr get_reg_state = app_state.GetState(reg_state); + HmiStatePtr get_reg_state = app_state.GetState(kDefaultWindowId, reg_state); EXPECT_EQ(state, get_reg_state); } diff --git a/src/components/application_manager/test/command_holder_test.cc b/src/components/application_manager/test/command_holder_test.cc index 9496e37924..acde0bfd86 100644 --- a/src/components/application_manager/test/command_holder_test.cc +++ b/src/components/application_manager/test/command_holder_test.cc @@ -36,8 +36,8 @@ #include "application_manager/commands/command.h" #include "smart_objects/smart_object.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" #include "application_manager/mock_rpc_service.h" namespace test { @@ -80,8 +80,10 @@ class CommandHolderImplTest : public testing::Test { TEST_F(CommandHolderImplTest, HoldOne_ExpectReleaseOne) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); @@ -93,8 +95,10 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { int32_t iterations = 0; do { - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); ++iterations; } while (iterations < 5); @@ -106,10 +110,14 @@ TEST_F(CommandHolderImplTest, HoldMany_ExpectReleaseSame) { TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act cmd_holder.Clear(mock_app_ptr_); @@ -119,10 +127,14 @@ TEST_F(CommandHolderImplTest, Hold_Drop_ExpectNoReleased) { TEST_F(CommandHolderImplTest, Hold_ReleaseAnotherId_ExpectNoReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); // Act std::shared_ptr<MockApplication> another_app = @@ -137,8 +149,10 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { int32_t iterations = 0; do { - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); ++iterations; } while (iterations < 3); @@ -155,11 +169,15 @@ TEST_F(CommandHolderImplTest, Hold_DropAnotherId_ExpectReleased) { TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) { am::CommandHolderImpl cmd_holder(mock_app_manager_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kHmiCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kHmiCommand, + am::commands::Command::CommandSource::SOURCE_HMI, + cmd_ptr_); - cmd_holder.Suspend( - mock_app_ptr_, am::CommandHolder::CommandType::kMobileCommand, cmd_ptr_); + cmd_holder.Suspend(mock_app_ptr_, + am::CommandHolder::CommandType::kMobileCommand, + am::commands::Command::CommandSource::SOURCE_MOBILE, + cmd_ptr_); // Act EXPECT_CALL(mock_rpc_service_, ManageHMICommand(cmd_ptr_, _)); @@ -173,6 +191,6 @@ TEST_F(CommandHolderImplTest, Hold_Mobile_and_HMI_commands_ExpectReleased) { am::CommandHolder::CommandType::kMobileCommand); } -} // application_manager_test -} // components -} // test +} // namespace 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 556f3a5032..ec7f454c47 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -58,7 +58,7 @@ set(LIBRARIES connectionHandler ApplicationManager jsoncpp - Policy + PolicyStatic Resumption ) diff --git a/src/components/application_manager/test/commands/command_impl_test.cc b/src/components/application_manager/test/commands/command_impl_test.cc index 53e8534c2b..734a7d91b8 100644 --- a/src/components/application_manager/test/commands/command_impl_test.cc +++ b/src/components/application_manager/test/commands/command_impl_test.cc @@ -31,35 +31,35 @@ */ #include <stdint.h> -#include <string> #include <algorithm> #include <functional> #include <set> +#include <string> #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" +#include "application_manager/application_manager.h" #include "application_manager/commands/command.h" #include "application_manager/commands/command_impl.h" -#include "application_manager/application_manager.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { namespace commands_test { namespace command_impl { -using ::testing::Return; -using ::testing::AtLeast; using ::testing::_; +using ::testing::AtLeast; +using ::testing::Return; namespace strings = ::application_manager::strings; -using ::application_manager::commands::CommandImpl; using ::application_manager::ApplicationManager; -using ::application_manager::commands::MessageSharedPtr; using ::application_manager::ApplicationSharedPtr; +using ::application_manager::commands::CommandImpl; +using ::application_manager::commands::MessageSharedPtr; using ::test::components::application_manager_test::MockApplication; typedef std::shared_ptr<MockApplication> MockAppPtr; @@ -82,8 +82,8 @@ class CommandImplTest : public CommandsTest<CommandsTestMocks::kIsNice> { public: class UnwrappedCommandImpl : CommandImpl { public: - using CommandImpl::ReplaceMobileWithHMIAppId; using CommandImpl::ReplaceHMIWithMobileAppId; + using CommandImpl::ReplaceMobileWithHMIAppId; UnwrappedCommandImpl( const MessageSharedPtr& message, 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 6d80a11440..86dba1c5ac 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -31,25 +31,25 @@ */ #include <stdint.h> -#include <string> #include <algorithm> +#include <string> -#include "gtest/gtest.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/command_request_impl.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command_request_test.h" +#include "application_manager/commands/commands_test.h" +#include "gtest/gtest.h" #include "utils/lock.h" -#include "utils/data_accessor.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" #include "application_manager/application_manager.h" -#include "application_manager/mock_application.h" #include "application_manager/event_engine/event.h" -#include "application_manager/mock_message_helper.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_hmi_interface.h" +#include "application_manager/mock_message_helper.h" +#include "application_manager/smart_object_keys.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" +#include "utils/data_accessor.h" #include "application_manager/mock_app_service_manager.h" #include "resumption/last_state_impl.h" @@ -64,20 +64,20 @@ namespace strings = am::strings; namespace hmi_response = am::hmi_response; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::SaveArg; -using ::testing::DoAll; using ::testing::SetArgReferee; -using am::commands::MessageSharedPtr; -using am::CommandParametersPermissions; -using am::event_engine::EventObserver; -using am::commands::CommandImpl; -using am::commands::CommandRequestImpl; using am::ApplicationManager; using am::ApplicationSet; -using am::RPCParams; +using am::CommandParametersPermissions; using am::MockHmiInterfaces; +using am::RPCParams; +using am::commands::CommandImpl; +using am::commands::CommandRequestImpl; +using am::commands::MessageSharedPtr; +using am::event_engine::EventObserver; using test::components::application_manager_test::MockAppServiceManager; typedef am::commands::CommandRequestImpl::RequestState RequestState; @@ -105,10 +105,10 @@ class CommandRequestImplTest class UnwrappedCommandRequestImpl : public CommandRequestImpl { public: - using CommandRequestImpl::CheckAllowedParameters; - using CommandRequestImpl::RemoveDisallowedParameters; using CommandRequestImpl::AddDisallowedParameters; + using CommandRequestImpl::CheckAllowedParameters; using CommandRequestImpl::HasDisallowedParams; + using CommandRequestImpl::RemoveDisallowedParameters; UnwrappedCommandRequestImpl(const MessageSharedPtr& message, ApplicationManager& am, @@ -154,6 +154,13 @@ class CommandRequestImplTest typedef CommandRequestImplTest::UnwrappedCommandRequestImpl UCommandRequestImpl; typedef std::shared_ptr<UCommandRequestImpl> CommandPtr; +TEST_F(CommandRequestImplTest, WindowID_ExpectDefaultWindowID) { + auto msg = CreateMessage(); + const auto command = CreateCommand<UCommandRequestImpl>(msg); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + command->window_id()); +} + TEST_F(CommandRequestImplTest, OnTimeOut_StateCompleted_UNSUCCESS) { CommandPtr command = CreateCommand<UCommandRequestImpl>(); @@ -311,13 +318,6 @@ TEST_F(CommandRequestImplTest, SendHMIRequest_UseEvent_SUCCESS) { } TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) { - am::VehicleData vehicle_data; - vehicle_data.insert(am::VehicleData::value_type( - kMissedParam, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY)); - - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - MessageSharedPtr msg = CreateMessage(); (*msg)[strings::msg_params][kDisallowedParam1] = 0u; (*msg)[strings::msg_params][kDisallowedParam2] = 0u; @@ -326,7 +326,6 @@ TEST_F(CommandRequestImplTest, RemoveDisallowedParameters_SUCCESS) { (*msg)[strings::msg_params][kMissedParam] = 0u; CommandPtr command = CreateCommand<UCommandRequestImpl>(msg); - CommandParametersPermissions& permission = command->parameters_permissions(); permission.disallowed_params.insert(kDisallowedParam1); permission.disallowed_params.insert(kDisallowedParam2); @@ -366,6 +365,12 @@ TEST_F(CommandRequestImplTest, TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) { MockAppPtr mock_app = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, GetWindowIds()) + .WillByDefault(Return( + am::WindowIds(1, mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + ON_CALL(*mock_app, + WindowIdExists(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(true)); MessageSharedPtr message = CreateMessage(); (*message)[strings::msg_params] = @@ -373,7 +378,7 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_NoMsgParamsMap_SUCCESS) { CommandPtr command = CreateCommand<UCommandRequestImpl>(message); - EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) + EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _)) .WillOnce(Return(kMobResultSuccess)); EXPECT_TRUE(command->CheckPermissions()); @@ -383,6 +388,12 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_WrongPolicyPermissions_UNSUCCESS) { MockAppPtr mock_app = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app)); + ON_CALL(*mock_app, GetWindowIds()) + .WillByDefault(Return( + am::WindowIds(1, mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + ON_CALL(*mock_app, + WindowIdExists(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(true)); MessageSharedPtr message = CreateMessage(); (*message)[strings::msg_params] = @@ -394,7 +405,7 @@ TEST_F(CommandRequestImplTest, .Times(1) .WillRepeatedly(Return(kConnectionKey)); - EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) + EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _)) .WillOnce(Return(mobile_apis::Result::INVALID_ENUM)); EXPECT_CALL(mock_message_helper_, CreateBlockedByPoliciesResponse(_, _, _, _)) @@ -405,7 +416,7 @@ TEST_F(CommandRequestImplTest, } ACTION_P(GetArg3, output) { - *output = arg2; + *output = arg3; } TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) { @@ -417,9 +428,14 @@ TEST_F(CommandRequestImplTest, CheckAllowedParameters_MsgParamsMap_SUCCESS) { MockAppPtr app = CreateMockApp(); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, GetWindowIds()) + .WillByDefault(Return( + am::WindowIds(1, mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + ON_CALL(*app, WindowIdExists(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(true)); RPCParams params; - EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _)) + EXPECT_CALL(app_mngr_, CheckPolicyPermissions(_, _, _, _, _)) .WillOnce(DoAll(GetArg3(¶ms), Return(kMobResultSuccess))); EXPECT_TRUE(command->CheckPermissions()); @@ -432,13 +448,13 @@ TEST_F(CommandRequestImplTest, AddDisallowedParameters_SUCCESS) { vehicle_data.insert(am::VehicleData::value_type( kDisallowedParam1, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - MessageSharedPtr msg; CommandPtr command = CreateCommand<UCommandRequestImpl>(msg); + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + command->removed_parameters_permissions().disallowed_params.insert( kDisallowedParam1); @@ -485,9 +501,6 @@ TEST_F(CommandRequestImplTest, vehicle_data.insert(am::VehicleData::value_type( kDisallowedParam1, mobile_apis::VehicleDataType::VEHICLEDATA_MYKEY)); - EXPECT_CALL(mock_message_helper_, vehicle_data()) - .WillOnce(ReturnRef(vehicle_data)); - MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::function_id] = mobile_apis::FunctionID::SubscribeVehicleDataID; @@ -499,6 +512,9 @@ TEST_F(CommandRequestImplTest, MessageSharedPtr result; + ON_CALL(mock_message_helper_, vehicle_data()) + .WillByDefault(ReturnRef(vehicle_data)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); diff --git a/src/components/application_manager/test/commands/command_response_impl_test.cc b/src/components/application_manager/test/commands/command_response_impl_test.cc index 41cc654a24..6362ea702e 100644 --- a/src/components/application_manager/test/commands/command_response_impl_test.cc +++ b/src/components/application_manager/test/commands/command_response_impl_test.cc @@ -35,12 +35,12 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" #include "application_manager/commands/command.h" #include "application_manager/commands/command_response_impl.h" +#include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { @@ -50,8 +50,8 @@ namespace command_response_impl { namespace strings = ::application_manager::strings; namespace hmi_response = ::application_manager::hmi_response; -using ::application_manager::commands::MessageSharedPtr; using ::application_manager::commands::CommandResponseImpl; +using ::application_manager::commands::MessageSharedPtr; class CommandResponseImplTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; diff --git a/src/components/application_manager/test/event_engine_test.cc b/src/components/application_manager/test/event_engine_test.cc index de0b5afb3c..6746e0d5ec 100644 --- a/src/components/application_manager/test/event_engine_test.cc +++ b/src/components/application_manager/test/event_engine_test.cc @@ -32,11 +32,11 @@ #include "gtest/gtest.h" -#include "application_manager/event_engine/event_observer.h" #include "application_manager/event_engine/event.h" #include "application_manager/event_engine/event_dispatcher_impl.h" -#include "application_manager/mock_event_observer.h" +#include "application_manager/event_engine/event_observer.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_event_observer.h" #include "smart_objects/smart_object.h" #include "interfaces/HMI_API.h" @@ -45,10 +45,12 @@ namespace test { namespace components { namespace event_engine_test { -using application_manager::event_engine::EventDispatcherImpl; using application_manager::event_engine::Event; +using application_manager::event_engine::EventDispatcherImpl; using application_manager::event_engine::EventObserver; using testing::_; +using ::testing::An; +using ::testing::Matcher; class EventEngineTest : public testing::Test { public: @@ -122,7 +124,9 @@ class EventEngineTest : public testing::Test { event_dispatcher_instance_->add_observer( event_id, correlation_id, event_observer_mock_); event_->set_smart_object(so); - EXPECT_CALL(event_observer_mock_, on_event(_)).Times(calls_number); + + EXPECT_CALL(event_observer_mock_, on_event(An<const Event&>())) + .Times(calls_number); event_dispatcher_instance_->raise_event(*event_); } }; diff --git a/src/components/application_manager/test/help_prompt_manager_test.cc b/src/components/application_manager/test/help_prompt_manager_test.cc index dc6635b049..caff56f675 100644 --- a/src/components/application_manager/test/help_prompt_manager_test.cc +++ b/src/components/application_manager/test/help_prompt_manager_test.cc @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2018, Ford Motor Company * All rights reserved. * @@ -65,6 +65,9 @@ const std::string kDirectoryName = "./test_storage"; const uint8_t expected_tread_pool_size = 2u; const uint8_t stop_streaming_timeout = 1u; const std::vector<std::string> kTimeoutPrompt{"timeoutPrompt"}; +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const std::string kDefaultWindowName = "DefaultName"; } // namespace using namespace application_manager; @@ -177,8 +180,10 @@ void HelpPromptManagerTest::SetUp() { mock_help_prompt_manager_ = std::shared_ptr<MockHelpPromptManager>(new MockHelpPromptManager()); - std::string path = file_system::CreateDirectory("storage"); - file_system::CreateFile(path + "/" + "certificate"); + const std::string path("storage"); + if (file_system::CreateDirectory(path)) { + file_system::CreateFile(path + "/" + "certificate"); + } mock_app_ = std::make_shared<application_manager_test::MockApplication>(); } @@ -244,7 +249,8 @@ void HelpPromptManagerTest::CreateApplication( app_mngr_, mock_help_prompt_manager)); HmiStatePtr initial_state = CreateTestHmiState(); - app_impl_->SetInitialState(initial_state); + app_impl_->SetInitialState( + kDefaultWindowId, kDefaultWindowName, initial_state); } TEST_F(HelpPromptManagerTest, AddCommand_OnVrCommandAdded) { diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index ca67d81d8c..afa5fa6056 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -355,11 +355,11 @@ "STATIC" ] }, - "audioPassThruCapabilities": { + "audioPassThruCapabilities": [{ "samplingRate": "44KHZ", "bitsPerSample": "RATE_8_BIT", "audioType": "PCM" - }, + }], "pcmStreamCapabilities": { "samplingRate": "16KHZ", "bitsPerSample": "RATE_16_BIT", diff --git a/src/components/application_manager/test/hmi_capabilities_old_apt.json b/src/components/application_manager/test/hmi_capabilities_old_apt.json new file mode 100644 index 0000000000..5a5af37e2f --- /dev/null +++ b/src/components/application_manager/test/hmi_capabilities_old_apt.json @@ -0,0 +1,9 @@ +{ + "UI": { + "audioPassThruCapabilities": { + "samplingRate": "22KHZ", + "bitsPerSample": "RATE_16_BIT", + "audioType": "PCM" + } + } +} diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index d67dfebaa5..3d47c717e1 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -36,32 +36,32 @@ #include <string> #include "application_manager/hmi_capabilities.h" -#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/mock_message_helper.h" -#include "smart_objects/enum_schema_item.h" +#include "gtest/gtest.h" #include "interfaces/HMI_API.h" +#include "smart_objects/enum_schema_item.h" +#include "smart_objects/smart_object.h" #include "application_manager/hmi_capabilities_for_testing.h" -#include "utils/file_system.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/state_controller.h" #include "resumption/last_state_impl.h" -#include "application_manager/resumption/resume_ctrl.h" +#include "utils/file_system.h" namespace test { namespace components { namespace application_manager_test { using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; using ::testing::AtLeast; -using ::testing::Invoke; using ::testing::InSequence; +using ::testing::Invoke; +using ::testing::Return; +using ::testing::ReturnRef; using namespace application_manager; @@ -76,7 +76,8 @@ class HMICapabilitiesTest : public ::testing::Test { EXPECT_CALL(app_mngr_, get_settings()) .WillRepeatedly(ReturnRef(mock_application_manager_settings_)); EXPECT_CALL(mock_application_manager_settings_, - hmi_capabilities_file_name()).WillOnce(ReturnRef(file_name_)); + hmi_capabilities_file_name()) + .WillOnce(ReturnRef(file_name_)); EXPECT_CALL(mock_event_dispatcher, add_observer(_, _, _)).Times(1); EXPECT_CALL(mock_event_dispatcher, remove_observer(_)).Times(1); EXPECT_CALL(mock_application_manager_settings_, launch_hmi()) @@ -140,9 +141,9 @@ struct CStringComparator { } }; -typedef std::map<const char*, - hmi_apis::Common_Language::eType, - CStringComparator> CStringToEnumMap; +typedef std:: + map<const char*, hmi_apis::Common_Language::eType, CStringComparator> + CStringToEnumMap; CStringToEnumMap InitCStringToEnumMap() { size_t value = sizeof(cstring_values_) / sizeof(cstring_values_[0]); @@ -335,15 +336,18 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { // Check audio pass thru const smart_objects::SmartObject audio_pass_thru_capabilities_so = *(hmi_capabilities_test->audio_pass_thru_capabilities()); + EXPECT_EQ(smart_objects::SmartType_Array, + audio_pass_thru_capabilities_so.getType()); + EXPECT_EQ(1u, audio_pass_thru_capabilities_so.length()); EXPECT_EQ(hmi_apis::Common_SamplingRate::RATE_44KHZ, static_cast<hmi_apis::Common_SamplingRate::eType>( - audio_pass_thru_capabilities_so["samplingRate"].asInt())); + audio_pass_thru_capabilities_so[0]["samplingRate"].asInt())); EXPECT_EQ(hmi_apis::Common_BitsPerSample::RATE_8_BIT, static_cast<hmi_apis::Common_BitsPerSample::eType>( - audio_pass_thru_capabilities_so["bitsPerSample"].asInt())); + audio_pass_thru_capabilities_so[0]["bitsPerSample"].asInt())); EXPECT_EQ(hmi_apis::Common_AudioType::PCM, static_cast<hmi_apis::Common_AudioType::eType>( - audio_pass_thru_capabilities_so["audioType"].asInt())); + audio_pass_thru_capabilities_so[0]["audioType"].asInt())); // Check hmi zone capabilities const smart_objects::SmartObject hmi_zone_capabilities_so = @@ -407,7 +411,8 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { .asInt()); EXPECT_EQ(350, vs_capability_so[strings::preferred_resolution] - [strings::resolution_height].asInt()); + [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)); @@ -454,7 +459,8 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { rc_capability_so["climateControlCapabilities"][0]["fanSpeedAvailable"] .asBool()); EXPECT_TRUE(rc_capability_so["climateControlCapabilities"][0] - ["desiredTemperatureAvailable"].asBool()); + ["desiredTemperatureAvailable"] + .asBool()); EXPECT_TRUE( rc_capability_so["climateControlCapabilities"][0]["acEnableAvailable"] .asBool()); @@ -566,6 +572,57 @@ TEST_F(HMICapabilitiesTest, EXPECT_FALSE(navigation_capability_so["getWayPointsEnabled"].asBool()); } +TEST_F(HMICapabilitiesTest, + LoadCapabilitiesFromFileAndVerifyOldAudioPassThruCapabilities) { + MockApplicationManager mock_app_mngr; + event_engine_test::MockEventDispatcher mock_dispatcher; + MockApplicationManagerSettings mock_application_manager_settings; + + const std::string hmi_capabilities_file = "hmi_capabilities_old_apt.json"; + + EXPECT_CALL(mock_app_mngr, event_dispatcher()) + .WillOnce(ReturnRef(mock_dispatcher)); + EXPECT_CALL(mock_app_mngr, get_settings()) + .WillRepeatedly(ReturnRef(mock_application_manager_settings)); + EXPECT_CALL(mock_application_manager_settings, hmi_capabilities_file_name()) + .WillOnce(ReturnRef(hmi_capabilities_file)); + EXPECT_CALL(mock_dispatcher, add_observer(_, _, _)).Times(1); + EXPECT_CALL(mock_dispatcher, remove_observer(_)).Times(1); + EXPECT_CALL(mock_application_manager_settings, launch_hmi()) + .WillOnce(Return(false)); + EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), + CommonLanguageFromString(_)) + .WillRepeatedly(Invoke(TestCommonLanguageFromString)); + + if (file_system::FileExists("./app_info_data")) { + EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); + } + + std::shared_ptr<HMICapabilitiesForTesting> hmi_capabilities = + std::make_shared<HMICapabilitiesForTesting>(mock_app_mngr); + hmi_capabilities->Init(&last_state_); + + // with old audio pass thru format, the object is an array containing a single + // object + smart_objects::SmartObject audio_pass_thru_capabilities_so = + *(hmi_capabilities->audio_pass_thru_capabilities()); + EXPECT_EQ(smart_objects::SmartType_Array, + audio_pass_thru_capabilities_so.getType()); + EXPECT_EQ(1u, audio_pass_thru_capabilities_so.length()); + EXPECT_TRUE(audio_pass_thru_capabilities_so[0].keyExists("samplingRate")); + EXPECT_EQ(hmi_apis::Common_SamplingRate::RATE_22KHZ, + static_cast<hmi_apis::Common_SamplingRate::eType>( + audio_pass_thru_capabilities_so[0]["samplingRate"].asInt())); + EXPECT_TRUE(audio_pass_thru_capabilities_so[0].keyExists("bitsPerSample")); + EXPECT_EQ(hmi_apis::Common_BitsPerSample::RATE_16_BIT, + static_cast<hmi_apis::Common_BitsPerSample::eType>( + audio_pass_thru_capabilities_so[0]["bitsPerSample"].asInt())); + EXPECT_TRUE(audio_pass_thru_capabilities_so[0].keyExists("audioType")); + EXPECT_EQ(hmi_apis::Common_AudioType::PCM, + static_cast<hmi_apis::Common_AudioType::eType>( + audio_pass_thru_capabilities_so[0]["audioType"].asInt())); +} + TEST_F(HMICapabilitiesTest, VerifyImageType) { const int32_t image_type = 1; smart_objects::SmartObject sm_obj; @@ -582,7 +639,8 @@ TEST_F(HMICapabilitiesTest, VerifyImageType) { void HMICapabilitiesTest::SetCooperating() { smart_objects::SmartObjectSPtr test_so; EXPECT_CALL(*(MockMessageHelper::message_helper_mock()), - CreateModuleInfoSO(_, _)).WillRepeatedly(Return(test_so)); + CreateModuleInfoSO(_, _)) + .WillRepeatedly(Return(test_so)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_, _)) .WillRepeatedly(Return(true)); } diff --git a/src/components/application_manager/test/hmi_language_handler_test.cc b/src/components/application_manager/test/hmi_language_handler_test.cc index ec88075212..5f07c1b9d1 100644 --- a/src/components/application_manager/test/hmi_language_handler_test.cc +++ b/src/components/application_manager/test/hmi_language_handler_test.cc @@ -32,18 +32,18 @@ #include <stdint.h> -#include "gtest/gtest.h" #include "application_manager/application_manager.h" #include "application_manager/hmi_language_handler.h" -#include "application_manager/state_controller.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/resumption/resume_ctrl_impl.h" #include "application_manager/smart_object_keys.h" +#include "application_manager/state_controller.h" +#include "gtest/gtest.h" #include "test/resumption/mock_last_state.h" #include "utils/lock.h" @@ -54,13 +54,13 @@ namespace hmi_language_handler { namespace am = ::application_manager; -using am::event_engine::Event; using am::ApplicationSet; +using am::event_engine::Event; +using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::_; typedef NiceMock< ::test::components::application_manager_test::MockApplicationManager> diff --git a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h index 8dd29ce244..3a44d7b3ff 100644 --- a/src/components/application_manager/test/include/application_manager/commands/command_request_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/command_request_test.h @@ -37,11 +37,11 @@ #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/smart_object_keys.h" #include "application_manager/test/include/application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_impl.h" #include "application_manager/test/include/application_manager/mock_event_dispatcher.h" +#include "smart_objects/smart_object.h" #include "application_manager/event_engine/event.h" @@ -49,12 +49,12 @@ namespace test { namespace components { namespace commands_test { +using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; -using ::testing::Return; -using ::testing::SaveArg; using ::testing::DoAll; using ::testing::NiceMock; -using ::test::components::event_engine_test::MockEventDispatcher; +using ::testing::Return; +using ::testing::SaveArg; namespace am = ::application_manager; using am::commands::Command; using am::commands::CommandRequestImpl; diff --git a/src/components/application_manager/test/include/application_manager/commands/commands_test.h b/src/components/application_manager/test/include/application_manager/commands/commands_test.h index 9a961ea1a9..a047de81b9 100644 --- a/src/components/application_manager/test/include/application_manager/commands/commands_test.h +++ b/src/components/application_manager/test/include/application_manager/commands/commands_test.h @@ -30,44 +30,44 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_ #include <stdint.h> #include "gtest/gtest.h" -#include "smart_objects/smart_object.h" #include "application_manager/commands/command.h" +#include "smart_objects/smart_object.h" #include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" -#include "application_manager/test/include/application_manager/mock_hmi_interface.h" -#include "application_manager/test/include/application_manager/mock_application.h" -#include "application_manager/test/include/application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager_settings.h" -#include "application_manager/mock_rpc_service.h" #include "application_manager/mock_hmi_capabilities.h" +#include "application_manager/mock_rpc_service.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/test/include/application_manager/mock_application.h" +#include "application_manager/test/include/application_manager/mock_hmi_interface.h" +#include "application_manager/test/include/application_manager/mock_message_helper.h" +#include "test/application_manager/mock_application_manager_settings.h" namespace test { namespace components { namespace commands_test { namespace am = ::application_manager; -using ::testing::ReturnRef; -using ::testing::Return; -using ::testing::NiceMock; -using ::testing::Mock; using ::testing::_; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Return; +using ::testing::ReturnRef; -using ::smart_objects::SmartObject; +using am::ApplicationSharedPtr; +using am::MockMessageHelper; using am::commands::MessageSharedPtr; +using ::smart_objects::SmartObject; +using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; -using am::ApplicationSharedPtr; -using am::MockMessageHelper; -using ::test::components::application_manager_test::MockApplication; // Depending on the value type will be selected template <const bool kIf, class ThenT, class ElseT> @@ -100,9 +100,8 @@ class CommandsTest : public ::testing::Test { typedef typename TypeIf<kIsNice, NiceMock<MockApplicationManager>, MockApplicationManager>::Result MockAppManager; - typedef typename TypeIf<kIsNice, - NiceMock<MockApplication>, - MockApplication>::Result MockApp; + typedef typename TypeIf<kIsNice, NiceMock<MockApplication>, MockApplication>:: + Result MockApp; typedef std::shared_ptr<MockApp> MockAppPtr; virtual ~CommandsTest() { @@ -183,11 +182,11 @@ class CommandsTest : public ::testing::Test { void InitHMIToMobileResultConverter() { namespace MobileResult = mobile_apis::Result; namespace HMIResult = hmi_apis::Common_Result; - auto link_hmi_to_mob_result = - [this](HMIResult::eType hmi_result, MobileResult::eType mobile_result) { - ON_CALL(mock_message_helper_, HMIToMobileResult(hmi_result)) - .WillByDefault(Return(mobile_result)); - }; + auto link_hmi_to_mob_result = [this](HMIResult::eType hmi_result, + MobileResult::eType mobile_result) { + ON_CALL(mock_message_helper_, HMIToMobileResult(hmi_result)) + .WillByDefault(Return(mobile_result)); + }; link_hmi_to_mob_result(HMIResult::INVALID_ENUM, MobileResult::INVALID_ENUM); link_hmi_to_mob_result(HMIResult::SUCCESS, MobileResult::SUCCESS); link_hmi_to_mob_result(HMIResult::UNSUPPORTED_REQUEST, @@ -233,17 +232,17 @@ class CommandsTest : public ::testing::Test { }; MATCHER_P(MobileResultCodeIs, result_code, "") { - return result_code == - static_cast<mobile_apis::Result::eType>( - (*arg)[application_manager::strings::msg_params] - [application_manager::strings::result_code].asInt()); + return result_code == static_cast<mobile_apis::Result::eType>( + (*arg)[application_manager::strings::msg_params] + [application_manager::strings::result_code] + .asInt()); } MATCHER_P(HMIResultCodeIs, result_code, "") { - return result_code == - static_cast<hmi_apis::FunctionID::eType>( - (*arg)[application_manager::strings::params] - [application_manager::strings::function_id].asInt()); + return result_code == static_cast<hmi_apis::FunctionID::eType>( + (*arg)[application_manager::strings::params] + [application_manager::strings::function_id] + .asInt()); } MATCHER_P3(MobileResponseIs, result_code, result_info, result_success, "") { @@ -260,4 +259,4 @@ MATCHER_P3(MobileResponseIs, result_code, result_info, result_success, "") { } // namespace components } // namespace test -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_TEST_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMANDS_TEST_H_ diff --git a/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h b/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h index 881ebb2575..9f50a73075 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_launch_data.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APP_LAUNCH_DATA_H_ -#include "gmock/gmock.h" #include "application_manager/app_launch/app_launch_data.h" +#include "gmock/gmock.h" namespace test { namespace components { 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 36d20f227d..362dda4efb 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 @@ -1,43 +1,45 @@ /* * 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. -*/ + * 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_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APPLICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_APPLICATION_H_ #include <string> -#include "gmock/gmock.h" -#include "application_manager/application.h" #include "application_manager/app_extension.h" +#include "application_manager/application.h" +#include "application_manager/display_capabilities_builder.h" +#include "application_manager/hmi_state.h" +#include "application_manager/usage_statistics.h" +#include "gmock/gmock.h" #include "smart_objects/smart_object.h" #include "utils/custom_string.h" -#include "application_manager/usage_statistics.h" #include "utils/semantic_version.h" namespace test { @@ -56,6 +58,8 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(is_application_data_changed, bool()); MOCK_METHOD1(set_is_application_data_changed, void(bool state_application_data)); + MOCK_CONST_METHOD0(is_app_data_resumption_allowed, bool()); + MOCK_METHOD1(set_app_data_resumption_allowance, void(bool allowed)); MOCK_METHOD0(CloseActiveMessage, void()); MOCK_CONST_METHOD0(IsFullscreen, bool()); MOCK_METHOD0(ChangeSupportingAppHMIType, void()); @@ -82,8 +86,9 @@ class MockApplication : public ::application_manager::Application { 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_METHOD2(WakeUpStreaming, + void(protocol_handler::ServiceType service_type, + uint32_t timer_len)); MOCK_CONST_METHOD0(is_voice_communication_supported, bool()); MOCK_METHOD1(set_voice_communication_supported, void(bool is_voice_communication_supported)); @@ -97,11 +102,15 @@ class MockApplication : public ::application_manager::Application { 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_METHOD1(hmi_level, + const mobile_apis::HMILevel::eType( + const application_manager::WindowID window_id)); 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_METHOD1(system_context, + const mobile_apis::SystemContext::eType( + const application_manager::WindowID window_id)); MOCK_CONST_METHOD0(audio_streaming_state, const mobile_apis::AudioStreamingState::eType()); MOCK_CONST_METHOD0(video_streaming_state, @@ -109,11 +118,20 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(app_icon_path, const std::string&()); MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle()); MOCK_CONST_METHOD0(secondary_device, connection_handler::DeviceHandle()); - MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr()); - MOCK_CONST_METHOD0(RegularHmiState, const application_manager::HmiStatePtr()); + MOCK_CONST_METHOD1(CurrentHmiState, + const application_manager::HmiStatePtr( + const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(RegularHmiState, + const application_manager::HmiStatePtr( + const application_manager::WindowID window_id)); + MOCK_CONST_METHOD0(GetWindowIds, application_manager::WindowIds()); + MOCK_CONST_METHOD0(GetWindowNames, application_manager::WindowNames()); + MOCK_CONST_METHOD1(WindowIdExists, + bool(const application_manager::WindowID window_id)); MOCK_CONST_METHOD0(IsAllowedToChangeAudioSource, bool()); - MOCK_CONST_METHOD0(PostponedHmiState, - const application_manager::HmiStatePtr()); + MOCK_CONST_METHOD1(PostponedHmiState, + const application_manager::HmiStatePtr( + const application_manager::WindowID window_id)); 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)); @@ -167,14 +185,24 @@ class MockApplication : public ::application_manager::Application { ::application_manager::HelpPromptManager&()); MOCK_CONST_METHOD0(help_prompt_manager, const ::application_manager::HelpPromptManager&()); - MOCK_METHOD1(SetInitialState, void(::application_manager::HmiStatePtr state)); - 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_METHOD3(SetInitialState, + void(const application_manager::WindowID window_id, + const std::string& window_name, + application_manager::HmiStatePtr state)); + MOCK_METHOD2(SetRegularState, + void(const application_manager::WindowID window_id, + application_manager::HmiStatePtr state)); + MOCK_METHOD2(SetPostponedState, + void(const application_manager::WindowID window_id, + ::application_manager::HmiStatePtr state)); + MOCK_METHOD1(RemovePostponedState, + void(const application_manager::WindowID window_id)); + MOCK_METHOD2(AddHMIState, + void(const application_manager::WindowID window_id, + application_manager::HmiStatePtr state)); + MOCK_METHOD2(RemoveHMIState, + void(const application_manager::WindowID window_id, + ::application_manager::HmiState::StateID state_id)); MOCK_METHOD2(SubscribeToSoftButtons, void(int32_t cmd_id, const ::application_manager::SoftButtonID& softbuttons_id)); @@ -220,9 +248,35 @@ class MockApplication : public ::application_manager::Application { 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_CONST_METHOD0(day_color_scheme, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(night_color_scheme, const smart_objects::SmartObject*()); - MOCK_CONST_METHOD0(display_layout, const std::string&()); + MOCK_CONST_METHOD0(day_color_scheme, smart_objects::SmartObject()); + MOCK_CONST_METHOD0(night_color_scheme, smart_objects::SmartObject()); + MOCK_CONST_METHOD0(display_layout, std::string()); + MOCK_CONST_METHOD0(display_capabilities, smart_objects::SmartObjectSPtr()); + MOCK_CONST_METHOD1(display_capabilities, + smart_objects::SmartObjectSPtr( + const application_manager::WindowID window_id)); + + MOCK_METHOD2(set_window_layout, + void(const application_manager::WindowID window_id, + const std::string& layout)); + MOCK_METHOD2(set_day_color_scheme, + void(const application_manager::WindowID window_id, + const smart_objects::SmartObject& color_scheme)); + MOCK_METHOD2(set_night_color_scheme, + void(const application_manager::WindowID window_id, + const smart_objects::SmartObject& color_scheme)); + MOCK_CONST_METHOD1( + window_layout, + std::string(const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(day_color_scheme, + smart_objects::SmartObject( + const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(night_color_scheme, + smart_objects::SmartObject( + const application_manager::WindowID window_id)); + MOCK_METHOD1(set_display_capabilities, + void(const smart_objects::SmartObject& display_capabilities)); + MOCK_METHOD1(load_global_properties, void(const smart_objects::SmartObject& so)); MOCK_METHOD1(set_help_prompt, @@ -316,9 +370,10 @@ class MockApplication : public ::application_manager::Application { SwapMobileMessageQueue, void(::application_manager::MobileMessageQueue& mobile_messages)); - MOCK_METHOD1( + MOCK_METHOD2( set_system_context, - void(const application_manager::mobile_api::SystemContext::eType&)); + void(const application_manager::WindowID window_id, + const application_manager::mobile_api::SystemContext::eType&)); MOCK_METHOD1( set_audio_streaming_state, void(const application_manager::mobile_api::AudioStreamingState::eType& @@ -329,9 +384,10 @@ class MockApplication : public ::application_manager::Application { bool(smart_objects::SmartObject module)); MOCK_METHOD1(UnsubscribeFromInteriorVehicleData, bool(smart_objects::SmartObject module)); - MOCK_METHOD1( + MOCK_METHOD2( set_hmi_level, - void(const application_manager::mobile_api::HMILevel::eType& hmi_level)); + void(const application_manager::WindowID window_id, + const application_manager::mobile_api::HMILevel::eType& hmi_level)); MOCK_METHOD1(QueryInterface, application_manager::AppExtensionPtr( application_manager::AppExtensionUID uid)); @@ -357,6 +413,24 @@ class MockApplication : public ::application_manager::Application { void(const mobile_apis::HybridAppPreference::eType& hybrid_app_preference)); MOCK_METHOD1(set_cloud_app_certificate, void(const std::string& certificate)); + MOCK_METHOD2(SetWindowInfo, + void(const ::application_manager::WindowID windowID, + const smart_objects::SmartObject& window_info)); + MOCK_METHOD1(RemoveWindowInfo, + void((const ::application_manager::WindowID window_id))); + MOCK_CONST_METHOD0(window_optional_params_map, + DataAccessor< ::application_manager::WindowParamsMap>()); + MOCK_METHOD0(display_capabilities_builder, + application_manager::DisplayCapabilitiesBuilder&()); + MOCK_METHOD1(GetSoftButtonWindowID, + application_manager::WindowID(const uint32_t button_id)); + MOCK_METHOD1(remove_window_capability, + void(const application_manager::WindowID window_id)); + MOCK_CONST_METHOD1(menu_layout_supported, + bool(const mobile_apis::MenuLayout::eType layout)); + MOCK_METHOD1(set_user_location, + void(const smart_objects::SmartObject& user_location)); + MOCK_CONST_METHOD0(get_user_location, const smart_objects::SmartObject&()); }; } // namespace application_manager_test diff --git a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h index c5aedba029..b345f53c1c 100644 --- a/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h +++ b/src/components/application_manager/test/include/application_manager/mock_event_dispatcher.h @@ -37,6 +37,7 @@ #include "application_manager/event_engine/event.h" #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/event_engine/event_observer.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/include/application_manager/mock_event_observer.h b/src/components/application_manager/test/include/application_manager/mock_event_observer.h index 8af31c1998..1357d67a65 100644 --- a/src/components/application_manager/test/include/application_manager/mock_event_observer.h +++ b/src/components/application_manager/test/include/application_manager/mock_event_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_EVENT_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_EVENT_OBSERVER_H_ -#include "application_manager/event_engine/event_observer.h" #include "application_manager/event_engine/event.h" +#include "application_manager/event_engine/event_observer.h" #include "gmock/gmock.h" namespace test { @@ -49,6 +49,9 @@ class MockEventObserver : application_manager::event_engine::EventObserver(event_dispatcher) {} MOCK_METHOD1(on_event, void(const application_manager::event_engine::Event& event)); + MOCK_METHOD1( + on_event, + void(const application_manager::event_engine::MobileEvent& event)); }; } // namespace event_engine_test diff --git a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h index a415f94d56..b44345deff 100644 --- a/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_help_prompt_manager.h @@ -1,34 +1,34 @@ /* * Copyright (c) 2018, Ford Motor Company -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following -* disclaimer in the documentation and/or other materials provided with the -* distribution. -* -* Neither the name of the Ford Motor Company nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ + * 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_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_HELP_PROMPT_MANAGER_H_ 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 468bdbe5eb..5e5f2eb4a4 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 @@ -103,6 +103,11 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_METHOD1(set_display_capabilities, void(const smart_objects::SmartObject& display_capabilities)); + MOCK_CONST_METHOD0(system_display_capabilities, + const smart_objects::SmartObjectSPtr()); + MOCK_METHOD1(set_system_display_capabilities, + void(const smart_objects::SmartObject& display_capabilities)); + MOCK_CONST_METHOD0(hmi_zone_capabilities, const smart_objects::SmartObject*()); MOCK_METHOD1(set_hmi_zone_capabilities, @@ -181,6 +186,12 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_METHOD1(set_rc_capability, void(const smart_objects::SmartObject& rc_capability)); + MOCK_CONST_METHOD0(seat_location_capability, + const smart_objects::SmartObject*()); + MOCK_METHOD1( + set_seat_location_capability, + void(const smart_objects::SmartObject& seat_location_capability)); + MOCK_METHOD1(Init, void(resumption::LastState* last_state)); MOCK_CONST_METHOD0(ccpu_version, const std::string&()); @@ -198,6 +209,9 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_CONST_METHOD2(convert_json_languages_to_obj, void(const Json::Value& json_languages, smart_objects::SmartObject& languages)); + MOCK_CONST_METHOD2(convert_audio_capability_to_obj, + void(const Json::Value& capability, + smart_objects::SmartObject& output_so)); }; } // namespace application_manager_test 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 ac39c39f22..072199082e 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 @@ -32,13 +32,14 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_MESSAGE_HELPER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_MESSAGE_HELPER_H_ -#include "gmock/gmock.h" #include "application_manager/application.h" +#include "application_manager/application_manager.h" +#include "application_manager/hmi_capabilities.h" #include "application_manager/message_helper.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "gmock/gmock.h" #include "interfaces/HMI_API.h" #include "policy/policy_types.h" -#include "application_manager/policies/policy_handler_interface.h" -#include "application_manager/application_manager.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" @@ -128,8 +129,9 @@ class MockMessageHelper { MOCK_METHOD2(CreateMessageForHMI, smart_objects::SmartObjectSPtr(hmi_apis::messageType::eType, const uint32_t)); - MOCK_METHOD2(SendHMIStatusNotification, - void(const Application& application_impl, + MOCK_METHOD3(SendHMIStatusNotification, + void(ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager)); MOCK_METHOD4(SendPolicyUpdate, void(const std::string& file_path, @@ -153,10 +155,11 @@ class MockMessageHelper { uint32_t correlation_id, ApplicationManager& app_mngr)); #endif // #ifdef EXTERNAL_PROPRIETARY_MODE - MOCK_METHOD3(SendOnPermissionsChangeNotification, + MOCK_METHOD4(SendOnPermissionsChangeNotification, void(uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr)); + ApplicationManager& app_mngr, + const bool require_encryption)); MOCK_METHOD4(SendPolicySnapshotNotification, void(uint32_t connection_key, const std::vector<uint8_t>& policy_data, @@ -168,6 +171,8 @@ class MockMessageHelper { hmi_apis::Common_LightName::eType(const std::string& lightName)); MOCK_METHOD1(CommonLanguageToString, std::string(hmi_apis::Common_Language::eType)); + MOCK_METHOD1(MobileLanguageToString, + std::string(mobile_apis::Language::eType)); MOCK_METHOD2(CreateModuleInfoSO, smart_objects::SmartObjectSPtr(uint32_t function_id, ApplicationManager& app_mngr)); @@ -201,14 +206,16 @@ class MockMessageHelper { MessageHelper::ChoiceSetVRCommandsStatus( const smart_objects::SmartObject&)); - MOCK_METHOD6(GetBCActivateAppRequestToHMI, + MOCK_METHOD5(GetBCActivateAppRequestToHMI, smart_objects::SmartObjectSPtr( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr)); + MOCK_METHOD2(GetBCCloseApplicationRequestToHMI, + smart_objects::SmartObjectSPtr(ApplicationConstSharedPtr app, + ApplicationManager& app_mngr)); MOCK_METHOD2(GetOnAppInterfaceUnregisteredNotificationToMobile, ns_smart_device_link::ns_smart_objects::SmartObjectSPtr( int32_t connection_key, @@ -219,6 +226,11 @@ class MockMessageHelper { ApplicationConstSharedPtr app, const policy::PolicyHandlerInterface& policy_handler, ApplicationManager& app_mngr)); + MOCK_METHOD4(SubscribeApplicationToSoftButton, + void(smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, + int32_t function_id, + const application_manager::WindowID window_id)); MOCK_METHOD3(SubscribeApplicationToSoftButton, void(smart_objects::SmartObject& message_params, ApplicationSharedPtr app, @@ -278,6 +290,10 @@ class MockMessageHelper { MOCK_METHOD1(PrintSmartObject, bool(const smart_objects::SmartObject& object)); + + MOCK_METHOD1(ExtractWindowIdFromSmartObject, + WindowID(const smart_objects::SmartObject& s_map)); + MOCK_METHOD3(SendTTSGlobalProperties, void(ApplicationSharedPtr app, const bool default_help_prompt, @@ -316,6 +332,22 @@ class MockMessageHelper { MOCK_METHOD2(BroadcastCapabilityUpdate, void(smart_objects::SmartObject& msg_params, ApplicationManager& app_mngr)); + MOCK_METHOD3(CreateUICreateWindowRequestsToHMI, + smart_objects::SmartObjectList( + ApplicationSharedPtr application, + ApplicationManager& app_manager, + const smart_objects::SmartObject& windows_info)); + MOCK_METHOD2( + CreateDisplayCapabilityUpdateToMobile, + smart_objects::SmartObjectSPtr(const smart_objects::SmartObject&, + application_manager::Application&)); + MOCK_METHOD4(CreateOnServiceUpdateNotification, + smart_objects::SmartObjectSPtr( + const hmi_apis::Common_ServiceType::eType service_type, + const hmi_apis::Common_ServiceEvent::eType service_event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType + service_update_reason, + const uint32_t app_id)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/include/application_manager/mock_request.h b/src/components/application_manager/test/include/application_manager/mock_request.h index e4cfa84841..77b5bb7c38 100644 --- a/src/components/application_manager/test/include/application_manager/mock_request.h +++ b/src/components/application_manager/test/include/application_manager/mock_request.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_REQUEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_REQUEST_H_ -#include "gmock/gmock.h" #include "application_manager/commands/command.h" +#include "gmock/gmock.h" namespace test { namespace components { @@ -55,6 +55,7 @@ class MockRequest : public application_manager::commands::Command { MOCK_METHOD0(CleanUp, bool()); MOCK_CONST_METHOD0(default_timeout, uint32_t()); MOCK_CONST_METHOD0(function_id, int32_t()); + MOCK_CONST_METHOD0(window_id, application_manager::WindowID()); MOCK_METHOD0(onTimeOut, void()); MOCK_METHOD0(AllowedToTerminate, bool()); MOCK_METHOD1(SetAllowedToTerminate, void(bool is_allowed)); diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h index 0fa7a898be..56c2ae3cd4 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h +++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h @@ -31,9 +31,9 @@ */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUME_CTRL_H_ -#include "gmock/gmock.h" -#include "application_manager/resumption/resume_ctrl.h" #include "application_manager/application.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "gmock/gmock.h" #include "resumption/last_state.h" namespace test { @@ -94,13 +94,23 @@ class MockResumeCtrl : public resumption::ResumeCtrl { MOCK_METHOD1(SetupDefaultHMILevel, bool(application_manager::ApplicationSharedPtr application)); MOCK_METHOD1(StartAppHmiStateResumption, - void(application_manager::ApplicationSharedPtr application)); + bool(application_manager::ApplicationSharedPtr application)); MOCK_METHOD3(SetAppHMIState, bool(application_manager::ApplicationSharedPtr application, const mobile_apis::HMILevel::eType hmi_level, bool check_policy)); MOCK_CONST_METHOD0(LaunchTime, time_t()); + MOCK_METHOD2(RestoreAppWidgets, + void(app_mngr::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app)); + + MOCK_METHOD1(RestoreWidgetsHMIState, + void(const smart_objects::SmartObject& response_message)); + + MOCK_METHOD1(StartWaitingForDisplayCapabilitiesUpdate, + void(application_manager::ApplicationSharedPtr application)); + #ifdef BUILD_TESTS MOCK_METHOD1(set_resumption_storage, void(std::shared_ptr<resumption::ResumptionData> mock_storage)); diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h index 38d1944dba..7cabc12086 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h @@ -1,42 +1,42 @@ /* -* 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. -*/ + * 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_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUMPTION_DATA_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RESUMPTION_DATA_H_ #include <string> -#include "gmock/gmock.h" -#include "application_manager/resumption/resumption_data.h" #include "application_manager/application.h" -#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/resumption/resumption_data.h" +#include "gmock/gmock.h" #include "smart_objects/smart_object.h" namespace test { diff --git a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h new file mode 100644 index 0000000000..112de0fea5 --- /dev/null +++ b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_manager.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ + +#include "application_manager/rpc_protection_manager.h" +#include "gmock/gmock.h" + +namespace application_manager { +class MockRPCProtectionManager : public RPCProtectionManager { + public: + MOCK_CONST_METHOD3(CheckPolicyEncryptionFlag, + bool(const uint32_t function_id, + const ApplicationSharedPtr app, + const bool is_rpc_service_secure)); + + MOCK_METHOD3(CreateEncryptionNeededResponse, + std::shared_ptr<smart_objects::SmartObject>( + const uint32_t connection_key, + const uint32_t function_id, + const uint32_t conrrelation_id)); + + MOCK_CONST_METHOD2(IsInEncryptionNeededCache, + bool(const uint32_t app_id, + const uint32_t conrrelation_id)); + + MOCK_METHOD2(AddToEncryptionNeededCache, + void(const uint32_t app_id, const uint32_t correlation_id)); + + MOCK_METHOD2(RemoveFromEncryptionNeededCache, + void(const uint32_t app_id, const uint32_t correlation_id)); +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_RPC_PROTECTION_MANAGER_H_ diff --git a/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h new file mode 100644 index 0000000000..858673e3b3 --- /dev/null +++ b/src/components/application_manager/test/include/application_manager/mock_rpc_protection_mediator.h @@ -0,0 +1,22 @@ +#pragma once + +#include "application_manager/rpc_protection_mediator.h" +#include "gmock/gmock.h" + +namespace application_manager { +class MockRPCProtectionMediator : public RPCProtectionMediator { + public: + MOCK_METHOD4(DoesRPCNeedEncryption, + bool(const uint32_t function_id, + std::shared_ptr<Application> app, + const uint32_t conrrelation_id, + const bool is_rpc_service_secure)); + MOCK_METHOD1(DoesRPCNeedEncryption, bool(const uint32_t conrrelation_id)); + MOCK_METHOD1(EncryptResponseByForce, void(const uint32_t conrrelation_id)); + MOCK_METHOD3(CreateNegativeResponse, + std::shared_ptr<smart_objects::SmartObject>( + const uint32_t connection_key, + const uint32_t function_id, + const uint32_t conrrelation_id)); +}; +} // namespace application_manager diff --git a/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h b/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h index cd4632965c..c79a31817e 100644 --- a/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h +++ b/src/components/application_manager/test/include/application_manager/mock_telemetry_observer.h @@ -33,8 +33,8 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_TELEMETRY_OBSERVER_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_MOCK_TELEMETRY_OBSERVER_H_ -#include "gmock/gmock.h" #include "application_manager/telemetry_observer.h" +#include "gmock/gmock.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/include/application_manager/resumption_data_test.h b/src/components/application_manager/test/include/application_manager/resumption_data_test.h index 4e614c4d9f..e313427547 100644 --- a/src/components/application_manager/test/include/application_manager/resumption_data_test.h +++ b/src/components/application_manager/test/include/application_manager/resumption_data_test.h @@ -33,20 +33,20 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_RESUMPTION_DATA_TEST_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_RESUMPTION_DATA_TEST_H_ -#include <string> #include <algorithm> -#include "gtest/gtest.h" -#include "application_manager/usage_statistics.h" +#include <string> +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/mock_app_extension.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" -#include "application_manager/mock_app_extension.h" -#include "utils/data_accessor.h" -#include "config_profile/profile.h" +#include "application_manager/mock_application_manager_settings.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/state_controller.h" +#include "application_manager/usage_statistics.h" +#include "config_profile/profile.h" +#include "gtest/gtest.h" +#include "utils/data_accessor.h" namespace test { namespace components { @@ -74,7 +74,9 @@ class ResumptionDataTest : public ::testing::Test { , comlock_ptr_(std::make_shared<sync_primitives::Lock>()) , setlock_ptr_(std::make_shared<sync_primitives::Lock>()) , btnlock_ptr_(std::make_shared<sync_primitives::Lock>()) - , ivilock_ptr_(std::make_shared<sync_primitives::Lock>()) {} + , ivilock_ptr_(std::make_shared<sync_primitives::Lock>()) + , window_params_map_lock_ptr_(std::make_shared<sync_primitives::Lock>()) { + } // Check structure in saved application void CheckSavedApp(sm::SmartObject& saved_data); // Set data for resumption @@ -114,6 +116,9 @@ class ResumptionDataTest : public ::testing::Test { void SetHelpAndTimeoutPrompt(); void SetVRHelpTitle(); void SetSubscriptions(); + void SetWindowsInfo(); + void SetDefaultCurrentHmiState(); + void SetDefaultWindowIds(); void CheckCommands(sm::SmartObject& res_list); void CheckGlobalProporties(sm::SmartObject& res_list); @@ -129,6 +134,7 @@ class ResumptionDataTest : public ::testing::Test { ns_smart_device_link::ns_smart_objects::SmartObject& res_list); void CheckVRTitle(sm::SmartObject& res_list); void CheckSubscriptions(sm::SmartObject& res_list); + void CheckWindowsInfo(sm::SmartObject& res_list); const size_t kCountOfCommands_; const size_t kCountOfChoice_; @@ -145,11 +151,14 @@ class ResumptionDataTest : public ::testing::Test { am::ButtonSubscriptions btn_subscr; + am::WindowParamsMap test_window_params_map_; + std::shared_ptr<sync_primitives::Lock> sublock_ptr_; std::shared_ptr<sync_primitives::Lock> comlock_ptr_; std::shared_ptr<sync_primitives::Lock> setlock_ptr_; std::shared_ptr<sync_primitives::Lock> btnlock_ptr_; std::shared_ptr<sync_primitives::Lock> ivilock_ptr_; + std::shared_ptr<sync_primitives::Lock> window_params_map_lock_ptr_; application_manager_test::MockApplicationManagerSettings mock_application_manager_settings_; application_manager_test::MockApplicationManager mock_application_manager_; diff --git a/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h b/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h index e10f60afac..3f5802cb5a 100644 --- a/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h +++ b/src/components/application_manager/test/include/application_manager/test_resumption_data_db.h @@ -33,10 +33,10 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_TEST_RESUMPTION_DATA_DB_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_TEST_INCLUDE_APPLICATION_MANAGER_TEST_RESUMPTION_DATA_DB_H_ -#include "utils/sqlite_wrapper/sql_database.h" -#include "application_manager/resumption/resumption_data_db.h" -#include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/resumption/resumption_data_db.h" +#include "utils/sqlite_wrapper/sql_database.h" using ::resumption::ResumptionDataDB; diff --git a/src/components/application_manager/test/message_helper/CMakeLists.txt b/src/components/application_manager/test/message_helper/CMakeLists.txt index 99031849f6..31b175cbf0 100755 --- a/src/components/application_manager/test/message_helper/CMakeLists.txt +++ b/src/components/application_manager/test/message_helper/CMakeLists.txt @@ -40,7 +40,7 @@ set(LIBRARIES ApplicationManager MessageHelper jsoncpp - Policy + PolicyStatic connectionHandler MediaManager Resumption 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 92be221ec9..a174d74d5d 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 @@ -36,18 +36,18 @@ #include "gmock/gmock.h" #include "utils/macro.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_help_prompt_manager.h" -#include "utils/custom_string.h" -#include "utils/lock.h" -#include "policy/mock_policy_settings.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/event_engine/event_dispatcher.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_rpc_service.h" -#include "application_manager/event_engine/event_dispatcher.h" -#include "application_manager/state_controller.h" +#include "application_manager/policies/policy_handler.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/state_controller.h" +#include "policy/mock_policy_settings.h" +#include "utils/custom_string.h" +#include "utils/lock.h" #include "policy/policy_table/types.h" #include "rpc_base/rpc_base_json_inl.h" @@ -70,12 +70,12 @@ typedef std::shared_ptr<MockApplication> MockApplicationSharedPtr; typedef std::vector<std::string> StringArray; typedef std::shared_ptr<application_manager::Application> ApplicationSharedPtr; +using testing::_; using testing::AtLeast; -using testing::ReturnRefOfCopy; -using testing::ReturnRef; using testing::Return; +using testing::ReturnRef; +using testing::ReturnRefOfCopy; using testing::SaveArg; -using testing::_; TEST(MessageHelperTestCreate, CreateBlockedByPoliciesResponse_SmartObject_Equal) { @@ -951,7 +951,8 @@ TEST_F(MessageHelperTest, SubscribeApplicationToSoftButton_CallFromApp) { size_t function_id = 1; // EXPECT_CALL(*appSharedPtr, - SubscribeToSoftButtons(function_id, SoftButtonID())).Times(1); + SubscribeToSoftButtons(function_id, SoftButtonID())) + .Times(1); MessageHelper::SubscribeApplicationToSoftButton( message_params, appSharedPtr, function_id); } @@ -1083,6 +1084,27 @@ TEST_F(MessageHelperTest, SendNaviSetVideoConfigRequest) { EXPECT_EQ(480, msg_params[strings::config][strings::height].asInt()); } +TEST_F(MessageHelperTest, ExtractWindowIdFromSmartObject_SUCCESS) { + const WindowID window_id = 145; + smart_objects::SmartObject message(smart_objects::SmartType_Map); + message[strings::msg_params][strings::window_id] = window_id; + EXPECT_EQ(window_id, + MessageHelper::ExtractWindowIdFromSmartObject( + message[strings::msg_params])); +} + +TEST_F(MessageHelperTest, ExtractWindowIdFromSmartObject_FromEmptyMessage) { + smart_objects::SmartObject message(smart_objects::SmartType_Map); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + MessageHelper::ExtractWindowIdFromSmartObject(message)); +} + +TEST_F(MessageHelperTest, ExtractWindowIdFromSmartObject_FromWrongType) { + smart_objects::SmartObject message(smart_objects::SmartType_Array); + EXPECT_EQ(mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + MessageHelper::ExtractWindowIdFromSmartObject(message)); +} + } // namespace application_manager_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/mobile_event_engine_test.cc b/src/components/application_manager/test/mobile_event_engine_test.cc new file mode 100644 index 0000000000..cad1ff14ff --- /dev/null +++ b/src/components/application_manager/test/mobile_event_engine_test.cc @@ -0,0 +1,171 @@ +/* + * 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 "gtest/gtest.h" + +#include "application_manager/event_engine/event.h" +#include "application_manager/event_engine/event_dispatcher_impl.h" +#include "application_manager/event_engine/event_observer.h" +#include "application_manager/message.h" +#include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_event_observer.h" +#include "smart_objects/smart_object.h" + +#include "interfaces/MOBILE_API.h" + +namespace test { +namespace components { +namespace event_engine_test { + +using application_manager::event_engine::Event; +using application_manager::event_engine::EventDispatcherImpl; +using application_manager::event_engine::EventObserver; +using application_manager::event_engine::MobileEvent; +using testing::_; +using ::testing::An; +using ::testing::Matcher; + +class MobileEventEngineTest : public testing::Test { + public: + MobileEventEngineTest() + : event_id(MobileEvent::MobileEventID::GetAppServiceDataID) + , event_observer_mock_(mock_event_dispatcher_) {} + + protected: + EventDispatcherImpl* event_dispatcher_instance_; + MobileEvent* event_; + const MobileEvent::MobileEventID event_id; + MockEventDispatcher mock_event_dispatcher_; + MockEventObserver event_observer_mock_; + const int32_t correlation_id = 1121; + smart_objects::SmartObject smart_object_with_type_notification; + smart_objects::SmartObject smart_object_with_type_response; + smart_objects::SmartObject smart_object_with_type_error_response; + smart_objects::SmartObject smart_object_with_type_request; + smart_objects::SmartObject smart_object_with_invalid_type; + + virtual void SetUp() OVERRIDE { + event_dispatcher_instance_ = new EventDispatcherImpl(); + event_ = + new MobileEvent(mobile_apis::FunctionID::eType::GetAppServiceDataID); + smart_object_with_type_notification["params"]["message_type"] = + application_manager::MessageType::kNotification; + smart_object_with_type_notification["params"]["correlation_id"] = + correlation_id; + smart_object_with_type_notification["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + + smart_object_with_type_response["params"]["message_type"] = + application_manager::MessageType::kResponse; + smart_object_with_type_response["params"]["correlation_id"] = + correlation_id; + smart_object_with_type_response["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + + smart_object_with_type_request["params"]["message_type"] = + application_manager::MessageType::kRequest; + smart_object_with_type_request["params"]["correlation_id"] = correlation_id; + smart_object_with_type_request["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + + smart_object_with_invalid_type["params"]["message_type"] = + application_manager::MessageType::kUnknownType; + smart_object_with_invalid_type["params"]["correlation_id"] = correlation_id; + smart_object_with_invalid_type["params"]["function_id"] = + mobile_apis::FunctionID::eType::GetAppServiceDataID; + } + + void TearDown() OVERRIDE { + delete event_dispatcher_instance_; + delete event_; + } + + void CheckRaiseMobileEvent(const MobileEvent::MobileEventID& event_id, + const uint32_t calls_number, + const smart_objects::SmartObject& so) { + // Arrange + event_dispatcher_instance_->add_mobile_observer( + event_id, correlation_id, event_observer_mock_); + event_->set_smart_object(so); + EXPECT_CALL(event_observer_mock_, on_event(An<const MobileEvent&>())) + .Times(calls_number); + event_dispatcher_instance_->raise_mobile_event(*event_); + } +}; + +TEST_F(MobileEventEngineTest, EventObserverTest_ExpectObserversEmpty) { + // Arrange + EventObserver* event_observer_ptr = + static_cast<EventObserver*>(&event_observer_mock_); + // Check + EXPECT_EQ(reinterpret_cast<unsigned long>(event_observer_ptr), + event_observer_mock_.id()); +} + +TEST_F(MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeResponse_ExpectEventRaised) { + CheckRaiseMobileEvent(event_id, 1u, smart_object_with_type_response); +} + +TEST_F(MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeInvalid_ExpectEventNotRaised) { + CheckRaiseMobileEvent(event_id, 0u, smart_object_with_invalid_type); +} + +TEST_F(MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeRequest_ExpectEventNotRaised) { + CheckRaiseMobileEvent(event_id, 0u, smart_object_with_type_request); +} + +TEST_F( + MobileEventEngineTest, + EventDispatcherImpl_RaiseEvent_EventSOTypeNotification_ExpectEventNotRaised) { + CheckRaiseMobileEvent(event_id, 0u, smart_object_with_type_notification); +} + +TEST_F(MobileEventEngineTest, Event_set_smart_object_ExpectObjectSet) { + // Act + event_->set_smart_object(smart_object_with_type_response); + const int32_t obj_type = + static_cast<int32_t>(application_manager::MessageType::kResponse); + const int32_t function_id = + static_cast<int32_t>(mobile_apis::FunctionID::eType::GetAppServiceDataID); + // Checks + EXPECT_EQ(obj_type, event_->smart_object_type()); + EXPECT_EQ(function_id, event_->smart_object_function_id()); + EXPECT_EQ(correlation_id, event_->smart_object_correlation_id()); + EXPECT_EQ(smart_object_with_type_response, event_->smart_object()); +} + +} // namespace event_engine_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 23957b61fb..3ae79ce8ce 100644 --- a/src/components/application_manager/test/mobile_message_handler_test.cc +++ b/src/components/application_manager/test/mobile_message_handler_test.cc @@ -32,30 +32,30 @@ #include "application_manager/mobile_message_handler.h" -#include <string> -#include <ctime> #include <algorithm> +#include <ctime> #include <iterator> +#include <string> #include <vector> -#include "gmock/gmock.h" #include "application_manager/message.h" +#include "gmock/gmock.h" #include "protocol/raw_message.h" namespace test { namespace components { namespace application_manager_test { +using ::application_manager::Message; +using ::application_manager::MobileMessage; +using application_manager::MobileMessageHandler; +using protocol_handler::MajorProtocolVersion; +using protocol_handler::MessagePriority; +using protocol_handler::PROTOCOL_HEADER_V2_SIZE; using protocol_handler::RawMessage; using protocol_handler::RawMessagePtr; using protocol_handler::ServiceType; -using protocol_handler::MessagePriority; -using protocol_handler::PROTOCOL_HEADER_V2_SIZE; -using application_manager::MobileMessageHandler; -using protocol_handler::MajorProtocolVersion; using ::testing::_; -using ::application_manager::Message; -using ::application_manager::MobileMessage; using testing::Return; @@ -109,6 +109,7 @@ class MobileMessageHandlerTest : public testing::Test { protocol_version, &full_data[0], full_size, + false, ServiceType::kRpc, payload_size); 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 5cbc28b20c..ab37694c28 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 @@ -32,19 +32,19 @@ #include "application_manager/mobile_message_handler.h" -#include <string> -#include <vector> #include <algorithm> #include <iterator> +#include <string> +#include <vector> -#include "gmock/gmock.h" #include "application_manager/message.h" +#include "gmock/gmock.h" #include "protocol/raw_message.h" +using application_manager::MobileMessageHandler; +using protocol_handler::PROTOCOL_HEADER_V1_SIZE; using protocol_handler::RawMessage; using protocol_handler::RawMessagePtr; -using protocol_handler::PROTOCOL_HEADER_V1_SIZE; -using application_manager::MobileMessageHandler; namespace test { namespace components { @@ -69,8 +69,11 @@ const unsigned char* data_v1 = TEST(MobileMessageHandlerTestV1Test, HandleIncomingMessageProtocolV1_SendJSONData_ExpectEqual) { - RawMessagePtr message = std::make_shared<RawMessage>( - connection_key_p1, protocol_version_1, data_v1, data_json.length()); + RawMessagePtr message = std::make_shared<RawMessage>(connection_key_p1, + protocol_version_1, + data_v1, + data_json.length(), + false); application_manager::Message* ptr = MobileMessageHandler::HandleIncomingMessageProtocol(message); @@ -89,8 +92,11 @@ TEST(MobileMessageHandlerTestV1Test, const unsigned char* data_v1 = reinterpret_cast<const unsigned char*>(full_data.c_str()); - RawMessagePtr message = std::make_shared<RawMessage>( - connection_key_p1, protocol_version_1, data_v1, full_data.length()); + RawMessagePtr message = std::make_shared<RawMessage>(connection_key_p1, + protocol_version_1, + data_v1, + full_data.length(), + false); application_manager::Message* ptr = MobileMessageHandler::HandleIncomingMessageProtocol(message); diff --git a/src/components/application_manager/test/mock_application_helper.cc b/src/components/application_manager/test/mock_application_helper.cc index c64a56e53e..ea57709a73 100644 --- a/src/components/application_manager/test/mock_application_helper.cc +++ b/src/components/application_manager/test/mock_application_helper.cc @@ -41,15 +41,16 @@ MockApplicationHelper& MockApplicationHelper::application_helper_mock() { return application_helper_mock; } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test namespace application_manager { void DeleteApplicationData(ApplicationSharedPtr app, ApplicationManager& app_manager) { test::components::application_manager_test::MockApplicationHelper:: - application_helper_mock().RecallApplicationData(app, app_manager); + application_helper_mock() + .RecallApplicationData(app, app_manager); } -} // application_managers +} // namespace application_manager diff --git a/src/components/application_manager/test/mock_hmi_command_factory.cc b/src/components/application_manager/test/mock_hmi_command_factory.cc index 375da26067..5f76a9300b 100644 --- a/src/components/application_manager/test/mock_hmi_command_factory.cc +++ b/src/components/application_manager/test/mock_hmi_command_factory.cc @@ -30,9 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "application_manager/mock_hmi_command_factory.h" #include <gmock/gmock.h> #include "application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/hmi_command_factory.h" -#include "application_manager/mock_hmi_command_factory.h" namespace test { namespace components { @@ -43,9 +43,9 @@ MockHMICommandFactory* MockHMICommandFactory::mock_hmi_command_factory() { return &mock_hmi_command_factory; } -} // application_manager_test -} // components -} // test +} // namespace application_manager_test +} // namespace components +} // namespace test namespace sdl_rpc_plugin { namespace app_mngr = application_manager; @@ -53,6 +53,7 @@ app_mngr::CommandSharedPtr HMICommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager) { return test::components::application_manager_test::MockHMICommandFactory:: - mock_hmi_command_factory()->CreateCommand(message, application_manager); + mock_hmi_command_factory() + ->CreateCommand(message, application_manager); } -} // application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 518761c315..628fd97ae8 100644..100755 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -30,12 +30,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/message_helper.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler_interface.h" -#include "transport_manager/common.h" -#include "gtest/gtest.h" #include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "transport_manager/common.h" namespace application_manager { @@ -212,9 +212,10 @@ void MessageHelper::SendGetListOfPermissionsResponse( void MessageHelper::SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, - ApplicationManager& app_mngr) { + ApplicationManager& app_mngr, + const policy::EncryptionRequired require_encryption) { MockMessageHelper::message_helper_mock()->SendOnPermissionsChangeNotification( - connection_key, permissions, app_mngr); + connection_key, permissions, app_mngr, require_encryption); } void MessageHelper::SendPolicySnapshotNotification( @@ -258,10 +259,11 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI( } void MessageHelper::SendHMIStatusNotification( - const Application& application_impl, + ApplicationSharedPtr application, + const WindowID window_id, ApplicationManager& application_manager) { MockMessageHelper::message_helper_mock()->SendHMIStatusNotification( - application_impl, application_manager); + application, window_id, application_manager); } void MessageHelper::SendUpdateSDLResponse(const std::string& result, @@ -366,20 +368,25 @@ std::string MessageHelper::CommonLanguageToString( return MockMessageHelper::message_helper_mock()->CommonLanguageToString(lang); } +std::string MessageHelper::MobileLanguageToString( + mobile_apis::Language::eType lang) { + return MockMessageHelper::message_helper_mock()->MobileLanguageToString(lang); +} + smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( ApplicationConstSharedPtr app, - const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority, ApplicationManager& app_mngr) { return MockMessageHelper::message_helper_mock()->GetBCActivateAppRequestToHMI( - app, - session_observer, - policy_handler, - level, - send_policy_priority, - app_mngr); + app, policy_handler, level, send_policy_priority, app_mngr); +} + +smart_objects::SmartObjectSPtr MessageHelper::GetBCCloseApplicationRequestToHMI( + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { + return MockMessageHelper::message_helper_mock() + ->GetBCCloseApplicationRequestToHMI(app, app_mngr); } ns_smart_device_link::ns_smart_objects::SmartObjectSPtr @@ -403,6 +410,16 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( void MessageHelper::SubscribeApplicationToSoftButton( smart_objects::SmartObject& message_params, ApplicationSharedPtr app, + int32_t function_id, + const WindowID window_id) { + return MockMessageHelper::message_helper_mock() + ->SubscribeApplicationToSoftButton( + message_params, app, function_id, window_id); +} + +void MessageHelper::SubscribeApplicationToSoftButton( + smart_objects::SmartObject& message_params, + ApplicationSharedPtr app, int32_t function_id) { return MockMessageHelper::message_helper_mock() ->SubscribeApplicationToSoftButton(message_params, app, function_id); @@ -523,6 +540,12 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return MockMessageHelper::message_helper_mock()->PrintSmartObject(object); } +WindowID MessageHelper::ExtractWindowIdFromSmartObject( + const smart_objects::SmartObject& s_map) { + return MockMessageHelper::message_helper_mock() + ->ExtractWindowIdFromSmartObject(s_map); +} + void MessageHelper::SendSetAppIcon(const uint32_t app_id, const std::string& icon_path, ApplicationManager& application_manager) { @@ -589,4 +612,30 @@ void MessageHelper::BroadcastCapabilityUpdate( MockMessageHelper::message_helper_mock()->BroadcastCapabilityUpdate( msg_params, app_mngr); } + +smart_objects::SmartObjectList MessageHelper::CreateUICreateWindowRequestsToHMI( + application_manager::ApplicationSharedPtr application, + ApplicationManager& app_mngr, + const smart_objects::SmartObject& windows_info) { + return MockMessageHelper::message_helper_mock() + ->CreateUICreateWindowRequestsToHMI(application, app_mngr, windows_info); +} + +smart_objects::SmartObjectSPtr +MessageHelper::CreateDisplayCapabilityUpdateToMobile( + const smart_objects::SmartObject& system_capabilities, Application& app) { + return MockMessageHelper::message_helper_mock() + ->CreateDisplayCapabilityUpdateToMobile(system_capabilities, app); +} + +smart_objects::SmartObjectSPtr MessageHelper::CreateOnServiceUpdateNotification( + const hmi_apis::Common_ServiceType::eType service_type, + const hmi_apis::Common_ServiceEvent::eType service_event, + const hmi_apis::Common_ServiceStatusUpdateReason::eType + service_update_reason, + const uint32_t app_id) { + return MockMessageHelper::message_helper_mock() + ->CreateOnServiceUpdateNotification( + service_type, service_event, service_update_reason, app_id); +} } // namespace application_manager diff --git a/src/components/application_manager/test/policy_event_observer_test.cc b/src/components/application_manager/test/policy_event_observer_test.cc index 9b97f054b3..a74b12071c 100644 --- a/src/components/application_manager/test/policy_event_observer_test.cc +++ b/src/components/application_manager/test/policy_event_observer_test.cc @@ -33,10 +33,10 @@ #include "application_manager/policies/policy_event_observer.h" #include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/mock_event_dispatcher.h" #include "gmock/gmock.h" #include "policy/policy_types.h" #include "smart_objects/smart_object.h" -#include "application_manager/mock_event_dispatcher.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index af21a705bf..f99b76b9ad 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -30,48 +30,47 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <fstream> #include <string> #include <vector> -#include <fstream> #include "gmock/gmock.h" -#include "application_manager/policies/policy_handler.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager_impl.h" #include "application_manager/policies/delegates/app_permission_delegate.h" +#include "application_manager/policies/policy_handler.h" #include "connection_handler/connection_handler_impl.h" -#include "application_manager/application_manager_impl.h" -#include "application_manager/application_impl.h" #ifdef ENABLE_SECURITY -#include "security_manager/mock_security_manager.h" #include "security_manager/mock_crypto_manager.h" +#include "security_manager/mock_security_manager.h" #endif // ENABLE_SECURITY #include "application_manager/mock_message_helper.h" #include "connection_handler/mock_connection_handler_settings.h" -#include "transport_manager/mock_transport_manager.h" -#include "policy/policy_types.h" #include "json/reader.h" -#include "json/writer.h" #include "json/value.h" +#include "json/writer.h" +#include "policy/policy_types.h" #include "smart_objects/smart_object.h" +#include "transport_manager/mock_transport_manager.h" #include "utils/file_system.h" -#include "utils/custom_string.h" -#include "policy/usage_statistics/counter.h" -#include "policy/usage_statistics/statistics_manager.h" #include "interfaces/MOBILE_API.h" #include "policy/mock_policy_settings.h" +#include "policy/usage_statistics/counter.h" +#include "policy/usage_statistics/statistics_manager.h" +#include "utils/custom_string.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 "application_manager/mock_state_controller.h" #include "application_manager/mock_hmi_capabilities.h" #include "application_manager/mock_rpc_service.h" +#include "application_manager/mock_state_controller.h" +#include "application_manager/policies/mock_policy_handler_observer.h" +#include "connection_handler/mock_connection_handler.h" #include "policy/mock_policy_manager.h" #include "policy/usage_statistics/mock_statistics_manager.h" +#include "protocol_handler/mock_session_observer.h" namespace test { namespace components { @@ -92,6 +91,8 @@ using ::testing::SetArgReferee; typedef NiceMock<application_manager_test::MockRPCService> MockRPCService; const std::string kDummyData = "some_data"; +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; class PolicyHandlerTest : public ::testing::Test { public: @@ -174,8 +175,9 @@ class PolicyHandlerTest : public ::testing::Test { ON_CALL(policy_settings_, enable_policy()).WillByDefault(Return(true)); ON_CALL(app_manager_, event_dispatcher()) .WillByDefault(ReturnRef(mock_event_dispatcher_)); - std::string path = file_system::CreateDirectory("storage"); - file_system::CreateFile(path + "/" + "certificate"); + const std::string path("storage"); + if (file_system::CreateDirectory(path)) + file_system::CreateFile(path + "/" + "certificate"); mock_policy_manager_ = std::make_shared<policy_manager_test::MockPolicyManager>(); ASSERT_TRUE(mock_policy_manager_.use_count() != 0); @@ -234,21 +236,25 @@ class PolicyHandlerTest : public ::testing::Test { void TestOnPermissionsUpdated(const std::string& default_hmi_level, const mobile_apis::HMILevel::eType hmi_level) { - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(default_hmi_level)) .WillOnce(Return(hmi_level)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()).Times(0); Permissions permissions; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, permissions, default_hmi_level); + kDeviceId, kPolicyAppId_, permissions, default_hmi_level); } void CreateFunctionalGroupPermission( @@ -396,7 +402,10 @@ TEST_F(PolicyHandlerTest, AppServiceUpdate_CheckAppService) { ifile.close(); BinaryMessage msg(json.begin(), json.end()); // Checks - EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true)); + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)) + .WillOnce(Return(PolicyManager::PtProcessingResult::kSuccess)); + EXPECT_CALL(*mock_policy_manager_, + OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess)); policy_handler_.ReceiveMessageFromSDK("", msg); policy_table::AppServiceParameters app_service_params = @@ -463,7 +472,10 @@ TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK) { EXPECT_CALL(app_manager_, GetNextHMICorrelationID()); EXPECT_CALL(mock_message_helper_, CreateGetVehicleDataRequest(_, _, _)); EXPECT_CALL(*mock_policy_manager_, PTUpdatedAt(_, _)); - EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(true)); + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)) + .WillOnce(Return(PolicyManager::PtProcessingResult::kSuccess)); + EXPECT_CALL(*mock_policy_manager_, + OnPTUFinished(PolicyManager::PtProcessingResult::kSuccess)); EXPECT_CALL(*mock_policy_manager_, CleanupUnpairedDevices()); policy_handler_.ReceiveMessageFromSDK("", msg); } @@ -474,7 +486,11 @@ TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK_PTNotLoaded) { BinaryMessage msg; // Checks - EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(false)); + EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)) + .WillOnce(Return(PolicyManager::PtProcessingResult::kWrongPtReceived)); + EXPECT_CALL( + *mock_policy_manager_, + OnPTUFinished(PolicyManager::PtProcessingResult::kWrongPtReceived)); EXPECT_CALL(app_manager_, GetNextHMICorrelationID()).Times(0); EXPECT_CALL(mock_message_helper_, CreateGetVehicleDataRequest(_, _, _)) .Times(0); @@ -495,38 +511,52 @@ TEST_F(PolicyHandlerTest, UnloadPolicyLibrary_method_ExpectLibraryUnloaded) { TEST_F(PolicyHandlerTest, OnPermissionsUpdated_method_With2Parameters) { // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillOnce(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); // Act Permissions perms; - policy_handler_.OnPermissionsUpdated(kPolicyAppId_, perms); + policy_handler_.OnPermissionsUpdated(kDeviceId, kPolicyAppId_, perms); } TEST_F(PolicyHandlerTest, OnPermissionsUpdated_TwoParams_InvalidApp_UNSUCCESS) { std::shared_ptr<application_manager_test::MockApplication> invalid_app; - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillOnce(Return(invalid_app)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .Times(0); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(_, _, _)).Times(0); + SendOnPermissionsChangeNotification(_, _, _, _)) + .Times(0); Permissions permissions; - policy_handler_.OnPermissionsUpdated(kPolicyAppId_, permissions); + policy_handler_.OnPermissionsUpdated(kDeviceId, kPolicyAppId_, permissions); } TEST_F(PolicyHandlerTest, OnPermissionsUpdated_InvalidApp_UNSUCCESS) { std::shared_ptr<application_manager_test::MockApplication> invalid_app; - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .WillOnce(Return(mock_app_)) .WillOnce(Return(invalid_app)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); Permissions permissions; - policy_handler_.OnPermissionsUpdated(kPolicyAppId_, permissions, "HMI_FULL"); + policy_handler_.OnPermissionsUpdated( + kDeviceId, kPolicyAppId_, permissions, "HMI_FULL"); } TEST_F(PolicyHandlerTest, OnPermissionsUpdated_HmiLevelInvalidEnum_UNSUCCESS) { @@ -544,25 +574,30 @@ TEST_F(PolicyHandlerTest, const std::string new_kHmiLevel_string = "HMI_FULL"; mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_FULL; // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()) .WillRepeatedly(ReturnRef(mock_state_controller)); - EXPECT_CALL(mock_state_controller, SetRegularState(_, new_hmi_level, true)); + EXPECT_CALL(mock_state_controller, + SetRegularState(_, kDefaultWindowId, new_hmi_level, true)); // Act Permissions perms; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, perms, new_kHmiLevel_string); + kDeviceId, kPolicyAppId_, perms, new_kHmiLevel_string); } TEST_F(PolicyHandlerTest, @@ -572,25 +607,30 @@ TEST_F(PolicyHandlerTest, mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_NONE)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()) .WillRepeatedly(ReturnRef(mock_state_controller)); - EXPECT_CALL(mock_state_controller, SetRegularState(_, new_hmi_level, false)); + EXPECT_CALL(mock_state_controller, + SetRegularState(_, kDefaultWindowId, new_hmi_level, false)); // Act Permissions perms; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, perms, new_kHmiLevel_string); + kDeviceId, kPolicyAppId_, perms, new_kHmiLevel_string); } TEST_F(PolicyHandlerTest, @@ -599,23 +639,27 @@ TEST_F(PolicyHandlerTest, std::string new_kHmiLevel_string = "HMI_FULL"; mobile_apis::HMILevel::eType new_hmi_level = mobile_apis::HMILevel::HMI_FULL; // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId, kPolicyAppId_)) .Times(2) .WillRepeatedly(Return(mock_app_)); EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId1_)); EXPECT_CALL(mock_message_helper_, StringToHMILevel(new_kHmiLevel_string)) .WillOnce(Return(new_hmi_level)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_LIMITED)); + ChangePolicyManagerToMock(); + const policy::EncryptionRequired require_encryption; + EXPECT_CALL(*mock_policy_manager_, GetAppEncryptionRequired(kPolicyAppId_)) + .WillOnce(Return(require_encryption)); EXPECT_CALL(mock_message_helper_, - SendOnPermissionsChangeNotification(kAppId1_, _, _)); + SendOnPermissionsChangeNotification(kAppId1_, _, _, _)); EXPECT_CALL(app_manager_, state_controller()).Times(0); // Act Permissions perms; policy_handler_.OnPermissionsUpdated( - kPolicyAppId_, perms, new_kHmiLevel_string); + kDeviceId, kPolicyAppId_, perms, new_kHmiLevel_string); } TEST_F(PolicyHandlerTest, GetPriority) { @@ -636,13 +680,14 @@ TEST_F(PolicyHandlerTest, CheckPermissions) { const uint32_t device = 3; const mobile_apis::HMILevel::eType hmi_level = mobile_apis::HMILevel::HMI_NONE; - EXPECT_CALL(*mock_app_, hmi_level()).WillOnce(Return(hmi_level)); + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) + .WillOnce(Return(hmi_level)); EXPECT_CALL(*mock_app_, device()).WillOnce(Return(device)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); #ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL( - *mock_policy_manager_, - CheckPermissions(kPolicyAppId_, kHmiLevel_, kRpc_, kRpc_params, _)); + EXPECT_CALL(*mock_policy_manager_, + CheckPermissions( + kDeviceId, kPolicyAppId_, kHmiLevel_, kRpc_, kRpc_params, _)); #else // EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(*mock_policy_manager_, @@ -654,7 +699,8 @@ TEST_F(PolicyHandlerTest, CheckPermissions) { EXPECT_CALL(mock_message_helper_, GetDeviceMacAddressForHandle(device, _)) .WillOnce(Return(kDeviceId)); // Act - policy_handler_.CheckPermissions(mock_app_, kRpc_, kRpc_params, result); + policy_handler_.CheckPermissions( + mock_app_, kDefaultWindowId, kRpc_, kRpc_params, result); } TEST_F(PolicyHandlerTest, GetNotificationsNumber) { @@ -681,9 +727,9 @@ TEST_F(PolicyHandlerTest, GetDefaultHmi) { EnablePolicyAndPolicyManagerMock(); // Check expectations EXPECT_CALL(*mock_policy_manager_, - GetDefaultHmi(kPolicyAppId_, &default_hmi_)); + GetDefaultHmi(kDeviceId_, kPolicyAppId_, &default_hmi_)); // Act - policy_handler_.GetDefaultHmi(kPolicyAppId_, &default_hmi_); + policy_handler_.GetDefaultHmi(kDeviceId_, kPolicyAppId_, &default_hmi_); } TEST_F(PolicyHandlerTest, GetInitialAppData) { @@ -882,12 +928,14 @@ void PolicyHandlerTest::TestActivateApp(const uint32_t connection_key, #endif // EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(*application1, policy_app_id()).WillOnce(Return(kPolicyAppId_)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kMacAddr_, kPolicyAppId_)) .WillOnce(Return(permissions)); ON_CALL(*mock_policy_manager_, Increment(_, _)).WillByDefault(Return()); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(_)); EXPECT_CALL(mock_message_helper_, SendSDLActivateAppResponse(_, _, _)); ON_CALL(*application1, app_id()).WillByDefault(Return(kAppId1_)); + ON_CALL(*application1, mac_address()).WillByDefault(ReturnRef(kMacAddr_)); // Act policy_handler_.OnActivateApp(connection_key, correlation_id); } @@ -936,12 +984,14 @@ TEST_F(PolicyHandlerTest, OnActivateApp_AppIsRevoked_AppNotActivated) { // Check expectations EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDefaultId, kPolicyAppId_)) .WillOnce(Return(permissions)); ON_CALL(*mock_policy_manager_, Increment(_, _)).WillByDefault(Return()); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(_)); EXPECT_CALL(mock_message_helper_, SendSDLActivateAppResponse(_, _, _)); ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId1_)); + ON_CALL(*mock_app_, mac_address()).WillByDefault(ReturnRef(kDefaultId)); // Act policy_handler_.OnActivateApp(kConnectionKey_, kCorrelationKey_); } @@ -963,10 +1013,10 @@ void PolicyHandlerTest::OnPendingPermissionChangePrecondition( std::shared_ptr<application_manager_test::MockApplication> application = std::make_shared<application_manager_test::MockApplication>(); - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) - .WillOnce(Return(application)); + EXPECT_CALL(app_manager_, application(_, _)).WillOnce(Return(application)); EXPECT_CALL(*application, app_id()).WillRepeatedly(Return(kAppId1_)); - EXPECT_CALL(*application, hmi_level()).WillRepeatedly(Return(hmi_level)); + EXPECT_CALL(*application, hmi_level(kDefaultWindowId)) + .WillRepeatedly(Return(hmi_level)); } TEST_F(PolicyHandlerTest, @@ -978,14 +1028,15 @@ TEST_F(PolicyHandlerTest, AppPermissions permissions(kPolicyAppId_); permissions.appPermissionsConsentNeeded = false; EXPECT_CALL(mock_message_helper_, - SendOnAppPermissionsChangedNotification(kAppId1_, _, _)).Times(0); - - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + SendOnAppPermissionsChangedNotification(kAppId1_, _, _)) + .Times(0); + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInLimitedConsentNeeded) { @@ -997,12 +1048,13 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInLimitedConsentNeeded) { // Check expectations EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppLimitedAndRevoked) { @@ -1019,17 +1071,19 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppLimitedAndRevoked) { SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); EXPECT_CALL(mock_state_controller, SetRegularState(_, + kDefaultWindowId, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, mobile_apis::VideoStreamingState::NOT_STREAMABLE, true)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInBackgroundAndRevoked) { @@ -1043,12 +1097,13 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppInBackgroundAndRevoked) { EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, @@ -1065,7 +1120,8 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(mock_message_helper_, @@ -1082,7 +1138,7 @@ TEST_F(PolicyHandlerTest, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, @@ -1095,13 +1151,14 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(kAppId1_, _, _)); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(*mock_policy_manager_, RemovePendingPermissionChanges(kPolicyAppId_)); - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, @@ -1117,9 +1174,11 @@ TEST_F(PolicyHandlerTest, // Check expectations // Notification won't be sent EXPECT_CALL(mock_message_helper_, - SendOnAppPermissionsChangedNotification(kAppId1_, _, _)).Times(0); + SendOnAppPermissionsChangedNotification(kAppId1_, _, _)) + .Times(0); - EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) + EXPECT_CALL(*mock_policy_manager_, + GetAppPermissionsChanges(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(permissions)); EXPECT_CALL(mock_message_helper_, @@ -1136,7 +1195,7 @@ TEST_F(PolicyHandlerTest, RemovePendingPermissionChanges(kPolicyAppId_)); // Act - policy_handler_.OnPendingPermissionChange(kPolicyAppId_); + policy_handler_.OnPendingPermissionChange(kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, PTExchangeAtUserRequest) { @@ -1232,7 +1291,7 @@ TEST_F(PolicyHandlerTest, OnCurrentDeviceIdUpdateRequired) { // Check expectations std::shared_ptr<application_manager_test::MockApplication> application = std::make_shared<application_manager_test::MockApplication>(); - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(application)); EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); @@ -1249,10 +1308,11 @@ TEST_F(PolicyHandlerTest, OnCurrentDeviceIdUpdateRequired) { _, _, _, - _)); + _)) + .WillOnce(DoAll(SetArgPointee<3>(kDeviceId_), Return(0))); // Act - policy_handler_.OnCurrentDeviceIdUpdateRequired(kPolicyAppId_); + policy_handler_.OnCurrentDeviceIdUpdateRequired(handle, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnSystemInfoChanged) { @@ -1301,11 +1361,17 @@ TEST_F(PolicyHandlerTest, GetAppRequestTypes) { // Arrange EnablePolicy(); ChangePolicyManagerToMock(); - // Check expectations + const transport_manager::DeviceHandle handle = 0u; +// Check expectations +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(handle, kPolicyAppId_)) + .WillOnce(Return(std::vector<std::string>())); +#else EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_)) .WillOnce(Return(std::vector<std::string>())); +#endif // Act - policy_handler_.GetAppRequestTypes(kPolicyAppId_); + policy_handler_.GetAppRequestTypes(handle, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnVIIsReady) { @@ -1374,13 +1440,14 @@ TEST_F(PolicyHandlerTest, SendOnAppPermissionsChanged) { std::shared_ptr<application_manager_test::MockApplication> application = std::make_shared<application_manager_test::MockApplication>(); // Check expectations - EXPECT_CALL(app_manager_, application_by_policy_id(kPolicyAppId_)) + EXPECT_CALL(app_manager_, application(kDeviceId_, kPolicyAppId_)) .WillOnce(Return(application)); EXPECT_CALL(mock_message_helper_, SendOnAppPermissionsChangedNotification(_, _, _)); AppPermissions permissions(kPolicyAppId_); // Act - policy_handler_.SendOnAppPermissionsChanged(permissions, kPolicyAppId_); + policy_handler_.SendOnAppPermissionsChanged( + permissions, kDeviceId_, kPolicyAppId_); } TEST_F(PolicyHandlerTest, OnPTExchangeNeeded) { @@ -1398,11 +1465,12 @@ TEST_F(PolicyHandlerTest, AddApplication) { // Check expectations EXPECT_CALL( *mock_policy_manager_, - AddApplication(kPolicyAppId_, HmiTypes(policy_table::AHT_DEFAULT))) + AddApplication( + kMacAddr_, kPolicyAppId_, HmiTypes(policy_table::AHT_DEFAULT))) .WillOnce(Return(std::make_shared<utils::CallNothing>())); // Act - policy_handler_.AddApplication(kPolicyAppId_, - HmiTypes(policy_table::AHT_DEFAULT)); + policy_handler_.AddApplication( + kMacAddr_, kPolicyAppId_, HmiTypes(policy_table::AHT_DEFAULT)); } TEST_F(PolicyHandlerTest, HeartBeatTimeout) { @@ -1437,9 +1505,10 @@ TEST_F(PolicyHandlerTest, OnAppRegisteredOnMobile) { EnablePolicyAndPolicyManagerMock(); // Check expectations - EXPECT_CALL(*mock_policy_manager_, OnAppRegisteredOnMobile(kPolicyAppId_)); + EXPECT_CALL(*mock_policy_manager_, + OnAppRegisteredOnMobile(kDeviceId, kPolicyAppId_)); // Act - policy_handler_.OnAppRegisteredOnMobile(kPolicyAppId_); + policy_handler_.OnAppRegisteredOnMobile(kDeviceId, kPolicyAppId_); } TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) { @@ -1450,13 +1519,20 @@ TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) { mobile_apis::RequestType::eType type = mobile_apis::RequestType::eType::EMERGENCY; + const transport_manager::DeviceHandle handle = 0u; + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypesState(kPolicyAppId_)) .WillOnce(Return(policy::RequestType::State::AVAILABLE)); - +#ifdef EXTERNAL_PROPRIETARY_MODE + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(handle, kPolicyAppId_)) + .WillOnce(Return(std::vector<std::string>({"HTTP"}))); +#else EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_)) .WillOnce(Return(std::vector<std::string>({"HTTP"}))); +#endif // Act - EXPECT_FALSE(policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type)); + EXPECT_FALSE( + policy_handler_.IsRequestTypeAllowed(handle, kPolicyAppId_, type)); } TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) { @@ -1475,16 +1551,6 @@ TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) { EXPECT_TRUE(policy_handler_.IsRequestSubTypeAllowed(kPolicyAppId_, subtype)); } -TEST_F(PolicyHandlerTest, GetVehicleInfo) { - // Arrange - EnablePolicyAndPolicyManagerMock(); - // Check expectations - EXPECT_CALL(*mock_policy_manager_, GetVehicleInfo()) - .WillOnce(Return(VehicleInfo())); - // Act - policy_handler_.GetVehicleInfo(); -} - TEST_F(PolicyHandlerTest, Increment_method_WithOneParameter) { // Arrange EnablePolicyAndPolicyManagerMock(); @@ -1720,7 +1786,8 @@ TEST_F(PolicyHandlerTest, OnSnapshotCreated_UrlNotAdded) { .WillRepeatedly(SetArgReferee<1>(test_data)); policy_handler_.OnSnapshotCreated(msg, retry_delay_seconds, timeout_exchange); #else // EXTERNAL_PROPRIETARY_MODE - policy_handler_.OnSnapshotCreated(msg); + policy_handler_.OnSnapshotCreated(msg, + policy::PTUIterationType::DefaultIteration); #endif // EXTERNAL_PROPRIETARY_MODE } @@ -1798,7 +1865,8 @@ TEST_F(PolicyHandlerTest, DISABLED_OnSnapshotCreated_UrlAdded) { #endif // PROPRIETARY_MODE EXPECT_CALL(*mock_policy_manager_, OnUpdateStarted()); - policy_handler_.OnSnapshotCreated(msg); + policy_handler_.OnSnapshotCreated(msg, + policy::PTUIterationType::DefaultIteration); } #endif // EXTERNAL_PROPRIETARY_MODE @@ -1846,8 +1914,9 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentAllowed) { connection_handler::DeviceHandle test_device_id = 100u; EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); + EXPECT_CALL(app_manager_, applications()).WillRepeatedly(Return(app_set)); - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) + EXPECT_CALL(conn_handler, GetDeviceID(kDeviceId, _)) .WillOnce(DoAll(SetArgPointee<1>(test_device_id), Return(true))); test_app.insert(mock_app_); @@ -1857,12 +1926,13 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentAllowed) { EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) .WillOnce(Return(true)); + EXPECT_CALL( + *mock_policy_manager_, + ReactOnUserDevConsentForApp(test_device_id, kPolicyAppId_, is_allowed)); EXPECT_CALL(*mock_policy_manager_, - ReactOnUserDevConsentForApp(kPolicyAppId_, is_allowed)); - EXPECT_CALL(*mock_policy_manager_, - SendNotificationOnPermissionsUpdated(kPolicyAppId_)); + SendNotificationOnPermissionsUpdated(kDeviceId, kPolicyAppId_)); - policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); + policy_handler_.OnDeviceConsentChanged(kDeviceId, is_allowed); } TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentNotAllowed) { @@ -1870,27 +1940,29 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentNotAllowed) { // Arrange EnablePolicyAndPolicyManagerMock(); - connection_handler::DeviceHandle test_device_id = 100u; + connection_handler::DeviceHandle handle = 100u; EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); // Check expectations - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) - .WillOnce(DoAll(SetArgPointee<1>(test_device_id), Return(true))); + EXPECT_CALL(conn_handler, GetDeviceID(kMacAddr_, _)) + .WillOnce(DoAll(SetArgPointee<1>(handle), Return(true))); test_app.insert(mock_app_); - EXPECT_CALL(*mock_app_, device()).WillOnce(Return(test_device_id)); + EXPECT_CALL(*mock_app_, device()).WillOnce(Return(handle)); EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) .WillOnce(Return(true)); - EXPECT_CALL(*mock_policy_manager_, ReactOnUserDevConsentForApp(_, _)) + EXPECT_CALL(*mock_policy_manager_, + ReactOnUserDevConsentForApp(handle, kPolicyAppId_, is_allowed)) .Times(0); - EXPECT_CALL(*mock_policy_manager_, SendNotificationOnPermissionsUpdated(_)) + EXPECT_CALL(*mock_policy_manager_, + SendNotificationOnPermissionsUpdated(kMacAddr_, kPolicyAppId_)) .Times(0); - policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); + policy_handler_.OnDeviceConsentChanged(kMacAddr_, is_allowed); } TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { @@ -1901,8 +1973,9 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { connection_handler::DeviceHandle test_device_id = 100u; EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); + EXPECT_CALL(app_manager_, applications()).WillRepeatedly(Return(app_set)); - EXPECT_CALL(conn_handler, GetDeviceID(kPolicyAppId_, _)) + EXPECT_CALL(conn_handler, GetDeviceID(kMacAddr_, _)) .WillOnce(DoAll(SetArgPointee<1>(test_device_id), Return(true))); test_app.insert(mock_app_); @@ -1914,12 +1987,13 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) .WillOnce(Return(false)); + EXPECT_CALL( + *mock_policy_manager_, + ReactOnUserDevConsentForApp(test_device_id, kPolicyAppId_, is_allowed)); EXPECT_CALL(*mock_policy_manager_, - ReactOnUserDevConsentForApp(kPolicyAppId_, is_allowed)); - EXPECT_CALL(*mock_policy_manager_, - SendNotificationOnPermissionsUpdated(kPolicyAppId_)); + SendNotificationOnPermissionsUpdated(kMacAddr_, kPolicyAppId_)); - policy_handler_.OnDeviceConsentChanged(kPolicyAppId_, is_allowed); + policy_handler_.OnDeviceConsentChanged(kMacAddr_, is_allowed); } #ifdef ENABLE_SECURITY #ifdef EXTERNAL_PROPRIETARY_MODE @@ -1970,7 +2044,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_GetDefaultMacAddress) { test_app.insert(mock_app_); EXPECT_CALL(*mock_app_, IsRegistered()).WillOnce(Return(true)); EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(app_manager_, connection_handler()) .WillOnce(ReturnRef(conn_handler)); @@ -1993,7 +2067,7 @@ void PolicyHandlerTest::GetAppIDForSending() { // Check expectations EXPECT_CALL(*mock_app_, app_id()).WillRepeatedly(Return(kAppId1_)); EXPECT_CALL(*mock_app_, IsRegistered()).WillOnce(Return(true)); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); EXPECT_CALL(mock_session_observer, GetDataOnDeviceID( @@ -2020,7 +2094,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_full_id = 1; EXPECT_CALL(*mock_app_in_full, app_id()) .WillRepeatedly(Return(app_in_full_id)); - EXPECT_CALL(*mock_app_in_full, hmi_level()) + EXPECT_CALL(*mock_app_in_full, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); ON_CALL(*mock_app_in_full, IsRegistered()).WillByDefault(Return(true)); @@ -2032,7 +2106,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_limited_id = 2; EXPECT_CALL(*mock_app_in_limited, app_id()) .WillRepeatedly(Return(app_in_limited_id)); - EXPECT_CALL(*mock_app_in_limited, hmi_level()) + EXPECT_CALL(*mock_app_in_limited, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_LIMITED)); ON_CALL(*mock_app_in_limited, IsRegistered()).WillByDefault(Return(true)); @@ -2044,7 +2118,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_background_id = 3; EXPECT_CALL(*mock_app_in_background, app_id()) .WillRepeatedly(Return(app_in_background_id)); - EXPECT_CALL(*mock_app_in_background, hmi_level()) + EXPECT_CALL(*mock_app_in_background, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_BACKGROUND)); ON_CALL(*mock_app_in_background, IsRegistered()).WillByDefault(Return(true)); @@ -2055,7 +2129,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyIdButNone) { const uint32_t app_in_none_id = 4; EXPECT_CALL(*mock_app_in_none, app_id()) .WillRepeatedly(Return(app_in_none_id)); - EXPECT_CALL(*mock_app_in_none, hmi_level()) + EXPECT_CALL(*mock_app_in_none, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_NONE)); EXPECT_CALL(*mock_app_in_none, IsRegistered()).Times(0); @@ -2085,7 +2159,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyAppInNone) { const uint32_t app_in_none_id_1 = 1; EXPECT_CALL(*mock_app_in_none_1, app_id()) .WillRepeatedly(Return(app_in_none_id_1)); - EXPECT_CALL(*mock_app_in_none_1, hmi_level()) + EXPECT_CALL(*mock_app_in_none_1, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_FULL)); ON_CALL(*mock_app_in_none_1, IsRegistered()).WillByDefault(Return(true)); @@ -2097,7 +2171,7 @@ TEST_F(PolicyHandlerTest, GetAppIdForSending_ExpectReturnAnyAppInNone) { const uint32_t app_in_none_id_2 = 2; EXPECT_CALL(*mock_app_in_none_2, app_id()) .WillRepeatedly(Return(app_in_none_id_2)); - EXPECT_CALL(*mock_app_in_none_2, hmi_level()) + EXPECT_CALL(*mock_app_in_none_2, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_api::HMILevel::HMI_NONE)); ON_CALL(*mock_app_in_none_2, IsRegistered()).WillByDefault(Return(true)); @@ -2132,7 +2206,7 @@ TEST_F(PolicyHandlerTest, 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()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); EXPECT_CALL(*mock_app_, IsRegistered()).WillRepeatedly(Return(true)); @@ -2159,7 +2233,7 @@ TEST_F(PolicyHandlerTest, 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()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(*mock_app_, IsRegistered()).WillRepeatedly(Return(true)); @@ -2187,9 +2261,9 @@ TEST_F(PolicyHandlerTest, CanUpdate_TwoApplicationForSending_SUCCESS) { std::shared_ptr<application_manager_test::MockApplication> second_mock_app = std::make_shared<application_manager_test::MockApplication>(); - EXPECT_CALL(*mock_app_, hmi_level()) + EXPECT_CALL(*mock_app_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_FULL)); - EXPECT_CALL(*second_mock_app, hmi_level()) + EXPECT_CALL(*second_mock_app, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_LIMITED)); EXPECT_CALL(*second_mock_app, app_id()).WillRepeatedly(Return(kAppId2_)); @@ -2242,7 +2316,8 @@ TEST_F(PolicyHandlerTest, _, NULL, _, - _)).WillOnce(Return(1u)); + _)) + .WillOnce(Return(1u)); EXPECT_CALL(app_manager_, application(kConnectionKey_)) .WillOnce(Return(mock_app_)); diff --git a/src/components/application_manager/test/rc_policy_handler_test.cc b/src/components/application_manager/test/rc_policy_handler_test.cc index b7caf635c9..818a014a3f 100644 --- a/src/components/application_manager/test/rc_policy_handler_test.cc +++ b/src/components/application_manager/test/rc_policy_handler_test.cc @@ -30,34 +30,34 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <fstream> #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 "application_manager/policies/delegates/app_permission_delegate.h" +#include "application_manager/policies/policy_handler.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 "json/writer.h" +#include "policy/access_remote.h" +#include "policy/mock_cache_manager.h" +#include "policy/policy_types.h" #include "smart_objects/smart_object.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 "application_manager/policies/mock_policy_handler_observer.h" +#include "connection_handler/mock_connection_handler.h" +#include "interfaces/MOBILE_API.h" #include "policy/mock_policy_manager.h" +#include "policy/mock_policy_settings.h" +#include "policy/usage_statistics/mock_statistics_manager.h" +#include "protocol_handler/mock_session_observer.h" +#include "utils/custom_string.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/request_controller/request_controller_test.cc b/src/components/application_manager/test/request_controller/request_controller_test.cc index 112e3c1c39..71e12b2825 100644 --- a/src/components/application_manager/test/request_controller/request_controller_test.cc +++ b/src/components/application_manager/test/request_controller/request_controller_test.cc @@ -32,24 +32,23 @@ #include <stdint.h> -#include "gtest/gtest.h" +#include "application_manager/mock_request.h" #include "application_manager/request_controller.h" #include "application_manager/request_info.h" -#include "application_manager/mock_request.h" +#include "gtest/gtest.h" -#include "smart_objects/smart_object.h" +#include "application_manager/application_impl.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/message_helper.h" -#include "application_manager/application_impl.h" +#include "smart_objects/smart_object.h" -#include "application_manager/mock_application_manager.h" #include "application_manager/event_engine/event_dispatcher.h" -#include "resumption/last_state.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_request_controller_settings.h" #include "application_manager/policies/policy_handler.h" -#include "application_manager/state_controller.h" #include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/mock_request_controller_settings.h" -#include "application_manager/mock_application_manager.h" +#include "application_manager/state_controller.h" +#include "resumption/last_state.h" #include "utils/test_async_waiter.h" namespace test { @@ -59,10 +58,10 @@ namespace request_controller_test { using ::application_manager::request_controller::RequestController; using ::application_manager::request_controller::RequestInfo; +using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::_; typedef NiceMock<application_manager_test::MockRequest> MRequest; typedef std::shared_ptr<MRequest> RequestPtr; diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index 0abef44e9a..a0b1793cf5 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -31,10 +31,10 @@ */ #include "application_manager/request_info.h" -#include "application_manager/mock_request.h" #include <iostream> -#include <vector> #include <limits> +#include <vector> +#include "application_manager/mock_request.h" #include "gmock/gmock.h" namespace request_info = application_manager::request_controller; diff --git a/src/components/application_manager/test/request_tracker_test.cc b/src/components/application_manager/test/request_tracker_test.cc index ee09e0a3e0..9175652da6 100644 --- a/src/components/application_manager/test/request_tracker_test.cc +++ b/src/components/application_manager/test/request_tracker_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" -#include "utils/macro.h" #include "application_manager/request_tracker.h" #include "application_manager/mock_request_controller_settings.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" -#include "utils/lock.h" #include "utils/conditional_variable.h" +#include "utils/lock.h" +#include "utils/macro.h" namespace test { namespace components { @@ -246,6 +246,6 @@ TEST_F(RequestTrackerTestClass, tracker_.Track(app_id, none_level)); } -} // namespace request_controller +} // namespace request_controller_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 2413421c7f..9f0430a937 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -30,26 +30,28 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <algorithm> +#include <string> -#include "gtest/gtest.h" -#include "application_manager/resumption/resume_ctrl_impl.h" -#include "application_manager/usage_statistics.h" -#include "application_manager/mock_application.h" +#include "application_manager/application.h" +#include "application_manager/application_manager_impl.h" +#include "application_manager/display_capabilities_builder.h" #include "application_manager/mock_app_extension.h" +#include "application_manager/mock_application.h" #include "application_manager/mock_help_prompt_manager.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/resumption/resume_ctrl_impl.h" +#include "application_manager/usage_statistics.h" +#include "config_profile/profile.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" -#include "application_manager/application_manager_impl.h" -#include "application_manager/application.h" #include "utils/data_accessor.h" -#include "config_profile/profile.h" -#include "application_manager/mock_message_helper.h" #include "application_manager/mock_application_manager.h" #include "application_manager/mock_application_manager_settings.h" #include "application_manager/mock_event_dispatcher.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/mock_state_controller.h" namespace test { @@ -64,15 +66,21 @@ using ::testing::Eq; using ::testing::Mock; using ::testing::NiceMock; using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::SetArgReferee; using ::testing::ReturnPointee; +using ::testing::ReturnRef; using ::testing::SaveArg; +using ::testing::SetArgReferee; using namespace application_manager_test; using namespace resumption; using namespace mobile_apis::HMILevel; +namespace { +const WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const int32_t kDefaultHmiAppId = 111; +} // namespace + class ResumeCtrlTest : public ::testing::Test { protected: ResumeCtrlTest() @@ -156,6 +164,43 @@ class ResumeCtrlTest : public ::testing::Test { ON_CALL(*mock_app_, is_cloud_app()).WillByDefault(Return(false)); } + smart_objects::SmartObjectSPtr CreateStubCreateWindowRequest( + const std::string window_name, + const WindowID window_id, + const mobile_apis::WindowType::eType window_type) const { + auto request = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); + smart_objects::SmartObject params(smart_objects::SmartType_Map); + + params[strings::correlation_id] = window_id; + + msg_params[strings::window_name] = window_name; + msg_params[strings::window_id] = window_id; + msg_params[strings::window_type] = window_type; + msg_params[strings::app_id] = kDefaultHmiAppId; + + (*request)[strings::msg_params] = msg_params; + (*request)[strings::params] = params; + + return request; + } + + smart_objects::SmartObjectSPtr CreateStubCreateWindowResponse( + const int32_t correlation_id, + const hmi_apis::Common_Result::eType result_code) const { + auto response = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + smart_objects::SmartObject params(smart_objects::SmartType_Map); + + params[strings::correlation_id] = correlation_id; + params[hmi_response::code] = result_code; + + (*response)[strings::params] = params; + + return response; + } + NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; application_manager_test::MockApplicationManagerSettings mock_application_manager_settings_; @@ -185,6 +230,7 @@ class ResumeCtrlTest : public ::testing::Test { const std::string kNaviLowbandwidthLevel_; const std::string kProjectionLowbandwidthLevel_; const std::string kMediaLowbandwidthLevel_; + NiceMock<application_manager_test::MockRPCService> mock_rpc_service_; }; /** @@ -501,7 +547,8 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscribeOnButtons) { EXPECT_CALL(*mock_app_extension_, ProcessResumption(test_subscriptions)); EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), - SendAllOnButtonSubscriptionNotificationsForApp(_, _)).Times(2); + SendAllOnButtonSubscriptionNotificationsForApp(_, _)) + .Times(2); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_); EXPECT_TRUE(res); @@ -571,12 +618,231 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscriptionToWayPoints) { mobile_apis::HMILevel::HMI_FULL; ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillByDefault(Return(hmi_test_level)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, hmi_test_level)); + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, hmi_test_level)); const bool result = res_ctrl_->StartResumption(mock_app_, kHash_); EXPECT_TRUE(result); } +TEST_F(ResumeCtrlTest, + RestoreAppWidgets_AppWithWidgets_SendCreateWindowRequests) { + using namespace smart_objects; + using namespace application_manager; + GetInfoFromApp(); + const uint32_t count_of_widgets = 10u; + + auto create_window_info_so = []() -> SmartObject { + SmartObject widgets_info(SmartType_Array); + for (uint32_t i = 0; i < count_of_widgets; ++i) { + SmartObject widget_info(SmartType_Map); + widget_info[strings::associated_service_type] = "ServiceType"; + widget_info[strings::duplicate_updates_from_window_id] = 0; + widget_info[strings::window_name] = + std::string("Widget ") + std::to_string(i + 1); + widget_info[strings::window_type] = + static_cast<int32_t>(mobile_apis::WindowType::WIDGET); + widget_info[strings::window_id] = i + 1; + widgets_info[widgets_info.length()] = widget_info; + } + return widgets_info; + }; + + auto create_saved_app_so = [&create_window_info_so, this]() -> SmartObject { + smart_objects::SmartObject saved_app; + const auto test_app_widgets = create_window_info_so(); + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = test_app_widgets; + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + return saved_app; + }; + + const auto saved_app = create_saved_app_so(); + + const auto hmi_request = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + const auto hmi_requests = + smart_objects::SmartObjectList(count_of_widgets, hmi_request); + + DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + EXPECT_CALL( + *application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, saved_app[strings::windows_info])) + .WillOnce(Return(hmi_requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .Times(count_of_widgets) + .WillRepeatedly(Return(true)); + + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); +} + +TEST_F(ResumeCtrlTest, + RestoreWidgetsHMIState_AppWithWidgets_AddWidgetsInternally) { + const uint32_t count_of_widgets = 10u; + + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = smart_objects::SmartObject(); + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + ON_CALL(mock_app_mngr_, application_by_hmi_app(kDefaultHmiAppId)) + .WillByDefault(Return(mock_app_)); + DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + smart_objects::SmartObjectList requests; + smart_objects::SmartObjectList responses; + for (uint32_t i = 0; i < count_of_widgets; ++i) { + const auto window_type = mobile_apis::WindowType::WIDGET; + const WindowID window_id = i + 1; + const auto window_name = std::string("Widget ") + std::to_string(window_id); + requests.push_back( + CreateStubCreateWindowRequest(window_name, window_id, window_type)); + responses.push_back(CreateStubCreateWindowResponse( + window_id, hmi_apis::Common_Result::SUCCESS)); + EXPECT_CALL(mock_app_mngr_, CreateRegularState(_, window_type, _, _, _, _)) + .WillRepeatedly(Return(nullptr)); + EXPECT_CALL(*mock_app_, SetInitialState(window_id, window_name, _)); + EXPECT_CALL(mock_state_controller_, + OnAppWindowAdded(_, window_id, window_type, _)); + } + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .WillOnce(Return(requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .Times(count_of_widgets) + .WillRepeatedly(Return(true)); + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); + for (const auto& response : responses) { + res_ctrl_->RestoreWidgetsHMIState(*response); + } +} + +TEST_F(ResumeCtrlTest, + RestoreAppWidgets_AppWithoutWidgets_NoCreateWindowRqSent) { + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .Times(0); + + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); +} + +TEST_F(ResumeCtrlTest, RestoreWidgetsHMIState_HMIResponseWith_InvalidCorrId) { + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = smart_objects::SmartObject(); + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + const int32_t invalid_corr_id = -1; + auto response = CreateStubCreateWindowResponse( + invalid_corr_id, hmi_apis::Common_Result::SUCCESS); + + ON_CALL(mock_app_mngr_, application_by_hmi_app(kDefaultHmiAppId)) + .WillByDefault(Return(mock_app_)); + + DisplayCapabilitiesBuilder builder(*mock_app_); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + smart_objects::SmartObjectList requests; + + const auto window_type = mobile_apis::WindowType::WIDGET; + const WindowID window_id = 1; + const auto window_name = std::string("Widget ") + std::to_string(window_id); + requests.push_back( + CreateStubCreateWindowRequest(window_name, window_id, window_type)); + + EXPECT_CALL(mock_app_mngr_, CreateRegularState(_, window_type, _, _, _, _)) + .Times(0); + EXPECT_CALL(*mock_app_, SetInitialState(window_id, window_name, _)).Times(0); + EXPECT_CALL(mock_state_controller_, + OnAppWindowAdded(_, window_id, window_type, _)) + .Times(0); + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .WillOnce(Return(requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .WillRepeatedly(Return(true)); + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); + res_ctrl_->RestoreWidgetsHMIState(*response); +} + +TEST_F(ResumeCtrlTest, RestoreWidgetsHMIState_HMIResponseWith_Unsuccess) { + smart_objects::SmartObject saved_app; + saved_app[strings::hash_id] = kHash_; + saved_app[strings::windows_info] = smart_objects::SmartObject(); + saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; + saved_app[application_manager::strings::hmi_level] = eType::HMI_FULL; + + const int32_t correlation_id = 1; + auto response = CreateStubCreateWindowResponse( + correlation_id, hmi_apis::Common_Result::GENERIC_ERROR); + + ON_CALL(mock_app_mngr_, application_by_hmi_app(kDefaultHmiAppId)) + .WillByDefault(Return(mock_app_)); + + DisplayCapabilitiesBuilder builder(*mock_app_); + smart_objects::SmartObject stub_window_info(smart_objects::SmartType_Null); + auto stub_resume_cb = [](Application&, const smart_objects::SmartObject&) {}; + builder.InitBuilder(stub_resume_cb, stub_window_info); + ON_CALL(*mock_app_, display_capabilities_builder()) + .WillByDefault(ReturnRef(builder)); + + smart_objects::SmartObjectList requests; + smart_objects::SmartObjectList responses; + + const auto window_type = mobile_apis::WindowType::WIDGET; + const WindowID window_id = 1; + const auto window_name = std::string("Widget ") + std::to_string(window_id); + requests.push_back( + CreateStubCreateWindowRequest(window_name, window_id, window_type)); + + EXPECT_CALL(mock_app_mngr_, CreateRegularState(_, window_type, _, _, _, _)) + .Times(0); + EXPECT_CALL(*mock_app_, SetInitialState(window_id, window_name, _)).Times(0); + EXPECT_CALL(mock_state_controller_, + OnAppWindowAdded(_, window_id, window_type, _)) + .Times(0); + + EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), + CreateUICreateWindowRequestsToHMI(_, _, _)) + .WillOnce(Return(requests)); + + ON_CALL(mock_app_mngr_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(_, commands::Command::SOURCE_SDL_TO_HMI)) + .WillRepeatedly(Return(true)); + res_ctrl_->RestoreAppWidgets(mock_app_, saved_app); + res_ctrl_->RestoreWidgetsHMIState(*response); +} + TEST_F(ResumeCtrlTest, StartResumptionOnlyHMILevel) { smart_objects::SmartObject saved_app; @@ -631,7 +897,8 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppInFull) { DataAccessor<application_manager::CommandsMap> data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -680,7 +947,8 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppHasDeferredResumption) { saved_app[application_manager::strings::time_stamp] = time_stamp; // resume into deferred level instead of restored level - EXPECT_CALL(mock_state_controller_, SetRegularState(_, deferred_level)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, deferred_level)) .Times(AtLeast(1)); GetInfoFromApp(); ON_CALL(*mock_storage_, @@ -715,7 +983,8 @@ TEST_F(ResumeCtrlTest, saved_app[application_manager::strings::hmi_level] = restored_test_type; saved_app[application_manager::strings::time_stamp] = time_stamp; - EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_LIMITED)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, eType::HMI_LIMITED)) .Times(AtLeast(1)); GetInfoFromApp(); ON_CALL(*mock_storage_, @@ -759,7 +1028,8 @@ TEST_F( // in this test, it is expected that the app will resume into LIMITED, which // is the higher level among NONE and LIMITED - EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_LIMITED)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, eType::HMI_LIMITED)) .Times(AtLeast(1)); GetInfoFromApp(); ON_CALL(*mock_storage_, @@ -815,7 +1085,8 @@ TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) { saved_app[application_manager::strings::grammar_id] = kTestGrammarId_; saved_app[application_manager::strings::hmi_level] = restored_test_type; - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -827,7 +1098,6 @@ TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); const bool res = res_ctrl_->RestoreAppHMIState(mock_app_); EXPECT_TRUE(res); @@ -846,7 +1116,8 @@ TEST_F(ResumeCtrlTest, SetupDefaultHMILevel) { ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillByDefault(Return(kDefaultTestLevel_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, kDefaultTestLevel_)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, kDefaultTestLevel_)) .Times(AtLeast(1)); res_ctrl_->SetupDefaultHMILevel(mock_app_); @@ -875,7 +1146,8 @@ TEST_F(ResumeCtrlTest, EXPECT_CALL(*mock_app_, is_media_application()).WillRepeatedly(Return(false)); // SetRegularState() should be called with kProjectionLowbandwidthLevel_ - EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_NONE)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, eType::HMI_NONE)) .Times(AtLeast(1)); res_ctrl_->SetupDefaultHMILevel(mock_app_); @@ -902,7 +1174,8 @@ TEST_F(ResumeCtrlTest, ApplicationResumptiOnTimer_AppInFull) { MockStateController state_controller; EXPECT_CALL(mock_app_mngr_, state_controller()) .WillOnce(ReturnRef(state_controller)); - EXPECT_CALL(state_controller, SetRegularState(_, restored_test_type)) + EXPECT_CALL(state_controller, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -930,8 +1203,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMINone_WithoutCheckPolicy) { EXPECT_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")).Times(0); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, kDefaultTestLevel_)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, kDefaultTestLevel_)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, kDefaultTestLevel_, false); @@ -943,8 +1216,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMILimited_WithoutCheckPolicy) { GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")).Times(0); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, test_type)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, false); EXPECT_TRUE(res); @@ -957,8 +1230,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMIFull_WithoutCheckPolicy) { EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)).Times(0); EXPECT_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")).Times(0); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, test_type)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, false); @@ -972,8 +1245,8 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMIFull_WithPolicy_DevAllowed) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, test_type)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, true); @@ -987,10 +1260,10 @@ TEST_F(ResumeCtrlTest, SetAppHMIState_HMIFull_WithPolicy_DevDisallowed) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceDisallowed)); - EXPECT_CALL(*mock_app_, set_is_resuming(true)); ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) .WillByDefault(Return(kDefaultTestLevel_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, kDefaultTestLevel_)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, kDefaultTestLevel_)) .Times(AtLeast(1)); const bool res = res_ctrl_->SetAppHMIState(mock_app_, test_type, true); EXPECT_FALSE(res); @@ -1245,7 +1518,8 @@ TEST_F( DataAccessor<application_manager::CommandsMap> data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) @@ -1352,7 +1626,8 @@ TEST_F( DataAccessor<application_manager::CommandsMap> data_accessor( command, app_set_lock_ptr_); - EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type)) + EXPECT_CALL(mock_state_controller_, + SetRegularState(_, kDefaultWindowId, restored_test_type)) .Times(AtLeast(1)); GetInfoFromApp(); EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc index 8423520b9f..d67c229cc3 100644 --- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc @@ -30,30 +30,30 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <algorithm> -#include "gtest/gtest.h" +#include <string> #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager_settings.h" +#include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" #include "utils/sqlite_wrapper/sql_database.h" #include "utils/sqlite_wrapper/sql_query.h" -#include "utils/file_system.h" #include "application_manager/resumption_data_test.h" #include "application_manager/test_resumption_data_db.h" +#include "utils/file_system.h" -#include "application_manager/resumption/resumption_sql_queries.h" #include "application_manager/resumption/resumption_data_db.h" +#include "application_manager/resumption/resumption_sql_queries.h" namespace test { namespace components { namespace resumption_test { +using application_manager_test::MockApplication; +using ::testing::_; using ::testing::NiceMock; using ::testing::ReturnRef; -using ::testing::_; -using application_manager_test::MockApplication; namespace am = application_manager; using namespace file_system; @@ -344,7 +344,8 @@ void ResumptionDataDBTest::CheckCharacters(int64_t global_properties_key) { while (select_characters.Next()) { std::string character = (*keyboard_props_)[am::strings::limited_character_list] - [characters_idx++].asString(); + [characters_idx++] + .asString(); EXPECT_EQ(character, select_characters.GetString(0)); } } @@ -392,16 +393,17 @@ void ResumptionDataDBTest::CheckCommandsData() { ++i; uint cmd = (*test_commands_map[i])[am::strings::cmd_id].asUInt(); EXPECT_EQ(cmd, select_commands.GetUInteger(1)); - std::string name = - (*test_commands_map[i])[am::strings::menu_params] - [am::strings::menu_name].asString(); + std::string name = (*test_commands_map[i])[am::strings::menu_params] + [am::strings::menu_name] + .asString(); EXPECT_EQ(name, select_commands.GetString(2)); int position = (*test_commands_map[i])[am::strings::menu_params] - [am::strings::position].asInt(); + [am::strings::position] + .asInt(); EXPECT_EQ(position, select_commands.GetInteger(4)); - int parent_id = - (*test_commands_map[i])[am::strings::menu_params] - [am::hmi_request::parent_id].asInt(); + int parent_id = (*test_commands_map[i])[am::strings::menu_params] + [am::hmi_request::parent_id] + .asInt(); EXPECT_EQ(parent_id, select_commands.GetInteger(3)); std::string icon_name = (*test_commands_map[i])[am::strings::cmd_icon][am::strings::value] @@ -409,7 +411,8 @@ void ResumptionDataDBTest::CheckCommandsData() { EXPECT_EQ(icon_name, select_commands.GetString(5)); int icon_type = (*test_commands_map[i])[am::strings::cmd_icon] - [am::strings::image_type].asInt(); + [am::strings::image_type] + .asInt(); EXPECT_EQ(icon_type, select_commands.GetInteger(6)); j = 0; @@ -461,12 +464,12 @@ void ResumptionDataDBTest::CheckChoiceSetData() { std::string menu_name = command[am::strings::choice_set][choice_idx][am::strings::menu_name] .asString(); - std::string secondary_text = - command[am::strings::choice_set][choice_idx] - [am::strings::secondary_text].asString(); - std::string tertiary_text = - command[am::strings::choice_set][choice_idx] - [am::strings::tertiary_text].asString(); + std::string secondary_text = command[am::strings::choice_set][choice_idx] + [am::strings::secondary_text] + .asString(); + std::string tertiary_text = command[am::strings::choice_set][choice_idx] + [am::strings::tertiary_text] + .asString(); EXPECT_EQ(choice_id, select_choice_set.GetInteger(4)); EXPECT_EQ(menu_name, select_choice_set.GetString(5)); @@ -478,12 +481,12 @@ void ResumptionDataDBTest::CheckChoiceSetData() { EXPECT_TRUE(select_image.Prepare(kSelectImage)); select_image.Bind(0, select_choice_set.GetLongInt(8)); EXPECT_TRUE(select_image.Exec()); - std::string image_value = - command[am::strings::choice_set][choice_idx][am::strings::image] - [am::strings::value].asString(); - int image_type = - command[am::strings::choice_set][choice_idx][am::strings::image] - [am::strings::image_type].asInt(); + std::string image_value = command[am::strings::choice_set][choice_idx] + [am::strings::image][am::strings::value] + .asString(); + int image_type = command[am::strings::choice_set][choice_idx] + [am::strings::image][am::strings::image_type] + .asInt(); EXPECT_EQ(image_value, select_image.GetString(1)); EXPECT_EQ(image_type, select_image.GetInteger(0)); @@ -491,9 +494,9 @@ void ResumptionDataDBTest::CheckChoiceSetData() { EXPECT_TRUE(select_image.Prepare(kSelectImage)); select_image.Bind(0, select_choice_set.GetLongInt(9)); EXPECT_TRUE(select_image.Exec()); - image_value = - command[am::strings::choice_set][choice_idx] - [am::strings::secondary_image][am::strings::value].asString(); + image_value = command[am::strings::choice_set][choice_idx] + [am::strings::secondary_image][am::strings::value] + .asString(); image_type = command[am::strings::choice_set][choice_idx] [am::strings::secondary_image][am::strings::image_type] @@ -503,9 +506,9 @@ void ResumptionDataDBTest::CheckChoiceSetData() { vr_cmd_idx = 0; } - std::string vr_comm = - command[am::strings::choice_set][choice_idx][am::strings::vr_commands] - [vr_cmd_idx++].asString(); + std::string vr_comm = command[am::strings::choice_set][choice_idx] + [am::strings::vr_commands][vr_cmd_idx++] + .asString(); EXPECT_EQ(vr_comm, select_choice_set.GetString(10)); } } diff --git a/src/components/application_manager/test/resumption/resumption_data_json_test.cc b/src/components/application_manager/test/resumption/resumption_data_json_test.cc index 40e61a3c53..955309e091 100644 --- a/src/components/application_manager/test/resumption/resumption_data_json_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_json_test.cc @@ -30,13 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <algorithm> +#include <string> #include "gtest/gtest.h" -#include "application_manager/usage_statistics.h" #include "application_manager/mock_application.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/usage_statistics.h" #include "interfaces/MOBILE_API.h" #include "resumption/last_state_impl.h" @@ -51,9 +51,9 @@ namespace components { namespace resumption_test { using ::testing::_; +using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; -using ::testing::NiceMock; namespace am = application_manager; using namespace Json; diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index fe24ea39b6..e362064a78 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -30,16 +30,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <algorithm> +#include <string> #include "gtest/gtest.h" -#include "application_manager/usage_statistics.h" +#include "application_manager/application.h" +#include "application_manager/message_helper.h" #include "application_manager/mock_resumption_data.h" +#include "application_manager/usage_statistics.h" #include "utils/custom_string.h" -#include "application_manager/application.h" #include "utils/data_accessor.h" -#include "application_manager/message_helper.h" #include "application_manager/resumption_data_test.h" @@ -47,10 +47,10 @@ namespace test { namespace components { namespace resumption_test { namespace custom_str = utils::custom_string; +using ::testing::_; using ::testing::Return; -using ::testing::ReturnRef; using ::testing::ReturnPointee; -using ::testing::_; +using ::testing::ReturnRef; void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { EXPECT_EQ(policy_app_id_, resume_app_list[am::strings::app_id].asString()); @@ -74,14 +74,15 @@ void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { CheckGlobalProporties( resume_app_list[am::strings::application_global_properties]); CheckSubscriptions(resume_app_list[am::strings::application_subscriptions]); + CheckWindowsInfo(resume_app_list[am::strings::windows_info]); } void ResumptionDataTest::CheckCommands(sm::SmartObject& res_list) { for (uint32_t i = 0; i < kCountOfCommands_; ++i) { EXPECT_EQ(i, res_list[i][am::strings::cmd_id].asUInt()); - std::string name = - (*test_commands_map[i])[am::strings::menu_params] - [am::strings::menu_name].asString(); + std::string name = (*test_commands_map[i])[am::strings::menu_params] + [am::strings::menu_name] + .asString(); EXPECT_EQ(name, res_list[i][am::strings::menu_params][am::strings::menu_name] .asString()); @@ -93,7 +94,8 @@ void ResumptionDataTest::CheckCommands(sm::SmartObject& res_list) { res_list[i][am::strings::menu_params][am::strings::position].asInt()); int parent_id = (*test_commands_map[i])[am::strings::menu_params] - [am::hmi_request::parent_id].asInt(); + [am::hmi_request::parent_id] + .asInt(); EXPECT_EQ(parent_id, res_list[i][am::strings::menu_params][am::hmi_request::parent_id] .asInt()); @@ -150,20 +152,24 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { std::snprintf(numb, 12, "%d", i + j); std::string test_choice = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::vr_commands][0].asString(); + [am::strings::vr_commands][0] + .asString(); EXPECT_EQ(test_choice, command[am::strings::vr_commands][0].asString()); std::string menu_name = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::menu_name].asString(); + [am::strings::menu_name] + .asString(); EXPECT_EQ(menu_name, command[am::strings::menu_name].asString()); std::string secondary_text = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::secondary_text].asString(); + [am::strings::secondary_text] + .asString(); EXPECT_EQ(secondary_text, command[am::strings::secondary_text].asString()); std::string tertiary_text = (*test_choiceset_map[i])[am::strings::choice_set][j] - [am::strings::tertiary_text].asString(); + [am::strings::tertiary_text] + .asString(); EXPECT_EQ(tertiary_text, command[am::strings::tertiary_text].asString()); std::string image_value = @@ -181,13 +187,15 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { image_value = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::secondary_image] - [am::strings::value].asString(); + [am::strings::value] + .asString(); EXPECT_EQ( image_value, command[am::strings::secondary_image][am::strings::value].asString()); image_type = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::secondary_image] - [am::strings::image_type].asInt(); + [am::strings::image_type] + .asInt(); EXPECT_EQ(image_type, command[am::strings::secondary_image][am::strings::image_type] .asInt()); @@ -320,6 +328,33 @@ void ResumptionDataTest::CheckVRTitle( EXPECT_EQ(vtitle, res_list[am::strings::vr_help_title].asString()); } +void ResumptionDataTest::CheckWindowsInfo(sm::SmartObject& res_list) { + using namespace application_manager; + auto check_window_info = [this]( + const smart_objects::SmartObject& window_info) { + using namespace application_manager; + const WindowID saved_window_id = window_info[strings::window_id].asInt(); + const auto test_window_info = test_window_params_map_[saved_window_id]; + const auto& saved_window_name = + window_info[strings::window_name].asString(); + ASSERT_TRUE(0 != test_window_info.use_count()); + const auto& window_name = + (*test_window_info)[strings::window_name].asString(); + const auto& saved_duplicate_window_id = + window_info[strings::duplicate_updates_from_window_id].asInt(); + const auto& saved_associated_service_type = + window_info[strings::associated_service_type].asString(); + EXPECT_EQ(saved_window_name, window_name); + EXPECT_EQ("ServiceType", saved_associated_service_type); + EXPECT_EQ(0, saved_duplicate_window_id); + }; + + for (size_t i = 0; i < res_list.length(); ++i) { + const auto& saved_window_info = res_list[i]; + check_window_info(saved_window_info); + } +} + void ResumptionDataTest::PrepareData() { mock_app_extension_ = std::make_shared<NiceMock<application_manager_test::MockAppExtension> >(); @@ -334,9 +369,14 @@ void ResumptionDataTest::PrepareData() { DataAccessor<am::SubMenuMap> sub_menu_m(test_submenu_map, sublock_ptr_); DataAccessor<am::CommandsMap> commands_m(test_commands_map, comlock_ptr_); DataAccessor<am::ChoiceSetMap> choice_set_m(test_choiceset_map, setlock_ptr_); + DataAccessor<am::WindowParamsMap> window_params_map( + test_window_params_map_, window_params_map_lock_ptr_); SetSubscriptions(); DataAccessor<am::ButtonSubscriptions> btn_sub(btn_subscr, btnlock_ptr_); + SetWindowsInfo(); + SetDefaultCurrentHmiState(); + SetDefaultWindowIds(); ON_CALL(*app_mock, is_application_data_changed()).WillByDefault(Return(true)); @@ -345,7 +385,8 @@ void ResumptionDataTest::PrepareData() { ON_CALL(*app_mock, curHash()).WillByDefault(ReturnRef(hash_)); ON_CALL(*app_mock, get_grammar_id()).WillByDefault(Return(grammar_id_)); ON_CALL(*app_mock, device()).WillByDefault(Return(device_handle_)); - ON_CALL(*app_mock, hmi_level()).WillByDefault(Return(hmi_level_)); + ON_CALL(*app_mock, hmi_level(mobile_apis::PredefinedWindows::DEFAULT_WINDOW)) + .WillByDefault(Return(hmi_level_)); ON_CALL(*app_mock, app_id()).WillByDefault(Return(app_id_)); ON_CALL(*app_mock, hmi_app_id()).WillByDefault(Return(hmi_app_id_)); ON_CALL(*app_mock, IsAudioApplication()).WillByDefault(Return(is_audio_)); @@ -368,6 +409,21 @@ void ResumptionDataTest::PrepareData() { ON_CALL(*app_mock, SubscribedButtons()).WillByDefault(Return(btn_sub)); ON_CALL(*app_mock, getAppFiles()).WillByDefault(ReturnRef(app_files_map_)); + ON_CALL(*app_mock, window_optional_params_map()) + .WillByDefault(Return(window_params_map)); +} + +void ResumptionDataTest::SetDefaultCurrentHmiState() { + am::HmiStatePtr hmi_state = + std::make_shared<am::HmiState>(app_mock, mock_application_manager_); + hmi_state->set_window_type(mobile_apis::WindowType::WIDGET); + + ON_CALL(*app_mock, CurrentHmiState(_)).WillByDefault(Return(hmi_state)); +} + +void ResumptionDataTest::SetDefaultWindowIds() { + const am::WindowIds window_ids{1, 2, 3, 4, 5}; + ON_CALL(*app_mock, GetWindowIds()).WillByDefault(Return(window_ids)); } void ResumptionDataTest::SetGlobalProporties() { @@ -543,6 +599,21 @@ void ResumptionDataTest::SetSubscriptions() { btn_subscr.insert(ButtonName::eType::OK); } +void ResumptionDataTest::SetWindowsInfo() { + using namespace application_manager; + const uint32_t number_of_widgets = 5; + for (uint32_t i = 0; i < number_of_widgets; ++i) { + auto window_info = std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + const WindowID window_id = i + 1; + (*window_info)[strings::window_name] = + std::string("Widget ") + std::to_string(window_id); + (*window_info)[strings::associated_service_type] = "ServiceType"; + (*window_info)[strings::duplicate_updates_from_window_id] = 0; + test_window_params_map_[window_id] = window_info; + } +} + } // namespace resumption_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/resumption_sql_queries_test.cc b/src/components/application_manager/test/resumption_sql_queries_test.cc index 0ec902085f..61490ae4af 100644 --- a/src/components/application_manager/test/resumption_sql_queries_test.cc +++ b/src/components/application_manager/test/resumption_sql_queries_test.cc @@ -31,17 +31,17 @@ */ #include <algorithm> -#include <vector> -#include <string> #include <sstream> +#include <string> #include <utility> +#include <vector> #include "gtest/gtest.h" -#include "utils/sqlite_wrapper/sql_database.h" -#include "utils/sqlite_wrapper/sql_query.h" -#include "utils/file_system.h" #include "application_manager/resumption/resumption_sql_queries.h" #include "policy/sql_pt_queries.h" +#include "utils/file_system.h" +#include "utils/sqlite_wrapper/sql_database.h" +#include "utils/sqlite_wrapper/sql_query.h" namespace test { namespace components { @@ -49,8 +49,8 @@ namespace resumption_test { using namespace ::resumption; -using std::string; using std::pair; +using std::string; using utils::dbms::SQLDatabase; using utils::dbms::SQLQuery; @@ -808,7 +808,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMILevel_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -838,7 +839,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMILevel_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -866,7 +868,8 @@ TEST_F(ResumptionSqlQueriesTest, kCheckHMIId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -894,7 +897,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMIId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -922,7 +926,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMIId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -951,7 +956,8 @@ TEST_F(ResumptionSqlQueriesTest, kCountHashId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -980,7 +986,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHashId_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1017,7 +1024,8 @@ TEST_F(ResumptionSqlQueriesTest, kCheckApplication_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1045,7 +1053,8 @@ TEST_F(ResumptionSqlQueriesTest, kCountApplications_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1091,7 +1100,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1122,7 +1132,8 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateHMILevel_ExpectDataUpdated) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1158,7 +1169,8 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateIgnOffCount_ExpectDataUpdated) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1192,7 +1204,8 @@ TEST_F(ResumptionSqlQueriesTest, kCountApplicationsIgnOff_ExpectDataCorrect) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1236,7 +1249,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1279,7 +1293,8 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateSuspendData_ExpectDataUpdated) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1311,7 +1326,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteFile_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1326,7 +1342,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteFile_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key2 = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, key1, key2); @@ -1344,7 +1361,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1359,7 +1377,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key2 = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, key1, key2); @@ -1383,7 +1402,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteSubMenu_ExpectDataDeleted) { int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1398,7 +1418,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteSubMenu_ExpectDataDeleted) { false, app_id2, device_id, - key).LastInsertId(); + key) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "tst_menuName", 2).LastInsertId(); @@ -1417,7 +1438,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1432,7 +1454,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key).LastInsertId(); + key) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "tst_menuName", 2).LastInsertId(); @@ -1454,7 +1477,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1469,7 +1493,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key2 = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); key1 = FillApplicationFilesArrayTable(temp_query, key1, key2).LastInsertId(); @@ -1494,7 +1519,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1511,7 +1537,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillApplicationCommandsArrayTable(temp_query, key1, key2); // Check before action const std::string select_count_image = "SELECT COUNT(*) FROM image;"; @@ -1527,7 +1554,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1544,7 +1572,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillVRCommandsArrayTable( temp_query, "tst_vr_command", kVRCommandFromCommand, key2); @@ -1564,7 +1593,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteCommands_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1582,7 +1612,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteCommands_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillApplicationCommandsArrayTable(temp_query, key1, key2); // Check @@ -1599,7 +1630,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1617,7 +1649,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillApplicationCommandsArrayTable(temp_query, key1, key2); // Check @@ -1640,13 +1673,15 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromChoiceSet_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillChoiceTable(temp_query, 2, "tst_menu_name", "secondary_txt", "tst_tert_text", - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key3 = FillApplicationTable(temp_query, connection_key, grammarID, @@ -1658,7 +1693,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromChoiceSet_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key4 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillChoiceArrayTable(temp_query, key4, key2); FillApplicationChoiceSetArrayTable(temp_query, key4, key3); @@ -1678,7 +1714,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1694,7 +1731,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); FillVRCommandsArrayTable( temp_query, "tst_vr_command", kVRCommandFromChoice, key2); @@ -1724,7 +1762,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteChoice_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1740,7 +1779,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteChoice_ExpectDataDeleted) { false, app_id2, device_id, - key1).LastInsertId(); + key1) + .LastInsertId(); int64_t key3 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillChoiceArrayTable(temp_query, key3, key2); FillApplicationChoiceSetArrayTable(temp_query, key3, key1); @@ -1773,7 +1813,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteChoiceArray_ExpectDataDeleted) { false, app_id2, device_id, - 1).LastInsertId(); + 1) + .LastInsertId(); FillApplicationChoiceSetArrayTable( temp_query, application_choiceset_table_key, application_table_key); FillChoiceArrayTable( @@ -1803,7 +1844,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - 1).LastInsertId(); + 1) + .LastInsertId(); int64_t key2 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillApplicationChoiceSetArrayTable(temp_query, key2, key1); @@ -1838,7 +1880,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id2, device_id, - 1).LastInsertId(); + 1) + .LastInsertId(); int64_t key2 = FillApplicationChoiceSetTable(temp_query, 1, 2).LastInsertId(); FillApplicationChoiceSetArrayTable(temp_query, key2, key1); @@ -1864,7 +1907,8 @@ TEST_F(ResumptionSqlQueriesTest, int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1896,7 +1940,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItem_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1929,7 +1974,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItemArray_ExpectDataDeleted) { int64_t key1 = FillImageTable(temp_query, /*image_type=*/1, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1963,9 +2009,9 @@ TEST_F(ResumptionSqlQueriesTest, string character_list = "abcdefghij"; int64_t key1 = FillTableLimitedCharacterListTable(temp_query, character_list) .LastInsertId(); - int64_t key2 = - FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + int64_t key2 = FillGlobalPropertiesTable( + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -1999,9 +2045,9 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteCharacterArray_ExpectDataDeleted) { string character_list = "abcdefghij"; int64_t key1 = FillTableLimitedCharacterListTable(temp_query, character_list) .LastInsertId(); - int64_t key2 = - FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + int64_t key2 = FillGlobalPropertiesTable( + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -2031,7 +2077,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteTTSChunk_ExpectDataDeleted) { FillTTSChunkTable(temp_query, 1, "tst_text").LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, @@ -2087,7 +2134,8 @@ TEST_F(ResumptionSqlQueriesTest, FillTTSChunkTable(temp_query, 1, "tst_text").LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -2121,7 +2169,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteGlobalProperties_ExpectDataDeleted) { SQLQuery temp_query(db()); int64_t glob_prop_key = FillGlobalPropertiesTable( - temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0).LastInsertId(); + temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", 0) + .LastInsertId(); FillApplicationTable(temp_query, connection_key, grammarID, @@ -2160,7 +2209,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectPrimaryKeyImage_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); ValToPosPair p1(0, "tst_image"); ValToPosPair p2(1, ""); // Check @@ -2588,7 +2638,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountFiles_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t file_key = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, app_key, file_key); @@ -2613,7 +2664,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectFiles_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t file_key = FillFileTable(temp_query, 1, true, true, "tst_name").LastInsertId(); FillApplicationFilesArrayTable(temp_query, app_key, file_key); @@ -2640,7 +2692,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountSubMenu_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "menu_name", 1).LastInsertId(); FillApplicationSubMenuArrayTable(temp_query, app_key, submenu_key); @@ -2664,7 +2717,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectSubMenu_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t submenu_key = FillSubMenuTable(temp_query, 1, "menu_name", 1).LastInsertId(); @@ -2691,7 +2745,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountCommands_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t command_key = FillCommandTable(temp_query, 1, "menu_name", 1, 2, 5).LastInsertId(); FillApplicationCommandsArrayTable(temp_query, app_key, command_key); @@ -2715,11 +2770,13 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromCommand_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2758,11 +2815,13 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromChoice_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t choice_key = FillChoiceTable( @@ -2814,7 +2873,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountSubscriptions_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); FillAppSubscriptionsArrayTable(temp_query, 2, 3, app_key); ValToPosPair p1(0, app_id1); ValToPosPair p2(1, device_id); @@ -2836,7 +2896,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectSubscriptions_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); FillAppSubscriptionsArrayTable(temp_query, 2, 3, app_key); ValToPosPair p1(0, app_id1); ValToPosPair p2(1, device_id); @@ -2859,7 +2920,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountChoiceSet_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); FillApplicationChoiceSetArrayTable(temp_query, 2, app_key); ValToPosPair p1(0, app_id1); ValToPosPair p2(1, device_id); @@ -2881,11 +2943,13 @@ TEST_F(ResumptionSqlQueriesTest, kSelectChoiceSets_ExpectDataCorrect) { false, app_id1, device_id, - 9).LastInsertId(); + 9) + .LastInsertId(); int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t choice_key = FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2920,7 +2984,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectImage_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); // Check ValToPosPair p1(0, IntToString(image_key)); ValToPosPair p2(1, ""); @@ -2947,7 +3012,8 @@ TEST_F(ResumptionSqlQueriesTest, false, app_id1, device_id, - glob_prop_key).LastInsertId(); + glob_prop_key) + .LastInsertId(); // Check ValToPosPair p1(0, app_id1); @@ -2961,7 +3027,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, test_image, - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -2977,7 +3044,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { false, app_id1, device_id, - glob_prop_key).LastInsertId(); + glob_prop_key) + .LastInsertId(); FillHelpTimeoutPromptArrayTable(temp_query, glob_prop_key, 3, 7); // Check @@ -3001,7 +3069,8 @@ TEST_F(ResumptionSqlQueriesTest, kChecksVrHelpItem_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -3021,7 +3090,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectVrHelpItem_ExpectDataCorrect) { int64_t image_key = FillImageTable(temp_query, /*image_type=*/2, "tst_image", - /*is_template=*/true).LastInsertId(); + /*is_template=*/true) + .LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -3046,8 +3116,9 @@ TEST_F(ResumptionSqlQueriesTest, kChecksCharacter_ExpectDataCorrect) { temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", 2) .LastInsertId(); string character_list = "abcdefghijkl"; - int64_t lim_char_list_key = FillTableLimitedCharacterListTable( - temp_query, character_list).LastInsertId(); + int64_t lim_char_list_key = + FillTableLimitedCharacterListTable(temp_query, character_list) + .LastInsertId(); FillCharacterArrayTable(temp_query, glob_prop_key, lim_char_list_key); // Check ValToPosPair p1(0, IntToString(glob_prop_key)); @@ -3063,8 +3134,9 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCharacter_ExpectDataCorrect) { temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", 2) .LastInsertId(); string character_list = "abcdefghijkl"; - int64_t lim_char_list_key = FillTableLimitedCharacterListTable( - temp_query, character_list).LastInsertId(); + int64_t lim_char_list_key = + FillTableLimitedCharacterListTable(temp_query, character_list) + .LastInsertId(); FillCharacterArrayTable(temp_query, glob_prop_key, lim_char_list_key); // Check ValToPosPair p1(0, IntToString(glob_prop_key)); diff --git a/src/components/application_manager/test/rpc_passing_handler_test.cc b/src/components/application_manager/test/rpc_passing_handler_test.cc new file mode 100644 index 0000000000..fb74a0a7e3 --- /dev/null +++ b/src/components/application_manager/test/rpc_passing_handler_test.cc @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <gmock/gmock.h> +#include "gtest/gtest.h" + +#include "application_manager/rpc_passing_handler.h" + +#include "application_manager/mock_app_service_manager.h" +#include "application_manager/mock_application.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_application_manager_settings.h" +#include "application_manager/mock_rpc_handler.h" +#include "application_manager/mock_rpc_service.h" +#include "resumption/mock_last_state.h" + +#include <vector> +#include "application_manager/smart_object_keys.h" +#include "smart_objects/smart_object.h" +#include "utils/semantic_version.h" +#include "utils/test_async_waiter.h" + +namespace test { +namespace components { +namespace application_manager_test { + +namespace am = application_manager; +using ::testing::_; +using ::testing::DoAll; +using ::testing::InSequence; +using ::testing::Mock; +using ::testing::NiceMock; +using ::testing::Pointee; +using ::testing::Return; +using ::testing::ReturnRef; + +struct PassthroughParams { + const uint32_t connection_key; + const int32_t correlation_id; + smart_objects::SmartObject message; + smart_objects::SmartObject forwarded_message; +}; + +class RPCPassingHandlerTest : public ::testing::Test { + public: + RPCPassingHandlerTest() + : mock_app_service_manager_(mock_app_manager_, mock_last_state_) + , mock_app_ptr_(std::make_shared<NiceMock<MockApplication> >()) + , version_(utils::SemanticVersion(5, 1, 0)) {} + + ~RPCPassingHandlerTest() {} + + void SetUp() OVERRIDE { + rpc_passing_handler_ = + new am::RPCPassingHandler(mock_app_service_manager_, mock_app_manager_); + app_services_.clear(); + + ON_CALL(mock_app_manager_, IncreaseForwardedRequestTimeout(_, _)) + .WillByDefault(Return()); + ON_CALL(mock_app_manager_, get_settings()) + .WillByDefault(ReturnRef(mock_app_manager_settings_)); + + ON_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()) + .WillByDefault(Return(kRPCPassthroughTimeout)); + + ON_CALL(mock_app_manager_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + ON_CALL(mock_rpc_service_, ManageMobileCommand(_, _)) + .WillByDefault(Return(true)); + ON_CALL(mock_rpc_service_, SendMessageToMobile(_, _)) + .WillByDefault(Return()); + + ON_CALL(mock_app_manager_, GetAppServiceManager()) + .WillByDefault(ReturnRef(mock_app_service_manager_)); + ON_CALL(mock_app_service_manager_, GetActiveServices()) + .WillByDefault(Return(app_services_)); + + ON_CALL(mock_app_manager_, GetRPCHandler()) + .WillByDefault(ReturnRef(mock_rpc_handler_)); + ON_CALL(mock_rpc_handler_, ValidateRpcSO(_, _, _, _)) + .WillByDefault(Return(true)); + + ON_CALL(mock_app_manager_, application(_)) + .WillByDefault(Return(mock_app_ptr_)); + ON_CALL(*mock_app_ptr_, msg_version()).WillByDefault(ReturnRef(version_)); + } + + void TearDown() OVERRIDE { + delete rpc_passing_handler_; + rpc_passing_handler_ = NULL; + } + + protected: + am::AppService CreateAppService(uint32_t connection_key, + const std::string& service_id, + const std::string& service_type) { + am::AppService app_service; + + app_service.connection_key = connection_key; + app_service.mobile_service = true; + app_service.default_service = false; + + smart_objects::SmartObject record(smart_objects::SmartType::SmartType_Map); + record[am::strings::service_id] = service_id; + record[am::strings::service_manifest][am::strings::service_type] = + service_type; + record[am::strings::service_manifest][am::strings::allow_app_consumers] = + true; + record[am::strings::service_manifest][am::strings::handled_rpcs] = + smart_objects::SmartObject(smart_objects::SmartType::SmartType_Array); + record[am::strings::service_manifest][am::strings::handled_rpcs][0] = + mobile_apis::FunctionID::SendLocationID; + record[am::strings::service_published] = true; + record[am::strings::service_active] = true; + app_service.record = record; + + return app_service; + } + + smart_objects::SmartObject CreatePassThroughRequest(uint32_t connection_key, + int32_t correlation_id) { + smart_objects::SmartObject record(smart_objects::SmartType::SmartType_Map); + record[am::strings::params][am::strings::connection_key] = connection_key; + record[am::strings::params][am::strings::correlation_id] = correlation_id; + record[am::strings::params][am::strings::function_id] = + mobile_apis::FunctionID::SendLocationID; + record[am::strings::params][am::strings::message_type] = + am::MessageType::kRequest; + record[am::strings::msg_params][am::strings::latitude_degrees] = 50; + record[am::strings::msg_params][am::strings::longitude_degrees] = 50; + record[am::strings::msg_params][am::strings::location_name] = + "TestLocation"; + + return record; + } + + smart_objects::SmartObject CreatePassThroughResponse( + uint32_t connection_key, + int32_t correlation_id, + const std::string& result_code, + bool success, + std::string info = std::string()) { + smart_objects::SmartObject record(smart_objects::SmartType::SmartType_Map); + record[am::strings::params][am::strings::connection_key] = connection_key; + record[am::strings::params][am::strings::correlation_id] = correlation_id; + record[am::strings::params][am::strings::function_id] = + mobile_apis::FunctionID::SendLocationID; + record[am::strings::params][am::strings::message_type] = + am::MessageType::kResponse; + record[am::strings::msg_params][am::strings::result_code] = result_code; + record[am::strings::msg_params][am::strings::success] = success; + record[am::strings::msg_params][am::strings::info] = info; + + return record; + } + + void SendRequestToASP(const PassthroughParams& params, uint32_t timeout = 0) { + if (timeout == 0) { + // If timeout argument is not sepcified + timeout = kRPCPassthroughTimeout; + } + + // Call RPCPassThrough with request smart object + + // Will call PopulateRPCRequestQueue + EXPECT_CALL(mock_app_service_manager_, GetActiveServices()) + .WillOnce(Return(app_services_)); + + // Will call ForwardRequesttoMobile + EXPECT_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()) + .WillOnce(Return(timeout)); + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(Pointee(params.forwarded_message), false)); + + bool mobile_result = rpc_passing_handler_->RPCPassThrough(params.message); + EXPECT_EQ(mobile_result, true); + } + + NiceMock<MockApplicationManager> mock_app_manager_; + NiceMock<MockApplicationManagerSettings> mock_app_manager_settings_; + MockRPCService mock_rpc_service_; + MockRPCHandler mock_rpc_handler_; + resumption_test::MockLastState mock_last_state_; + MockAppServiceManager mock_app_service_manager_; + std::shared_ptr<NiceMock<MockApplication> > mock_app_ptr_; + const utils::SemanticVersion version_; + am::RPCPassingHandler* rpc_passing_handler_; + std::vector<am::AppService> app_services_; + + uint32_t kRPCPassthroughTimeout = 10000; + uint32_t kConnectionKey_ASC = 1; + uint32_t kConnectionKey_NAV_ASP = 2; + uint32_t kConnectionKey_MEDIA_ASP = 3; + int32_t kCorrelationId = 1; + const uint32_t MAX_TEST_DURATION = 1000; // 1 second +}; + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_ForwardToMobile) { + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_NoPassthrough) { + smart_objects::SmartObject request = + CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId); + + // Call RPCPassThrough with request smart object + + // Will call PopulateRPCRequestQueue + EXPECT_CALL(mock_app_service_manager_, GetActiveServices()) + .WillOnce(Return(app_services_)); + EXPECT_CALL( + mock_app_manager_, + IncreaseForwardedRequestTimeout(kConnectionKey_ASC, kCorrelationId)) + .Times(0); + // Will return false since there are no active services to handle the rpc + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + bool result = rpc_passing_handler_->RPCPassThrough(request); + EXPECT_EQ(result, false); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_RESPONSE_UnknownCorrelationID) { + smart_objects::SmartObject invalid_response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId + 1, "SUCCESS", true); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will return false since the correlation id does not exist in the map + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, _)).Times(0); + + bool result = rpc_passing_handler_->RPCPassThrough(invalid_response); + EXPECT_EQ(result, false); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_SUCCESS) { + smart_objects::SmartObject response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId, "SUCCESS", true); + smart_objects::SmartObject forwarded_response = CreatePassThroughResponse( + kConnectionKey_ASC, kCorrelationId, "SUCCESS", true); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will ForwardResponseToMobile + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(Pointee(forwarded_response), false)); + + bool result = rpc_passing_handler_->RPCPassThrough(response); + EXPECT_EQ(result, true); +} + +TEST_F(RPCPassingHandlerTest, + RPCPassingTest_UNSUPPORTED_REQUEST_ForwardToCore) { + smart_objects::SmartObject unsupported_response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId, "UNSUPPORTED_REQUEST", false); + smart_objects::SmartObject forwarded_request = + CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will cycle to core (no other app services in list) + EXPECT_CALL(mock_app_manager_, GetRPCHandler()); + EXPECT_CALL(mock_rpc_handler_, ValidateRpcSO(forwarded_request, _, _, false)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(Pointee(forwarded_request), + am::commands::Command::SOURCE_MOBILE)); + + bool result = rpc_passing_handler_->RPCPassThrough(unsupported_response); + EXPECT_EQ(result, true); +} + +TEST_F(RPCPassingHandlerTest, + RPCPassingTest_UNSUPPORTED_REQUEST_ForwardToMobile) { + smart_objects::SmartObject unsupported_response = CreatePassThroughResponse( + kConnectionKey_NAV_ASP, kCorrelationId, "UNSUPPORTED_REQUEST", false); + smart_objects::SmartObject forwarded_request = + CreatePassThroughRequest(kConnectionKey_MEDIA_ASP, kCorrelationId); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + app_services_.push_back( + CreateAppService(kConnectionKey_MEDIA_ASP, "Media service", "MEDIA")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + SendRequestToASP(request_params); + + // Call RPCPassThrough with response smart object + // Will cycle to next compatible active app service + EXPECT_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()); + EXPECT_CALL(mock_app_manager_, GetRPCService()); + EXPECT_CALL(mock_rpc_service_, + SendMessageToMobile(Pointee(forwarded_request), false)); + + bool result = rpc_passing_handler_->RPCPassThrough(unsupported_response); + EXPECT_EQ(result, true); +} + +TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_Timeout) { + uint32_t timeout_in_ms = 4; + std::shared_ptr<TestAsyncWaiter> waiter = std::make_shared<TestAsyncWaiter>(); + + app_services_.push_back(CreateAppService( + kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); + + PassthroughParams request_params{ + .connection_key = kConnectionKey_ASC, + .correlation_id = kCorrelationId, + .message = CreatePassThroughRequest(kConnectionKey_ASC, kCorrelationId), + .forwarded_message = + CreatePassThroughRequest(kConnectionKey_NAV_ASP, kCorrelationId), + }; + + // Call RPCPassThrough with request smart object + + // Will call PopulateRPCRequestQueue + EXPECT_CALL(mock_app_service_manager_, GetActiveServices()) + .WillOnce(Return(app_services_)); + + // Will call ForwardRequesttoMobile + EXPECT_CALL(mock_app_manager_settings_, rpc_pass_through_timeout()) + .WillOnce(Return(timeout_in_ms)); + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile(Pointee(request_params.forwarded_message), false)); + + // Request timeout will trigger perform next request + // Will cycle to core (no other app services in list) + EXPECT_CALL(mock_app_manager_, GetRPCHandler()); + EXPECT_CALL(mock_rpc_handler_, + ValidateRpcSO(request_params.message, _, _, false)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_app_manager_, GetRPCService()).Times(2); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand(Pointee(request_params.message), + am::commands::Command::SOURCE_MOBILE)) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); + + bool mobile_result = + rpc_passing_handler_->RPCPassThrough(request_params.message); + EXPECT_EQ(mobile_result, true); + + const uint32_t wait_time = MAX_TEST_DURATION + timeout_in_ms; + EXPECT_TRUE(waiter->WaitFor(1, wait_time)); + + // This sleep prevents a SEGFAULT which occurs after the + // RPCPassingHandlerTests are completed and the next test set runs + usleep(6000); // sleep 6 ms +} + +} // namespace application_manager_test +} // namespace components +} // namespace test diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index 9574f8d00f..9799dbcac2 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -30,55 +30,60 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "gtest/gtest.h" +#include "application_manager/application_manager_impl.h" #include "application_manager/hmi_state.h" +#include "application_manager/mock_application.h" #include "application_manager/state_controller_impl.h" #include "application_manager/usage_statistics.h" -#include "application_manager/application_manager_impl.h" -#include "application_manager/mock_application.h" -#include "connection_handler/mock_connection_handler_settings.h" #include "connection_handler/connection_handler_impl.h" +#include "connection_handler/mock_connection_handler_settings.h" +#include "gtest/gtest.h" #include "transport_manager/mock_transport_manager.h" -#include "utils/lock.h" #include "utils/data_accessor.h" +#include "utils/lock.h" -#include "application_manager/message_helper.h" #include "application_manager/event_engine/event.h" -#include "application_manager/smart_object_keys.h" +#include "application_manager/message_helper.h" +#include "application_manager/mock_application_manager.h" +#include "application_manager/mock_event_dispatcher.h" #include "application_manager/mock_message_helper.h" +#include "application_manager/mock_rpc_service.h" +#include "application_manager/policies/mock_policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/smart_object_keys.h" +#include "connection_handler/mock_connection_handler.h" #include "policy/mock_policy_settings.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/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/resumption/resume_ctrl.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_rpc_service.h" namespace am = application_manager; using am::HmiState; using am::HmiStatePtr; using am::UsageStatistics; using ::testing::_; +using ::testing::AtLeast; +using ::testing::InSequence; +using ::testing::Mock; +using ::testing::NiceMock; using ::testing::Return; -using ::testing::ReturnRef; using ::testing::ReturnPointee; +using ::testing::ReturnRef; using ::testing::SaveArg; -using ::testing::Mock; -using ::testing::NiceMock; -using ::testing::InSequence; using ::testing::Truly; -using ::testing::AtLeast; + +using application_manager::MockMessageHelper; namespace test { namespace components { namespace state_controller_test { -namespace constants { +namespace { const uint32_t kCorrID = 314u; const uint32_t kHMIAppID = 2718u; -} // namespace constants +const am::WindowID kDefaultWindowId = + mobile_apis::PredefinedWindows::DEFAULT_WINDOW; +const am::WindowID kCustomWindowId = 2; +} // namespace struct HmiStatesComparator { mobile_apis::HMILevel::eType hmi_level_; @@ -151,7 +156,6 @@ class StateControllerImplTest : public ::testing::Test { ~StateControllerImplTest() { Mock::VerifyAndClearExpectations(&message_helper_mock_); } - NiceMock<application_manager_test::MockApplicationManager> app_manager_mock_; NiceMock<application_manager_test::MockRPCService> mock_rpc_service_; NiceMock<policy_test::MockPolicyHandlerInterface> policy_interface_; @@ -213,7 +217,11 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr> invalid_states_for_not_audio_app; std::vector<am::HmiStatePtr> invalid_states_for_audio_app; std::vector<am::HmiState::StateID> valid_state_ids_; - std::vector<am::ApplicationSharedPtr> applications_list_; + + typedef std::map<am::ApplicationSharedPtr, + NiceMock<application_manager_test::MockApplication>*> + AppPtrMockMapping; + AppPtrMockMapping applications_list_; connection_handler_test::MockConnectionHandlerSettings mock_connection_handler__settings; @@ -554,21 +562,26 @@ class StateControllerImplTest : public ::testing::Test { // application properties, i.e. is_media_application flag from RAI and // AppHmiTypes (NAVIGATION, etc.). Most likely logic should be changed // after conclusion on APPLINK-20231 - std::vector<am::ApplicationSharedPtr>::iterator app = std::find_if( - applications_list_.begin(), - applications_list_.end(), - [app_id](am::ApplicationSharedPtr a) { return app_id == a->app_id(); }); - - if (app == applications_list_.end()) { + AppPtrMockMapping::iterator it = + std::find_if(applications_list_.begin(), + applications_list_.end(), + [app_id](AppPtrMockMapping::value_type& item) { + return app_id == item.first->app_id(); + }); + + if (applications_list_.end() == it) { return APP_TYPE_NON_MEDIA; } - if ((*app)->is_navi()) { + auto app = it->first; + if (app->is_navi()) { return APP_TYPE_NAVI; } - if ((*app)->is_media_application()) { + + if (app->is_media_application()) { return APP_TYPE_MEDIA; } + return APP_TYPE_NON_MEDIA; } @@ -644,17 +657,16 @@ class StateControllerImplTest : public ::testing::Test { template <typename T, typename Q> void TestMixState(void (StateControllerImplTest::*call_back_result)( std::vector<am::HmiStatePtr>&, ApplicationType)) { - std::vector<am::ApplicationSharedPtr>::iterator it_begin = - applications_list_.begin(); - std::vector<am::ApplicationSharedPtr>::iterator it_end = - applications_list_.end(); + AppPtrMockMapping::iterator it_begin = applications_list_.begin(); + AppPtrMockMapping::iterator it_end = applications_list_.end(); ApplicationType app_type; uint32_t app_id; am::ApplicationSharedPtr app; + for (; it_begin != it_end; ++it_begin) { - app_id = (*it_begin)->app_id(); + app_id = it_begin->first->app_id(); app_type = AppType(app_id); - app = (*it_begin); + app = it_begin->first; am::HmiStatePtr state_first = std::make_shared<T>(app, app_manager_mock_); am::HmiStatePtr state_second = std::make_shared<Q>(app, app_manager_mock_); @@ -925,14 +937,14 @@ class StateControllerImplTest : public ::testing::Test { MEDIA, NAVI, VC); - applications_list_.push_back(simple_app_); - applications_list_.push_back(media_app_); - applications_list_.push_back(navi_app_); - applications_list_.push_back(vc_app_); - applications_list_.push_back(media_navi_app_); - applications_list_.push_back(media_vc_app_); - applications_list_.push_back(navi_vc_app_); - applications_list_.push_back(media_navi_vc_app_); + applications_list_[simple_app_] = simple_app_ptr_; + applications_list_[media_app_] = media_app_ptr_; + applications_list_[navi_app_] = navi_app_ptr_; + applications_list_[vc_app_] = vc_app_ptr_; + applications_list_[media_navi_app_] = media_navi_app_ptr_; + applications_list_[media_vc_app_] = media_vc_app_ptr_; + applications_list_[navi_vc_app_] = navi_vc_app_ptr_; + applications_list_[media_navi_vc_app_] = media_navi_vc_app_ptr_; } void CheckAppConfiguration() { ASSERT_EQ(simple_app_.get(), simple_app_ptr_); @@ -1003,7 +1015,6 @@ class StateControllerImplTest : public ::testing::Test { ON_CALL(app_manager_mock_, event_dispatcher()) .WillByDefault(ReturnRef(mock_event_dispatcher_)); state_ctrl_ = std::make_shared<am::StateControllerImpl>(app_manager_mock_); - ON_CALL(app_manager_mock_, applications()) .WillByDefault(Return(applications_)); ConfigureApps(); @@ -1016,6 +1027,22 @@ class StateControllerImplTest : public ::testing::Test { delete conn_handler; } + application_manager::commands::MessageSharedPtr CreateCloseAppMessage() { + using namespace application_manager; + + smart_objects::SmartObjectSPtr message = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_CloseApplication; + (*message)[strings::params][strings::message_type] = MessageType::kRequest; + (*message)[strings::params][strings::correlation_id] = kCorrID; + (*message)[strings::msg_params][strings::app_id] = kHMIAppID; + + return message; + } + void SetConnection() { conn_handler = new connection_handler::ConnectionHandlerImpl( mock_connection_handler__settings, mock_transport_manager); @@ -1036,7 +1063,7 @@ class StateControllerImplTest : public ::testing::Test { (*bc_activate_app_request)[am::strings::params] [am::strings::correlation_id] = corr_id; ON_CALL(message_helper_mock_, - GetBCActivateAppRequestToHMI(_, _, _, hmi_lvl, _, _)) + GetBCActivateAppRequestToHMI(_, _, hmi_lvl, _, _)) .WillByDefault(Return(bc_activate_app_request)); ON_CALL(app_manager_mock_, GetRPCService()) .WillByDefault(ReturnRef(mock_rpc_service_)); @@ -1044,22 +1071,36 @@ class StateControllerImplTest : public ::testing::Test { .WillByDefault(Return(true)); } - void ExpectSuccesfullSetHmiState( + void ExpectSuccessfulSetHmiState( am::ApplicationSharedPtr app, NiceMock<application_manager_test::MockApplication>* app_mock, am::HmiStatePtr old_state, am::HmiStatePtr new_state) { - EXPECT_CALL(*app_mock, CurrentHmiState()) + ExpectSuccessfulSetHmiState( + app, app_mock, kDefaultWindowId, old_state, new_state); + } + + void ExpectSuccessfulSetHmiState( + am::ApplicationSharedPtr app, + NiceMock<application_manager_test::MockApplication>* app_mock, + am::WindowID window_id, + am::HmiStatePtr old_state, + am::HmiStatePtr new_state) { + EXPECT_CALL(*app_mock, CurrentHmiState(window_id)) .WillOnce(Return(old_state)) .WillOnce(Return(new_state)); - EXPECT_CALL(*app_mock, - SetRegularState(Truly(HmiStatesComparator(new_state)))); + EXPECT_CALL( + *app_mock, + SetRegularState(window_id, Truly(HmiStatesComparator(new_state)))); if (!HmiStatesComparator(old_state)(new_state)) { - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(app)); - EXPECT_CALL( - app_manager_mock_, - OnHMILevelChanged( - app->app_id(), old_state->hmi_level(), new_state->hmi_level())); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(app, window_id, _)); + if (kDefaultWindowId == window_id) { + EXPECT_CALL( + app_manager_mock_, + OnHMILevelChanged( + app->app_id(), old_state->hmi_level(), new_state->hmi_level())); + } } } @@ -1068,22 +1109,33 @@ class StateControllerImplTest : public ::testing::Test { NiceMock<application_manager_test::MockApplication>* app_mock, am::HmiStatePtr old_state, am::HmiStatePtr new_state) { - EXPECT_CALL(*app_mock, RegularHmiState()) + EXPECT_CALL(*app_mock, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(old_state)) .WillOnce(Return(old_state)); - ExpectSuccesfullSetHmiState(app, app_mock, old_state, new_state); + ExpectSuccessfulSetHmiState(app, app_mock, old_state, new_state); } void ExpectAppWontChangeHmiStateDueToConflictResolving( am::ApplicationSharedPtr app, NiceMock<application_manager_test::MockApplication>* app_mock, + const am::WindowID window_id, am::HmiStatePtr state) { - ON_CALL(*app_mock, RegularHmiState()).WillByDefault(Return(state)); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(app)).Times(0); + ON_CALL(*app_mock, RegularHmiState(window_id)).WillByDefault(Return(state)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(app, window_id, _)) + .Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(app->app_id(), _, _)) .Times(0); } + void ExpectAppWontChangeHmiStateDueToConflictResolving( + am::ApplicationSharedPtr app, + NiceMock<application_manager_test::MockApplication>* app_mock, + am::HmiStatePtr state) { + ExpectAppWontChangeHmiStateDueToConflictResolving( + app, app_mock, kDefaultWindowId, state); + } + void InsertApplication(am::ApplicationSharedPtr app) { application_set_.insert(app); ON_CALL(app_manager_mock_, application(app->app_id())) @@ -1135,13 +1187,14 @@ class StateControllerImplTest : public ::testing::Test { using smart_objects::SmartObject; namespace FunctionID = hmi_apis::FunctionID; - EXPECT_CALL(app_mock, CurrentHmiState()) + EXPECT_CALL(app_mock, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(NoneNotAudibleState())); for (size_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; EXPECT_CALL(app_mock, - AddHMIState(Truly(HmiStatesIDComparator(state_id)))); + AddHMIState(kDefaultWindowId, + Truly(HmiStatesIDComparator(state_id)))); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { Event vr_start_event(FunctionID::VR_Started); @@ -1182,7 +1235,7 @@ class StateControllerImplTest : public ::testing::Test { default: break; } - EXPECT_CALL(app_mock, AddHMIState(_)).Times(0); + EXPECT_CALL(app_mock, AddHMIState(kDefaultWindowId, _)).Times(0); } } @@ -1194,12 +1247,23 @@ class StateControllerImplTest : public ::testing::Test { using smart_objects::SmartObject; namespace FunctionID = hmi_apis::FunctionID; - EXPECT_CALL(app_mock, CurrentHmiState()) + ON_CALL(message_helper_mock_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(CreateCloseAppMessage())); + ON_CALL(app_manager_mock_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + ON_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillByDefault(Return(true)); + EXPECT_CALL(app_mock, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(NoneNotAudibleState())); + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(app_mock, GetWindowIds()).WillRepeatedly(Return(window_ids)); + for (uint32_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(app_mock, AddHMIState(Truly(HmiStatesIDComparator(state_id)))) + EXPECT_CALL( + app_mock, + AddHMIState(kDefaultWindowId, Truly(HmiStatesIDComparator(state_id)))) .Times(1); switch (state_id) { @@ -1243,16 +1307,17 @@ class StateControllerImplTest : public ::testing::Test { break; } - EXPECT_CALL(app_mock, AddHMIState(_)).Times(0); + EXPECT_CALL(app_mock, AddHMIState(kDefaultWindowId, _)).Times(0); } for (uint32_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(app_mock, RemoveHMIState(state_id)).Times(1); + EXPECT_CALL(app_mock, RemoveHMIState(kDefaultWindowId, state_id)) + .Times(1); - EXPECT_CALL(app_mock, PostponedHmiState()) + EXPECT_CALL(app_mock, PostponedHmiState(kDefaultWindowId)) .WillOnce(Return(NoneNotAudibleState())); - EXPECT_CALL(app_mock, RemovePostponedState()); + EXPECT_CALL(app_mock, RemovePostponedState(kDefaultWindowId)); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { @@ -1295,7 +1360,7 @@ class StateControllerImplTest : public ::testing::Test { break; } - EXPECT_CALL(app_mock, RemoveHMIState(_)).Times(0); + EXPECT_CALL(app_mock, RemoveHMIState(kDefaultWindowId, _)).Times(0); } } }; @@ -1307,6 +1372,7 @@ TEST_F(StateControllerImplTest, OnStateChangedWithEqualStates) { for (uint32_t i = 0; i < valid_states_for_not_audio_app_.size(); ++i) { state_ctrl_->OnStateChanged(simple_app_, + kDefaultWindowId, valid_states_for_not_audio_app_[i], valid_states_for_not_audio_app_[i]); } @@ -1317,8 +1383,9 @@ TEST_F(StateControllerImplTest, OnStateChangedWithDifferentStates) { for (uint32_t j = 0; j < valid_states_for_not_audio_app_.size(); ++j) { HmiStatesComparator comp(valid_states_for_not_audio_app_[i]); if (!comp(valid_states_for_not_audio_app_[j])) { - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)) - .Times(1); + EXPECT_CALL( + message_helper_mock_, + SendHMIStatusNotification(simple_app_, kDefaultWindowId, _)); EXPECT_CALL( app_manager_mock_, OnHMILevelChanged(simple_app_id_, @@ -1330,10 +1397,12 @@ TEST_F(StateControllerImplTest, OnStateChangedWithDifferentStates) { EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(1); } state_ctrl_->OnStateChanged(simple_app_, + kDefaultWindowId, valid_states_for_not_audio_app_[i], valid_states_for_not_audio_app_[j]); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(_)).Times(0); + EXPECT_CALL(message_helper_mock_, SendHMIStatusNotification(_, _, _)) + .Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); } @@ -1356,10 +1425,12 @@ TEST_F(StateControllerImplTest, OnStateChangedToNone) { SystemContext::SYSCTXT_MAIN); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); - state_ctrl_->OnStateChanged(simple_app_, none_state, not_none_state); + state_ctrl_->OnStateChanged( + simple_app_, kDefaultWindowId, none_state, not_none_state); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(1); - state_ctrl_->OnStateChanged(simple_app_, not_none_state, none_state); + state_ctrl_->OnStateChanged( + simple_app_, kDefaultWindowId, not_none_state, none_state); } TEST_F(StateControllerImplTest, MoveSimpleAppToValidStates) { @@ -1377,18 +1448,21 @@ TEST_F(StateControllerImplTest, MoveSimpleAppToValidStates) { it != valid_states_for_not_audio_app_.end(); ++it) { HmiStatePtr state_to_setup = *it; - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(initial_state)) .WillOnce(Return(state_to_setup)); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(simple_app_, kDefaultWindowId, _)); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(simple_app_id_, initial_state->hmi_level(), state_to_setup->hmi_level())); EXPECT_CALL(*simple_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(state_to_setup)))); - state_ctrl_->SetRegularState(simple_app_, state_to_setup, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(state_to_setup)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, state_to_setup, false); initial_state = state_to_setup; } } @@ -1413,18 +1487,21 @@ TEST_F(StateControllerImplTest, MoveAudioNotResumeAppToValidStates) { it != valid_states_for_audio_app_.end(); ++it) { HmiStatePtr state_to_setup = *it; - EXPECT_CALL(*audio_app_mock, CurrentHmiState()) + EXPECT_CALL(*audio_app_mock, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(initial_state)) .WillOnce(Return(state_to_setup)); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(audio_app)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(audio_app, kDefaultWindowId, _)); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(audio_app->app_id(), initial_state->hmi_level(), state_to_setup->hmi_level())); EXPECT_CALL(*audio_app_mock, - SetRegularState(Truly(HmiStatesComparator(state_to_setup)))); - state_ctrl_->SetRegularState(media_navi_vc_app_, state_to_setup, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(state_to_setup)))); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, state_to_setup, false); initial_state = state_to_setup; } } @@ -1452,7 +1529,7 @@ TEST_F(StateControllerImplTest, MoveAudioResumeAppToValidStates) { HmiStatePtr state_to_setup = *it; HmiStatePtr state_to_check = state_to_setup; // First time current state is initial, then it changes to setup state - EXPECT_CALL(*audio_app_mock, CurrentHmiState()) + EXPECT_CALL(*audio_app_mock, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(initial_state)) .WillOnce(Return(state_to_setup)); // Audio resume app when HMI level is LIMITED or FULL gets audible state @@ -1480,8 +1557,10 @@ TEST_F(StateControllerImplTest, MoveAudioResumeAppToValidStates) { // Check that we set correct state EXPECT_CALL(*audio_app_mock, - SetRegularState(Truly(HmiStatesComparator(state_to_check)))); - state_ctrl_->SetRegularState(media_navi_vc_app_, state_to_setup, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(state_to_check)))); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, state_to_setup, false); initial_state = state_to_setup; } } @@ -1494,11 +1573,13 @@ TEST_F(StateControllerImplTest, MoveAppFromValidStateToInvalid) { invalid_state_it != common_invalid_states_.end(); ++invalid_state_it) { HmiStatePtr invalid_state = *invalid_state_it; - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); EXPECT_CALL(*simple_app_ptr_, is_resuming()).Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); - state_ctrl_->SetRegularState(simple_app_, invalid_state, false); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)) + .Times(0); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, invalid_state, false); } for (std::vector<HmiStatePtr>::iterator invalid_state_it = @@ -1506,11 +1587,14 @@ TEST_F(StateControllerImplTest, MoveAppFromValidStateToInvalid) { invalid_state_it != common_invalid_states_.end(); ++invalid_state_it) { HmiStatePtr invalid_state = *invalid_state_it; - EXPECT_CALL(*media_navi_vc_app_ptr_, CurrentHmiState()).Times(0); + EXPECT_CALL(*media_navi_vc_app_ptr_, CurrentHmiState(kDefaultWindowId)) + .Times(0); EXPECT_CALL(*media_navi_vc_app_ptr_, is_resuming()).Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); - EXPECT_CALL(*media_navi_vc_app_ptr_, SetRegularState(_)).Times(0); - state_ctrl_->SetRegularState(media_navi_vc_app_, invalid_state, false); + EXPECT_CALL(*media_navi_vc_app_ptr_, SetRegularState(kDefaultWindowId, _)) + .Times(0); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, invalid_state, false); } } @@ -1532,7 +1616,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1540,7 +1624,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullNotAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAudioAppAppIsInFull) { @@ -1557,14 +1642,15 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAudioAppAppIsInFull) { InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1583,14 +1669,15 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1607,7 +1694,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1615,7 +1702,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1633,7 +1721,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_limited); InsertApplication(app_moved_to_full); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1641,7 +1729,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1660,7 +1749,7 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_limited); InsertApplication(app_moved_to_limited); - ExpectSuccesfullSetHmiState(app_moved_to_limited, + ExpectSuccessfulSetHmiState(app_moved_to_limited, app_moved_to_limited_mock, BackgroundState(), LimitedState()); @@ -1668,7 +1757,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); + state_ctrl_->SetRegularState( + app_moved_to_limited, kDefaultWindowId, LimitedState(), false); } TEST_F(StateControllerImplTest, @@ -1686,14 +1776,15 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_limited); InsertApplication(app_moved_to_limited); - ExpectSuccesfullSetHmiState(app_moved_to_limited, + ExpectSuccessfulSetHmiState(app_moved_to_limited, app_moved_to_limited_mock, BackgroundState(), LimitedState()); ExpectAppWontChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); + state_ctrl_->SetRegularState( + app_moved_to_limited, kDefaultWindowId, LimitedState(), false); } TEST_F(StateControllerImplTest, @@ -1712,14 +1803,15 @@ TEST_F(StateControllerImplTest, InsertApplication(app_in_full); InsertApplication(app_moved_to_limited); - ExpectSuccesfullSetHmiState(app_moved_to_limited, + ExpectSuccessfulSetHmiState(app_moved_to_limited, app_moved_to_limited_mock, BackgroundState(), LimitedState()); ExpectAppWontChangeHmiStateDueToConflictResolving( app_in_full, app_in_full_mock, FullAudibleState()); - state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); + state_ctrl_->SetRegularState( + app_moved_to_limited, kDefaultWindowId, LimitedState(), false); } TEST_F(StateControllerImplTest, SetFullToSimpleAppWhile2AudioAppsInLimited) { @@ -1743,7 +1835,7 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhile2AudioAppsInLimited) { InsertApplication(limited_app1); InsertApplication(limited_app2); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1753,7 +1845,8 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhile2AudioAppsInLimited) { ExpectAppWontChangeHmiStateDueToConflictResolving( limited_app2, limited_app2_mock, LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1778,7 +1871,7 @@ TEST_F(StateControllerImplTest, InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1789,7 +1882,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1814,7 +1908,7 @@ TEST_F(StateControllerImplTest, InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullNotAudibleState()); @@ -1825,7 +1919,8 @@ TEST_F(StateControllerImplTest, ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullNotAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullNotAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullNotAudibleState(), false); } TEST_F( @@ -1851,7 +1946,7 @@ TEST_F( InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1862,7 +1957,8 @@ TEST_F( ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullNotAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F( @@ -1888,7 +1984,7 @@ TEST_F( InsertApplication(limited_app); InsertApplication(full_app); - ExpectSuccesfullSetHmiState(app_moved_to_full, + ExpectSuccessfulSetHmiState(app_moved_to_full, app_moved_to_full_mock, BackgroundState(), FullAudibleState()); @@ -1899,7 +1995,8 @@ TEST_F( ExpectAppChangeHmiStateDueToConflictResolving( full_app, full_app_mock, FullAudibleState(), LimitedState()); - state_ctrl_->SetRegularState(app_moved_to_full, FullAudibleState(), false); + state_ctrl_->SetRegularState( + app_moved_to_full, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1912,19 +2009,20 @@ TEST_F(StateControllerImplTest, InsertApplication(media_app_); InsertApplication(navi_app_); InsertApplication(vc_app_); - ExpectSuccesfullSetHmiState(media_navi_vc_app_, + ExpectSuccessfulSetHmiState(media_navi_vc_app_, media_navi_vc_app_ptr_, BackgroundState(), FullAudibleState()); - EXPECT_CALL(*media_app_ptr_, RegularHmiState()) + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(LimitedState())); ExpectAppChangeHmiStateDueToConflictResolving( navi_app_, navi_app_ptr_, LimitedState(), BackgroundState()); ExpectAppChangeHmiStateDueToConflictResolving( vc_app_, vc_app_ptr_, LimitedState(), BackgroundState()); - state_ctrl_->SetRegularState(media_navi_vc_app_, FullAudibleState(), false); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, FullAudibleState(), false); } TEST_F(StateControllerImplTest, @@ -1937,19 +2035,20 @@ TEST_F(StateControllerImplTest, InsertApplication(media_app_); InsertApplication(navi_app_); InsertApplication(vc_app_); - ExpectSuccesfullSetHmiState(media_navi_vc_app_, + ExpectSuccessfulSetHmiState(media_navi_vc_app_, media_navi_vc_app_ptr_, BackgroundState(), FullAudibleState()); - EXPECT_CALL(*media_app_ptr_, RegularHmiState()) + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(LimitedState())); ExpectAppChangeHmiStateDueToConflictResolving( navi_app_, navi_app_ptr_, LimitedState(), BackgroundState()); ExpectAppChangeHmiStateDueToConflictResolving( vc_app_, vc_app_ptr_, FullAudibleState(), BackgroundState()); - state_ctrl_->SetRegularState(media_navi_vc_app_, FullAudibleState(), false); + state_ctrl_->SetRegularState( + media_navi_vc_app_, kDefaultWindowId, FullAudibleState(), false); } // TODO {AKozoriz} Changed logic in state_controller @@ -1969,12 +2068,6 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) { StateLevelPair(LimitedState(), Common_HMILevel::LIMITED)); hmi_states.push_back( StateLevelPair(BackgroundState(), Common_HMILevel::BACKGROUND)); - hmi_states.push_back( - StateLevelPair(createHmiState(HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - VideoStreamingState::NOT_STREAMABLE, - SystemContext::SYSCTXT_MAIN), - Common_HMILevel::NONE)); std::vector<StateLevelPair> initial_hmi_states = hmi_states; std::vector<StateLevelPair>::iterator it = hmi_states.begin(); std::vector<StateLevelPair>::iterator it2 = initial_hmi_states.begin(); @@ -1998,9 +2091,9 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) { .WillOnce(Return(hmi_app_id)); EXPECT_CALL(app_manager_mock_, application_by_hmi_app(hmi_app_id)) .WillOnce(Return(media_app_)); - ExpectSuccesfullSetHmiState( + ExpectSuccessfulSetHmiState( media_app_, media_app_ptr_, initial_hmi_state, hmi_state); - state_ctrl_->SetRegularState(media_app_, hmi_state, true); + state_ctrl_->SetRegularState(media_app_, kDefaultWindowId, hmi_state, true); smart_objects::SmartObject message; message[am::strings::params][am::hmi_response::code] = Common_Result::SUCCESS; @@ -2056,14 +2149,16 @@ TEST_F(StateControllerImplTest, SendEventBCActivateApp_HMIReceivesError) { EXPECT_CALL(app_manager_mock_, application_by_hmi_app(hmi_app_id)) .WillOnce(Return(simple_app_)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)) + .Times(0); EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)) .Times(0); EXPECT_CALL(app_manager_mock_, - OnHMILevelChanged(simple_app_->app_id(), _, _)).Times(0); + OnHMILevelChanged(simple_app_->app_id(), _, _)) + .Times(0); smart_objects::SmartObject message; message[am::strings::params][am::hmi_response::code] = *it; @@ -2083,13 +2178,14 @@ TEST_F(StateControllerImplTest, ActivateAppInvalidCorrelationId) { .WillOnce(Return(hmi_app_id)); EXPECT_CALL(app_manager_mock_, application_by_hmi_app(hmi_app_id)) .WillOnce(Return(am::ApplicationSharedPtr())); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(simple_app_)) .Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(simple_app_->app_id(), _, _)) .Times(0); SetBCActivateAppRequestToHMI(Common_HMILevel::FULL, corr_id); - state_ctrl_->SetRegularState(simple_app_, FullNotAudibleState(), true); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, FullNotAudibleState(), true); smart_objects::SmartObject message; message[am::strings::params][am::hmi_response::code] = Common_Result::SUCCESS; message[am::strings::params][am::strings::correlation_id] = corr_id; @@ -2513,45 +2609,52 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetRegularStateWithNewHmiLvl) { using namespace mobile_apis; + auto message = CreateCloseAppMessage(); + ON_CALL(message_helper_mock_, GetBCCloseApplicationRequestToHMI(_, _)) + .WillByDefault(Return(message)); + ON_CALL(app_manager_mock_, GetRPCService()) + .WillByDefault(ReturnRef(mock_rpc_service_)); + ON_CALL(mock_rpc_service_, ManageHMICommand(_, _)) + .WillByDefault(Return(true)); + + ON_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillByDefault(Return(NoneNotAudibleState())); + ON_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) + .WillByDefault(Return(NoneNotAudibleState())); HMILevel::eType set_lvl = HMILevel::HMI_NONE; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) - .WillOnce(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) - .WillOnce(Return(BackgroundState())) - .WillOnce(Return(BackgroundState())); - - state_ctrl_->SetRegularState(simple_app_, set_lvl); + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); set_lvl = HMILevel::HMI_LIMITED; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); - state_ctrl_->SetRegularState(simple_app_, set_lvl); + + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); set_lvl = HMILevel::HMI_FULL; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())); const uint32_t corr_id = 314; SetBCActivateAppRequestToHMI( static_cast<hmi_apis::Common_HMILevel::eType>(set_lvl), corr_id); - state_ctrl_->SetRegularState(simple_app_, set_lvl); + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); set_lvl = HMILevel::HMI_BACKGROUND; - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); - state_ctrl_->SetRegularState(simple_app_, set_lvl); + state_ctrl_->SetRegularState(simple_app_, kDefaultWindowId, set_lvl); } TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { @@ -2561,16 +2664,18 @@ TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { AudioStreamingState::AUDIBLE, VideoStreamingState::STREAMABLE, SystemContext::SYSCTXT_MAIN); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillRepeatedly(Return(BackgroundState())); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(check_state)) .WillOnce(Return(check_state)); EXPECT_CALL(*simple_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(check_state)))); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); state_ctrl_->SetRegularState(simple_app_, + kDefaultWindowId, AudioStreamingState::AUDIBLE, VideoStreamingState::STREAMABLE); } @@ -2587,23 +2692,27 @@ TEST_F(StateControllerImplTest, // Non-media app can't have LIMITED-AUDIO state EXPECT_CALL(*simple_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(app_manager_mock_, GetDefaultHmiLevel(_)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); EXPECT_CALL(*simple_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, check_state, false); check_state = LimitedState(); EXPECT_CALL(*media_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*media_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*media_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*media_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*media_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, SetRegularStateMediaToNonMediaApp_VR_Stopped) { @@ -2620,25 +2729,29 @@ TEST_F(StateControllerImplTest, SetRegularStateMediaToNonMediaApp_VR_Stopped) { HmiStatePtr check_state = FullNotAudibleState(); // Non-media app can't have LIMITED-AUDIO state - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(check_state)) .WillOnce(Return(check_state)); EXPECT_CALL(*simple_app_ptr_, is_resuming()).WillRepeatedly(Return(false)); EXPECT_CALL(message_helper_mock_, - SendOnResumeAudioSourceToHMI(simple_app_id_, _)).Times(0); + SendOnResumeAudioSourceToHMI(simple_app_id_, _)) + .Times(0); EXPECT_CALL(*simple_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))) + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))) .Times(0); EXPECT_CALL(*simple_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, check_state, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, check_state, false); // Set state of media app after vr has stopped check_state = LimitedState(); - EXPECT_CALL(*media_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*media_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(check_state)) .WillOnce(Return(check_state)); @@ -2647,11 +2760,14 @@ TEST_F(StateControllerImplTest, SetRegularStateMediaToNonMediaApp_VR_Stopped) { EXPECT_CALL(message_helper_mock_, SendOnResumeAudioSourceToHMI(media_app_id_, _)); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))) + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))) .Times(0); EXPECT_CALL(*media_app_ptr_, - SetRegularState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetRegularState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, @@ -2674,28 +2790,32 @@ TEST_F(StateControllerImplTest, HmiStatePtr check_state = FullNotAudibleState(); EXPECT_CALL(*simple_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*simple_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(app_manager_mock_, GetDefaultHmiLevel(_)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_NONE)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); EXPECT_CALL(*simple_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, check_state, false); // Set media app check_state = LimitedState(); EXPECT_CALL(*media_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); - EXPECT_CALL(*media_app_ptr_, RegularHmiState()).Times(0); - EXPECT_CALL(*media_app_ptr_, CurrentHmiState()).Times(0); - EXPECT_CALL(*media_app_ptr_, SetRegularState(_)).Times(0); + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*media_app_ptr_, CurrentHmiState(kDefaultWindowId)).Times(0); + EXPECT_CALL(*media_app_ptr_, SetRegularState(kDefaultWindowId, _)).Times(0); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, @@ -2728,8 +2848,10 @@ TEST_F(StateControllerImplTest, .WillRepeatedly(Return(am::ApplicationSharedPtr())); EXPECT_CALL(*media_app_ptr_, - SetPostponedState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(media_app_, check_state, false); + SetPostponedState(kDefaultWindowId, + Truly(HmiStatesComparator(check_state)))); + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, check_state, false); } TEST_F(StateControllerImplTest, @@ -2757,13 +2879,13 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - state_ctrl_->SetRegularState(navi_app_, hmi_state, false); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, false); } TEST_F(StateControllerImplTest, @@ -2791,15 +2913,15 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - EXPECT_CALL(*navi_app_ptr_, SetPostponedState(_)).Times(0); + EXPECT_CALL(*navi_app_ptr_, SetPostponedState(kDefaultWindowId, _)).Times(0); - state_ctrl_->SetRegularState(navi_app_, hmi_state, false); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, false); } TEST_F(StateControllerImplTest, @@ -2807,7 +2929,6 @@ TEST_F(StateControllerImplTest, using namespace hmi_apis; using namespace smart_objects; using namespace am::event_engine; - using namespace constants; const uint32_t app_id = navi_app_->app_id(); // Precondition @@ -2831,13 +2952,13 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - state_ctrl_->SetRegularState(navi_app_, hmi_state, true); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, true); } TEST_F(StateControllerImplTest, @@ -2845,7 +2966,6 @@ TEST_F(StateControllerImplTest, using namespace hmi_apis; using namespace smart_objects; using namespace am::event_engine; - using namespace constants; const uint32_t app_id = navi_app_->app_id(); // Precondition @@ -2869,15 +2989,15 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, IsAppTypeExistsInFullOrLimited(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*navi_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*navi_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(hmi_state)); EXPECT_CALL(app_manager_mock_, active_application()) .WillRepeatedly(Return(am::ApplicationSharedPtr())); - EXPECT_CALL(*navi_app_ptr_, SetPostponedState(_)).Times(0); + EXPECT_CALL(*navi_app_ptr_, SetPostponedState(kDefaultWindowId, _)).Times(0); - state_ctrl_->SetRegularState(navi_app_, hmi_state, true); + state_ctrl_->SetRegularState(navi_app_, kDefaultWindowId, hmi_state, true); } TEST_F(StateControllerImplTest, @@ -2898,13 +3018,16 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(*simple_app_ptr_, keep_context()).WillOnce(Return(true)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(FullAudibleState())); EXPECT_CALL(*simple_app_ptr_, set_keep_context(false)); HmiStatePtr new_state; - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) - .WillOnce(SaveArg<0>(&new_state)); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)) + .WillOnce(SaveArg<1>(&new_state)); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); state_ctrl_->on_event(event); @@ -2929,12 +3052,15 @@ TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppToBackground) { EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(LimitedState())); HmiStatePtr new_state; - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)) - .WillOnce(SaveArg<0>(&new_state)); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)) + .WillOnce(SaveArg<1>(&new_state)); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); state_ctrl_->on_event(event); @@ -2953,9 +3079,13 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedIncorrectHmiLevel) { event.set_smart_object(msg); EXPECT_CALL(app_manager_mock_, application(app_id)) .WillOnce(Return(simple_app_)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()) + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)) .WillOnce(Return(mobile_apis::HMILevel::HMI_BACKGROUND)); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).Times(0); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)).Times(0); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); + state_ctrl_->on_event(event); } @@ -2969,7 +3099,7 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedIncorrectApp) { const am::ApplicationSharedPtr incorrect_app; EXPECT_CALL(app_manager_mock_, application(_)) .WillOnce(Return(incorrect_app)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()).Times(0); + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)).Times(0); state_ctrl_->on_event(event); } @@ -2990,15 +3120,20 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedAudioApplication) { EXPECT_CALL(app_manager_mock_, application(app_id)) .WillOnce(Return(simple_app_)); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()) + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); // DeactivateApp - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); + state_ctrl_->on_event(event); } @@ -3019,16 +3154,21 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedNotAudioApplication) { EXPECT_CALL(app_manager_mock_, application(app_id)) .WillOnce(Return(simple_app_)); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, hmi_level()) + EXPECT_CALL(*simple_app_ptr_, hmi_level(kDefaultWindowId)) .WillRepeatedly(Return(mobile_apis::HMILevel::HMI_FULL)); // DeactivateApp - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state)); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(state)); EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) .WillRepeatedly(Return(false)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillOnce(Return(BackgroundState())) .WillOnce(Return(BackgroundState())); + + am::WindowIds window_ids = {kDefaultWindowId}; + EXPECT_CALL(*simple_app_ptr_, GetWindowIds()).WillOnce(Return(window_ids)); + state_ctrl_->on_event(event); } @@ -3048,25 +3188,35 @@ TEST_F(StateControllerImplTest, OnEventOnAppActivatedIncorrectApp) { } TEST_F(StateControllerImplTest, OnEventOnAppActivated) { - using namespace constants; - smart_objects::SmartObject msg; - for (std::vector<am::ApplicationSharedPtr>::const_iterator it = - applications_list_.begin(); + am::WindowIds window_ids = {kDefaultWindowId}; + + for (AppPtrMockMapping::const_iterator it = applications_list_.begin(); it != applications_list_.end(); ++it) { - uint32_t app_id = (*it)->app_id(); + uint32_t app_id = it->first->app_id(); msg[am::strings::msg_params][am::strings::app_id] = app_id; const hmi_apis::FunctionID::eType event_id = hmi_apis::FunctionID::BasicCommunication_OnAppActivated; am::event_engine::Event event(event_id); event.set_smart_object(msg); - EXPECT_CALL(app_manager_mock_, application(app_id)).WillOnce(Return(*it)); + EXPECT_CALL(app_manager_mock_, application(app_id)) + .WillOnce(Return(it->first)); // SetRegularState - EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, IsAudioApplication()) - .WillRepeatedly(Return(true)); + EXPECT_CALL(*it->second, app_id()).WillRepeatedly(Return(app_id)); + EXPECT_CALL(*it->second, IsAudioApplication()).WillRepeatedly(Return(true)); + EXPECT_CALL(*it->second, GetWindowIds()).WillOnce(Return(window_ids)); + + const am::HmiStatePtr old_state = + CreateHmiStateByHmiStateType<am::HmiState>( + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + mobile_apis::SystemContext::SYSCTXT_MAIN, + simple_app_); + EXPECT_CALL(*it->second, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); smart_objects::SmartObjectSPtr activate_app = std::make_shared<smart_objects::SmartObject>(); @@ -3147,9 +3297,9 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredDifferentStates) { simple_app_); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(old_state)); - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)).Times(4); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)).Times(4); const am::HmiStatePtr default_state = CreateHmiStateByHmiStateType<am::HmiState>( @@ -3159,12 +3309,14 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredDifferentStates) { mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(old_state)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(default_state)); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); - EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(_)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(simple_app_, kDefaultWindowId, _)); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)); state_ctrl_->OnApplicationRegistered(simple_app_, @@ -3198,9 +3350,9 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { simple_app_); EXPECT_CALL(*simple_app_ptr_, app_id()).WillRepeatedly(Return(app_id)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(old_state)); - EXPECT_CALL(*simple_app_ptr_, AddHMIState(_)).Times(2); + EXPECT_CALL(*simple_app_ptr_, AddHMIState(kDefaultWindowId, _)).Times(2); const am::HmiStatePtr default_state = CreateHmiStateByHmiStateType<am::HmiState>( @@ -3209,9 +3361,9 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); - EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) .WillOnce(Return(default_state)); - EXPECT_CALL(*simple_app_ptr_, CurrentHmiState()) + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kDefaultWindowId)) .WillRepeatedly(Return(default_state)); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); @@ -3222,6 +3374,328 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { mobile_apis::HMILevel::HMI_BACKGROUND); } +TEST_F( + StateControllerImplTest, + SetRegularState_AppIsResumingAndAudioSourceIsActive_HmiStateIsNotChanged) { + am::event_engine::Event audio_source_event( + hmi_apis::FunctionID::BasicCommunication_OnEventChanged); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::hmi_notification::is_active] = true; + message[am::strings::msg_params][am::hmi_notification::event_name] = + hmi_apis::Common_EventTypes::AUDIO_SOURCE; + audio_source_event.set_smart_object(message); + state_ctrl_->on_event(audio_source_event); + + EXPECT_CALL(*media_app_ptr_, is_resuming()).WillRepeatedly(Return(true)); + EXPECT_CALL(*media_app_ptr_, SetRegularState(_, _)).Times(0); + + const am::HmiStatePtr new_state = FullAudibleState(); + const bool send_activate_app = true; + state_ctrl_->SetRegularState( + media_app_, kDefaultWindowId, new_state, send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_BcActivateAppSendFailed_HmiLevelIsNotChanged) { + const am::HmiStatePtr new_state = FullAudibleState(); + SetBCActivateAppRequestToHMI( + static_cast<hmi_apis::Common_HMILevel::eType>(new_state->hmi_level()), + kCorrID); + + smart_objects::SmartObjectSPtr bc_activate_app_request; + EXPECT_CALL(message_helper_mock_, GetBCActivateAppRequestToHMI(_, _, _, _, _)) + .WillOnce(Return(bc_activate_app_request)); + EXPECT_CALL(*simple_app_ptr_, SetRegularState(_, _)).Times(0); + + const bool send_activate_app = true; + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, new_state, send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_SetLevelAudioAndVideoState_HmiStateIsChanged) { + HmiStatePtr old_state = NoneNotAudibleState(); + HmiStatePtr new_state = BackgroundState(); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, old_state, new_state); + + const bool send_activate_app = false; + state_ctrl_->SetRegularState(simple_app_, + kDefaultWindowId, + new_state->hmi_level(), + new_state->audio_streaming_state(), + new_state->video_streaming_state(), + send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_SetLevelAudioVideoStatesAndContext_HmiStateIsChanged) { + HmiStatePtr old_state = NoneNotAudibleState(); + HmiStatePtr new_state = BackgroundState(); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, old_state, new_state); + + const bool send_activate_app = false; + state_ctrl_->SetRegularState(simple_app_, + kDefaultWindowId, + new_state->hmi_level(), + new_state->audio_streaming_state(), + new_state->video_streaming_state(), + new_state->system_context(), + send_activate_app); +} + +TEST_F(StateControllerImplTest, + SetRegularState_SetSystemContextOnly_HmiStateIsChanged) { + HmiStatePtr old_state = FullAudibleState(); + HmiStatePtr new_state = FullNotAudibleState(); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, old_state, new_state); + + state_ctrl_->SetRegularState( + simple_app_, kDefaultWindowId, new_state->system_context()); +} + +TEST_F(StateControllerImplTest, + OnAppActivated_ActivateNotExistingWindow_HmiLevelIsNotChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppActivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + ExpectAppWontChangeHmiStateDueToConflictResolving( + simple_app_, simple_app_ptr_, kCustomWindowId, NoneNotAudibleState()); + + state_ctrl_->on_event(activate_widget_event); +} + +TEST_F(StateControllerImplTest, + OnAppActivated_ActivateCustomWindow_HmiStateIsChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppActivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + std::vector<std::pair<HmiStatePtr, HmiStatePtr> > states_transition = { + std::make_pair(NoneNotAudibleState(), BackgroundState()), + std::make_pair(BackgroundState(), FullNotAudibleState())}; + + for (auto& states_pair : states_transition) { + HmiStatePtr old_state = states_pair.first; + HmiStatePtr new_state = states_pair.second; + + EXPECT_CALL(*simple_app_ptr_, hmi_level(kCustomWindowId)) + .WillOnce(Return(old_state->hmi_level())); + EXPECT_CALL(*simple_app_ptr_, audio_streaming_state()) + .WillOnce(Return(old_state->audio_streaming_state())); + EXPECT_CALL(*simple_app_ptr_, video_streaming_state()) + .WillOnce(Return(old_state->video_streaming_state())); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, kCustomWindowId, old_state, new_state); + + EXPECT_CALL(message_helper_mock_, + GetBCActivateAppRequestToHMI(_, _, _, _, _)) + .Times(0); + + state_ctrl_->on_event(activate_widget_event); + } +} + +TEST_F(StateControllerImplTest, + OnAppDeactivated_DeactivateNotExistingWindow_HmiStateIsNotChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + ExpectAppWontChangeHmiStateDueToConflictResolving( + simple_app_, simple_app_ptr_, kCustomWindowId, FullNotAudibleState()); + + state_ctrl_->on_event(activate_widget_event); +} + +TEST_F(StateControllerImplTest, + OnAppDeactivated_DeactivateCustomWindow_HmiStateIsChanged) { + InsertApplication(simple_app_); + + am::event_engine::Event activate_widget_event( + hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::strings::app_id] = simple_app_id_; + message[am::strings::msg_params][am::strings::window_id] = kCustomWindowId; + activate_widget_event.set_smart_object(message); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*simple_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + std::vector<std::pair<HmiStatePtr, HmiStatePtr> > states_transition = { + std::make_pair(FullNotAudibleState(), BackgroundState()), + std::make_pair(BackgroundState(), NoneNotAudibleState())}; + + for (auto& states_pair : states_transition) { + HmiStatePtr old_state = states_pair.first; + HmiStatePtr new_state = states_pair.second; + + EXPECT_CALL(*simple_app_ptr_, hmi_level(kCustomWindowId)) + .WillOnce(Return(old_state->hmi_level())); + EXPECT_CALL(*simple_app_ptr_, audio_streaming_state()) + .WillOnce(Return(old_state->audio_streaming_state())); + EXPECT_CALL(*simple_app_ptr_, video_streaming_state()) + .WillOnce(Return(old_state->video_streaming_state())); + + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + ExpectSuccessfulSetHmiState( + simple_app_, simple_app_ptr_, kCustomWindowId, old_state, new_state); + + EXPECT_CALL(message_helper_mock_, + GetBCActivateAppRequestToHMI(_, _, _, _, _)) + .Times(0); + + state_ctrl_->on_event(activate_widget_event); + } +} + +TEST_F( + StateControllerImplTest, + ActivateDefaultWindow_AppWithWindowWasActivated_WindowStreamingStateIsUpdated) { + HmiStatePtr old_state = NoneNotAudibleState(); + HmiStatePtr new_state = FullAudibleState(); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)) + .WillRepeatedly(Return(new_state)); + ExpectSuccessfulSetHmiState( + media_app_, media_app_ptr_, kDefaultWindowId, old_state, new_state); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*media_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + + HmiStatePtr expected_window_state = NoneNotAudibleState(); + expected_window_state->set_audio_streaming_state( + new_state->audio_streaming_state()); + expected_window_state->set_video_streaming_state( + new_state->video_streaming_state()); + + EXPECT_CALL( + *media_app_ptr_, + SetRegularState(kCustomWindowId, + Truly(HmiStatesComparator(expected_window_state)))); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(media_app_, kCustomWindowId, _)); + + state_ctrl_->ActivateDefaultWindow(media_app_); +} + +TEST_F(StateControllerImplTest, + ExitDefaultWindow_AppWithWindowWasExited_WindowStreamingStateIsUpdated) { + HmiStatePtr old_state = FullAudibleState(); + HmiStatePtr new_state = NoneNotAudibleState(); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kDefaultWindowId)) + .WillOnce(Return(old_state)) + .WillRepeatedly(Return(new_state)); + ExpectSuccessfulSetHmiState( + media_app_, media_app_ptr_, kDefaultWindowId, old_state, new_state); + + const am::WindowIds window_ids = {kDefaultWindowId, kCustomWindowId}; + ON_CALL(*media_app_ptr_, GetWindowIds()).WillByDefault(Return(window_ids)); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(old_state)); + + HmiStatePtr expected_window_state = FullAudibleState(); + expected_window_state->set_audio_streaming_state( + new_state->audio_streaming_state()); + expected_window_state->set_video_streaming_state( + new_state->video_streaming_state()); + + EXPECT_CALL( + *media_app_ptr_, + SetRegularState(kCustomWindowId, + Truly(HmiStatesComparator(expected_window_state)))); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(media_app_, kCustomWindowId, _)); + + state_ctrl_->ExitDefaultWindow(media_app_); +} + +TEST_F(StateControllerImplTest, + OnAppWindowAdded_NewAppWindowWasAdded_HmiNotificationIsSent) { + am::event_engine::Event audio_source_event( + hmi_apis::FunctionID::BasicCommunication_OnEventChanged); + smart_objects::SmartObject message; + message[am::strings::msg_params][am::hmi_notification::is_active] = true; + message[am::strings::msg_params][am::hmi_notification::event_name] = + hmi_apis::Common_EventTypes::AUDIO_SOURCE; + audio_source_event.set_smart_object(message); + state_ctrl_->on_event(audio_source_event); + + HmiStatePtr initial_state = + createHmiState(mobile_apis::HMILevel::INVALID_ENUM, + mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, + mobile_apis::SystemContext::INVALID_ENUM); + HmiStatePtr expected_state = NoneNotAudibleState(); + + EXPECT_CALL(*simple_app_ptr_, + AddHMIState(kCustomWindowId, + Truly(HmiStatesIDComparator( + HmiState::StateID::STATE_ID_AUDIO_SOURCE)))); + EXPECT_CALL(*simple_app_ptr_, RegularHmiState(kCustomWindowId)) + .WillOnce(Return(initial_state)); + EXPECT_CALL(*simple_app_ptr_, + SetRegularState(kCustomWindowId, + Truly(HmiStatesComparator(expected_state)))); + EXPECT_CALL(*simple_app_ptr_, CurrentHmiState(kCustomWindowId)) + .WillOnce(Return(initial_state)) + .WillOnce(Return(expected_state)); + EXPECT_CALL(message_helper_mock_, + SendHMIStatusNotification(simple_app_, kCustomWindowId, _)); + EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(_, _, _)).Times(0); + + state_ctrl_->OnAppWindowAdded(simple_app_, + kCustomWindowId, + mobile_apis::WindowType::WIDGET, + mobile_apis::HMILevel::HMI_NONE); +} + } // namespace state_controller_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/usage_statistics_test.cc b/src/components/application_manager/test/usage_statistics_test.cc index dfc694f3c5..b494afb68e 100644 --- a/src/components/application_manager/test/usage_statistics_test.cc +++ b/src/components/application_manager/test/usage_statistics_test.cc @@ -33,9 +33,9 @@ #include "application_manager/usage_statistics.h" #include <memory> #include "gmock/gmock.h" -#include "smart_objects/enum_schema_item.h" -#include "policy/usage_statistics/mock_statistics_manager.h" #include "policy/usage_statistics/mock_app_stopwatch.h" +#include "policy/usage_statistics/mock_statistics_manager.h" +#include "smart_objects/enum_schema_item.h" namespace test { namespace components { diff --git a/src/components/application_manager/test/zero_request_amount_test.cc b/src/components/application_manager/test/zero_request_amount_test.cc index 640a186e2b..0166c036c1 100644 --- a/src/components/application_manager/test/zero_request_amount_test.cc +++ b/src/components/application_manager/test/zero_request_amount_test.cc @@ -30,19 +30,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <string> #include <algorithm> +#include <string> #include "gtest/gtest.h" -#include "application_manager/request_controller.h" -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application_manager_impl.h" -#include "application_manager/message_helper.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/mobile/put_file_request.h" #include "application_manager/commands/mobile/register_app_interface_request.h" #include "application_manager/commands/mobile/unregister_app_interface_request.h" -#include "smart_objects/smart_object.h" +#include "application_manager/message_helper.h" +#include "application_manager/request_controller.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/smart_object.h" namespace test { namespace components { |