diff options
Diffstat (limited to 'src/components/application_manager/include')
66 files changed, 1946 insertions, 816 deletions
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" |