diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-04-11 16:26:03 +0300 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-04-25 12:15:46 +0300 |
commit | daf2d2134715074cc58ae0264606c3349851bae1 (patch) | |
tree | c946d28f188a48c339cd26a722f0d2daed6271ca /src/components | |
parent | 313ed4ba92a5eb75befe9ede65eef5c15dac068c (diff) | |
download | sdl_core-daf2d2134715074cc58ae0264606c3349851bae1.tar.gz |
ApplicationManager correctives after remove all singletones
Removed singletone from AM
Updated after removing Profile singleton
Diffstat (limited to 'src/components')
49 files changed, 2723 insertions, 2330 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index abd3ba3490..b8e4d65340 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -79,6 +79,7 @@ set (MESSAGE_HELPER_SOURCES set (POLICIES_MANAGER ${AM_SOURCE_DIR}/src/policies/policy_handler.cc +${AM_SOURCE_DIR}/src/usage_statistics.cc ${AM_SOURCE_DIR}/src/policies/policy_event_observer.cc ${AM_SOURCE_DIR}/src/policies/delegates/app_permission_delegate.cc ${AM_SOURCE_DIR}/src/policies/delegates/statistics_delegate.cc diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index ee4b12a367..c40ebe68cd 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -109,7 +109,7 @@ class InitialApplicationData { virtual const smart_objects::SmartObject* app_types() const = 0; virtual const smart_objects::SmartObject* vr_synonyms() const = 0; virtual const std::string& mac_address() const = 0; - virtual std::string mobile_app_id() const = 0; + virtual std::string policy_app_id() const = 0; virtual const smart_objects::SmartObject* tts_name() const = 0; virtual const smart_objects::SmartObject* ngn_media_screen_name() const = 0; virtual const mobile_api::Language::eType& language() const = 0; @@ -117,7 +117,7 @@ class InitialApplicationData { virtual void set_app_types(const smart_objects::SmartObject& app_types) = 0; virtual void set_vr_synonyms( const smart_objects::SmartObject& vr_synonyms) = 0; - virtual void set_mobile_app_id(const std::string& mobile_app_id) = 0; + virtual void set_mobile_app_id(const std::string& policy_app_id) = 0; virtual void set_tts_name(const smart_objects::SmartObject& tts_name) = 0; virtual void set_ngn_media_screen_name( const smart_objects::SmartObject& ngn_name) = 0; @@ -766,6 +766,12 @@ class Application : public virtual InitialApplicationData, */ virtual void LoadPersistentFiles() = 0; + /** + * @brief Get available app space + * @param name of the app folder(make + mobile app id) + * @return free app space. + */ + virtual uint32_t GetAvailableDiskSpace() = 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 35c638e207..b6653bc3ee 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 @@ -50,14 +50,14 @@ class InitialApplicationDataImpl : public virtual Application { const smart_objects::SmartObject* app_types() const; const smart_objects::SmartObject* vr_synonyms() const; - virtual std::string mobile_app_id() const; + virtual std::string policy_app_id() const; const smart_objects::SmartObject* tts_name() const; const smart_objects::SmartObject* ngn_media_screen_name() const; const mobile_api::Language::eType& language() const; const mobile_api::Language::eType& ui_language() const; void set_app_types(const smart_objects::SmartObject& app_types); void set_vr_synonyms(const smart_objects::SmartObject& vr_synonyms); - void set_mobile_app_id(const std::string& mobile_app_id); + void set_mobile_app_id(const std::string& policy_app_id); void set_tts_name(const smart_objects::SmartObject& tts_name); void set_ngn_media_screen_name(const smart_objects::SmartObject& ngn_name); void set_language(const mobile_api::Language::eType& language); 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 dbe7ee9b2b..bdef552c0b 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -68,10 +68,11 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, public: ApplicationImpl( uint32_t application_id, - const std::string& mobile_app_id, + const std::string& policy_app_id, const std::string& mac_address, const custom_str::CustomString& app_name, - utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager); + utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager, + ApplicationManager& application_manager); ~ApplicationImpl(); @@ -130,9 +131,9 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void set_folder_name(const std::string& folder_name) OVERRIDE; const std::string folder_name() const; bool is_media_application() const; - virtual bool is_foreground() const; - virtual void set_foreground(bool is_foreground); - virtual const mobile_api::HMILevel::eType hmi_level() const; + bool is_foreground() const OVERRIDE; + void set_foreground(bool is_foreground) OVERRIDE; + const mobile_apis::HMILevel::eType hmi_level() const; 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; @@ -188,6 +189,10 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, virtual DataAccessor<ButtonSubscriptions> SubscribedButtons() const OVERRIDE; virtual const std::string& curHash() const; +#ifdef CUSTOMER_PASA + virtual bool flag_sending_hash_change_after_awake() const; + virtual void set_flag_sending_hash_change_after_awake(bool flag); +#endif // CUSTOMER_PASA /** * @brief Change Hash for current application * and send notification to mobile @@ -218,11 +223,6 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, virtual bool IsAudioApplication() const; /** - * @brief Load persistent files from application folder. - */ - virtual void LoadPersistentFiles(); - - /** * @brief SetRegularState set permanent state of application * * @param state state to setup @@ -287,6 +287,17 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void set_video_stream_retry_number(const uint32_t& video_stream_retry_number); + /** + * @brief Load persistent files from application folder. + */ + void LoadPersistentFiles() OVERRIDE; + + /** + * @brief Get available app space + * @param name of the app folder(make + mobile app id) + * @return free app space. + */ + uint32_t GetAvailableDiskSpace() OVERRIDE; protected: /** * @brief Clean up application folder. Persistent files will stay @@ -294,7 +305,6 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void CleanupFiles(); private: - /** * @brief Callback for video streaming suspend timer. * Suspends video streaming process for application @@ -387,6 +397,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, mutable sync_primitives::Lock vi_lock_; sync_primitives::Lock button_lock_; std::string folder_name_; + ApplicationManager& application_manager_; DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); }; diff --git a/src/components/application_manager/include/application_manager/application_manager.h b/src/components/application_manager/include/application_manager/application_manager.h index dba3357d42..298abcca59 100644 --- a/src/components/application_manager/include/application_manager/application_manager.h +++ b/src/components/application_manager/include/application_manager/application_manager.h @@ -36,15 +36,17 @@ #include <string> #include <vector> #include <set> - +#include "vehicle_info_data.h" #include "application_manager/application.h" #include "application_manager/hmi_capabilities.h" #include "application_manager/commands/command.h" - +#include "connection_handler/connection_handler.h" #include "utils/data_accessor.h" #include "utils/shared_ptr.h" #include "telemetry_monitor/telemetry_observable.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/application_manager_settings.h" +#include "application_manager/state_controller.h" namespace resumption { class LastState; @@ -64,9 +66,21 @@ class ProtocolHandler; namespace connection_handler { class ConnectionHandler; } +namespace resumption { +class ResumeCtrl; +} namespace application_manager { +namespace event_engine { +class EventDispatcher; +} + +class Application; +class StateControllerImpl; +struct CommandParametersPermissions; +typedef std::vector<std::string> RPCParams; + struct ApplicationsAppIdSorter { bool operator()(const ApplicationSharedPtr lhs, const ApplicationSharedPtr rhs) const { @@ -104,13 +118,11 @@ class ApplicationManager { protocol_handler::ProtocolHandler* handler) = 0; virtual void set_connection_handler( connection_handler::ConnectionHandler* handler) = 0; - virtual connection_handler::ConnectionHandler& connection_handler() const = 0; virtual DataAccessor<ApplicationSet> applications() const = 0; virtual ApplicationSharedPtr application(uint32_t app_id) const = 0; virtual ApplicationSharedPtr active_application() const = 0; - // /** * Function used only by HMI request/response/notification base classes @@ -159,7 +171,7 @@ class ApplicationManager { * * @return application id associated with correlation id */ - virtual const uint32_t application_id(const int32_t correlation_id) = 0; + virtual uint32_t application_id(const int32_t correlation_id) = 0; /** * @brief Sets application id correlation id @@ -192,6 +204,38 @@ class ApplicationManager { virtual void SendHMIStatusNotification( const utils::SharedPtr<Application> app) = 0; + /** + * @brief Checks if Application is subscribed for way points + * @param Application AppID + * @return true if Application is subscribed for way points + * otherwise false + */ + virtual bool IsAppSubscribedForWayPoints(const uint32_t app_id) const = 0; + + /** + * @brief Subscribe Application for way points + * @param Application AppID + */ + virtual void SubscribeAppForWayPoints(const uint32_t app_id) = 0; + + /** + * @brief Unsubscribe Application for way points + * @param Application AppID + */ + virtual void UnsubscribeAppFromWayPoints(const uint32_t app_id) = 0; + + /** + * @brief Is Any Application is subscribed for way points + * @return true if some app is subscribed otherwise false + */ + virtual bool IsAnyAppSubscribedForWayPoints() const = 0; + + /** + * @brief Get subscribed for way points + * @return reference to set of subscribed apps for way points + */ + virtual const std::set<int32_t> GetAppsSubscribedForWayPoints() const = 0; + virtual void SendMessageToMobile(const commands::MessageSharedPtr message, bool final_message = false) = 0; @@ -200,8 +244,6 @@ class ApplicationManager { virtual bool ManageHMICommand(const commands::MessageSharedPtr message) = 0; virtual bool ManageMobileCommand(const commands::MessageSharedPtr message, commands::Command::CommandOrigin origin) = 0; - - virtual mobile_api::HMILevel::eType GetDefaultHmiLevel( ApplicationConstSharedPtr application) const = 0; /** @@ -210,7 +252,12 @@ class ApplicationManager { */ virtual HMICapabilities& hmi_capabilities() = 0; - virtual bool is_attenuated_supported() = 0; + virtual const HMICapabilities& hmi_capabilities() const = 0; + + virtual void ProcessQueryApp(const smart_objects::SmartObject& sm_object, + const uint32_t connection_key) = 0; + + virtual bool is_attenuated_supported() const = 0; /** * @brief Checks if application with the same HMI type @@ -231,6 +278,252 @@ class ApplicationManager { */ virtual void OnApplicationRegistered(ApplicationSharedPtr app) = 0; + virtual connection_handler::ConnectionHandler& connection_handler() const = 0; + virtual protocol_handler::ProtocolHandler& protocol_handler() const = 0; + virtual policy::PolicyHandlerInterface& GetPolicyHandler() = 0; + + virtual uint32_t GetNextHMICorrelationID() = 0; + virtual uint32_t GenerateNewHMIAppID() = 0 ; + + /** + * @brief Ends opened navi services (audio/video) for application + * @param app_id Application id + */ + virtual void EndNaviServices(uint32_t app_id) = 0; + + /* @brief Starts audio passthru process + * + * @return true on success, false if passthru is already in process + */ + virtual bool BeginAudioPassThrough() = 0; + + /* + * @brief Finishes already started audio passthru process + * + * @return true on success, false if passthru is not active + */ + virtual bool EndAudioPassThrough() = 0 ; + + + virtual void ConnectToDevice(const std::string& device_mac) = 0; + + virtual void OnHMIStartedCooperation() = 0 ; + + virtual bool IsHMICooperating() const = 0; + /** + * @brief Notifies all components interested in Vehicle Data update + * i.e. new value of odometer etc and returns list of applications + * subscribed for event. + * @param vehicle_info Enum value of type of vehicle data + * @param new value (for integer values currently) of vehicle data + */ + virtual std::vector<ApplicationSharedPtr> IviInfoUpdated( + VehicleDataType vehicle_info, int value) = 0; + + virtual ApplicationSharedPtr RegisterApplication(const utils::SharedPtr< + smart_objects::SmartObject>& request_for_registration) = 0; + + virtual void SendUpdateAppList() = 0; + + virtual void MarkAppsGreyOut(const connection_handler::DeviceHandle handle, + bool is_greyed_out) = 0; + virtual bool IsAppsQueriedFrom( + const connection_handler::DeviceHandle handle) const = 0; + + virtual bool IsStopping() const = 0; + + virtual void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) = 0; + + virtual mobile_apis::Result::eType SaveBinary(const std::vector<uint8_t>& binary_data, + const std::string& file_path, + const std::string& file_name, + const int64_t offset) = 0; + /* + * @brief Sets SDL access to all mobile apps + * + * @param allowed SDL access to all mobile apps + */ + virtual void SetAllAppsAllowed(const bool& allowed) = 0; + + /* + * @brief Sets state for driver distraction + * + * @param state New state to be set + */ + virtual void set_driver_distraction(bool is_distracting) = 0; + + /* + * @brief Starts audio pass thru thread + * + * @param session_key Session key of connection for Mobile side + * @param correlation_id Correlation id for response for Mobile side + * @param max_duration Max duration of audio recording in milliseconds + * @param sampling_rate Value for rate(8, 16, 22, 44 kHz) + * @param bits_per_sample The quality the audio is recorded. + * @param audio_type Type of audio data + */ + virtual void StartAudioPassThruThread(int32_t session_key, + int32_t correlation_id, + int32_t max_duration, + int32_t sampling_rate, + int32_t bits_per_sample, + int32_t audio_type) = 0; + + virtual void StartDevicesDiscovery() = 0; + + virtual void StopAudioPassThru(int32_t application_key) = 0; + + /** + * @brief TerminateRequest forces termination of request + * @param connection_key - application id of request + * @param corr_id correlation id of request + */ + virtual void TerminateRequest(uint32_t connection_key, uint32_t corr_id) = 0; + + /* + * @brief Closes application by id + * + * @param app_id Application id + * @param reason reason of unregistering application + * @param is_resuming describes - is this unregister + * is normal or need to be resumed\ + * @param is_unexpected_disconnect + * Indicates if connection was unexpectedly lost(TM layer, HB) + */ + virtual void UnregisterApplication(const uint32_t& app_id, + mobile_apis::Result::eType reason, + bool is_resuming = false, + bool is_unexpected_disconnect = false) = 0; + + /** + * @ Updates request timeout + * + * @param connection_key Connection key of application + * @param mobile_correlation_id Correlation ID of the mobile request + * @param new_timeout_value New timeout in milliseconds to be set + */ + virtual void updateRequestTimeout(uint32_t connection_key, + uint32_t mobile_correlation_id, + uint32_t new_timeout_value) = 0; + + virtual StateController& state_controller() = 0; + + virtual void SetUnregisterAllApplicationsReason( + mobile_api::AppInterfaceUnregisteredReason::eType reason) = 0; + + /* + * @brief Called on Master_reset or Factory_defaults + * when User chooses to reset HU. + * Resets Policy Table if applicable. + */ + virtual void HeadUnitReset(mobile_api::AppInterfaceUnregisteredReason::eType reason) = 0; + + /** + * @brief Checks HMI level and returns true if streaming is allowed + * @param app_id Application id + * @param service_type Service type to check + * @return True if streaming is allowed, false in other case + */ + virtual bool HMILevelAllowsStreaming( + uint32_t app_id, protocol_handler::ServiceType service_type) const = 0; + + /** + * @brief Checks, if given RPC is allowed at current HMI level for specific + * application in policy table + * @param policy_app_id Application id + * @param hmi_level Current HMI level of application + * @param function_id FunctionID of RPC + * @param params_permissions Permissions for RPC parameters (e.g. + * SubscribeVehicleData) defined in policy table + * @return SUCCESS, if allowed, otherwise result code of check + */ + virtual mobile_apis::Result::eType CheckPolicyPermissions( + const std::string& policy_app_id, + mobile_apis::HMILevel::eType hmi_level, + mobile_apis::FunctionID::eType function_id, + const RPCParams& rpc_params, + CommandParametersPermissions* params_permissions = NULL) = 0; + + + /** + * @brief IsApplicationForbidden allows to distinguish if application is + * not allowed to register, because of spamming. + * + * @param connection_key the connection key ofthe required application + * + * @param policy_app_id application's mobile(policy) identifier. + * + * @return true in case application is allowed to register, false otherwise. + */ + virtual bool IsApplicationForbidden(uint32_t connection_key, + const std::string& policy_app_id) const = 0; + + virtual resumption::ResumeCtrl& resume_controller() = 0 ; + /* + * @brief Converts connection string transport type representation + * to HMI Common_TransportType + * + * @param transport_type String representing connection type + * + * @return Corresponding HMI TransporType value + */ + virtual hmi_apis::Common_TransportType::eType GetDeviceTransportType( + const std::string& transport_type) = 0; + + /** + * @brief method adds application + * to tts_global_properties_app_list_ + * @param app_id contains application which will + * send TTS global properties after timeout + */ + virtual void AddAppToTTSGlobalPropertiesList(const uint32_t app_id) = 0; + + /** + * Generate grammar ID + * + * @return New grammar ID + */ + virtual uint32_t GenerateGrammarID() = 0; + + virtual policy::DeviceConsent GetUserConsentForDevice( + const std::string& device_id) const = 0; + + /** + * @brief Handle sequence for unauthorized application + * @param app_id Application id + */ + virtual void OnAppUnauthorized(const uint32_t& app_id) = 0; + + virtual bool ActivateApplication(ApplicationSharedPtr app) = 0; + + /** + * @brief Callback calls when application starts/stops data streaming + * @param app_id Streaming application id + * @param service_type Streaming service type + * @param state Shows if streaming started or stopped + */ + virtual void OnAppStreaming(uint32_t app_id, + protocol_handler::ServiceType service_type, + bool state) = 0; + + + /** + * @brief CreateRegularState create regular HMI state for application + * @param app_id + * @param hmi_level of returned state + * @param audio_state of returned state + * @param system_context of returned state + * @return new regular HMI state + */ + virtual HmiStatePtr CreateRegularState( + uint32_t app_id, + mobile_apis::HMILevel::eType hmi_level, + mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::SystemContext::eType system_context) const = 0; + + virtual void SendAudioPassThroughNotification(uint32_t session_key, + std::vector<uint8_t>& binary_data) = 0; + /** * @brief Checks if application can stream (streaming service is started and * streaming is enabled in application) @@ -238,27 +531,19 @@ class ApplicationManager { * @param service_type Service type to check * @return True if streaming is allowed, false in other case */ - virtual bool CanAppStream( - uint32_t app_id, protocol_handler::ServiceType service_type) const = 0; + virtual bool CanAppStream(uint32_t app_id, + protocol_handler::ServiceType service_type) const = 0; - /** - * @brief ForbidStreaming forbids the stream over the certain application. - * @param app_id the application's id which should stop streaming. - */ - virtual void ForbidStreaming(uint32_t app_id) = 0; + /** + * @brief ForbidStreaming forbid the stream over the certain application. + * @param app_id the application's id which should stop streaming. + */ + virtual void ForbidStreaming(uint32_t app_id) = 0; + + virtual const ApplicationManagerSettings& get_settings() const = 0; + + virtual event_engine::EventDispatcher& event_dispatcher() = 0; - /* - * @brief Creates AudioPassThru data chunk and inserts it - * to audio_pass_thru_messages_ - * - * @param session_key Id of application for which - * audio pass thru should be sent - * - * @param binary_data AudioPassThru data chunk - */ - virtual void SendAudioPassThroughNotification(uint32_t session_key, - std::vector<uint8_t>& binary_data) = 0; - virtual policy::PolicyHandlerInterface& GetPolicyHandler() = 0; }; } // namespace application_manager 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 2134fd3b18..6b286e5af6 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 @@ -48,7 +48,10 @@ #include "application_manager/request_controller.h" #include "application_manager/resumption/resume_ctrl.h" #include "application_manager/vehicle_info_data.h" -#include "application_manager/state_controller.h" +#include "application_manager/state_controller_impl.h" +#include "application_manager/application_manager_settings.h" +#include "application_manager/event_engine/event_dispatcher_impl.h" + #include "protocol_handler/protocol_observer.h" #include "protocol_handler/protocol_handler.h" #include "hmi_message_handler/hmi_message_observer.h" @@ -83,7 +86,6 @@ #include "utils/threads/thread.h" #include "utils/threads/message_loop_thread.h" #include "utils/lock.h" -#include "utils/singleton.h" #include "utils/data_accessor.h" #include "utils/timer.h" @@ -170,13 +172,13 @@ struct MessageToHmi : public utils::SharedPtr<Message> { }; // Short type names for prioritized message queues -typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile>> +typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromMobile> > FromMobileQueue; -typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToMobile>> +typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToMobile> > ToMobileQueue; -typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi>> +typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageFromHmi> > FromHmiQueue; -typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToHmi>> +typedef threads::MessageLoopThread<utils::PrioritizedQueue<MessageToHmi> > ToHmiQueue; // AudioPassThru @@ -189,6 +191,7 @@ typedef threads::MessageLoopThread<RawAudioDataQueue> AudioPassThruQueue; } CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") typedef std::vector<std::string> RPCParams; +typedef utils::SharedPtr<timer::Timer> TimerSPtr; class ApplicationManagerImpl : public ApplicationManager, @@ -203,16 +206,18 @@ class ApplicationManagerImpl public impl::ToMobileQueue::Handler, public impl::FromHmiQueue::Handler, public impl::ToHmiQueue::Handler, - public impl::AudioPassThruQueue::Handler, + public impl::AudioPassThruQueue::Handler #ifdef TELEMETRY_MONITOR - public telemetry_monitor::TelemetryObservable<AMTelemetryObserver>, + , public telemetry_monitor::TelemetryObservable<AMTelemetryObserver> #endif // TELEMETRY_MONITOR - public utils::Singleton<ApplicationManagerImpl> { +{ friend class ResumeCtrl; friend class CommandImpl; public: + ApplicationManagerImpl(const ApplicationManagerSettings& am_settings, + const policy::PolicySettings& policy_settings); ~ApplicationManagerImpl(); /** @@ -228,47 +233,34 @@ class ApplicationManagerImpl **/ bool Stop() OVERRIDE; - ///////////////////////////////////////////////////// - DataAccessor<ApplicationSet> applications() const OVERRIDE; - ApplicationSharedPtr application(uint32_t app_id) const; + ApplicationSharedPtr application(uint32_t app_id) const OVERRIDE; + + ApplicationSharedPtr active_application() const OVERRIDE; + + ApplicationSharedPtr application_by_hmi_app( + uint32_t hmi_app_id) const OVERRIDE; ApplicationSharedPtr application_by_policy_id( - const std::string& policy_app_id) const; - ApplicationSharedPtr active_application() const; - std::vector<ApplicationSharedPtr> applications_by_button(uint32_t button); - std::vector<ApplicationSharedPtr> applications_by_ivi(uint32_t vehicle_info); - std::vector<ApplicationSharedPtr> applications_with_navi(); + const std::string& policy_app_id) const OVERRIDE; - /** - * @brief Returns media application with LIMITED HMI Level if exist. - * - * @return Shared pointer to application if application does not - * exist returns empty shared pointer. - */ - ApplicationSharedPtr get_limited_media_application() const; + std::vector<ApplicationSharedPtr> applications_by_button( + uint32_t button) OVERRIDE; + std::vector<ApplicationSharedPtr> applications_with_navi() OVERRIDE; - /** - * @brief Returns navigation application with LIMITED HMI Level if exist. - * - * @return Shared pointer to application if application does not - * exist returns empty shared pointer - */ - ApplicationSharedPtr get_limited_navi_application() const; + ApplicationSharedPtr get_limited_media_application() const OVERRIDE; + ApplicationSharedPtr get_limited_navi_application() const OVERRIDE; + ApplicationSharedPtr get_limited_voice_application() const OVERRIDE; - /** - * @brief Returns voice communication application with LIMITED HMI Level if - * exist. - * - * @return Shared pointer to application if application does not - * exist returns empty shared pointer - */ - ApplicationSharedPtr get_limited_voice_application() const; + uint32_t application_id(const int32_t correlation_id) OVERRIDE; + void set_application_id(const int32_t correlation_id, + const uint32_t app_id) OVERRIDE; void OnHMILevelChanged(uint32_t app_id, mobile_apis::HMILevel::eType from, mobile_apis::HMILevel::eType to) OVERRIDE; - void SendHMIStatusNotification(const ApplicationSharedPtr app) OVERRIDE; + void SendHMIStatusNotification( + const utils::SharedPtr<Application> app) OVERRIDE; /** * @brief Checks if application with the same HMI type * (media, voice communication or navi) exists @@ -286,31 +278,31 @@ class ApplicationManagerImpl * @return true if Application is subscribed for way points * otherwise false */ - bool IsAppSubscribedForWayPoints(const uint32_t app_id) const; + bool IsAppSubscribedForWayPoints(const uint32_t app_id) const OVERRIDE; /** * @brief Subscribe Application for way points * @param Application AppID */ - void SubscribeAppForWayPoints(const uint32_t app_id); + void SubscribeAppForWayPoints(const uint32_t app_id) OVERRIDE; /** * @brief Unsubscribe Application for way points * @param Application AppID */ - void UnsubscribeAppFromWayPoints(const uint32_t app_id); + void UnsubscribeAppFromWayPoints(const uint32_t app_id) OVERRIDE; /** * @brief Is Any Application is subscribed for way points * @return true if some app is subscribed otherwise false */ - bool IsAnyAppSubscribedForWayPoints() const; + bool IsAnyAppSubscribedForWayPoints() const OVERRIDE; /** * @brief Get subscribed for way points * @return reference to set of subscribed apps for way points */ - const std::set<int32_t> GetAppsSubscribedForWayPoints() const; + const std::set<int32_t> GetAppsSubscribedForWayPoints() const OVERRIDE; /** * @brief Notifies all components interested in Vehicle Data update @@ -320,12 +312,12 @@ class ApplicationManagerImpl * @param new value (for integer values currently) of vehicle data */ std::vector<ApplicationSharedPtr> IviInfoUpdated(VehicleDataType vehicle_info, - int value); + int value) OVERRIDE; void OnApplicationRegistered(ApplicationSharedPtr app) OVERRIDE; - ///////////////////////////////////////////////////// HMICapabilities& hmi_capabilities(); + const HMICapabilities& hmi_capabilities() const; /** * @brief ProcessQueryApp executes logic related to QUERY_APP system request. @@ -335,9 +327,9 @@ class ApplicationManagerImpl * @param connection_key connection key for app, which sent system request */ void ProcessQueryApp(const smart_objects::SmartObject& sm_object, - const uint32_t connection_key); + const uint32_t connection_key) OVERRIDE; - bool is_attenuated_supported() OVERRIDE; + bool is_attenuated_supported() const OVERRIDE; #ifdef TELEMETRY_MONITOR /** @@ -345,12 +337,11 @@ class ApplicationManagerImpl * * @param observer - pointer to observer */ - void SetTelemetryObserver(AMTelemetryObserver* observer); + void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE; #endif // TELEMETRY_MONITOR - ApplicationSharedPtr RegisterApplication( - const utils::SharedPtr<smart_objects::SmartObject>& - request_for_registration); + ApplicationSharedPtr RegisterApplication(const utils::SharedPtr< + smart_objects::SmartObject>& request_for_registration) OVERRIDE; /* * @brief Closes application by id * @@ -364,13 +355,13 @@ class ApplicationManagerImpl void UnregisterApplication(const uint32_t& app_id, mobile_apis::Result::eType reason, bool is_resuming = false, - bool is_unexpected_disconnect = false); + bool is_unexpected_disconnect = false) OVERRIDE; /** * @brief Handle sequence for unauthorized application * @param app_id Application id */ - void OnAppUnauthorized(const uint32_t& app_id); + void OnAppUnauthorized(const uint32_t& app_id) OVERRIDE; /* * @brief Sets unregister reason for closing all registered applications @@ -379,14 +370,15 @@ class ApplicationManagerImpl * @param reason Describes the reason for HU switching off */ void SetUnregisterAllApplicationsReason( - mobile_api::AppInterfaceUnregisteredReason::eType reason); + mobile_api::AppInterfaceUnregisteredReason::eType reason) OVERRIDE; /* * @brief Called on Master_reset or Factory_defaults * when User chooses to reset HU. * Resets Policy Table if applicable. */ - void HeadUnitReset(mobile_api::AppInterfaceUnregisteredReason::eType reason); + void HeadUnitReset( + mobile_api::AppInterfaceUnregisteredReason::eType reason) OVERRIDE; /* * @brief Closes all registered applications @@ -395,7 +387,7 @@ class ApplicationManagerImpl bool RemoveAppDataFromHMI(ApplicationSharedPtr app); bool LoadAppDataToHMI(ApplicationSharedPtr app); - bool ActivateApplication(ApplicationSharedPtr app); + bool ActivateApplication(ApplicationSharedPtr app) OVERRIDE; /** * @brief Put application in FULL HMI Level if possible, @@ -406,28 +398,28 @@ class ApplicationManagerImpl */ mobile_api::HMILevel::eType IsHmiLevelFullAllowed(ApplicationSharedPtr app); - void ConnectToDevice(const std::string& device_mac); - void OnHMIStartedCooperation(); + void ConnectToDevice(const std::string& device_mac) OVERRIDE; + void OnHMIStartedCooperation() OVERRIDE; /* * @brief Returns unique correlation ID for HMI request * * @return Unique correlation ID */ - uint32_t GetNextHMICorrelationID(); + uint32_t GetNextHMICorrelationID() OVERRIDE; /* @brief Starts audio passthru process * * @return true on success, false if passthru is already in process */ - bool begin_audio_pass_thru(); + bool BeginAudioPassThrough() OVERRIDE; /* * @brief Finishes already started audio passthru process * * @return true on success, false if passthru is not active */ - bool end_audio_pass_thru(); + bool EndAudioPassThrough() OVERRIDE; /* * @brief Retrieves driver distraction state @@ -441,7 +433,7 @@ class ApplicationManagerImpl * * @param state New state to be set */ - void set_driver_distraction(bool is_distracting); + void set_driver_distraction(bool is_distracting) OVERRIDE; /* * @brief Retrieves if VR session has started @@ -469,7 +461,7 @@ class ApplicationManagerImpl * * @param allowed SDL access to all mobile apps */ - void set_all_apps_allowed(const bool& allowed); + void SetAllAppsAllowed(const bool& allowed) OVERRIDE; /** * @brief CreateRegularState create regular HMI state for application @@ -483,7 +475,7 @@ class ApplicationManagerImpl uint32_t app_id, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::SystemContext::eType system_context) const; + mobile_apis::SystemContext::eType system_context) const OVERRIDE; /** * @brief SetState set regular audio state @@ -515,7 +507,7 @@ class ApplicationManagerImpl "Application with appID=" << app_id << " does not exist"); return; } - state_ctrl_.SetRegularState<SendActivateApp>(app, new_state); + state_ctrl_.SetRegularState(app, new_state, SendActivateApp); } /** @@ -531,7 +523,7 @@ class ApplicationManagerImpl "Application with appID=" << app_id << " does not exist"); return; } - state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level); + state_ctrl_.SetRegularState(app, hmi_level, SendActivateApp); } /** @@ -551,7 +543,7 @@ class ApplicationManagerImpl "Application with appID=" << app_id << " does not exist"); return; } - state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level, audio_state); + state_ctrl_.SetRegularState(app, hmi_level, audio_state, SendActivateApp); } /** @@ -572,8 +564,8 @@ class ApplicationManagerImpl "Application with appID=" << app_id << " does not exist"); return; } - state_ctrl_.SetRegularState<SendActivateApp>( - app, hmi_level, audio_state, system_context); + state_ctrl_.SetRegularState( + app, hmi_level, audio_state, system_context, SendActivateApp); } /** @@ -622,7 +614,7 @@ class ApplicationManagerImpl state_ctrl_.SetRegularState(app, state); } - /** + /** * @brief Checks, if particular state is active * @param state_id State * @return True, if state is active, otherwise - false @@ -642,7 +634,7 @@ class ApplicationManagerImpl * for app with HMI level BACKGROUND. */ void OnUpdateHMIAppType( - std::map<std::string, std::vector<std::string>> app_hmi_types) OVERRIDE; + std::map<std::string, std::vector<std::string> > app_hmi_types) OVERRIDE; /* * @brief Starts audio pass thru thread @@ -659,14 +651,14 @@ class ApplicationManagerImpl int32_t max_duration, int32_t sampling_rate, int32_t bits_per_sample, - int32_t audio_type); + int32_t audio_type) OVERRIDE; /* * @brief Terminates audio pass thru thread * @param application_key Id of application for which * audio pass thru should be stopped */ - void StopAudioPassThru(int32_t application_key); + void StopAudioPassThru(int32_t application_key) OVERRIDE; /* * @brief Creates AudioPassThru data chunk and inserts it @@ -678,7 +670,7 @@ class ApplicationManagerImpl * @param binary_data AudioPassThru data chunk */ void SendAudioPassThroughNotification(uint32_t session_key, - std::vector<uint8_t>& binary_data); + std::vector<uint8_t>& binary_data) OVERRIDE; std::string GetDeviceName(connection_handler::DeviceHandle handle); @@ -692,12 +684,10 @@ class ApplicationManagerImpl */ hmi_apis::Common_TransportType::eType GetDeviceTransportType( const std::string& transport_type); - ///////////////////////////////////////////////////// void set_hmi_message_handler(hmi_message_handler::HMIMessageHandler* handler); void set_connection_handler(connection_handler::ConnectionHandler* handler); void set_protocol_handler(protocol_handler::ProtocolHandler* handler); - /////////////////////////////////////////////////////// void StartDevicesDiscovery(); @@ -707,20 +697,18 @@ class ApplicationManagerImpl void SendMessageToMobile(const commands::MessageSharedPtr message, bool final_message = false) OVERRIDE; + void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE; + + bool ManageMobileCommand(const commands::MessageSharedPtr message, + commands::Command::CommandOrigin origin) OVERRIDE; + bool ManageHMICommand(const commands::MessageSharedPtr message) OVERRIDE; + /** * @brief TerminateRequest forces termination of request * @param connection_key - application id of request * @param corr_id correlation id of request */ - void TerminateRequest(uint32_t connection_key, uint32_t corr_id); - - bool ManageMobileCommand( - const commands::MessageSharedPtr message, - commands::Command::CommandOrigin origin = commands::Command::ORIGIN_SDL) OVERRIDE; - void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE; - bool ManageHMICommand(const commands::MessageSharedPtr message) OVERRIDE; - - ///////////////////////////////////////////////////////// + void TerminateRequest(uint32_t connection_key, uint32_t corr_id)OVERRIDE; // Overriden ProtocolObserver method void OnMessageReceived( const ::protocol_handler::RawMessagePtr message) OVERRIDE; @@ -736,7 +724,6 @@ class ApplicationManagerImpl // Overriden ConnectionHandlerObserver method void OnDeviceListUpdated( const connection_handler::DeviceMap& device_list) OVERRIDE; - // TODO (EZamakhov): fix all indentations in this file void OnFindNewApplicationsRequest() OVERRIDE; void RemoveDevice( const connection_handler::DeviceHandle& device_handle) OVERRIDE; @@ -760,11 +747,12 @@ class ApplicationManagerImpl security_manager::SSLContext::HandshakeContext GetHandshakeContext( uint32_t key) const OVERRIDE FINAL; #endif // ENABLE_SECURITY - /** - * @ 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 CommandSharedPtr ptr); /** @@ -783,24 +771,8 @@ class ApplicationManagerImpl */ void updateRequestTimeout(uint32_t connection_key, uint32_t mobile_correlation_id, - uint32_t new_timeout_value); + uint32_t new_timeout_value) OVERRIDE; - /* - * @brief Retrieves application id associated whith correlation id - * - * @param correlation_id Correlation ID of the HMI request - * - * @return application id associated whith correlation id - */ - const uint32_t application_id(const int32_t correlation_id); - - /* - * @brief Sets application id correlation id - * - * @param correlation_id Correlation ID of the HMI request - * @param app_id Application ID - */ - void set_application_id(const int32_t correlation_id, const uint32_t app_id); /** * @brief AddPolicyObserver allows to subscribe needed component to events * from policy. @@ -823,7 +795,8 @@ class ApplicationManagerImpl * @return True if streaming is allowed, false in other case */ bool HMILevelAllowsStreaming( - uint32_t app_id, protocol_handler::ServiceType service_type) const; + uint32_t app_id, + protocol_handler::ServiceType service_type) const OVERRIDE; /** * @brief Checks if application can stream (streaming service is started and @@ -833,19 +806,19 @@ class ApplicationManagerImpl * @return True if streaming is allowed, false in other case */ bool CanAppStream(uint32_t app_id, - protocol_handler::ServiceType service_type) const; + protocol_handler::ServiceType service_type) const OVERRIDE; /** * @brief Ends opened navi services (audio/video) for application * @param app_id Application id */ - void EndNaviServices(uint32_t app_id); + void EndNaviServices(uint32_t app_id) OVERRIDE; /** - * @brief ForbidStreaming forbids the stream over the certain application. + * @brief ForbidStreaming forbid the stream over the certain application. * @param app_id the application's id which should stop streaming. */ - void ForbidStreaming(uint32_t app_id); + void ForbidStreaming(uint32_t app_id) OVERRIDE; /** * @brief Callback calls when application starts/stops data streaming @@ -855,7 +828,7 @@ class ApplicationManagerImpl */ void OnAppStreaming(uint32_t app_id, protocol_handler::ServiceType service_type, - bool state); + bool state) OVERRIDE; mobile_api::HMILevel::eType GetDefaultHmiLevel( ApplicationConstSharedPtr application) const; @@ -864,7 +837,7 @@ class ApplicationManagerImpl * Getter for resume_controller * @return Resume Controller */ - resumption::ResumeCtrl& resume_controller() { + resumption::ResumeCtrl& resume_controller() OVERRIDE{ return resume_ctrl_; } @@ -873,14 +846,14 @@ class ApplicationManagerImpl * * @return New grammar ID */ - uint32_t GenerateGrammarID(); + uint32_t GenerateGrammarID() OVERRIDE; /** * Generate new HMI application ID * * @return New HMI application ID */ - uint32_t GenerateNewHMIAppID(); + uint32_t GenerateNewHMIAppID()OVERRIDE; /** * @brief Parse smartObject and replace mobile app Id by HMI app ID @@ -911,7 +884,7 @@ class ApplicationManagerImpl mobile_apis::Result::eType SaveBinary(const std::vector<uint8_t>& binary_data, const std::string& file_path, const std::string& file_name, - const int64_t offset); + const int64_t offset) OVERRIDE; /** * @brief Get available app space @@ -923,7 +896,7 @@ class ApplicationManagerImpl /* * @brief returns true if HMI is cooperating */ - bool IsHMICooperating() const; + bool IsHMICooperating() const OVERRIDE; /** * @brief Method used to send default app tts globalProperties @@ -937,7 +910,7 @@ class ApplicationManagerImpl * @param app_id contains application which will * send TTS global properties after timeout */ - void AddAppToTTSGlobalPropertiesList(const uint32_t app_id); + void AddAppToTTSGlobalPropertiesList(const uint32_t app_id) OVERRIDE; /** * @brief method removes application @@ -945,7 +918,7 @@ class ApplicationManagerImpl * @param app_id contains application which will * send TTS global properties after timeout */ - void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id); + void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) OVERRIDE; /** * @brief method adds application in FULL and LIMITED state @@ -961,14 +934,9 @@ class ApplicationManagerImpl */ void ResetPhoneCallAppList(); - /** - * Function used only by HMI request/response/notification base classes - * to change HMI app id to Mobile app id and vice versa. - * Dot use it inside Core - */ - ApplicationSharedPtr application_by_hmi_app(uint32_t hmi_app_id) const; // TODO(AOleynik): Temporary added, to fix build. Should be reworked. connection_handler::ConnectionHandler& connection_handler() const OVERRIDE; + protocol_handler::ProtocolHandler& protocol_handler() const OVERRIDE; virtual policy::PolicyHandlerInterface& GetPolicyHandler() OVERRIDE { return policy_handler_; @@ -988,7 +956,7 @@ class ApplicationManagerImpl mobile_apis::HMILevel::eType hmi_level, mobile_apis::FunctionID::eType function_id, const RPCParams& rpc_params, - CommandParametersPermissions* params_permissions = NULL); + CommandParametersPermissions* params_permissions = NULL) OVERRIDE; /* * @brief Function Should be called when Low Voltage is occured */ @@ -1005,12 +973,15 @@ class ApplicationManagerImpl * * @param connection_key the connection key ofthe required application * - * @param mobile_app_id application's mobile(policy) identifier. + * @param policy_app_id application's mobile(policy) identifier. * * @return true in case application is allowed to register, false otherwise. */ bool IsApplicationForbidden(uint32_t connection_key, - const std::string& mobile_app_id); + const std::string& policy_app_id) const OVERRIDE; + + policy::DeviceConsent GetUserConsentForDevice( + const std::string& device_id) const OVERRIDE; struct ApplicationsAppIdSorter { bool operator()(const ApplicationSharedPtr lhs, @@ -1019,97 +990,18 @@ class ApplicationManagerImpl } }; - struct ApplicationsMobileAppIdSorter { + struct ApplicationsPolicyAppIdSorter { bool operator()(const ApplicationSharedPtr lhs, const ApplicationSharedPtr rhs) { - if (lhs->mobile_app_id() == rhs->mobile_app_id()) { - return lhs->device() < rhs->device(); - } - return lhs->mobile_app_id() < rhs->mobile_app_id(); + return lhs->policy_app_id() < rhs->policy_app_id(); } }; // typedef for Applications list - typedef std::set<ApplicationSharedPtr, ApplicationsAppIdSorter> ApplictionSet; - - typedef std::multiset<ApplicationSharedPtr, ApplicationsMobileAppIdSorter> + typedef std::set<ApplicationSharedPtr, ApplicationsPolicyAppIdSorter> AppsWaitRegistrationSet; typedef std::set<std::string> ForbiddenApps; - // typedef for Applications list iterator - - DataAccessor<AppsWaitRegistrationSet> apps_waiting_for_registration() const; - ApplicationConstSharedPtr waiting_app(const uint32_t hmi_id) const; - - /** - * Class for thread-safe access to applications list - */ - class ApplicationListAccessor : public DataAccessor<ApplicationSet> { - public: - /** - * @brief ApplicationListAccessor class constructor - */ - ApplicationListAccessor() - : DataAccessor<ApplicationSet>( - ApplicationManagerImpl::instance()->applications_, - ApplicationManagerImpl::instance()->applications_list_lock_) {} - - ~ApplicationListAccessor(); - - /** - * @brief thread-safe getter for applications - * @return applications list - */ - const ApplicationSet& applications() const { - return GetData(); - } - - ApplicationSetConstIt begin() { - return applications().begin(); - } - - ApplicationSetConstIt end() { - return applications().end(); - } - - template <class UnaryPredicate> - ApplicationSharedPtr Find(UnaryPredicate finder) { - ApplicationSharedPtr result; - ApplicationSetConstIt it = std::find_if(begin(), end(), finder); - if (it != end()) { - result = *it; - } - return result; - } - - template <class UnaryPredicate> - std::vector<ApplicationSharedPtr> FindAll(UnaryPredicate finder) { - std::vector<ApplicationSharedPtr> result; - ApplicationSetConstIt it = std::find_if(begin(), end(), finder); - while (it != end()) { - result.push_back(*it); - it = std::find_if(++it, end(), finder); - } - return result; - } - - void Erase(ApplicationSharedPtr app_to_remove) { - ApplicationManagerImpl::instance()->applications_.erase(app_to_remove); - } - - void Insert(ApplicationSharedPtr app_to_insert) { - ApplicationManagerImpl::instance()->applications_.insert(app_to_insert); - } - - bool Empty() { - return ApplicationManagerImpl::instance()->applications_.empty(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(ApplicationListAccessor); - }; - - friend class ApplicationListAccessor; struct AppIdPredicate { uint32_t app_id_; @@ -1127,12 +1019,12 @@ class ApplicationManagerImpl } }; - struct MobileAppIdPredicate { + struct PolicyAppIdPredicate { std::string policy_app_id_; - MobileAppIdPredicate(const std::string& policy_app_id) + PolicyAppIdPredicate(const std::string& policy_app_id) : policy_app_id_(policy_app_id) {} bool operator()(const ApplicationSharedPtr app) const { - return app ? policy_app_id_ == app->mobile_app_id() : false; + return app ? policy_app_id_ == app->policy_app_id() : false; } }; @@ -1175,10 +1067,18 @@ class ApplicationManagerImpl } }; + struct GrammarIdPredicate { + uint32_t grammar_id_; + GrammarIdPredicate(uint32_t grammar_id) : grammar_id_(grammar_id) {} + bool operator()(const ApplicationSharedPtr app) const { + return app ? grammar_id_ == app->get_grammar_id() : false; + } + }; + /** * @brief Sends UpdateAppList notification to HMI */ - void SendUpdateAppList(); + void SendUpdateAppList() OVERRIDE; /** * @brief Marks applications received through QueryApps as should be @@ -1187,20 +1087,24 @@ class ApplicationManagerImpl * @param handle, device handle */ void MarkAppsGreyOut(const connection_handler::DeviceHandle handle, - bool is_greyed_out); + bool is_greyed_out) OVERRIDE; /** * @brief Checks, if apps list had been queried already from certain device * @param handle, Device handle * @return true, if list had been queried already, otherwise - false */ - bool IsAppsQueriedFrom(const connection_handler::DeviceHandle handle) const; + bool IsAppsQueriedFrom(const connection_handler::DeviceHandle handle) const OVERRIDE; - bool IsStopping() const { + bool IsStopping() const OVERRIDE { return is_stopping_; } - private: + StateController& state_controller() OVERRIDE; + const ApplicationManagerSettings& get_settings() const OVERRIDE; + virtual event_engine::EventDispatcher& event_dispatcher() OVERRIDE; + +private: /** * @brief PullLanguagesInfo allows to pull information about languages. * @@ -1213,8 +1117,6 @@ class ApplicationManagerImpl smart_objects::SmartObject& ttsName, smart_objects::SmartObject& vrSynonym); - ApplicationManagerImpl(); - /** * @brief Method transforms string to AppHMIType * @param str contains string AppHMIType @@ -1266,7 +1168,8 @@ class ApplicationManagerImpl template <typename ApplicationList> void PrepareApplicationListSO(ApplicationList app_list, - smart_objects::SmartObject& applications) { + smart_objects::SmartObject& applications, + ApplicationManager& app_mngr) { CREATE_LOGGERPTR_LOCAL(logger_, "ApplicationManager"); smart_objects::SmartArray* app_array = applications.asArray(); @@ -1282,7 +1185,7 @@ class ApplicationManagerImpl const protocol_handler::SessionObserver& session_observer = connection_handler().get_session_observer(); if (MessageHelper::CreateHMIApplicationStruct( - *it, session_observer, GetPolicyHandler(), &hmi_application)) { + *it, session_observer, GetPolicyHandler(), &hmi_application, app_mngr)) { applications[app_count++] = hmi_application; } else { LOG4CXX_DEBUG(logger_, "Can't CreateHMIApplicationStruct "); @@ -1294,8 +1197,6 @@ class ApplicationManagerImpl } } - void ClearTTSGlobalPropertiesList(); - void OnApplicationListUpdateTimer(); /** @@ -1328,22 +1229,21 @@ class ApplicationManagerImpl * 1st value - is video service opened or not * 2nd value - is audio service opened or not */ - typedef std::map<uint32_t, std::pair<bool, bool>> NaviServiceStatusMap; + typedef std::map<uint32_t, std::pair<bool, bool> > NaviServiceStatusMap; -typedef utils::SharedPtr<timer::Timer> TimerSPtr; /** * @brief GetHashedAppID allows to obtain unique application id as a string. * It concatenates device mac and application id to obtain unique id. * * @param connection_key connection key for which need to obtain device mac; * - * @param mobile_app_id mobile(policy) application id on particular device. + * @param policy_app_id mobile(policy) application id on particular device. * This parameter will be concatenated with device id. * * @return unique aplication identifier. */ std::string GetHashedAppID(uint32_t connection_key, - const std::string& mobile_app_id); + const std::string& policy_app_id) const; /** * @brief Removes suspended and stopped timers from timer pool @@ -1440,7 +1340,10 @@ typedef utils::SharedPtr<timer::Timer> TimerSPtr; void RemoveAppsWaitingForRegistration( const connection_handler::DeviceHandle handle); + void ClearTTSGlobalPropertiesList(); + private: + const ApplicationManagerSettings& settings_; /** * @brief List of applications */ @@ -1476,6 +1379,8 @@ typedef utils::SharedPtr<timer::Timer> TimerSPtr; bool is_vr_session_strated_; bool hmi_cooperating_; bool is_all_apps_allowed_; + + event_engine::EventDispatcherImpl event_dispatcher_; media_manager::MediaManager* media_manager_; hmi_message_handler::HMIMessageHandler* hmi_handler_; @@ -1522,8 +1427,8 @@ typedef utils::SharedPtr<timer::Timer> TimerSPtr; std::vector<TimerSPtr> timer_pool_; sync_primitives::Lock timer_pool_lock_; - sync_primitives::Lock stopping_flag_lock_; - StateController state_ctrl_; + sync_primitives::Lock stopping_application_mng_lock_; + StateControllerImpl state_ctrl_; #ifdef TELEMETRY_MONITOR AMTelemetryObserver* metric_observer_; @@ -1534,10 +1439,10 @@ typedef utils::SharedPtr<timer::Timer> TimerSPtr; Timer tts_global_properties_timer_; bool is_low_voltage_; + volatile bool is_stopping_; DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl); - FRIEND_BASE_SINGLETON_CLASS(ApplicationManagerImpl); }; bool ApplicationManagerImpl::vr_session_started() const { 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 238e0b71c7..4932fa1ddb 100644 --- a/src/components/application_manager/include/application_manager/commands/command.h +++ b/src/components/application_manager/include/application_manager/commands/command.h @@ -32,19 +32,14 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_H_ - -#include "utils/shared_ptr.h" +#include <stdint.h> #include "smart_objects/smart_object.h" -#include "application_manager/event_engine/event_observer.h" -#include "application_manager/smart_object_keys.h" +#include "utils/shared_ptr.h" namespace application_manager { -/** - * @brief SmartObject type - **/ - namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; +class ApplicationManager; namespace commands { /** @@ -128,7 +123,6 @@ class Command { }; typedef smart_objects::SmartObjectSPtr MessageSharedPtr; - } // namespace commands } // namespace application_manager 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 6cc8f82330..03f03a6a50 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 @@ -34,6 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_COMMAND_IMPL_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 "utils/logger.h" namespace application_manager { @@ -49,7 +52,6 @@ struct CommandParametersPermissions { }; namespace commands { - /** * @brief Class is intended to encapsulate RPC as an object **/ @@ -60,7 +62,8 @@ class CommandImpl : public Command { * * @param message Incoming SmartObject message **/ - explicit CommandImpl(const MessageSharedPtr& message); + explicit CommandImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager); /** * @brief CommandImpl class destructor @@ -125,17 +128,13 @@ class CommandImpl : public Command { * If request need to terminate itself, it should override this function false * @return allowed_to_terminate_ value */ - virtual bool AllowedToTerminate() { - return allowed_to_terminate_; - } + virtual bool AllowedToTerminate(); /** * @brief SetAllowedToTerminate set up allowed to terminate flag. * If true, request controller will terminate request on response */ - virtual void SetAllowedToTerminate(bool allowed) { - allowed_to_terminate_ = allowed; - } + virtual void SetAllowedToTerminate(bool allowed); // members static const int32_t hmi_protocol_type_; @@ -143,15 +142,32 @@ class CommandImpl : public Command { static const int32_t protocol_version_; protected: + /** + * @brief Parse smartObject and replace mobile app Id by HMI app ID + * + * @param message Smartobject to be parsed + */ + void ReplaceMobileByHMIAppId(smart_objects::SmartObject& message); + + /** + * @brief Parse smartObject and replace HMI app ID by mobile app Id + * + * @param message Smartobject to be parsed + */ + void ReplaceHMIByMobileAppId(smart_objects::SmartObject& message); + MessageSharedPtr message_; uint32_t default_timeout_; bool allowed_to_terminate_; + ApplicationManager& application_manager_; + #ifdef ENABLE_LOG static log4cxx::LoggerPtr logger_; #endif // ENABLE_LOG private: DISALLOW_COPY_AND_ASSIGN(CommandImpl); + }; } // namespace commands diff --git a/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h b/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h index 9f95a52850..ffe909f96a 100644 --- a/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_notification_from_mobile_impl.h @@ -47,7 +47,8 @@ namespace commands { class CommandNotificationFromMobileImpl : public CommandImpl { public: - explicit CommandNotificationFromMobileImpl(const MessageSharedPtr& message); + explicit CommandNotificationFromMobileImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager); virtual ~CommandNotificationFromMobileImpl(); virtual bool Init(); virtual bool CleanUp(); diff --git a/src/components/application_manager/include/application_manager/commands/command_notification_impl.h b/src/components/application_manager/include/application_manager/commands/command_notification_impl.h index 7d0d11af89..db105dce1c 100644 --- a/src/components/application_manager/include/application_manager/commands/command_notification_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_notification_impl.h @@ -47,7 +47,8 @@ namespace commands { class CommandNotificationImpl : public CommandImpl { public: - explicit CommandNotificationImpl(const MessageSharedPtr& message); + explicit CommandNotificationImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager); virtual ~CommandNotificationImpl(); virtual bool Init(); virtual bool CleanUp(); 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 164871e1af..adba63e000 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 @@ -54,7 +54,8 @@ class CommandRequestImpl : public CommandImpl, public: enum RequestState { kAwaitingHMIResponse = 0, kTimedOut, kCompleted }; - explicit CommandRequestImpl(const MessageSharedPtr& message); + explicit CommandRequestImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager); virtual ~CommandRequestImpl(); virtual bool CheckPermissions(); virtual bool Init(); diff --git a/src/components/application_manager/include/application_manager/commands/command_response_impl.h b/src/components/application_manager/include/application_manager/commands/command_response_impl.h index 0c93bf54d4..8c1e7f2efc 100644 --- a/src/components/application_manager/include/application_manager/commands/command_response_impl.h +++ b/src/components/application_manager/include/application_manager/commands/command_response_impl.h @@ -48,7 +48,8 @@ namespace commands { class CommandResponseImpl : public CommandImpl { public: - explicit CommandResponseImpl(const MessageSharedPtr& message); + explicit CommandResponseImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager); virtual ~CommandResponseImpl(); virtual bool Init(); virtual bool CleanUp(); 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 18c9a972e9..7e90227bd7 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 @@ -41,6 +41,8 @@ namespace application_manager { namespace event_engine { +class EventDispatcher; + namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; class Event { @@ -65,7 +67,7 @@ class Event { * @brief Sends synchronously event to all subscribers. * */ - void raise(); + void raise(EventDispatcher& event_dispatcher); /* * @brief Provides event ID 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 e834889bff..0a58e329b3 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 @@ -37,7 +37,6 @@ #include <map> #include "utils/lock.h" -#include "utils/singleton.h" #include "application_manager/event_engine/event.h" #include "application_manager/event_engine/event_dispatcher.h" @@ -47,16 +46,33 @@ namespace event_engine { class EventObserver; -class EventDispatcherImpl : public EventDispatcher, - public utils::Singleton<EventDispatcherImpl> { +class EventDispatcherImpl : public EventDispatcher { public: + // Data types section + typedef std::vector<EventObserver*> ObserverVector; + typedef std::map<int32_t, ObserverVector> ObserversMap; + typedef std::map<Event::EventID, ObserversMap> EventObserverMap; + /* + * @brief Destructor + */ + virtual ~EventDispatcherImpl(); + + /* + * @brief Default constructor + */ + EventDispatcherImpl(); + +#ifdef BUILD_TESTS + EventObserverMap get_observers() const { return observers_event_; } + ObserverVector get_observers_list() const { return observers_; } +#endif // BUILD_TESTS /* * @brief Delivers the event to all subscribers * * @param event Received event */ - virtual void raise_event(const Event& event); + void raise_event(const Event& event) OVERRIDE; /* * @brief Subscribe the observer to event @@ -65,9 +81,9 @@ class EventDispatcherImpl : public EventDispatcher, * @param hmi_correlation_id The event HMI correlation ID * @param observer The observer to subscribe for event */ - virtual void add_observer(const Event::EventID& event_id, - int32_t hmi_correlation_id, - EventObserver* const observer); + void add_observer(const Event::EventID& event_id, + int32_t hmi_correlation_id, + EventObserver* const observer) OVERRIDE; /* * @brief Unsubscribes the observer from specific event @@ -75,29 +91,19 @@ class EventDispatcherImpl : public EventDispatcher, * @param event_id The event ID to unsubscribe from * @param observer The observer to be unsubscribed */ - virtual void remove_observer(const Event::EventID& event_id, - EventObserver* const observer); + void remove_observer(const Event::EventID& event_id, + EventObserver* const observer) OVERRIDE; /* * @brief Unsubscribes the observer from all events * * @param observer The observer to be unsubscribed */ - virtual void remove_observer(EventObserver* const observer); - - /* - * @brief Destructor - */ - virtual ~EventDispatcherImpl(); + void remove_observer(EventObserver* const observer) OVERRIDE; private: /* - * @brief Default constructor - */ - EventDispatcherImpl(); - - /* * @brief removes observer * when occurs unsubscribe from event * @param observer to be removed @@ -106,19 +112,12 @@ class EventDispatcherImpl : public EventDispatcher, DISALLOW_COPY_AND_ASSIGN(EventDispatcherImpl); - FRIEND_BASE_SINGLETON_CLASS(EventDispatcherImpl); - - // Data types section - typedef std::vector<EventObserver*> ObserverVector; - typedef std::map<int32_t, ObserverVector> ObserversMap; - typedef std::map<Event::EventID, ObserversMap> EventObserverMap; - + private: // Members section - sync_primitives::Lock state_lock_; - sync_primitives::Lock observer_lock_; - EventObserverMap observers_event_; - ObserverVector observers_; - + sync_primitives::Lock state_lock_; + sync_primitives::Lock observer_lock_; + EventObserverMap observers_event_; + ObserverVector observers_; }; } // namespace event_engine 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 04e73e3d86..d11591b587 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 @@ -35,14 +35,14 @@ #include <string> #include "application_manager/event_engine/event.h" -#include "application_manager/event_engine/event_dispatcher_impl.h" namespace application_manager { namespace event_engine { -class EventObserver -{ +class EventDispatcher; +class EventObserver { public: + friend class EventDispatcher; // Typedef for possible Observer ID's from mobile_apis functionID enum typedef unsigned long ObserverID; @@ -51,7 +51,7 @@ class EventObserver * @brief Constructor * */ - EventObserver(); + EventObserver(EventDispatcher& event_dispatcher); /* * @brief Destructor @@ -73,7 +73,6 @@ class EventObserver virtual void on_event(const Event& event) = 0; protected: - /* * @brief Subscribe to an event * @@ -81,8 +80,8 @@ class EventObserver * @param hmi_correlation_id The event HMI correlation ID. * If param is omitted, it means subscription for HMI notification */ - void subscribe_on_event( - const Event::EventID& event_id, int32_t hmi_correlation_id = 0); + void subscribe_on_event(const Event::EventID& event_id, + int32_t hmi_correlation_id = 0); /* * @brief Unsubscribes the observer from specific event @@ -98,8 +97,8 @@ class EventObserver void unsubscribe_from_all_events(); private: - ObserverID id_; + EventDispatcher& event_dispatcher_; DISALLOW_COPY_AND_ASSIGN(EventObserver); }; diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities.h b/src/components/application_manager/include/application_manager/hmi_capabilities.h index 85aaca0f4c..70f7987cf4 100644 --- a/src/components/application_manager/include/application_manager/hmi_capabilities.h +++ b/src/components/application_manager/include/application_manager/hmi_capabilities.h @@ -51,7 +51,7 @@ class LastState; namespace smart_objects = NsSmartDeviceLink::NsSmartObjects; namespace application_manager { -class ApplicationManagerImpl; +class ApplicationManager; class HMICapabilities { @@ -62,7 +62,7 @@ class HMICapabilities { * * @param app_mngr Application manager pointer */ - explicit HMICapabilities(ApplicationManagerImpl* const app_mngr); + explicit HMICapabilities(ApplicationManager& app_mngr); /* * @brief Class destructor @@ -477,7 +477,7 @@ class HMICapabilities { bool is_navigation_supported_; bool is_phone_call_supported_; - ApplicationManagerImpl* app_mngr_; + ApplicationManager& app_mngr_; HMILanguageHandler hmi_language_handler_; DISALLOW_COPY_AND_ASSIGN(HMICapabilities); diff --git a/src/components/application_manager/include/application_manager/hmi_command_factory.h b/src/components/application_manager/include/application_manager/hmi_command_factory.h index 89936e4ca6..0b37c54ea2 100644 --- a/src/components/application_manager/include/application_manager/hmi_command_factory.h +++ b/src/components/application_manager/include/application_manager/hmi_command_factory.h @@ -37,9 +37,7 @@ #include "utils/macro.h" namespace application_manager { - typedef utils::SharedPtr<commands::Command> CommandSharedPtr; - /** * @brief Factory class for command creation **/ @@ -51,7 +49,9 @@ class HMICommandFactory { * @param smartObject SmartObject shared pointer. * @return Pointer to created command object. **/ - static CommandSharedPtr CreateCommand(const commands::MessageSharedPtr& message); + static CommandSharedPtr CreateCommand( + const commands::MessageSharedPtr& message, + ApplicationManager& application_manager); private: HMICommandFactory(); 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 a16a8fdb0b..fe5d480c79 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 @@ -34,12 +34,15 @@ #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" namespace resumption { class LastState; } namespace application_manager { + +class ApplicationManager; /** * Class is used to handle edge case with slow HMI responses for current * languages. Main idea is to cache values within some persistent storage and @@ -63,7 +66,7 @@ public: /** * @brief Class constructor */ - HMILanguageHandler(); + HMILanguageHandler(ApplicationManager& application_manager); /** * @brief Sets language for interface @@ -174,6 +177,7 @@ private: */ bool is_tts_language_received_; resumption::LastState* last_state_; + ApplicationManager& application_manager_; }; } // namespace application_manager 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 fbcb5a4f29..ffdb183149 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -70,8 +70,8 @@ class HmiState { STATE_ID_EMBEDDED_NAVI }; - HmiState(uint32_t app_id, ApplicationManager* app_mngr); - HmiState(uint32_t app_id, ApplicationManager* app_mngr, StateID state_id); + HmiState(uint32_t app_id, const ApplicationManager& app_mngr); + HmiState(uint32_t app_id, const ApplicationManager& app_mngr, StateID state_id); virtual ~HmiState() {} @@ -166,7 +166,7 @@ class HmiState { protected: uint32_t app_id_; StateID state_id_; - ApplicationManager* app_mngr_; + const ApplicationManager& app_mngr_; HmiStatePtr parent_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; @@ -203,9 +203,8 @@ class HmiState { */ class VRHmiState : public HmiState { public: - mobile_apis::AudioStreamingState::eType audio_streaming_state() - const OVERRIDE; - VRHmiState(uint32_t app_id, ApplicationManager* app_mngr); + virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE; + VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr); }; /** @@ -213,9 +212,8 @@ class VRHmiState : public HmiState { */ class TTSHmiState : public HmiState { public: - TTSHmiState(uint32_t app_id, ApplicationManager* app_mngr); - mobile_apis::AudioStreamingState::eType audio_streaming_state() - const OVERRIDE; + TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr); + virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE; }; /** @@ -224,18 +222,16 @@ class TTSHmiState : public HmiState { */ class NaviStreamingHmiState : public HmiState { public: - NaviStreamingHmiState(uint32_t app_id, ApplicationManager* app_mngr); - mobile_apis::AudioStreamingState::eType audio_streaming_state() - const OVERRIDE; + NaviStreamingHmiState(uint32_t app_id, const ApplicationManager& app_mngr); + mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE; }; /** - * @brief The PhoneCallHmiState class implements logic of PhoneCall temporary - * state + * @brief The PhoneCallHmiState class implements logic of PhoneCall temporary state */ class PhoneCallHmiState : public HmiState { public: - PhoneCallHmiState(uint32_t app_id, ApplicationManager* app_mngr); + PhoneCallHmiState(uint32_t app_id, const ApplicationManager& app_mngr); mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { @@ -249,7 +245,7 @@ class PhoneCallHmiState : public HmiState { */ class SafetyModeHmiState : public HmiState { public: - SafetyModeHmiState(uint32_t app_id, ApplicationManager* app_mngr); + SafetyModeHmiState(uint32_t app_id, const ApplicationManager& app_mngr); mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { return mobile_apis::AudioStreamingState::NOT_AUDIBLE; @@ -262,7 +258,7 @@ class SafetyModeHmiState : public HmiState { */ class DeactivateHMI : public HmiState { public: - DeactivateHMI(uint32_t app_id, ApplicationManager* app_mngr); + DeactivateHMI(uint32_t app_id, const ApplicationManager& app_mngr); mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { @@ -276,7 +272,7 @@ class DeactivateHMI : public HmiState { */ class AudioSource : public HmiState { public: - AudioSource(uint32_t app_id, ApplicationManager* app_mngr); + AudioSource(uint32_t app_id, const ApplicationManager& app_mngr); mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { @@ -290,7 +286,7 @@ class AudioSource : public HmiState { */ class EmbeddedNavi : public HmiState { public: - EmbeddedNavi(uint32_t app_id, ApplicationManager* app_mngr); + EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr); mobile_apis::HMILevel::eType hmi_level() const OVERRIDE; mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE { 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 0cc7ed3dba..0b91bcf257 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -81,7 +81,9 @@ class MessageHelper { * (e.g. gps, odometer, fuel_level) */ static void CreateGetVehicleDataRequest( - uint32_t correlation_id, const std::vector<std::string>& params); + const uint32_t correlation_id, + const std::vector<std::string>& params, + ApplicationManager &app_mngr); /** * @brief Create mobile HashUpdateNotification @@ -89,45 +91,31 @@ class MessageHelper { static smart_objects::SmartObjectSPtr CreateHashUpdateNotification( const uint32_t app_id); - static smart_objects::SmartObjectSPtr GetHashUpdateNotification( - const uint32_t app_id); - /** * @brief Sends to mobile HashUpdateNotification */ - static void SendHashUpdateNotification(const uint32_t app_id); + static void SendHashUpdateNotification(const uint32_t app_id, ApplicationManager &app_mngr); /** - * @brief Sends OnAppInterfaceUnregistered notification to mobile - * - *@param connection_key Connection key - *@param reason Reason - * - **/ - static void SendOnAppInterfaceUnregisteredNotificationToMobile( - int32_t connection_key, - mobile_apis::AppInterfaceUnregisteredReason::eType reason); - - /** - * @brief Sends OnLanguageChange notification to application - * @param connection_key Connection key of application - */ - static void SendOnLanguageChangeToMobile(uint32_t connection_key); + * @brief Sends OnLanguageChange notification to application + * @param connection_key Connection key of application + */ + static void SendOnLanguageChangeToMobile(uint32_t connection_key); - /* - * @brief Retrieve vehicle data map for param name in mobile request - * to VehicleDataType - * - * @return VehicleData reference - */ - static const VehicleData& vehicle_data(); + /* + * @brief Retrieve vehicle data map for param name in mobile request + * to VehicleDataType + * + * @return VehicleData reference + */ + static const VehicleData& vehicle_data(); - /** - * @brief Converts HMI Result enum value to string - * @param hmi_result HMI Result enum value - * @return stringified value for enum if succedeed, otherwise - empty string - */ - static std::string HMIResultToString( + /** + * @brief Converts HMI Result enum value to string + * @param hmi_result HMI Result enum value + * @return stringified value for enum if succedeed, otherwise - empty string + */ + static std::string HMIResultToString( hmi_apis::Common_Result::eType hmi_result); /** @@ -200,7 +188,7 @@ class MessageHelper { static smart_objects::SmartObjectSPtr CreateBlockedByPoliciesResponse( mobile_apis::FunctionID::eType function_id, mobile_apis::Result::eType result, - uint32_t correlation_id, + const uint32_t correlation_id, uint32_t connection_key); /* @@ -210,12 +198,12 @@ class MessageHelper { * @param devices Devices list * */ - static smart_objects::SmartObjectSPtr CreateDeviceListSO( - const connection_handler::DeviceMap& devices, - const policy::PolicyHandlerInterface& policy_handler); + static smart_objects::SmartObjectSPtr CreateDeviceListSO(const connection_handler::DeviceMap& devices, + const policy::PolicyHandlerInterface& policy_handler, + ApplicationManager &app_mngr); static smart_objects::SmartObjectSPtr CreateModuleInfoSO( - uint32_t function_id); + uint32_t function_id, ApplicationManager& app_mngr); static smart_objects::SmartObjectSPtr CreateSetAppIcon( const std::string& path_to_icon, uint32_t app_id); @@ -223,64 +211,61 @@ class MessageHelper { /** * @brief Sends IVI subscription requests */ - static bool SendIVISubscribtions(const uint32_t app_id); + static bool SendIVISubscribtions(const uint32_t app_id, ApplicationManager &app_mngr); /** * @brief Returns IVI subscription requests */ - static smart_objects::SmartObjectList GetIVISubscriptionRequests( - ApplicationSharedPtr app); + static smart_objects::SmartObjectList GetIVISubscriptionRequests(ApplicationSharedPtr app, ApplicationManager& app_mngr); /** * @brief Sends button subscription notification */ static void SendOnButtonSubscriptionNotification( - const uint32_t app_id, - const hmi_apis::Common_ButtonName::eType button, - const bool is_subscribed); + const uint32_t app_id, + const hmi_apis::Common_ButtonName::eType button, + const bool is_subscribed, + ApplicationManager &app_mngr); /** * @brief Sends button subscription notifications for all buttons * that application is subscribed on */ - static void SendAllOnButtonSubscriptionNotificationsForApp( - ApplicationConstSharedPtr app); + static void SendAllOnButtonSubscriptionNotificationsForApp(ApplicationConstSharedPtr app, ApplicationManager &app_mngr); - static void SendAppDataToHMI(ApplicationConstSharedPtr app); - static void SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app); + static void SendAppDataToHMI(ApplicationConstSharedPtr app, ApplicationManager& app_man); + static void SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app, ApplicationManager &app_mngr); static smart_objects::SmartObjectList CreateGlobalPropertiesRequestsToHMI( - ApplicationConstSharedPtr app); + ApplicationConstSharedPtr app, const uint32_t correlation_id); static smart_objects::SmartObjectSPtr CreateAppVrHelp( ApplicationConstSharedPtr app); static smart_objects::SmartObjectList CreateShowRequestToHMI( - ApplicationConstSharedPtr app); - static void SendShowRequestToHMI(ApplicationConstSharedPtr app); - static void SendShowConstantTBTRequestToHMI(ApplicationConstSharedPtr app); - static void SendAddCommandRequestToHMI(ApplicationConstSharedPtr app); + ApplicationConstSharedPtr app, const uint32_t correlation_id); + static void SendShowRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager &app_mngr); + static void SendShowConstantTBTRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager& app_man); + static void SendAddCommandRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager &app_man); static smart_objects::SmartObjectList CreateAddCommandRequestToHMI( - ApplicationConstSharedPtr app); + ApplicationConstSharedPtr app, ApplicationManager& app_mngr); static smart_objects::SmartObjectList - CreateAddVRCommandRequestFromChoiceToHMI(ApplicationConstSharedPtr app); + CreateAddVRCommandRequestFromChoiceToHMI(ApplicationConstSharedPtr app, + ApplicationManager& app_mngr); /** * @brief Sends UI_ChangeRegistration to HMI with list of AppHMIType * @param app applicaton instace */ - static void SendUIChangeRegistrationRequestToHMI( - ApplicationConstSharedPtr app); - static void SendChangeRegistrationRequestToHMI(ApplicationConstSharedPtr app); - static void SendAddVRCommandToHMI( - const uint32_t cmd_id, + static void SendUIChangeRegistrationRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager &app_mngr); + static void SendChangeRegistrationRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager &app_mngr); + static void SendAddVRCommandToHMI(uint32_t cmd_id, const smart_objects::SmartObject& vr_commands, - const uint32_t app_id); + const uint32_t app_id, ApplicationManager &app_mngr); - static smart_objects::SmartObjectSPtr CreateAddVRCommandToHMI( - const uint32_t cmd_id, + static smart_objects::SmartObjectSPtr CreateAddVRCommandToHMI(uint32_t cmd_id, const smart_objects::SmartObject& vr_commands, - const uint32_t app_id); + const uint32_t app_id, ApplicationManager &app_mngr); /* * @brief Create Common.HMIApplication struct application instance @@ -291,11 +276,10 @@ class MessageHelper { static bool CreateHMIApplicationStruct(ApplicationConstSharedPtr app, const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface &policy_handler, - smart_objects::SmartObject* output); + smart_objects::SmartObject* output, ApplicationManager &app_mngr); - static void SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app); - static smart_objects::SmartObjectList CreateAddSubMenuRequestToHMI( - ApplicationConstSharedPtr app); + static void SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager &app_mngr); + static smart_objects::SmartObjectList CreateAddSubMenuRequestToHMI(ApplicationConstSharedPtr app, const uint32_t correlation_id); /* * @brief Creates BasicCommunication.OnAppUnregistered notification @@ -303,30 +287,29 @@ class MessageHelper { * @param is_unexpected_disconnect * Indicates if connection was unexpectedly lost by TM or HB */ - static void SendOnAppUnregNotificationToHMI( - ApplicationConstSharedPtr app, bool is_unexpected_disconnect = false); + static void SendOnAppUnregNotificationToHMI(ApplicationConstSharedPtr app, bool is_unexpected_disconnect, ApplicationManager &app_mngr); static NsSmartDeviceLink::NsSmartObjects::SmartObjectSPtr GetBCActivateAppRequestToHMI(ApplicationConstSharedPtr app, const protocol_handler::SessionObserver& session_observer, - const policy::PolicyHandlerInterface &policy_handler, + const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority); + bool send_policy_priority, ApplicationManager &app_mngr); - static void SendOnResumeAudioSourceToHMI(const uint32_t app_id); + static void SendOnResumeAudioSourceToHMI(const uint32_t app_id, ApplicationManager &app_mngr); /** * @brief Send SDL_ActivateApp response to HMI * @param permissions response parameters */ - static void SendSDLActivateAppResponse(policy::AppPermissions& permissions, - const uint32_t correlation_id); + 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 */ - static void SendOnSDLConsentNeeded(const policy::DeviceParams& device_info); + static void SendOnSDLConsentNeeded(const policy::DeviceParams& device_info, ApplicationManager& app_man); /** * @brief Send request to SyncP process to read file and send @@ -336,17 +319,17 @@ class MessageHelper { * @param retries Seconds between retries */ static void SendPolicyUpdate(const std::string& file_path, - const int timeout, - const std::vector<int>& retries); + int timeout, + const std::vector<int>& retries, + ApplicationManager &app_mngr); /** * @brief Send GetUserFriendlyMessage response to HMI * @param msg Appopriate messages params * @param correlation_id Correlation id of request */ - static void SendGetUserFriendlyMessageResponse( - const std::vector<policy::UserFriendlyMessage>& msg, - const uint32_t correlation_id); + static void SendGetUserFriendlyMessageResponse(const std::vector<policy::UserFriendlyMessage>& msg, + uint32_t correlation_id, ApplicationManager &app_mngr); /** * @brief Send GetListOfPermissions response to HMI @@ -355,7 +338,8 @@ class MessageHelper { */ static void SendGetListOfPermissionsResponse( const std::vector<policy::FunctionalGroupPermission>& permissions, - const uint32_t correlation_id); + uint32_t correlation_id, + ApplicationManager& app_mngr); /* * @brief Sends notification to HMI to start video streaming @@ -363,7 +347,7 @@ class MessageHelper { * @param connection_key Application connection key * */ - static void SendNaviStartStream(const int32_t app_id); + static void SendNaviStartStream(int32_t app_id, ApplicationManager &app_mngr); /* * @brief Sends notification to HMI to stop video streaming @@ -371,7 +355,7 @@ class MessageHelper { * @param connection_key Application connection key * */ - static void SendNaviStopStream(const int32_t app_id); + static void SendNaviStopStream(int32_t app_id, ApplicationManager &app_mngr); /* * @brief Send notification for Update of Policy Table @@ -381,13 +365,13 @@ class MessageHelper { * @param url If empty string, no URL is provided * @param timeout If -1 no timeout is provdied */ - static void SendPolicySnapshotNotification(const unsigned int connection_key, + static void SendPolicySnapshotNotification(uint32_t connection_key, const std::vector<uint8_t>& policy_data, - const std::string& url = ""); + const std::string& url, + ApplicationManager& app_mngr); - static void SendSystemRequestNotification( - const uint32_t connection_key, - NsSmartDeviceLink::NsSmartObjects::SmartObject*& content); + static void SendSystemRequestNotification(uint32_t connection_key, + NsSmartDeviceLink::NsSmartObjects::SmartObject& content, ApplicationManager &app_mngr); /** * @brief SendLaunchApp allows to send OnSystemRequest with LAUNCH_UP. @@ -400,21 +384,22 @@ class MessageHelper { */ static void SendLaunchApp(const uint32_t connection_key, const std::string& urlSchema, - const std::string& packageName); + const std::string& packageName, + ApplicationManager& app_man); /** * @brief Sends OnSystemRequest which queries remote apps list * @param connection_key application id, which is used for sending out */ - static void SendQueryApps(const uint32_t connection_key); + static void SendQueryApps(const uint32_t connection_key, + 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 */ - static void SendOnPermissionsChangeNotification( - const uint32_t connection_key, const policy::Permissions& permissions); + static void SendOnPermissionsChangeNotification(uint32_t connection_key, const policy::Permissions& permissions, ApplicationManager &app_mngr); /* * @brief Send notification to HMI on application permissions update @@ -422,7 +407,7 @@ class MessageHelper { * @param permissions updated permissions for application */ static void SendOnAppPermissionsChangedNotification( - const uint32_t connection_key, const policy::AppPermissions& permissions); + uint32_t connection_key, const policy::AppPermissions& permissions, ApplicationManager& app_mngr); /** * @brief Send GetStatusUpdate response to HMI with current policy update @@ -431,7 +416,7 @@ class MessageHelper { * @param correlation_id Correlation id from request */ static void SendGetStatusUpdateResponse(const std::string& status, - const uint32_t correlation_id); + const uint32_t correlation_id, ApplicationManager &app_mngr); /** * @brief Send UpdateSDL response to HMI with policy update result @@ -439,18 +424,18 @@ class MessageHelper { * @param correlation_id Correlation id from request */ static void SendUpdateSDLResponse(const std::string& result, - const uint32_t correlation_id); + const uint32_t correlation_id, ApplicationManager &app_mngr); /** * @brief Send OnStatusUpdate to HMI on policy update status change * @param status Policy table update status */ - static void SendOnStatusUpdate(const std::string& status); + static void SendOnStatusUpdate(const std::string& status, ApplicationManager& app_mngr); /** * @brief Send GetSystemInfo request to HMI */ - static void SendGetSystemInfoRequest(); + static void SendGetSystemInfoRequest(ApplicationManager &app_mngr); /* * @brief Sends notification to HMI to start audio streaming @@ -458,7 +443,7 @@ class MessageHelper { * @param connection_key Application connection key * */ - static void SendAudioStartStream(const int32_t app_id); + static void SendAudioStartStream(int32_t app_id, ApplicationManager &app_mngr); /* * @brief Sends notification to HMI to stop audio streaming @@ -466,10 +451,10 @@ class MessageHelper { * @param connection_key Application connection key * */ - static void SendAudioStopStream(const int32_t connection_key); + static void SendAudioStopStream(int32_t connection_key, ApplicationManager &app_mngr); - static void SendOnDataStreaming(const protocol_handler::ServiceType service, - const bool available); + static void SendOnDataStreaming(protocol_handler::ServiceType service, + bool available, ApplicationManager &app_mngr); /* * @brief Sends notification to HMI to stop audioPathThru @@ -478,18 +463,18 @@ class MessageHelper { * * @return TRUE on SUCCES otherwise return FALSE */ - static bool SendStopAudioPathThru(); + static bool SendStopAudioPathThru(ApplicationManager &app_mngr); /** * @brief Sends UnsubscribeWayPoints request * @return true if UnSubscribedWayPoints is send otherwise false */ - static bool SendUnsubscribedWayPoints(); + static bool SendUnsubscribedWayPoints(ApplicationManager& app_mngr); static smart_objects::SmartObjectSPtr CreateNegativeResponse( uint32_t connection_key, int32_t function_id, - uint32_t correlation_id, + const uint32_t correlation_id, int32_t result_code); /* @@ -503,7 +488,9 @@ class MessageHelper { * */ static mobile_apis::Result::eType VerifyImage( - smart_objects::SmartObject& image, ApplicationConstSharedPtr app); + smart_objects::SmartObject& image, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr); /* * @brief Finds "Image" structure in request and verify image file presence @@ -517,10 +504,9 @@ class MessageHelper { * */ static mobile_apis::Result::eType VerifyImageFiles( - smart_objects::SmartObject& message, ApplicationConstSharedPtr app); + smart_objects::SmartObject& message, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); - static mobile_apis::Result::eType VerifyImageVrHelpItems( - smart_objects::SmartObject& message, ApplicationConstSharedPtr app); + static mobile_apis::Result::eType VerifyImageVrHelpItems(smart_objects::SmartObject& message, ApplicationConstSharedPtr app, ApplicationManager &app_mngr); /** * @brief Checks string if it contains incorrect character \t\n \\t \\n @@ -534,7 +520,8 @@ class MessageHelper { static mobile_apis::Result::eType ProcessSoftButtons( smart_objects::SmartObject& message_params, ApplicationConstSharedPtr app, - const policy::PolicyHandlerInterface& policy_handler); + const policy::PolicyHandlerInterface& policy_handler, + ApplicationManager& app_mngr); /* * @brief subscribe application to softbutton @@ -558,7 +545,6 @@ class MessageHelper { } static const uint32_t GetPriorityCode(const std::string& priority); - /** * @brief Convert common language to string representation * @param language Common language @@ -610,7 +596,7 @@ class MessageHelper { * with empty helpPrompt array. */ static void SendTTSGlobalProperties( - ApplicationSharedPtr app, const bool default_help_prompt); + ApplicationSharedPtr app, const bool default_help_prompt, ApplicationManager& app_man); /** * @brief SendSetAppIcon allows to send SetAppIcon request. @@ -619,43 +605,45 @@ class MessageHelper { * * @param icon_path path to the icon. */ - static void SendSetAppIcon(const uint32_t app_id, const std::string& icon_path); - - /** - * @brief Sends DecryptCertificate request to HMI - * @param file_name path to file containing encrypted certificate - */ - static void SendDecryptCertificateToHMI(const std::string& file_name); + static void SendSetAppIcon(const uint32_t app_id, + const std::string& icon_path, + ApplicationManager& application_manager); static hmi_apis::Common_Language::eType CommonLanguageFromString( const std::string& language); + static smart_objects::SmartObjectSPtr + GetOnAppInterfaceUnregisteredNotificationToMobile( + int32_t connection_key, + mobile_api::AppInterfaceUnregisteredReason::eType reason); + private: - /** - * @brief Creates new request object and fill its header - * @return New request object - */ - static smart_objects::SmartObjectSPtr CreateRequestObject(); + /** + * @brief Creates new request object and fill its header + * @return New request object + */ + static smart_objects::SmartObjectSPtr CreateRequestObject(const uint32_t correlation_id); - /** - * @brief Allows to fill SO according to the current permissions. - * @param permissions application permissions. - * @param message which should be filled. - */ - static void FillAppRevokedPermissions( - const policy::AppPermissions& permissions, - smart_objects::SmartObject& message); + /** + * @brief Allows to fill SO according to the current permissions. + * @param permissions application permissions. + * @param message which should be filled. + */ + static void FillAppRevokedPermissions( + const policy::AppPermissions& permissions, + smart_objects::SmartObject& message); static smart_objects::SmartObjectSPtr CreateChangeRegistration( const int32_t function_id, const int32_t language, const uint32_t app_id, - const smart_objects::SmartObject* app_types = NULL); + const smart_objects::SmartObject* app_types, + ApplicationManager& app_mngr); - MessageHelper(); + MessageHelper(); - static const VehicleData vehicle_data_; - DISALLOW_COPY_AND_ASSIGN(MessageHelper); + static const VehicleData vehicle_data_; + DISALLOW_COPY_AND_ASSIGN(MessageHelper); }; } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/mobile_command_factory.h b/src/components/application_manager/include/application_manager/mobile_command_factory.h index 997e973828..f8097a83ef 100644 --- a/src/components/application_manager/include/application_manager/mobile_command_factory.h +++ b/src/components/application_manager/include/application_manager/mobile_command_factory.h @@ -52,8 +52,9 @@ class MobileCommandFactory { * @return Pointer to created command object. **/ static CommandSharedPtr CreateCommand( - const commands::MessageSharedPtr& message, - commands::Command::CommandOrigin origin); + const commands::MessageSharedPtr& message, + commands::Command::CommandOrigin origin, + ApplicationManager& application_manager); private: MobileCommandFactory(); 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 1e713c11d1..259abc6c0f 100644 --- a/src/components/application_manager/include/application_manager/request_controller.h +++ b/src/components/application_manager/include/application_manager/request_controller.h @@ -48,6 +48,7 @@ #include "interfaces/HMI_API.h" #include "application_manager/request_info.h" +#include "application_manager/request_controller_settings.h" namespace application_manager { @@ -86,7 +87,7 @@ class RequestController { * @brief Class constructor * */ - RequestController(); + RequestController(const RequestControlerSettings& settings); /** * @brief Class destructor @@ -284,6 +285,7 @@ class RequestController { timer::Timer timer_; bool is_low_voltage_; + const RequestControlerSettings& settings_; DISALLOW_COPY_AND_ASSIGN(RequestController); }; diff --git a/src/components/application_manager/include/application_manager/state_context.h b/src/components/application_manager/include/application_manager/state_context.h deleted file mode 100644 index 4654eb38b6..0000000000 --- a/src/components/application_manager/include/application_manager/state_context.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2015, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTEXT_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTEXT_H_ - -#include <cstdint> - -namespace application_manager { -/** -* @brief The StateContext implement acessing to data, that is required by HmiState -*/ -class StateContext { - public: - - /** - * @brief is_navi_app check if app is navi - * @param app_id application id - * @return true if app is navi, otherwise return false - */ - bool is_navi_app(const uint32_t app_id) const; - - /** - * @brief is_meida_app check if app is is meida - * @param app_id application id - * @return @return true if meida_app, otherwise return false - */ - bool is_meida_app(const uint32_t app_id) const; - - /** - * @brief is_voice_comunication_app check if app is voice comunication - * @param app_id application id - * @return @return true if voice_comunication_app, otherwise return false - */ - bool is_voice_comunication_app(const uint32_t app_id) const; - - /** - * @brief is_attenuated_supported check if HMI support attenuated mode - * @return true if supported, otherwise return false - */ - bool is_attenuated_supported() const; -}; - -} -#endif // STATE_CONTEXT_H - diff --git a/src/components/application_manager/include/application_manager/state_controller.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index a6cd06247d..e555d50b2f 100644 --- a/src/components/application_manager/include/application_manager/state_controller.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -30,14 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ #include <list> #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/message_helper.h" #include "interfaces/MOBILE_API.h" #include "utils/lock.h" @@ -45,9 +46,10 @@ namespace application_manager { -class StateController : public event_engine::EventObserver { +class StateControllerImpl : public event_engine::EventObserver, + public StateController { public: - explicit StateController(ApplicationManager* app_mngr); + explicit StateControllerImpl(ApplicationManager& app_mngr); /** * @brief SetRegularState setup regular hmi state, that will appear if @@ -55,53 +57,9 @@ class StateController : public event_engine::EventObserver { * @param app appication to setup regular State * @param state state of new regular state */ - template <bool SendActivateApp> - void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateController"); - LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - return; - } - DCHECK_OR_RETURN_VOID(state); - DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); - - if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || - state->audio_streaming_state() == - mobile_apis::AudioStreamingState::INVALID_ENUM || - state->system_context() == mobile_apis::SystemContext::INVALID_ENUM) { - LOG4CXX_ERROR(logger_, "Get invalid state"); - return; - } - if (app->is_resuming() && !IsResumptionAllowed(app, state)) { - return; - } - - HmiStatePtr resolved_state = ResolveHmiState(app, state); - if (!resolved_state) { - state->set_state_id(HmiState::STATE_ID_POSTPONED); - app->SetPostponedState(state); - return; - } - hmi_apis::Common_HMILevel::eType hmi_level = - static_cast<hmi_apis::Common_HMILevel::eType>( - resolved_state->hmi_level()); - - const bool is_full_allowed = hmi_apis::Common_HMILevel::FULL == hmi_level; - - if (SendActivateApp && is_full_allowed) { - int64_t corr_id = SendBCActivateApp(app, hmi_level, true); - if (-1 != corr_id) { - subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, - corr_id); - waiting_for_activate[app->app_id()] = resolved_state; - return; - } - LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); - return; - } - ApplyRegularState(app, resolved_state); - } + virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state, + const bool SendActivateApp); /** * @brief SetRegularState Change regular hmi level and audio state @@ -109,24 +67,12 @@ class StateController : public event_engine::EventObserver { * @param hmi_level of new regular state * @param audio_state of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ - template <bool SendActivateApp> - void SetRegularState( + + virtual void SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, - const mobile_apis::AudioStreamingState::eType audio_state) { - if (!app) { - return; - } - HmiStatePtr prev_regular = app->RegularHmiState(); - DCHECK_OR_RETURN_VOID(prev_regular); - HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(hmi_state); - hmi_state->set_hmi_level(hmi_level); - hmi_state->set_audio_streaming_state(audio_state); - hmi_state->set_system_context(prev_regular->system_context()); - SetRegularState<SendActivateApp>(app, hmi_state); - } + const mobile_apis::AudioStreamingState::eType audio_state, + const bool SendActivateApp); /** * @brief SetRegularState Change regular hmi level @@ -134,23 +80,9 @@ class StateController : public event_engine::EventObserver { * @param hmi_level of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ - template <bool SendActivateApp> - void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level) { - using namespace mobile_apis; - using namespace helpers; - if (!app) { - return; - } - const HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); - - DCHECK_OR_RETURN_VOID(hmi_state); - hmi_state->set_hmi_level(hmi_level); - hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); - hmi_state->set_system_context(SystemContext::SYSCTXT_MAIN); - SetRegularState<SendActivateApp>(app, hmi_state); - } + 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 @@ -160,24 +92,13 @@ class StateController : public event_engine::EventObserver { * @param audio_state of new regular state * @param system_context of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ - template <bool SendActivateApp> - void SetRegularState( + + virtual void SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, - const mobile_apis::SystemContext::eType system_context) { - if (!app) { - return; - } - - HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(hmi_state); - hmi_state->set_hmi_level(hmi_level); - hmi_state->set_audio_streaming_state(audio_state); - hmi_state->set_system_context(system_context); - SetRegularState<SendActivateApp>(app, hmi_state); - } + const mobile_apis::SystemContext::eType system_context, + const bool SendActivateApp); /** * @brief SetRegularState Sets regular state with new hmi level @@ -185,44 +106,17 @@ class StateController : public event_engine::EventObserver { * @param app appication to setup regular state * @param hmi_level new hmi level for application */ - void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level) { - if (!app) { - return; - } - HmiStatePtr prev_state = app->RegularHmiState(); - HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(hmi_state); - hmi_state->set_hmi_level(hmi_level); - hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); - hmi_state->set_system_context( - prev_state ? prev_state->system_context() - : mobile_apis::SystemContext::SYSCTXT_MAIN); - SetRegularState(app, hmi_state); - } + virtual void SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level); /** * @brief SetRegularState Change regular audio state * @param app appication to setup regular State * @param audio_state of new regular state */ - void SetRegularState( + virtual void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::AudioStreamingState::eType audio_state) { - if (!app) { - return; - } - HmiStatePtr prev_state = app->RegularHmiState(); - DCHECK_OR_RETURN_VOID(prev_state); - HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(hmi_state); - hmi_state->set_hmi_level(prev_state->hmi_level()); - hmi_state->set_audio_streaming_state(audio_state); - hmi_state->set_system_context(prev_state->system_context()); - SetRegularState<false>(app, hmi_state); - } + const mobile_apis::AudioStreamingState::eType audio_state); /** * @brief SetRegularState Change regular system context @@ -231,38 +125,14 @@ class StateController : public event_engine::EventObserver { */ virtual void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::SystemContext::eType system_context) { - if (!app) { - return; - } - HmiStatePtr prev_regular = app->RegularHmiState(); - DCHECK_OR_RETURN_VOID(prev_regular); - HmiStatePtr hmi_state = - CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); - DCHECK_OR_RETURN_VOID(hmi_state); - hmi_state->set_hmi_level(prev_regular->hmi_level()); - hmi_state->set_audio_streaming_state( - CalcAudioState(app, prev_regular->hmi_level())); - hmi_state->set_system_context(system_context); - SetRegularState<false>(app, hmi_state); - } + const mobile_apis::SystemContext::eType system_context); /** * @brief SetRegularState Sets new regular state to application * @param app appication to setup regular state * @param state new hmi state for application */ - void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state) { - if (!app) { - return; - } - DCHECK_OR_RETURN_VOID(state); - if (mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { - SetRegularState<true>(app, state); - } else { - SetRegularState<false>(app, state); - } - } + virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state); // EventObserver interface void on_event(const event_engine::Event& event); @@ -293,7 +163,7 @@ class StateController : public event_engine::EventObserver { * @param old_state state before change * @param new_state state after change */ - void OnStateChanged(ApplicationSharedPtr app, + virtual void OnStateChanged(ApplicationSharedPtr app, HmiStatePtr old_state, HmiStatePtr new_state); @@ -302,9 +172,7 @@ class StateController : public event_engine::EventObserver { * @return Returns TRUE if deactivate HMI state is active, otherwise returns * FALSE. */ - bool IsDeactivateHMIStateActive() const; - - bool IsStateActive(HmiState::StateID state_id) const; + virtual bool IsStateActive(HmiState::StateID state_id) const; private: int64_t SendBCActivateApp(ApplicationConstSharedPtr app, @@ -317,22 +185,22 @@ class StateController : public event_engine::EventObserver { struct HmiLevelConflictResolver { ApplicationSharedPtr applied_; HmiStatePtr state_; - StateController* state_ctrl_; + StateControllerImpl* state_ctrl_; HmiLevelConflictResolver(ApplicationSharedPtr app, HmiStatePtr state, - StateController* state_ctrl) + StateControllerImpl* state_ctrl) : applied_(app), state_(state), state_ctrl_(state_ctrl) {} void operator()(ApplicationSharedPtr to_resolve); }; template <typename UnaryFunction> void ForEachApplication(UnaryFunction func) const { - DataAccessor<ApplicationSet> accessor = app_mngr_->applications(); + DataAccessor<ApplicationSet> accessor = app_mngr_.applications(); ApplicationSet::iterator it = accessor.GetData().begin(); for (; it != accessor.GetData().end(); ++it) { ApplicationConstSharedPtr const_app = *it; if (const_app) { - func(app_mngr_->application(const_app->app_id())); + func(app_mngr_.application(const_app->app_id())); } } } @@ -430,13 +298,13 @@ class StateController : public event_engine::EventObserver { } /** - * @brief TempStateStarted add HMI State ID in StateController collection + * @brief TempStateStarted add HMI State ID in StateControllerImpl collection * @param ID state identifier */ void TempStateStarted(HmiState::StateID ID); /** - * @brief TempStateStopped remove HMI State ID from StateController collection + * @brief TempStateStopped remove HMI State ID from StateControllerImpl collection * @param ID state identifier */ void TempStateStopped(HmiState::StateID ID); @@ -541,7 +409,7 @@ class StateController : public event_engine::EventObserver { template <HmiState::StateID ID> void ApplyTempState() { ForEachApplication(std::bind1st( - std::mem_fun(&StateController::HMIStateStarted<ID>), this)); + std::mem_fun(&StateControllerImpl::HMIStateStarted<ID>), this)); TempStateStarted(ID); } @@ -551,17 +419,11 @@ class StateController : public event_engine::EventObserver { template <HmiState::StateID ID> void CancelTempState() { ForEachApplication(std::bind1st( - std::mem_fun(&StateController::HMIStateStopped<ID>), this)); + std::mem_fun(&StateControllerImpl::HMIStateStopped<ID>), this)); TempStateStopped(ID); } /** - * @brief SetAplicationManager setter got app_mngr - * @param app_mngr - */ - void SetAplicationManager(ApplicationManager* app_mngr); - - /** * @brief CreateHmiState creates Hmi state according to state_id * @param app_id application ID * @param state_id state id @@ -577,8 +439,9 @@ class StateController : public event_engine::EventObserver { StateIDList active_states_; mutable sync_primitives::Lock active_states_lock_; std::map<uint32_t, HmiStatePtr> waiting_for_activate; - ApplicationManager* app_mngr_; + ApplicationManager& app_mngr_; }; + } -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index e83f49223d..d9aab44b31 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -80,7 +80,7 @@ InitialApplicationDataImpl::vr_synonyms() const { return vr_synonyms_; } -std::string InitialApplicationDataImpl::mobile_app_id() const { +std::string InitialApplicationDataImpl::policy_app_id() const { return mobile_app_id_; } diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 8800d608d4..9ed9e120f5 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -34,8 +34,8 @@ #include <string> #include <strings.h> #include "application_manager/message_helper.h" -#include "application_manager/application_manager_impl.h" #include "protocol_handler/protocol_handler.h" +#include "application_manager/application_manager.h" #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" @@ -72,13 +72,16 @@ mobile_apis::FileType::eType StringToFileType(const char* str) { } CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") + namespace application_manager { + ApplicationImpl::ApplicationImpl( - uint32_t application_id, - const std::string& mobile_app_id, - const std::string& mac_address, - const custom_str::CustomString& app_name, - utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager) + uint32_t application_id, + const std::string& mobile_app_id, + const std::string& mac_address, + const custom_str::CustomString& app_name, + utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager, + ApplicationManager& application_manager) : grammar_id_(0) , hmi_app_id_(0) , app_id_(application_id) @@ -110,13 +113,13 @@ ApplicationImpl::ApplicationImpl( , video_stream_suspend_timer_( "VideoStreamSuspend", new ::timer::TimerTaskImpl<ApplicationImpl>( - this, - &ApplicationImpl::OnVideoStreamSuspend)) + this, &ApplicationImpl::OnVideoStreamSuspend)) , audio_stream_suspend_timer_( "AudioStreamSuspend", new ::timer::TimerTaskImpl<ApplicationImpl>( - this, - &ApplicationImpl::OnAudioStreamSuspend)) { + this, &ApplicationImpl::OnAudioStreamSuspend)) + , application_manager_(application_manager) { + cmd_number_to_time_limits_[mobile_apis::FunctionID::ReadDIDID] = { date_time::DateTime::getCurrentTime(), 0}; cmd_number_to_time_limits_[mobile_apis::FunctionID::GetVehicleDataID] = { @@ -128,21 +131,18 @@ ApplicationImpl::ApplicationImpl( MarkUnregistered(); // subscribe application to custom button by default SubscribeToButton(mobile_apis::ButtonName::CUSTOM_BUTTON); - // load persistent files LoadPersistentFiles(); - HmiStatePtr initial_state = - ApplicationManagerImpl::instance()->CreateRegularState( + HmiStatePtr initial_state = application_manager_.CreateRegularState( app_id(), mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, mobile_api::SystemContext::SYSCTXT_MAIN); state_.InitState(initial_state); - video_stream_suspend_timeout_ = - profile::Profile::instance()->video_data_stopped_timeout(); + video_stream_suspend_timeout_ = application_manager_.get_settings().video_data_stopped_timeout(); audio_stream_suspend_timeout_ = - profile::Profile::instance()->audio_data_stopped_timeout(); + application_manager_.get_settings().audio_data_stopped_timeout(); } ApplicationImpl::~ApplicationImpl() { @@ -268,7 +268,7 @@ const custom_str::CustomString& ApplicationImpl::name() const { return app_name_; } -void application_manager::ApplicationImpl::set_folder_name( +void ApplicationImpl::set_folder_name( const std::string& folder_name) { folder_name_ = folder_name; } @@ -322,7 +322,7 @@ connection_handler::DeviceHandle ApplicationImpl::device() const { return device_; } -const std::string& ApplicationImpl::mac_address() const{ +const std::string& ApplicationImpl::mac_address() const { return mac_address_; } @@ -399,14 +399,14 @@ void ApplicationImpl::StartStreaming( LOG4CXX_TRACE(logger_, "ServiceType = Video"); if (!video_streaming_approved()) { LOG4CXX_TRACE(logger_, "Video streaming not approved"); - MessageHelper::SendNaviStartStream(app_id()); + MessageHelper::SendNaviStartStream(app_id(), application_manager_); set_video_stream_retry_number(0); } } else if (ServiceType::kAudio == service_type) { LOG4CXX_TRACE(logger_, "ServiceType = Audio"); if (!audio_streaming_approved()) { LOG4CXX_TRACE(logger_, "Audio streaming not approved"); - MessageHelper::SendAudioStartStream(app_id()); + MessageHelper::SendAudioStartStream(app_id(), application_manager_); set_audio_stream_retry_number(0); } } @@ -445,7 +445,7 @@ void ApplicationImpl::StopStreaming( void ApplicationImpl::StopNaviStreaming() { LOG4CXX_AUTO_TRACE(logger_); video_stream_suspend_timer_.Stop(); - MessageHelper::SendNaviStopStream(app_id()); + MessageHelper::SendNaviStopStream(app_id(), application_manager_); set_video_streaming_approved(false); set_video_stream_retry_number(0); } @@ -453,7 +453,7 @@ void ApplicationImpl::StopNaviStreaming() { void ApplicationImpl::StopAudioStreaming() { LOG4CXX_AUTO_TRACE(logger_); audio_stream_suspend_timer_.Stop(); - MessageHelper::SendAudioStopStream(app_id()); + MessageHelper::SendAudioStopStream(app_id(), application_manager_); set_audio_streaming_approved(false); set_audio_stream_retry_number(0); } @@ -465,18 +465,18 @@ void ApplicationImpl::SuspendStreaming( if (ServiceType::kMobileNav == service_type) { video_stream_suspend_timer_.Stop(); - ApplicationManagerImpl::instance()->OnAppStreaming( + application_manager_.OnAppStreaming( app_id(), service_type, false); sync_primitives::AutoLock lock(video_streaming_suspended_lock_); video_streaming_suspended_ = true; } else if (ServiceType::kAudio == service_type) { audio_stream_suspend_timer_.Stop(); - ApplicationManagerImpl::instance()->OnAppStreaming( + application_manager_.OnAppStreaming( app_id(), service_type, false); sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); audio_streaming_suspended_ = true; } - MessageHelper::SendOnDataStreaming(service_type, false); + MessageHelper::SendOnDataStreaming(service_type, false, application_manager_); } void ApplicationImpl::WakeUpStreaming( @@ -487,18 +487,18 @@ void ApplicationImpl::WakeUpStreaming( if (ServiceType::kMobileNav == service_type) { sync_primitives::AutoLock lock(video_streaming_suspended_lock_); if (video_streaming_suspended_) { - ApplicationManagerImpl::instance()->OnAppStreaming( + application_manager_.OnAppStreaming( app_id(), service_type, true); - MessageHelper::SendOnDataStreaming(ServiceType::kMobileNav, true); + MessageHelper::SendOnDataStreaming(ServiceType::kMobileNav, true, application_manager_); video_streaming_suspended_ = false; } video_stream_suspend_timer_.Start(video_stream_suspend_timeout_, false); } else if (ServiceType::kAudio == service_type) { sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { - ApplicationManagerImpl::instance()->OnAppStreaming( + application_manager_.OnAppStreaming( app_id(), service_type, true); - MessageHelper::SendOnDataStreaming(ServiceType::kAudio, true); + MessageHelper::SendOnDataStreaming(ServiceType::kAudio, true, application_manager_); audio_streaming_suspended_ = false; } audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_, false); @@ -713,11 +713,11 @@ bool ApplicationImpl::IsCommandLimitsExceeded( if (mobile_apis::FunctionID::ReadDIDID == cmd_id) { frequency_restrictions = - profile::Profile::instance()->read_did_frequency(); + application_manager_.get_settings().read_did_frequency(); } else if (mobile_apis::FunctionID::GetVehicleDataID == cmd_id) { frequency_restrictions = - profile::Profile::instance()->get_vehicle_data_frequency(); + application_manager_.get_settings().get_vehicle_data_frequency(); } else { LOG4CXX_INFO(logger_, "No restrictions for request"); return false; @@ -756,9 +756,9 @@ bool ApplicationImpl::IsCommandLimitsExceeded( // commands per minute, e.g. 10 command per minute i.e. 1 command per 6 sec case POLICY_TABLE: { const policy::PolicyHandlerInterface& policy_handler = - ApplicationManagerImpl::instance()->GetPolicyHandler(); + application_manager_.GetPolicyHandler(); std::string priority; - policy_handler.GetPriority(mobile_app_id(), &priority); + policy_handler.GetPriority(policy_app_id(), &priority); uint32_t cmd_limit = policy_handler.GetNotificationsNumber(priority); if (0 == cmd_limit) { @@ -822,16 +822,15 @@ void ApplicationImpl::set_is_application_data_changed( void ApplicationImpl::UpdateHash() { LOG4CXX_AUTO_TRACE(logger_); - hash_val_ = utils::gen_hash(profile::Profile::instance()->hash_string_size()); + hash_val_ = utils::gen_hash( application_manager_.get_settings().hash_string_size()); set_is_application_data_changed(true); - MessageHelper::SendHashUpdateNotification(app_id()); + MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); } void ApplicationImpl::CleanupFiles() { - profile::Profile* profile = - profile::Profile::instance(); - std::string directory_name = profile->app_storage_folder(); + std::string directory_name = + application_manager_.get_settings().app_storage_folder(); directory_name += "/" + folder_name(); if (file_system::DirectoryExists(directory_name)) { @@ -860,7 +859,8 @@ void ApplicationImpl::LoadPersistentFiles() { using namespace profile; if (kWaitingForRegistration == app_state_) { - const std::string app_icon_dir(Profile::instance()->app_icons_folder()); + const std::string app_icon_dir( + application_manager_.get_settings().app_icons_folder()); const std::string full_icon_path(app_icon_dir + "/" + mobile_app_id_); if (file_system::FileExists(full_icon_path)) { AppFile file; @@ -873,7 +873,8 @@ void ApplicationImpl::LoadPersistentFiles() { return; } - std::string directory_name = Profile::instance()->app_storage_folder(); + std::string directory_name = + application_manager_.get_settings().app_storage_folder(); directory_name += "/" + folder_name(); if (file_system::DirectoryExists(directory_name)) { @@ -905,6 +906,34 @@ void ApplicationImpl::LoadPersistentFiles() { } } +uint32_t ApplicationImpl::GetAvailableDiskSpace() { + const uint32_t app_quota = application_manager_.get_settings().app_dir_quota(); + std::string app_storage_path = + application_manager_.get_settings().app_storage_folder(); + + app_storage_path += "/"; + app_storage_path += folder_name(); + + if (file_system::DirectoryExists(app_storage_path)) { + size_t size_of_directory = file_system::DirectorySize(app_storage_path); + if (app_quota < size_of_directory) { + return 0; + } + + uint32_t current_app_quota = app_quota - size_of_directory; + uint32_t available_disk_space = + file_system::GetAvailableDiskSpace(app_storage_path); + + if (current_app_quota > available_disk_space) { + return available_disk_space; + } else { + return current_app_quota; + } + } else { + return app_quota; + } +} + void ApplicationImpl::SubscribeToSoftButtons( int32_t cmd_id, const SoftButtonID& softbuttons_id) { sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 6a4192bcd6..378af9ac0a 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -50,7 +50,7 @@ #include "formatters/formatter_json_rpc.h" #include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" -#include "config_profile/profile.h" + #include "utils/threads/thread.h" #include "utils/file_system.h" #include "utils/helpers.h" @@ -83,7 +83,6 @@ DeviceTypes devicesType = { std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)}; } - uint32_t ApplicationManagerImpl::corelation_id_ = 0; const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; @@ -92,8 +91,11 @@ namespace jhs = NsSmartDeviceLink::NsJSONHandler::strings; using namespace NsSmartDeviceLink::NsSmartObjects; -ApplicationManagerImpl::ApplicationManagerImpl() - : applications_list_lock_(true) +ApplicationManagerImpl::ApplicationManagerImpl( + const ApplicationManagerSettings& am_settings, + const policy::PolicySettings& policy_settings) + : settings_(am_settings) + , applications_list_lock_(true) , audio_pass_thru_active_(false) , is_distracting_driver_(false) , is_vr_session_strated_(false) @@ -102,9 +104,9 @@ ApplicationManagerImpl::ApplicationManagerImpl() , media_manager_(NULL) , hmi_handler_(NULL) , connection_handler_(NULL) - , policy_handler_(*profile::Profile::instance()) + , policy_handler_(policy_settings, *this) , protocol_handler_(NULL) - , request_ctrl_() + , request_ctrl_(am_settings) , hmi_so_factory_(NULL) , mobile_so_factory_(NULL) , messages_from_mobile_("AM FromMobile", this) @@ -112,21 +114,18 @@ ApplicationManagerImpl::ApplicationManagerImpl() , messages_from_hmi_("AM FromHMI", this) , messages_to_hmi_("AM ToHMI", this) , audio_pass_thru_messages_("AudioPassThru", this) - , hmi_capabilities_(this) + , hmi_capabilities_(*this) , unregister_reason_( mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM) - , navi_close_app_timeout_( - profile::Profile::instance()->stop_streaming_timeout()) - , navi_end_stream_timeout_( - profile::Profile::instance()->stop_streaming_timeout()) - , stopping_flag_lock_(true) - , state_ctrl_(this) - , + , resume_ctrl_(*this) + , navi_close_app_timeout_(am_settings.stop_streaming_timeout()) + , navi_end_stream_timeout_(am_settings.stop_streaming_timeout()) + , stopping_application_mng_lock_(true) + , state_ctrl_(*this) #ifdef TELEMETRY_MONITOR - metric_observer_(NULL) - , + , metric_observer_(NULL) #endif // TELEMETRY_MONITOR - application_list_update_timer_( + , application_list_update_timer_( "AM ListUpdater", new TimerTaskImpl<ApplicationManagerImpl>( this, @@ -134,11 +133,9 @@ ApplicationManagerImpl::ApplicationManagerImpl() , tts_global_properties_timer_( "AM TTSGLPRTimer", new TimerTaskImpl<ApplicationManagerImpl>( - this, - &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties)) + this, &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties)) , is_low_voltage_(false) , is_stopping_(false) { - std::srand(std::time(0)); AddPolicyObserver(this); @@ -184,63 +181,58 @@ ApplicationManagerImpl::~ApplicationManagerImpl() { navi_app_to_end_stream_.clear(); } -DataAccessor<ApplicationSet> ApplicationManagerImpl::applications() const { - ApplicationListAccessor accessor; - return accessor; +template <class UnaryPredicate> +ApplicationSharedPtr FindApp(DataAccessor<ApplicationSet> accessor, + UnaryPredicate finder) { + ApplicationSet::iterator it = std::find_if( + accessor.GetData().begin(), accessor.GetData().end(), finder); + if (accessor.GetData().end() == it) { + LOG4CXX_DEBUG(logger_, "Unable to find application"); + return ApplicationSharedPtr(); + } + ApplicationSharedPtr app = *it; + LOG4CXX_DEBUG(logger_," Found Application app_id = " << app->app_id()); + return app; } -bool ApplicationManagerImpl::Stop() { - LOG4CXX_AUTO_TRACE(logger_); - stopping_flag_lock_.Acquire(); - is_stopping_ = true; - stopping_flag_lock_.Release(); - application_list_update_timer_.Stop(); - try { - UnregisterAllApplications(); - } catch (...) { - LOG4CXX_ERROR(logger_, - "An error occurred during unregistering applications."); +template <class UnaryPredicate> +std::vector<ApplicationSharedPtr> FindAllApps( + DataAccessor<ApplicationSet> accessor, UnaryPredicate finder) { + std::vector<ApplicationSharedPtr> result; + ApplicationSetConstIt it = std::find_if( + accessor.GetData().begin(), accessor.GetData().end(), finder); + while (it != accessor.GetData().end()) { + result.push_back(*it); + it = std::find_if(++it, accessor.GetData().end(), finder); } - request_ctrl_.DestroyThreadpool(); - - // for PASA customer policy backup should happen :AllApp(SUSPEND) - LOG4CXX_DEBUG(logger_, "Unloading policy library."); - GetPolicyHandler().UnloadPolicyLibrary(); + return result; +} - return true; +DataAccessor<ApplicationSet> ApplicationManagerImpl::applications() const { + DataAccessor<ApplicationSet> accessor(applications_, applications_list_lock_); + return accessor; } ApplicationSharedPtr ApplicationManagerImpl::application( uint32_t app_id) const { AppIdPredicate finder(app_id); - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(finder); - LOG4CXX_DEBUG(logger_, " app_id << " << app_id << "Found = " << app); - return app; + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, finder); } + ApplicationSharedPtr ApplicationManagerImpl::application_by_hmi_app( uint32_t hmi_app_id) const { HmiAppIdPredicate finder(hmi_app_id); - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(finder); - LOG4CXX_DEBUG(logger_, " hmi_app_id << " << hmi_app_id << "Found = " << app); - return app; -} - -connection_handler::ConnectionHandler& -ApplicationManagerImpl::connection_handler() const { - return *connection_handler_; + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, finder); } ApplicationSharedPtr ApplicationManagerImpl::application_by_policy_id( const std::string& policy_app_id) const { - MobileAppIdPredicate finder(policy_app_id); - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(finder); - LOG4CXX_DEBUG(logger_, - " policy_app_id << " << policy_app_id << "Found = " << app); - return app; + PolicyAppIdPredicate finder(policy_app_id); + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, finder); } bool ActiveAppPredicate(const ApplicationSharedPtr app) { @@ -249,10 +241,8 @@ bool ActiveAppPredicate(const ApplicationSharedPtr app) { ApplicationSharedPtr ApplicationManagerImpl::active_application() const { // TODO(DK) : check driver distraction - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(ActiveAppPredicate); - LOG4CXX_DEBUG(logger_, " Found = " << app); - return app; + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, ActiveAppPredicate); } bool LimitedAppPredicate(const ApplicationSharedPtr app) { @@ -261,10 +251,8 @@ bool LimitedAppPredicate(const ApplicationSharedPtr app) { ApplicationSharedPtr ApplicationManagerImpl::get_limited_media_application() const { - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(LimitedAppPredicate); - LOG4CXX_DEBUG(logger_, " Found = " << app); - return app; + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, LimitedAppPredicate); } bool LimitedNaviAppPredicate(const ApplicationSharedPtr app) { @@ -275,10 +263,8 @@ bool LimitedNaviAppPredicate(const ApplicationSharedPtr app) { ApplicationSharedPtr ApplicationManagerImpl::get_limited_navi_application() const { - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(LimitedNaviAppPredicate); - LOG4CXX_DEBUG(logger_, " Found = " << app); - return app; + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, LimitedNaviAppPredicate); } bool LimitedVoiceAppPredicate(const ApplicationSharedPtr app) { @@ -289,10 +275,8 @@ bool LimitedVoiceAppPredicate(const ApplicationSharedPtr app) { ApplicationSharedPtr ApplicationManagerImpl::get_limited_voice_application() const { - ApplicationListAccessor accessor; - ApplicationSharedPtr app = accessor.Find(LimitedVoiceAppPredicate); - LOG4CXX_DEBUG(logger_, " Found = " << app); - return app; + DataAccessor<ApplicationSet> accessor = applications(); + return FindApp(accessor, LimitedVoiceAppPredicate); } bool NaviAppPredicate(const ApplicationSharedPtr app) { @@ -301,21 +285,26 @@ bool NaviAppPredicate(const ApplicationSharedPtr app) { std::vector<ApplicationSharedPtr> ApplicationManagerImpl::applications_with_navi() { - ApplicationListAccessor accessor; - std::vector<ApplicationSharedPtr> apps = accessor.FindAll(NaviAppPredicate); - LOG4CXX_DEBUG(logger_, " Found count: " << apps.size()); - return apps; + DataAccessor<ApplicationSet> accessor = applications(); + return FindAllApps(accessor, NaviAppPredicate); } std::vector<ApplicationSharedPtr> ApplicationManagerImpl::applications_by_button(uint32_t button) { SubscribedToButtonPredicate finder( static_cast<mobile_apis::ButtonName::eType>(button)); - ApplicationListAccessor accessor; - std::vector<ApplicationSharedPtr> apps = accessor.FindAll(finder); - LOG4CXX_DEBUG(logger_, " Found count: " << apps.size()); - return apps; + DataAccessor<ApplicationSet> accessor = applications(); + return FindAllApps(accessor, finder); } +struct SubscribedToIVIPredicate { + int32_t vehicle_info_; + SubscribedToIVIPredicate(int32_t vehicle_info) + : vehicle_info_(vehicle_info) {} + bool operator()(const ApplicationSharedPtr app) const { + return app ? app->IsSubscribedToIVI(vehicle_info_) : false; + } +}; + std::vector<ApplicationSharedPtr> ApplicationManagerImpl::IviInfoUpdated( VehicleDataType vehicle_info, int value) { // Notify Policy Manager if available about info it's interested in, @@ -329,10 +318,8 @@ std::vector<ApplicationSharedPtr> ApplicationManagerImpl::IviInfoUpdated( } SubscribedToIVIPredicate finder(static_cast<int32_t>(vehicle_info)); - ApplicationListAccessor accessor; - std::vector<ApplicationSharedPtr> apps = accessor.FindAll(finder); - LOG4CXX_DEBUG(logger_, " vehicle_info << " << vehicle_info << "Found count: " << apps.size()); - return apps; + DataAccessor<ApplicationSet> accessor = applications(); + return FindAllApps(accessor, finder); } void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { @@ -346,7 +333,7 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { // block all the requests/notifications to mobile // APPLINK-20764 - introduce usage of internal events or re-implement event_engine::Event event( - hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); + hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); smart_objects::SmartObject msg; msg[strings::params][strings::message_type] = @@ -354,7 +341,7 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) { msg[strings::params][strings::app_id] = app->app_id(); event.set_smart_object(msg); - event.raise(); + event.raise(event_dispatcher()); } bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( @@ -406,6 +393,7 @@ bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited( return true; } } + return false; } @@ -434,15 +422,15 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( mobile_apis::FunctionID::RegisterAppInterfaceID, message[strings::params][strings::correlation_id].asUInt(), mobile_apis::Result::GENERIC_ERROR)); - ManageMobileCommand(response); + ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return ApplicationSharedPtr(); } LOG4CXX_DEBUG(logger_, "Restarting application list update timer"); GetPolicyHandler().OnAppsSearchStarted(); uint32_t timeout = - profile::Profile::instance()->application_list_update_timeout(); - application_list_update_timer_.Start(timeout, true); + get_settings().application_list_update_timeout(); + application_list_update_timer_.Start(timeout, false); if (!is_all_apps_allowed_) { LOG4CXX_WARN(logger_, @@ -453,7 +441,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( mobile_apis::FunctionID::RegisterAppInterfaceID, message[strings::params][strings::correlation_id].asUInt(), mobile_apis::Result::DISALLOWED)); - ManageMobileCommand(response); + ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return ApplicationSharedPtr(); } @@ -461,7 +449,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const std::string& policy_app_id = params[strings::app_id].asString(); const custom_str::CustomString& app_name = message[strings::msg_params][strings::app_name].asCustomString(); - std::string device_mac = ""; if (connection_handler().get_session_observer().GetDataOnDeviceID( device_id, NULL, NULL, &device_mac, NULL) == -1) { @@ -470,16 +457,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( LOG4CXX_DEBUG(logger_, "Device mac for id" << device_id << " is " << device_mac); } - LOG4CXX_DEBUG(logger_, - "App with connection key: " << connection_key - << " registered from handle: " - << device_id); - ApplicationSharedPtr application(new ApplicationImpl( - app_id, - policy_app_id, - device_mac, - app_name, - GetPolicyHandler().GetStatisticManager())); + ApplicationSharedPtr application( + new ApplicationImpl(app_id, + policy_app_id, + device_mac, + app_name, + GetPolicyHandler().GetStatisticManager(), + *this)); if (!application) { usage_statistics::AppCounter count_of_rejections_sync_out_of_memory( GetPolicyHandler().GetStatisticManager(), @@ -493,11 +477,12 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( mobile_apis::FunctionID::RegisterAppInterfaceID, message[strings::params][strings::correlation_id].asUInt(), mobile_apis::Result::OUT_OF_MEMORY)); - ManageMobileCommand(response); + ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return ApplicationSharedPtr(); } - application->set_folder_name(policy_app_id + "_" + device_mac); + application->set_folder_name(policy_app_id + "_" + + application->mac_address()); // To load persistent files, app folder name must be known first, which is now // depends on device_id and mobile_app_id application->LoadPersistentFiles(); @@ -520,13 +505,11 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( Version version; int32_t min_version = message[strings::msg_params][strings::sync_msg_version] - [strings::minor_version] - .asInt(); + [strings::minor_version].asInt(); version.min_supported_api_version = static_cast<APIVersion>(min_version); int32_t max_version = message[strings::msg_params][strings::sync_msg_version] - [strings::major_version] - .asInt(); + [strings::major_version].asInt(); version.max_supported_api_version = static_cast<APIVersion>(max_version); application->set_version(version); @@ -538,8 +521,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( connection_handler().BindProtocolVersionWithSession( connection_key, static_cast<uint8_t>(protocol_version)); } - if (protocol_version >= ProtocolVersion::kV3 && - profile::Profile::instance()->heart_beat_timeout() > 0) { + if ((protocol_version == ProtocolVersion::kV3) && + (get_settings().heart_beat_timeout() != 0)) { connection_handler().StartSessionHeartBeat(connection_key); } @@ -564,7 +547,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( // doesn't erase data from resumption storage. // Timer will be started after hmi level resumption. resume_ctrl_.OnAppRegistrationStart(policy_app_id, device_mac); - // Add application to registered app list and set appropriate mark. // Lock has to be released before adding app to policy DB to avoid possible // deadlock with simultaneous PTU processing @@ -574,7 +556,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( applications_list_lock_.Release(); GetPolicyHandler().AddApplication( - application->mobile_app_id()); + application->policy_app_id()); return application; } @@ -598,7 +580,7 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { AudioStreamingState::eType audio_state; app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE : audio_state = AudioStreamingState::NOT_AUDIBLE; - state_ctrl_.SetRegularState<false>(app, hmi_level, audio_state); + state_ctrl_.SetRegularState(app, hmi_level, audio_state, false); return true; } @@ -623,14 +605,13 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed( } else if (is_active_app_exist && (!is_audio_app)) { result = GetDefaultHmiLevel(app); } - LOG4CXX_ERROR(logger_, - "is_audio_app : " << is_audio_app - << "; does_audio_app_with_same_type_exist : " - << does_audio_app_with_same_type_exist - << "; is_active_app_exist : " - << is_active_app_exist - << "; result : " - << result); + LOG4CXX_ERROR( + logger_, + "is_audio_app : " << is_audio_app + << "; does_audio_app_with_same_type_exist : " + << does_audio_app_with_same_type_exist + << "; is_active_app_exist : " << is_active_app_exist + << "; result : " << result); return result; } @@ -654,39 +635,38 @@ void ApplicationManagerImpl::ConnectToDevice(const std::string& device_mac) { void ApplicationManagerImpl::OnHMIStartedCooperation() { LOG4CXX_AUTO_TRACE(logger_); hmi_cooperating_ = true; - MessageHelper::SendGetSystemInfoRequest(); + MessageHelper::SendGetSystemInfoRequest(*this); utils::SharedPtr<smart_objects::SmartObject> is_vr_ready( - MessageHelper::CreateModuleInfoSO( - static_cast<uint32_t>(hmi_apis::FunctionID::VR_IsReady))); + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_IsReady, *this)); ManageHMICommand(is_vr_ready); utils::SharedPtr<smart_objects::SmartObject> is_tts_ready( - MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_IsReady)); + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::TTS_IsReady, *this)); ManageHMICommand(is_tts_ready); utils::SharedPtr<smart_objects::SmartObject> is_ui_ready( - MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_IsReady)); + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::UI_IsReady, *this)); ManageHMICommand(is_ui_ready); utils::SharedPtr<smart_objects::SmartObject> is_navi_ready( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::Navigation_IsReady)); + hmi_apis::FunctionID::Navigation_IsReady, *this)); ManageHMICommand(is_navi_ready); utils::SharedPtr<smart_objects::SmartObject> is_ivi_ready( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VehicleInfo_IsReady)); + hmi_apis::FunctionID::VehicleInfo_IsReady, *this)); ManageHMICommand(is_ivi_ready); utils::SharedPtr<smart_objects::SmartObject> button_capabilities( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::Buttons_GetCapabilities)); + hmi_apis::FunctionID::Buttons_GetCapabilities, *this)); ManageHMICommand(button_capabilities); utils::SharedPtr<smart_objects::SmartObject> mixing_audio_supported_request( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::BasicCommunication_MixingAudioSupported)); + hmi_apis::FunctionID::BasicCommunication_MixingAudioSupported, *this)); ManageHMICommand(mixing_audio_supported_request); resume_controller().ResetLaunchTime(); } @@ -701,7 +681,7 @@ uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { return corelation_id_; } -bool ApplicationManagerImpl::begin_audio_pass_thru() { +bool ApplicationManagerImpl::BeginAudioPassThrough() { sync_primitives::AutoLock lock(audio_pass_thru_lock_); if (audio_pass_thru_active_) { return false; @@ -711,7 +691,7 @@ bool ApplicationManagerImpl::begin_audio_pass_thru() { } } -bool ApplicationManagerImpl::end_audio_pass_thru() { +bool ApplicationManagerImpl::EndAudioPassThrough() { sync_primitives::AutoLock lock(audio_pass_thru_lock_); if (audio_pass_thru_active_) { audio_pass_thru_active_ = false; @@ -729,7 +709,7 @@ void ApplicationManagerImpl::set_vr_session_started(const bool& state) { is_vr_session_strated_ = state; } -void ApplicationManagerImpl::set_all_apps_allowed(const bool& allowed) { +void ApplicationManagerImpl::SetAllAppsAllowed(const bool& allowed) { is_all_apps_allowed_ = allowed; } @@ -738,7 +718,7 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, mobile_apis::SystemContext::eType system_context) const { - HmiStatePtr state(new HmiState(app_id, ApplicationManagerImpl::instance())); + HmiStatePtr state(new HmiState(app_id, *this)); state->set_hmi_level(hmi_level); state->set_audio_streaming_state(audio_state); state->set_system_context(system_context); @@ -762,7 +742,7 @@ void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key, DCHECK_OR_RETURN_VOID(media_manager_); media_manager_->StartMicrophoneRecording( session_key, - profile::Profile::instance()->recording_file_name(), + get_settings().recording_file_name(), max_duration); } @@ -795,7 +775,7 @@ std::string ApplicationManagerImpl::GetDeviceName( DCHECK(connection_handler_); std::string device_name = ""; if (connection_handler().get_session_observer().GetDataOnDeviceID( - handle, &device_name, NULL, NULL, NULL) == -1) { + handle, &device_name, NULL, NULL, NULL) == -1) { LOG4CXX_ERROR(logger_, "Failed to extract device name for id " << handle); } else { LOG4CXX_DEBUG(logger_, "\t\t\t\t\tDevice name is " << device_name); @@ -833,6 +813,7 @@ void ApplicationManagerImpl::OnMessageReceived( utils::SharedPtr<Message> outgoing_message = ConvertRawMsgToMessage(message); if (outgoing_message) { + LOG4CXX_DEBUG(logger_, "Posting new Message"); messages_from_mobile_.PostMessage( impl::MessageFromMobile(outgoing_message)); } @@ -856,28 +837,6 @@ void ApplicationManagerImpl::OnMessageReceived( messages_from_hmi_.PostMessage(impl::MessageFromHmi(message)); } -ApplicationConstSharedPtr ApplicationManagerImpl::waiting_app( - const uint32_t hmi_id) const { - AppsWaitRegistrationSet app_list = apps_waiting_for_registration().GetData(); - - AppsWaitRegistrationSet::const_iterator it_end = app_list.end(); - - HmiAppIdPredicate finder(hmi_id); - ApplicationSharedPtr result; - ApplicationSetConstIt it_app = std::find_if(app_list.begin(), it_end, finder); - if (it_app != it_end) { - result = *it_app; - } - return result; -} - -DataAccessor<ApplicationManagerImpl::AppsWaitRegistrationSet> -ApplicationManagerImpl::apps_waiting_for_registration() const { - return DataAccessor<AppsWaitRegistrationSet>( - ApplicationManagerImpl::instance()->apps_to_register_, - ApplicationManagerImpl::instance()->apps_to_register_list_lock_); -} - bool ApplicationManagerImpl::IsAppsQueriedFrom( const connection_handler::DeviceHandle handle) const { sync_primitives::AutoLock lock(apps_to_register_list_lock_); @@ -891,6 +850,14 @@ bool ApplicationManagerImpl::IsAppsQueriedFrom( return false; } +StateController& ApplicationManagerImpl::state_controller() { + return state_ctrl_; +} + +const ApplicationManagerSettings& ApplicationManagerImpl::get_settings() const { + return settings_; +} + void application_manager::ApplicationManagerImpl::MarkAppsGreyOut( const connection_handler::DeviceHandle handle, bool is_greyed_out) { sync_primitives::AutoLock lock(apps_to_register_list_lock_); @@ -916,11 +883,11 @@ void ApplicationManagerImpl::OnDeviceListUpdated( for (; device_list.end() != it; ++it) { policy::DeviceParams dev_params; connection_handler().get_session_observer().GetDataOnDeviceID( - it->second.device_handle(), - &dev_params.device_name, - NULL, - &dev_params.device_mac_address, - &dev_params.device_connection_type); + it->second.device_handle(), + &dev_params.device_name, + NULL, + &dev_params.device_mac_address, + &dev_params.device_connection_type); policy::DeviceInfo device_info; device_info.AdoptDeviceType(dev_params.device_connection_type); @@ -930,7 +897,7 @@ void ApplicationManagerImpl::OnDeviceListUpdated( } smart_objects::SmartObjectSPtr msg_params = - MessageHelper::CreateDeviceListSO(device_list, GetPolicyHandler()); + MessageHelper::CreateDeviceListSO(device_list, GetPolicyHandler(), *this); if (!msg_params) { LOG4CXX_WARN(logger_, "Failed to create sub-smart object."); return; @@ -953,8 +920,8 @@ void ApplicationManagerImpl::OnFindNewApplicationsRequest() { connection_handler().ConnectToAllDevices(); LOG4CXX_DEBUG(logger_, "Starting application list update timer"); uint32_t timeout = - profile::Profile::instance()->application_list_update_timeout(); - application_list_update_timer_.Start(timeout, true); + get_settings().application_list_update_timeout(); + application_list_update_timer_.Start(timeout, false); GetPolicyHandler().OnAppsSearchStarted(); } @@ -965,7 +932,7 @@ void ApplicationManagerImpl::SendUpdateAppList() { using namespace hmi_apis; SmartObjectSPtr request = MessageHelper::CreateModuleInfoSO( - FunctionID::BasicCommunication_UpdateAppList); + FunctionID::BasicCommunication_UpdateAppList, *this); (*request)[strings::msg_params][strings::applications] = SmartObject(SmartType_Array); @@ -973,8 +940,8 @@ void ApplicationManagerImpl::SendUpdateAppList() { SmartObject& applications = (*request)[strings::msg_params][strings::applications]; - PrepareApplicationListSO(applications_, applications); - PrepareApplicationListSO(apps_to_register_, applications); + PrepareApplicationListSO(applications_, applications, *this); + PrepareApplicationListSO(apps_to_register_, applications, *this); ManageHMICommand(request); } @@ -991,7 +958,7 @@ mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel( HMILevel::eType default_hmi = HMILevel::HMI_NONE; if (policy_handler_.PolicyEnabled()) { - const std::string policy_app_id = application->mobile_app_id(); + const std::string policy_app_id = application->policy_app_id(); std::string default_hmi_string = ""; if (policy_handler_.GetDefaultHmi(policy_app_id, &default_hmi_string)) { @@ -1021,7 +988,7 @@ uint32_t ApplicationManagerImpl::GenerateGrammarID() { } uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() { - LOG4CXX_TRACE(logger_, "ENTER"); + LOG4CXX_AUTO_TRACE(logger_); uint32_t hmi_app_id = get_rand_from_range(1); LOG4CXX_DEBUG(logger_, "GenerateNewHMIAppID value is: " << hmi_app_id); @@ -1031,7 +998,6 @@ uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() { LOG4CXX_DEBUG(logger_, "Trying new value: " << hmi_app_id); } - LOG4CXX_TRACE(logger_, "EXIT"); return hmi_app_id; } @@ -1039,16 +1005,15 @@ void ApplicationManagerImpl::ReplaceMobileByHMIAppId( smart_objects::SmartObject& message) { MessageHelper::PrintSmartObject(message); if (message.keyExists(strings::app_id)) { - ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application( + ApplicationSharedPtr application_ptr = application( message[strings::app_id].asUInt()); - if (application.valid()) { + if (application_ptr.valid()) { LOG4CXX_DEBUG(logger_, "ReplaceMobileByHMIAppId from " << message[strings::app_id].asInt() << " to " - << application->hmi_app_id()); - message[strings::app_id] = application->hmi_app_id(); + << application_ptr->hmi_app_id()); + message[strings::app_id] = application_ptr->hmi_app_id(); } } else { switch (message.getType()) { @@ -1077,8 +1042,7 @@ void ApplicationManagerImpl::ReplaceMobileByHMIAppId( void ApplicationManagerImpl::ReplaceHMIByMobileAppId( smart_objects::SmartObject& message) { if (message.keyExists(strings::app_id)) { - ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application_by_hmi_app( + ApplicationSharedPtr application = application_by_hmi_app( message[strings::app_id].asUInt()); if (application.valid()) { @@ -1122,7 +1086,7 @@ bool ApplicationManagerImpl::StartNaviService( if (navi_service_status_.end() == it) { std::pair<NaviServiceStatusMap::iterator, bool> res = navi_service_status_.insert( - std::pair<uint32_t, std::pair<bool, bool>>( + std::pair<uint32_t, std::pair<bool, bool> >( app_id, std::make_pair(false, false))); if (!res.second) { LOG4CXX_WARN(logger_, "Navi service refused"); @@ -1165,6 +1129,7 @@ void ApplicationManagerImpl::StopNaviService( LOG4CXX_WARN(logger_, "An application is not registered."); return; } + app->StopStreaming(service_type); } @@ -1185,9 +1150,9 @@ bool ApplicationManagerImpl::OnServiceStartedCallback( } ApplicationSharedPtr app = application(session_key); if (!app) { - LOG4CXX_DEBUG(logger_, - "The application with id:" << session_key - << " doesn't exists."); + LOG4CXX_WARN(logger_, + "The application with id:" << session_key + << " doesn't exists."); return false; } @@ -1199,7 +1164,7 @@ bool ApplicationManagerImpl::OnServiceStartedCallback( LOG4CXX_WARN(logger_, "Refuse not navi application"); } } else { - LOG4CXX_WARN(logger_, "Refuse unknows service"); + LOG4CXX_WARN(logger_, "Refuse unknown service"); } return false; } @@ -1210,16 +1175,13 @@ void ApplicationManagerImpl::OnServiceEndedCallback( const connection_handler::CloseSessionReason& close_reason) { using namespace helpers; using namespace protocol_handler; - using namespace mobile_apis; using namespace connection_handler; using namespace mobile_apis; LOG4CXX_DEBUG(logger_, - "OnServiceEndedCallback for service " << type << " with reason " - << close_reason - << " in session 0x" - << std::hex - << session_key); + "OnServiceEndedCallback for service " + << type << " with reason " << close_reason + << " in session 0x" << std::hex << session_key); if (type == kRpc) { LOG4CXX_INFO(logger_, "Remove application."); @@ -1239,13 +1201,13 @@ void ApplicationManagerImpl::OnServiceEndedCallback( is_resuming = true; is_unexpected_disconnect = false; - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - session_key, AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS); + ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + session_key, AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS), commands::Command::ORIGIN_SDL); break; } case CloseSessionReason::kMalformed: { reason = Result::INVALID_ENUM; - is_resuming = true; + is_resuming = false; is_unexpected_disconnect = false; break; } @@ -1307,7 +1269,7 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const { ApplicationConstSharedPtr app = application(key); security_manager::SSLContext::HandshakeContext res; DCHECK_OR_RETURN(app.valid(), res); - return res.make_context(custom_str::CustomString(app->mobile_app_id()), + return res.make_context(custom_str::CustomString(app->policy_app_id()), app->name()); } #endif // ENABLE_SECURITY @@ -1322,6 +1284,15 @@ void ApplicationManagerImpl::set_connection_handler( connection_handler_ = handler; } +connection_handler::ConnectionHandler& +ApplicationManagerImpl::connection_handler() const { + return *connection_handler_; +} + +protocol_handler::ProtocolHandler& ApplicationManagerImpl::protocol_handler() const { + return *protocol_handler_; +} + void ApplicationManagerImpl::set_protocol_handler( protocol_handler::ProtocolHandler* handler) { protocol_handler_ = handler; @@ -1366,8 +1337,9 @@ void ApplicationManagerImpl::SendMessageToMobile( } mobile_so_factory().attachSchema(*message, false); - LOG4CXX_INFO(logger_, "Attached schema to message, result if valid: " - << message->isValid()); + LOG4CXX_DEBUG( + logger_, + "Attached schema to message, result if valid: " << message->isValid()); // Messages to mobile are not yet prioritized so use default priority value utils::SharedPtr<Message> message_to_send( @@ -1403,7 +1375,7 @@ void ApplicationManagerImpl::SendMessageToMobile( } } const mobile_apis::Result::eType check_result = CheckPolicyPermissions( - app->mobile_app_id(), app->hmi_level(), function_id, params); + app->policy_app_id(), app->hmi_level(), function_id, params); if (mobile_apis::Result::SUCCESS != check_result) { const std::string string_functionID = MessageHelper::StringifiedFunctionID(function_id); @@ -1458,7 +1430,7 @@ bool ApplicationManagerImpl::ManageMobileCommand( LOG4CXX_DEBUG(logger_, "Trying to create message in mobile factory."); utils::SharedPtr<commands::Command> command( - MobileCommandFactory::CreateCommand(message, origin)); + MobileCommandFactory::CreateCommand(message, origin, *this)); if (!command) { LOG4CXX_WARN(logger_, @@ -1489,7 +1461,7 @@ bool ApplicationManagerImpl::ManageMobileCommand( if (((mobile_apis::FunctionID::RegisterAppInterfaceID != function_id) && (protocol_type == commands::CommandImpl::mobile_protocol_type_)) && (mobile_apis::FunctionID::UnregisterAppInterfaceID != function_id)) { - app = ApplicationManagerImpl::instance()->application(connection_key); + app = application(connection_key); if (!app) { LOG4CXX_ERROR(logger_, "RET APPLICATION_NOT_REGISTERED"); smart_objects::SmartObjectSPtr response = @@ -1555,6 +1527,10 @@ bool ApplicationManagerImpl::ManageMobileCommand( correlation_id, static_cast<int32_t>( mobile_apis::Result::TOO_MANY_PENDING_REQUESTS)); + ApplicationSharedPtr app_ptr = application(connection_key); + if (app_ptr) { + app_ptr->usage_report().RecordRemovalsForBadBehavior(); + } SendMessageToMobile(response); return false; @@ -1564,14 +1540,17 @@ bool ApplicationManagerImpl::ManageMobileCommand( "RET Unable to perform request: " << "TOO_MANY_REQUESTS"); - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( connection_key, - mobile_api::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS); + mobile_api::AppInterfaceUnregisteredReason::TOO_MANY_REQUESTS), commands::Command::ORIGIN_SDL); UnregisterApplication(connection_key, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS, false); - + ApplicationSharedPtr app_ptr = application(connection_key); + if (app_ptr) { + app_ptr->usage_report().RecordRemovalsForBadBehavior(); + } return false; } else if (result == request_controller::RequestController:: NONE_HMI_LEVEL_MANY_REQUESTS) { @@ -1579,10 +1558,10 @@ bool ApplicationManagerImpl::ManageMobileCommand( "RET Unable to perform request: " << "REQUEST_WHILE_IN_NONE_HMI_LEVEL"); - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( + ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( connection_key, mobile_api::AppInterfaceUnregisteredReason:: - REQUEST_WHILE_IN_NONE_HMI_LEVEL); + REQUEST_WHILE_IN_NONE_HMI_LEVEL), commands::Command::ORIGIN_SDL); ApplicationSharedPtr app_ptr = application(connection_key); if (app_ptr) { @@ -1626,8 +1605,9 @@ void ApplicationManagerImpl::SendMessageToHMI( } hmi_so_factory().attachSchema(*message, false); - LOG4CXX_INFO(logger_, "Attached schema to message, result if valid: " - << message->isValid()); + LOG4CXX_INFO( + logger_, + "Attached schema to message, result if valid: " << message->isValid()); #ifdef HMI_DBUS_API message_to_send->set_smart_object(*message); @@ -1658,7 +1638,7 @@ bool ApplicationManagerImpl::ManageHMICommand( MessageHelper::PrintSmartObject(*message); - CommandSharedPtr command = HMICommandFactory::CreateCommand(message); + CommandSharedPtr command = HMICommandFactory::CreateCommand(message, *this); if (!command) { LOG4CXX_WARN(logger_, "Failed to create command from smart object"); return false; @@ -1667,17 +1647,16 @@ bool ApplicationManagerImpl::ManageHMICommand( int32_t message_type = (*(message.get()))[strings::params][strings::message_type].asInt(); - // Init before adding to request controller to be able to set request timeout - if (command->Init()) { - if (kRequest == message_type) { - LOG4CXX_DEBUG(logger_, "ManageHMICommand"); - request_ctrl_.addHMIRequest(command); - } + if (kRequest == message_type) { + LOG4CXX_DEBUG(logger_, "ManageHMICommand"); + request_ctrl_.addHMIRequest(command); + } + if (command->Init()) { command->Run(); if (kResponse == message_type) { const uint32_t correlation_id = - (*(message.get()))[strings::params][strings::correlation_id].asUInt(); + (*(message.get()))[strings::params][strings::correlation_id].asInt(); request_ctrl_.OnHMIResponse(correlation_id); } return true; @@ -1689,13 +1668,14 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, media_manager::MediaManager* media_manager) { LOG4CXX_TRACE(logger_, "Init application manager"); const std::string app_storage_folder = - profile::Profile::instance()->app_storage_folder(); + get_settings().app_storage_folder(); if (!InitDirectory(app_storage_folder, TYPE_STORAGE) || !IsReadWriteAllowed(app_storage_folder, TYPE_STORAGE)) { return false; } if (!resume_ctrl_.Init(last_state)) { LOG4CXX_ERROR(logger_, "Problem with initialization of resume controller"); + return false; } hmi_capabilities_.Init(&last_state); @@ -1707,13 +1687,13 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, } const std::string system_files_path = - profile::Profile::instance()->system_files_path(); + get_settings().system_files_path(); if (!InitDirectory(system_files_path, TYPE_SYSTEM) || !IsReadWriteAllowed(system_files_path, TYPE_SYSTEM)) { return false; } const std::string app_icons_folder = - profile::Profile::instance()->app_icons_folder(); + get_settings().app_icons_folder(); if (!InitDirectory(app_icons_folder, TYPE_ICONS)) { return false; } @@ -1739,12 +1719,33 @@ bool ApplicationManagerImpl::Init(resumption::LastState& last_state, return true; } +bool ApplicationManagerImpl::Stop() { + LOG4CXX_AUTO_TRACE(logger_); + stopping_application_mng_lock_.Acquire(); + is_stopping_ = true; + stopping_application_mng_lock_.Release(); + application_list_update_timer_.Stop(); + try { + UnregisterAllApplications(); + } catch (...) { + LOG4CXX_ERROR(logger_, + "An error occurred during unregistering applications."); + } + request_ctrl_.DestroyThreadpool(); + + // for PASA customer policy backup should happen :AllApp(SUSPEND) + LOG4CXX_DEBUG(logger_, "Unloading policy library."); + GetPolicyHandler().UnloadPolicyLibrary(); + + return true; +} + bool ApplicationManagerImpl::ConvertMessageToSO( const Message& message, smart_objects::SmartObject& output) { + LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "\t\t\tMessage to convert: protocol " - << message.protocol_version() - << "; json " + << message.protocol_version() << "; json " << message.json_message()); switch (message.protocol_version()) { @@ -1758,7 +1759,8 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.function_id(), message.type(), message.correlation_id()); - if (!conversion_result || !mobile_so_factory().attachSchema(output, false) || + if (!conversion_result || + !mobile_so_factory().attachSchema(output, true) || ((output.validate() != smart_objects::Errors::OK))) { LOG4CXX_WARN(logger_, "Failed to parse string to smart object :" @@ -1769,13 +1771,13 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.function_id(), message.correlation_id(), mobile_apis::Result::INVALID_DATA)); - ManageMobileCommand(response); + ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return false; } LOG4CXX_DEBUG(logger_, - "Convertion result for sdl object is true" - << " function_id " + "Convertion result for sdl object is true function_id " << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + output[strings::params][strings::connection_key] = message.connection_key(); output[strings::params][strings::protocol_version] = @@ -1784,8 +1786,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( if (message.payload_size() < message.data_size()) { LOG4CXX_ERROR(logger_, "Incomplete binary" - << " binary size should be " - << message.data_size() + << " binary size should be " << message.data_size() << " payload data size is " << message.payload_size()); utils::SharedPtr<smart_objects::SmartObject> response( @@ -1794,7 +1795,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( message.function_id(), message.correlation_id(), mobile_apis::Result::INVALID_DATA)); - ManageMobileCommand(response); + ManageMobileCommand(response, commands::Command::ORIGIN_SDL); return false; } output[strings::params][strings::binary_data] = @@ -1806,13 +1807,13 @@ bool ApplicationManagerImpl::ConvertMessageToSO( #ifdef ENABLE_LOG int32_t result = #endif - formatters::FormatterJsonRpc::FromString< - hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>( - message.json_message(), output); - LOG4CXX_INFO(logger_, - "Convertion result: " - << result << " function id " - << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + formatters::FormatterJsonRpc::FromString< + hmi_apis::FunctionID::eType, + hmi_apis::messageType::eType>(message.json_message(), output); + LOG4CXX_DEBUG(logger_, + "Convertion result: " + << result << " function id " + << output[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); if (!hmi_so_factory().attachSchema(output, false)) { LOG4CXX_WARN(logger_, "Failed to attach schema to object."); return false; @@ -1868,14 +1869,13 @@ bool ApplicationManagerImpl::ConvertMessageToSO( output[strings::msg_params][strings::result_code] = NsSmartDeviceLinkRPC::V1::Result::UNSUPPORTED_VERSION; - smart_objects::SmartObjectSPtr msg_to_send = + smart_objects::SmartObjectSPtr msg_to_send = new smart_objects::SmartObject(output); v1_shema.attachSchema(*msg_to_send, false); SendMessageToMobile(msg_to_send); return false; } } - break; } default: @@ -1883,8 +1883,7 @@ bool ApplicationManagerImpl::ConvertMessageToSO( // removed NOTREACHED() because some app can still have vesion 1. LOG4CXX_WARN(logger_, "Application used unsupported protocol :" - << message.protocol_version() - << "."); + << message.protocol_version() << "."); return false; } @@ -1909,12 +1908,12 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( .asInt()); std::string output_string; - const int64_t protocol_type = message.getElement(jhs::S_PARAMS) - .getElement(jhs::S_PROTOCOL_TYPE) - .asInt(); - const int64_t protocol_version = message.getElement(jhs::S_PARAMS) - .getElement(jhs::S_PROTOCOL_VERSION) - .asInt(); + const int64_t protocol_type = message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_PROTOCOL_TYPE) + .asInt(); + const int64_t protocol_version = message.getElement(jhs::S_PARAMS) + .getElement(jhs::S_PROTOCOL_VERSION) + .asInt(); switch (protocol_type) { case 0: { if (protocol_version == 1) { @@ -1930,9 +1929,10 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( LOG4CXX_WARN(logger_, "Failed to serialize smart object"); return false; } - output.set_protocol_version(static_cast<ProtocolVersion>( - protocol_version)); + output.set_protocol_version( + static_cast<ProtocolVersion>(protocol_version)); } + break; } case 1: { @@ -1994,11 +1994,11 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( utils::SharedPtr<Message> ApplicationManagerImpl::ConvertRawMsgToMessage( const ::protocol_handler::RawMessagePtr message) { + LOG4CXX_AUTO_TRACE(logger_); DCHECK(message); utils::SharedPtr<Message> outgoing_message; LOG4CXX_DEBUG(logger_, "Service type." << message->service_type()); - if (message->service_type() != protocol_handler::kRpc && message->service_type() != protocol_handler::kBulk) { // skip this message, not under handling of ApplicationManager @@ -2025,8 +2025,10 @@ void ApplicationManagerImpl::ProcessMessageFromMobile( new AMTelemetryObserver::MessageMetric()); metric->begin = date_time::DateTime::getCurrentTime(); #endif // TELEMETRY_MONITOR - smart_objects::SmartObjectSPtr so_from_mobile(new smart_objects::SmartObject); + smart_objects::SmartObjectSPtr so_from_mobile = + utils::MakeShared<smart_objects::SmartObject>(); + DCHECK_OR_RETURN_VOID(so_from_mobile); if (!so_from_mobile) { LOG4CXX_ERROR(logger_, "Null pointer"); return; @@ -2102,6 +2104,10 @@ HMICapabilities& ApplicationManagerImpl::hmi_capabilities() { return hmi_capabilities_; } +const HMICapabilities& ApplicationManagerImpl::hmi_capabilities() const { + return hmi_capabilities_; +} + void ApplicationManagerImpl::PullLanguagesInfo(const SmartObject& app_data, SmartObject& ttsName, SmartObject& vrSynonym) { @@ -2163,7 +2169,6 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, const uint32_t connection_key) { LOG4CXX_AUTO_TRACE(logger_); using namespace policy; - using namespace profile; const std::size_t arr_size(obj_array.size()); for (std::size_t idx = 0; idx < arr_size; ++idx) { @@ -2175,8 +2180,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, } const std::string policy_app_id(app_data[json::appId].asString()); - ApplicationSharedPtr registered_app = - ApplicationManagerImpl::instance()->application_by_policy_id( + ApplicationSharedPtr registered_app = application_by_policy_id( policy_app_id); if (registered_app) { LOG4CXX_DEBUG( @@ -2213,7 +2217,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, vrSynonym[0] = appName; } - const std::string app_icon_dir(Profile::instance()->app_icons_folder()); + const std::string app_icon_dir(settings_.app_icons_folder()); const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); uint32_t device_id = 0; @@ -2244,7 +2248,8 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array, policy_app_id, device_mac, appName, - GetPolicyHandler().GetStatisticManager())); + GetPolicyHandler().GetStatisticManager(), + *this)); DCHECK_OR_RETURN_VOID(app); app->SetShemaUrl(url_scheme); app->SetPackageName(package_name); @@ -2284,19 +2289,20 @@ void ApplicationManagerImpl::ProcessQueryApp( for (; it != apps_to_register_.end(); ++it) { const std::string full_icon_path((*it)->app_icon_path()); if (file_system::FileExists(full_icon_path)) { - MessageHelper::SendSetAppIcon((*it)->hmi_app_id(), full_icon_path); + MessageHelper::SendSetAppIcon((*it)->hmi_app_id(), full_icon_path, *this); } } } } -bool ApplicationManagerImpl::is_attenuated_supported() { +bool ApplicationManagerImpl::is_attenuated_supported() const { return hmi_capabilities().attenuated_supported() && - profile::Profile::instance()->is_mixing_audio_supported(); + get_settings().is_mixing_audio_supported(); } #ifdef TELEMETRY_MONITOR -void ApplicationManagerImpl::SetTelemetryObserver(AMTelemetryObserver* observer) { +void ApplicationManagerImpl::SetTelemetryObserver( + AMTelemetryObserver* observer) { metric_observer_ = observer; } #endif // TELEMETRY_MONITOR @@ -2319,7 +2325,7 @@ void ApplicationManagerImpl::updateRequestTimeout( connection_key, mobile_correlation_id, new_timeout_value); } -const uint32_t ApplicationManagerImpl::application_id( +uint32_t ApplicationManagerImpl::application_id( const int32_t correlation_id) { // ykazakov: there is no erase for const iterator for QNX std::map<const int32_t, const uint32_t>::iterator it = @@ -2357,9 +2363,9 @@ void ApplicationManagerImpl::SetUnregisterAllApplicationsReason( void ApplicationManagerImpl::HeadUnitReset( mobile_api::AppInterfaceUnregisteredReason::eType reason) { - stopping_flag_lock_.Acquire(); + stopping_application_mng_lock_.Acquire(); is_stopping_ = true; - stopping_flag_lock_.Release(); + stopping_application_mng_lock_.Release(); switch (reason) { case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET: { UnregisterAllApplications(); @@ -2368,7 +2374,7 @@ void ApplicationManagerImpl::HeadUnitReset( resume_controller().StopSavePersistentDataTimer(); file_system::remove_directory_content( - profile::Profile::instance()->app_storage_folder()); + get_settings().app_storage_folder()); break; } case mobile_api::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS: { @@ -2376,7 +2382,7 @@ void ApplicationManagerImpl::HeadUnitReset( resume_controller().StopSavePersistentDataTimer(); file_system::remove_directory_content( - profile::Profile::instance()->app_storage_folder()); + get_settings().app_storage_folder()); break; } default: { @@ -2412,8 +2418,9 @@ void ApplicationManagerImpl::SendOnSDLClose() { new Message(protocol_handler::MessagePriority::kDefault)); hmi_so_factory().attachSchema(*msg, false); - LOG4CXX_DEBUG(logger_, - "Attached schema to message, result if valid: " << msg->isValid()); + LOG4CXX_DEBUG( + logger_, + "Attached schema to message, result if valid: " << msg->isValid()); #ifdef HMI_DBUS_API message_to_send->set_smart_object(*msg); @@ -2450,19 +2457,19 @@ void ApplicationManagerImpl::UnregisterAllApplications() { ClearTTSGlobalPropertiesList(); { // A local scope to limit accessor's lifetime and release app list lock. - ApplicationListAccessor accessor; - ApplicationSetConstIt it = accessor.begin(); - while (it != accessor.end()) { + DataAccessor<ApplicationSet> accessor = applications(); + ApplicationSetConstIt it = accessor.GetData().begin(); + while (it != accessor.GetData().end()) { ApplicationSharedPtr app_to_remove = *it; - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - app_to_remove->app_id(), unregister_reason_); + ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_to_remove->app_id(), unregister_reason_), commands::Command::ORIGIN_SDL); UnregisterApplication(app_to_remove->app_id(), mobile_apis::Result::INVALID_ENUM, is_ignition_off, is_unexpected_disconnect); connection_handler().CloseSession(app_to_remove->app_id(), connection_handler::kCommon); - it = accessor.begin(); + it = accessor.GetData().begin(); } } if (is_ignition_off) { @@ -2496,8 +2503,7 @@ void ApplicationManagerImpl::UnregisterApplication( bool is_unexpected_disconnect) { LOG4CXX_DEBUG(logger_, "app_id = " << app_id << "; reason = " << reason - << "; is_resuming = " - << is_resuming + << "; is_resuming = " << is_resuming << "; is_unexpected_disconnect = " << is_unexpected_disconnect); size_t subscribed_for_way_points_app_count = 0; @@ -2510,7 +2516,7 @@ void ApplicationManagerImpl::UnregisterApplication( } if (1 == subscribed_for_way_points_app_count) { LOG4CXX_ERROR(logger_, "Send UnsubscribeWayPoints"); - MessageHelper::SendUnsubscribedWayPoints(); + MessageHelper::SendUnsubscribedWayPoints(*this); } NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); @@ -2539,9 +2545,9 @@ void ApplicationManagerImpl::UnregisterApplication( if (reason == mobile_apis::Result::TOO_MANY_PENDING_REQUESTS) { LOG4CXX_DEBUG( logger_, - "INSERT: " << GetHashedAppID(app_id, app_ptr->mobile_app_id())); + "INSERT: " << GetHashedAppID(app_id, app_ptr->policy_app_id())); forbidden_applications.insert( - GetHashedAppID(app_id, app_ptr->mobile_app_id())); + GetHashedAppID(app_id, app_ptr->policy_app_id())); } } break; @@ -2554,9 +2560,9 @@ void ApplicationManagerImpl::UnregisterApplication( ApplicationSharedPtr app_to_remove; connection_handler::DeviceHandle handle = 0; { - ApplicationListAccessor accessor; - ApplicationSetConstIt it = accessor.begin(); - for (; it != accessor.end(); ++it) { + DataAccessor<ApplicationSet> accessor(applications()); + ApplicationSetConstIt it = accessor.GetData().begin(); + for (; it != accessor.GetData().end(); ++it) { if ((*it)->app_id() == app_id) { app_to_remove = *it; handle = app_to_remove->device(); @@ -2573,9 +2579,9 @@ void ApplicationManagerImpl::UnregisterApplication( return; } - accessor.Erase(app_to_remove); + applications_.erase(app_to_remove); AppV4DevicePredicate finder(handle); - ApplicationSharedPtr app = accessor.Find(finder); + ApplicationSharedPtr app = FindApp(accessor,finder); if (!app) { LOG4CXX_DEBUG( logger_, "There is no more SDL4 apps with device handle: " << handle); @@ -2586,20 +2592,20 @@ void ApplicationManagerImpl::UnregisterApplication( } if (is_resuming) { - resume_ctrl_.SaveApplication(app_to_remove); + resume_ctrl_.SaveApplication(app_to_remove); } else { resume_ctrl_.RemoveApplicationFromSaved(app_to_remove); } if (audio_pass_thru_active_) { // May be better to put this code in MessageHelper? - end_audio_pass_thru(); + EndAudioPassThrough(); StopAudioPassThru(app_id); - MessageHelper::SendStopAudioPathThru(); + MessageHelper::SendStopAudioPathThru(*this); } MessageHelper::SendOnAppUnregNotificationToHMI(app_to_remove, - is_unexpected_disconnect); + is_unexpected_disconnect, *this); request_ctrl_.terminateAppRequests(app_id); return; } @@ -2616,7 +2622,7 @@ void ApplicationManagerImpl::Handle(const impl::MessageFromMobile message) { LOG4CXX_ERROR(logger_, "Null-pointer message received."); return; } - sync_primitives::AutoLock lock(stopping_flag_lock_); + sync_primitives::AutoLock lock(stopping_application_mng_lock_); if (is_stopping_) { LOG4CXX_INFO(logger_, "Application manager is stopping"); return; @@ -2705,9 +2711,14 @@ void ApplicationManagerImpl::Handle(const impl::AudioData message) { (*on_audio_pass)[strings::params][strings::binary_data] = smart_objects::SmartObject(message.binary_data); + LOG4CXX_DEBUG(logger_, "After fill binary data"); LOG4CXX_DEBUG(logger_, "Send data"); CommandSharedPtr command(MobileCommandFactory::CreateCommand( - on_audio_pass, commands::Command::ORIGIN_SDL)); + on_audio_pass, commands::Command::ORIGIN_SDL, *this)); + if (!command) { + LOG4CXX_WARN(logger_, "Failed to create mobile command from smart object"); + return; + } command->Init(); command->Run(); @@ -2733,8 +2744,7 @@ mobile_apis::Result::eType ApplicationManagerImpl::CheckPolicyPermissions( MessageHelper::StringifiedHMILevel(hmi_level); LOG4CXX_DEBUG(logger_, "Checking permissions for " << policy_app_id << " in " - << stringified_hmi_level - << " rpc " + << stringified_hmi_level << " rpc " << stringified_functionID); policy::CheckPermissionResult result; GetPolicyHandler().CheckPermissions(policy_app_id, @@ -2800,16 +2810,12 @@ bool ApplicationManagerImpl::IsLowVoltage() { } std::string ApplicationManagerImpl::GetHashedAppID( - uint32_t connection_key, const std::string& mobile_app_id) { + uint32_t connection_key, const std::string& mobile_app_id) const { uint32_t device_id = 0; - connection_handler().GetDataOnSessionKey( - connection_key, 0, NULL, &device_id); + connection_handler().GetDataOnSessionKey(connection_key, 0, NULL, &device_id); std::string device_name; - connection_handler().get_session_observer().GetDataOnDeviceID(device_id, - &device_name, - NULL, - NULL, - NULL); + connection_handler().get_session_observer().GetDataOnDeviceID( + device_id, &device_name, NULL, NULL, NULL); return mobile_app_id + device_name; } @@ -2848,7 +2854,7 @@ bool ApplicationManagerImpl::CanAppStream( LOG4CXX_WARN(logger_, "Unsupported service_type " << service_type); } - return HMILevelAllowsStreaming(app_id, service_type) && is_allowed; + return HMILevelAllowsStreaming(app_id, service_type) && is_allowed; } void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { @@ -2876,8 +2882,8 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); if (navi_service_status_.end() == it || (!it->second.first && !it->second.second)) { - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - app_id, PROTOCOL_VIOLATION); + ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, PROTOCOL_VIOLATION), commands::Command::ORIGIN_SDL); UnregisterApplication(app_id, ABORTED); return; } @@ -2948,9 +2954,10 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) { } } -void ApplicationManagerImpl::OnHMILevelChanged(uint32_t app_id, - mobile_apis::HMILevel::eType from, - mobile_apis::HMILevel::eType to) { +void ApplicationManagerImpl::OnHMILevelChanged( + uint32_t app_id, + mobile_apis::HMILevel::eType from, + mobile_apis::HMILevel::eType to) { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis::HMILevel; using namespace helpers; @@ -2977,7 +2984,6 @@ void ApplicationManagerImpl::OnHMILevelChanged(uint32_t app_id, if (from == HMI_FULL || from == HMI_LIMITED) { LOG4CXX_TRACE(logger_, "HMILevel from FULL or LIMITED"); navi_app_to_end_stream_.push_back(app_id); - TimerSPtr end_stream_timer(utils::MakeShared<timer::Timer>( "AppShouldFinishStreaming", new TimerTaskImpl<ApplicationManagerImpl>( @@ -2998,7 +3004,7 @@ void ApplicationManagerImpl::OnHMILevelChanged(uint32_t app_id, } void ApplicationManagerImpl::SendHMIStatusNotification( - const ApplicationSharedPtr app) { + const utils::SharedPtr<Application> app) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); smart_objects::SmartObjectSPtr notification = @@ -3055,9 +3061,10 @@ void ApplicationManagerImpl::CloseNaviApp() { NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); if (navi_service_status_.end() != it) { if (it->second.first || it->second.second) { - LOG4CXX_INFO(logger_, "App haven't answered for EndService. Unregister it."); - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - app_id, PROTOCOL_VIOLATION); + LOG4CXX_INFO(logger_, + "App haven't answered for EndService. Unregister it."); + ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, PROTOCOL_VIOLATION), commands::Command::ORIGIN_SDL); UnregisterApplication(app_id, ABORTED); } } @@ -3120,10 +3127,16 @@ void ApplicationManagerImpl::AllowStreaming(uint32_t app_id) { } bool ApplicationManagerImpl::IsApplicationForbidden( - uint32_t connection_key, const std::string& mobile_app_id) { + uint32_t connection_key, const std::string& mobile_app_id) const { const std::string name = GetHashedAppID(connection_key, mobile_app_id); return forbidden_applications.find(name) != forbidden_applications.end(); } + +policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice( + const std::string& device_id) const { + return policy_handler_.GetUserConsentForDevice(device_id); +} + void ApplicationManagerImpl::OnWakeUp() { LOG4CXX_AUTO_TRACE(logger_); is_low_voltage_ = false; @@ -3136,9 +3149,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( const std::string& file_name, const int64_t offset) { LOG4CXX_DEBUG(logger_, - "SaveBinaryWithOffset binary_size = " << binary_data.size() - << " offset = " - << offset); + "SaveBinaryWithOffset binary_size = " + << binary_data.size() << " offset = " << offset); if (binary_data.size() > file_system::GetAvailableDiskSpace(file_path)) { LOG4CXX_ERROR(logger_, "Out of free disc space."); @@ -3146,7 +3158,7 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( } const std::string full_file_path = file_path + "/" + file_name; - int64_t file_size = file_system::FileSize(full_file_path); + const int64_t file_size = file_system::FileSize(full_file_path); std::ofstream* file_stream; if (offset != 0) { if (file_size != offset) { @@ -3181,9 +3193,8 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( uint32_t ApplicationManagerImpl::GetAvailableSpaceForApp( const std::string& folder_name) { - const uint32_t app_quota = profile::Profile::instance()->app_dir_quota(); - std::string app_storage_path = - profile::Profile::instance()->app_storage_folder(); + const uint32_t app_quota = settings_.app_dir_quota(); + std::string app_storage_path = settings_.app_storage_folder(); app_storage_path += "/"; app_storage_path += folder_name; @@ -3239,7 +3250,7 @@ void ApplicationManagerImpl::OnTimerSendTTSGlobalProperties() { for (uint32_t i = 0; i < app_list.size(); ++i) { LOG4CXX_INFO(logger_, "Send TTS GlobalProperties to HMI with default helpPrompt"); - MessageHelper::SendTTSGlobalProperties(application(app_list[i]), true); + MessageHelper::SendTTSGlobalProperties(application(app_list[i]), true, *this); RemoveAppFromTTSGlobalPropertiesList(app_list[i]); } } @@ -3249,7 +3260,7 @@ void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList( const uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); uint16_t timeout = - profile::Profile::instance()->tts_global_properties_timeout(); + get_settings().tts_global_properties_timeout(); TimevalStruct current_time = date_time::DateTime::getCurrentTime(); current_time.tv_sec += timeout; // please avoid AutoLock usage to avoid deadlock @@ -3279,7 +3290,7 @@ void ApplicationManagerImpl::RemoveAppFromTTSGlobalPropertiesList( if (tts_global_properties_app_list_.end() != it) { tts_global_properties_app_list_.erase(it); if (tts_global_properties_app_list_.empty()) { - LOG4CXX_INFO(logger_, "Stop tts_global_properties_timer_"); + LOG4CXX_DEBUG(logger_, "Stop tts_global_properties_timer_"); // if container is empty need to stop timer tts_global_properties_app_list_lock_.Release(); tts_global_properties_timer_.Stop(); @@ -3341,18 +3352,18 @@ bool ApplicationManagerImpl::CompareAppHMIType( } void ApplicationManagerImpl::OnUpdateHMIAppType( - std::map<std::string, std::vector<std::string>> app_hmi_types) { + std::map<std::string, std::vector<std::string> > app_hmi_types) { LOG4CXX_AUTO_TRACE(logger_); - std::map<std::string, std::vector<std::string>>::iterator + std::map<std::string, std::vector<std::string> >::iterator it_app_hmi_types_from_policy; std::vector<std::string> hmi_types_from_policy; smart_objects::SmartObject transform_app_hmi_types( smart_objects::SmartType_Array); bool flag_diffirence_app_hmi_type = false; - ApplicationListAccessor accessor; - for (ApplicationSetIt it = accessor.begin(); it != accessor.end(); ++it) { - it_app_hmi_types_from_policy = app_hmi_types.find(((*it)->mobile_app_id())); + DataAccessor<ApplicationSet> accessor(applications()); + for (ApplicationSetIt it = accessor.GetData().begin(); it != accessor.GetData().end(); ++it) { + it_app_hmi_types_from_policy = app_hmi_types.find(((*it)->policy_app_id())); if (it_app_hmi_types_from_policy != app_hmi_types.end() && ((it_app_hmi_types_from_policy->second).size())) { @@ -3386,12 +3397,11 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( (*it)->set_app_types(transform_app_hmi_types); (*it)->ChangeSupportingAppHMIType(); if ((*it)->hmi_level() == mobile_api::HMILevel::HMI_BACKGROUND) { - MessageHelper::SendUIChangeRegistrationRequestToHMI(*it); + MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); } else if (((*it)->hmi_level() == mobile_api::HMILevel::HMI_FULL) || ((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) { - MessageHelper::SendUIChangeRegistrationRequestToHMI(*it); - ApplicationManagerImpl::instance()->SetState<true>( - (*it)->app_id(), mobile_apis::HMILevel::HMI_BACKGROUND); + MessageHelper::SendUIChangeRegistrationRequestToHMI(*it, *this); + state_controller().SetRegularState(*it, mobile_apis::HMILevel::HMI_BACKGROUND, true); } } } @@ -3400,8 +3410,8 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( ProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const { LOG4CXX_AUTO_TRACE(logger_); - bool heart_beat_support = profile::Profile::instance()->heart_beat_timeout(); - bool sdl4_support = profile::Profile::instance()->enable_protocol_4(); + bool heart_beat_support = get_settings().heart_beat_timeout(); + bool sdl4_support = protocol_handler_->get_settings().enable_protocol_4(); if (sdl4_support) { LOG4CXX_DEBUG(logger_, @@ -3418,6 +3428,10 @@ ProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const { return ProtocolVersion::kV2; } +event_engine::EventDispatcher& ApplicationManagerImpl::event_dispatcher() { + return event_dispatcher_; +} + const std::string ApplicationManagerImpl::DirectoryTypeToString( ApplicationManagerImpl::DirectoryType type) const { DirectoryTypeMap::const_iterator it = dir_type_to_string_map_.find(type); @@ -3505,6 +3519,4 @@ const std::set<int32_t> ApplicationManagerImpl::GetAppsSubscribedForWayPoints() return subscribed_way_points_apps_list_; } -ApplicationManagerImpl::ApplicationListAccessor::~ApplicationListAccessor() {} - } // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index 5fd3449165..1cdca1ffd9 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -31,7 +31,9 @@ */ #include "application_manager/commands/command_impl.h" -#include "config_profile/profile.h" +#include "application_manager/application_impl.h" +#include "application_manager/application_manager.h" + namespace application_manager { namespace commands { @@ -42,11 +44,12 @@ const int32_t CommandImpl::hmi_protocol_type_ = 1; const int32_t CommandImpl::mobile_protocol_type_ = 0; const int32_t CommandImpl::protocol_version_ = 3; -CommandImpl::CommandImpl(const MessageSharedPtr& message) - : message_(message), - default_timeout_(profile::Profile::instance()->default_timeout()), - allowed_to_terminate_(true) { -} +CommandImpl::CommandImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager) + : message_(message) + , default_timeout_(application_manager.get_settings().default_timeout()) + , allowed_to_terminate_(true) + , application_manager_(application_manager) {} CommandImpl::~CommandImpl() { CleanUp(); @@ -87,5 +90,86 @@ void CommandImpl::onTimeOut() { } +bool CommandImpl::AllowedToTerminate() { + return allowed_to_terminate_; +} + +void CommandImpl::SetAllowedToTerminate(bool allowed) { + allowed_to_terminate_ = allowed; +} + +void CommandImpl::ReplaceMobileByHMIAppId( + NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + if (message.keyExists(strings::app_id)) { + ApplicationSharedPtr application = application_manager_.application( + message[strings::app_id].asUInt()); + if (application.valid()) { + LOG4CXX_DEBUG(logger_, + "ReplaceMobileByHMIAppId from " + << message[strings::app_id].asInt() << " to " + << application->hmi_app_id()); + message[strings::app_id] = application->hmi_app_id(); + } + } else { + switch (message.getType()) { + case smart_objects::SmartType::SmartType_Array: { + smart_objects::SmartArray* message_array = message.asArray(); + smart_objects::SmartArray::iterator it = message_array->begin(); + for (; it != message_array->end(); ++it) { + ReplaceMobileByHMIAppId(*it); + } + break; + } + case smart_objects::SmartType::SmartType_Map: { + std::set<std::string> keys = message.enumerate(); + std::set<std::string>::const_iterator key = keys.begin(); + for (; key != keys.end(); ++key) { + std::string k = *key; + ReplaceMobileByHMIAppId(message[*key]); + } + break; + } + default: { break; } + } + } +} + +void CommandImpl::ReplaceHMIByMobileAppId( + NsSmartDeviceLink::NsSmartObjects::SmartObject& message) { + if (message.keyExists(strings::app_id)) { + ApplicationSharedPtr application = + application_manager_.application_by_hmi_app( + message[strings::app_id].asUInt()); + + if (application.valid()) { + LOG4CXX_DEBUG(logger_, + "ReplaceHMIByMobileAppId from " + << message[strings::app_id].asInt() << " to " + << application->app_id()); + message[strings::app_id] = application->app_id(); + } + } else { + switch (message.getType()) { + case smart_objects::SmartType::SmartType_Array: { + smart_objects::SmartArray* message_array = message.asArray(); + smart_objects::SmartArray::iterator it = message_array->begin(); + for (; it != message_array->end(); ++it) { + ReplaceHMIByMobileAppId(*it); + } + break; + } + case smart_objects::SmartType::SmartType_Map: { + std::set<std::string> keys = message.enumerate(); + std::set<std::string>::const_iterator key = keys.begin(); + for (; key != keys.end(); ++key) { + ReplaceHMIByMobileAppId(message[*key]); + } + break; + } + default: { break; } + } + } +} + } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc index ee7afaddf9..bbb04e4c18 100644 --- a/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_from_mobile_impl.cc @@ -31,16 +31,15 @@ */ #include "application_manager/commands/command_notification_from_mobile_impl.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace application_manager { namespace commands { -CommandNotificationFromMobileImpl::CommandNotificationFromMobileImpl( - const MessageSharedPtr& message) - : CommandImpl(message) { +CommandNotificationFromMobileImpl::CommandNotificationFromMobileImpl(const MessageSharedPtr& message, ApplicationManager &application_manager) + : CommandImpl(message, application_manager) { } CommandNotificationFromMobileImpl::~CommandNotificationFromMobileImpl() { @@ -66,7 +65,7 @@ void CommandNotificationFromMobileImpl::SendNotification() { LOG4CXX_INFO(logger_, "SendNotification"); MessageHelper::PrintSmartObject(*message_); - ApplicationManagerImpl::instance()->SendMessageToMobile(message_); + application_manager_.SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/command_notification_impl.cc b/src/components/application_manager/src/commands/command_notification_impl.cc index c99f2d9086..0f2a2bde24 100644 --- a/src/components/application_manager/src/commands/command_notification_impl.cc +++ b/src/components/application_manager/src/commands/command_notification_impl.cc @@ -31,7 +31,7 @@ */ #include "application_manager/commands/command_notification_impl.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" namespace application_manager { @@ -39,9 +39,8 @@ namespace application_manager { namespace commands { CommandNotificationImpl::CommandNotificationImpl( - const MessageSharedPtr& message) - : CommandImpl(message) { -} + const MessageSharedPtr& message, ApplicationManager& application_manager) + : CommandImpl(message, application_manager) {} CommandNotificationImpl::~CommandNotificationImpl() { } @@ -66,7 +65,7 @@ void CommandNotificationImpl::SendNotification() { LOG4CXX_INFO(logger_, "SendNotification"); MessageHelper::PrintSmartObject(*message_); - ApplicationManagerImpl::instance()->SendMessageToMobile(message_); + application_manager_.SendMessageToMobile(message_); } } // namespace commands diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index d42fb0e3f5..36627be735 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -33,7 +33,7 @@ #include <algorithm> #include <string> #include "application_manager/commands/command_request_impl.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" #include "smart_objects/smart_object.h" @@ -44,7 +44,9 @@ namespace commands { struct DisallowedParamsInserter { DisallowedParamsInserter(smart_objects::SmartObject& response, mobile_apis::VehicleDataResultCode::eType code) - : response_(response), code_(code) {} + : response_(response), + code_(code) { + } bool operator()(const std::string& param) { const VehicleData& vehicle_data = @@ -60,16 +62,19 @@ struct DisallowedParamsInserter { } return false; } - - private: +private: smart_objects::SmartObject& response_; mobile_apis::VehicleDataResultCode::eType code_; }; -CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message) - : CommandImpl(message), current_state_(kAwaitingHMIResponse) {} +CommandRequestImpl::CommandRequestImpl(const MessageSharedPtr& message, + ApplicationManager& application_manager) + : CommandImpl(message, application_manager) + , EventObserver(application_manager.event_dispatcher()) + , current_state_(kAwaitingHMIResponse) {} -CommandRequestImpl::~CommandRequestImpl() {} +CommandRequestImpl::~CommandRequestImpl() { +} bool CommandRequestImpl::Init() { return true; @@ -83,7 +88,8 @@ bool CommandRequestImpl::CleanUp() { return true; } -void CommandRequestImpl::Run() {} +void CommandRequestImpl::Run() { +} void CommandRequestImpl::onTimeOut() { LOG4CXX_AUTO_TRACE(logger_); @@ -102,15 +108,14 @@ void CommandRequestImpl::onTimeOut() { } smart_objects::SmartObjectSPtr response = - MessageHelper::CreateNegativeResponse(connection_key(), - function_id(), - correlation_id(), - mobile_api::Result::GENERIC_ERROR); + MessageHelper::CreateNegativeResponse(connection_key(), function_id(), + correlation_id(), mobile_api::Result::GENERIC_ERROR); - ApplicationManagerImpl::instance()->ManageMobileCommand(response); + application_manager_.ManageMobileCommand(response, ORIGIN_SDL); } -void CommandRequestImpl::on_event(const event_engine::Event& event) {} +void CommandRequestImpl::on_event(const event_engine::Event& event) { +} void CommandRequestImpl::SendResponse( const bool success, @@ -151,13 +156,12 @@ void CommandRequestImpl::SendResponse( response[strings::msg_params][strings::info] = std::string(info); } - // Add disallowed parameters and info from request back to response with - // appropriate + // Add disallowed parameters and info from request back to response with appropriate // reasons (VehicleData result codes) if (result_code != mobile_apis::Result::APPLICATION_NOT_REGISTERED) { const mobile_apis::FunctionID::eType& id = static_cast<mobile_apis::FunctionID::eType>(function_id()); - if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) || + if ((id == mobile_apis::FunctionID::SubscribeVehicleDataID) || (id == mobile_apis::FunctionID::UnsubscribeVehicleDataID)) { AddDisallowedParameters(response); AddDisallowedParametersToInfo(response); @@ -169,11 +173,10 @@ void CommandRequestImpl::SendResponse( response[strings::msg_params][strings::success] = success; response[strings::msg_params][strings::result_code] = result_code; - ApplicationManagerImpl::instance()->ManageMobileCommand(result); + application_manager_.ManageMobileCommand(result, ORIGIN_SDL); } -bool CommandRequestImpl::CheckSyntax(const std::string& str, - bool allow_empty_line) { +bool CommandRequestImpl::CheckSyntax(const std::string& str, bool allow_empty_line) { if (std::string::npos != str.find_first_of("\t\n")) { LOG4CXX_ERROR(logger_, "CheckSyntax failed! :" << str); return false; @@ -193,16 +196,14 @@ bool CommandRequestImpl::CheckSyntax(const std::string& str, uint32_t CommandRequestImpl::SendHMIRequest( const hmi_apis::FunctionID::eType& function_id, - const smart_objects::SmartObject* msg_params, - bool use_events) { + const smart_objects::SmartObject* msg_params, bool use_events) { + smart_objects::SmartObjectSPtr result = new smart_objects::SmartObject; const uint32_t hmi_correlation_id = - ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + application_manager_.GetNextHMICorrelationID(); if (use_events) { - LOG4CXX_DEBUG(logger_, - "subscribe_on_event " << function_id << " " - << hmi_correlation_id); + LOG4CXX_DEBUG(logger_, "subscribe_on_event " << function_id << " " << hmi_correlation_id); subscribe_on_event(function_id, hmi_correlation_id); } @@ -219,7 +220,7 @@ uint32_t CommandRequestImpl::SendHMIRequest( request[strings::msg_params] = *msg_params; } - if (!ApplicationManagerImpl::instance()->ManageHMICommand(result)) { + if (!application_manager_.ManageHMICommand(result)) { LOG4CXX_ERROR(logger_, "Unable to send request"); SendResponse(false, mobile_apis::Result::OUT_OF_MEMORY); } @@ -245,7 +246,7 @@ void CommandRequestImpl::CreateHMINotification( notify[strings::params][strings::function_id] = function_id; notify[strings::msg_params] = msg_params; - if (!ApplicationManagerImpl::instance()->ManageHMICommand(result)) { + if (!application_manager_.ManageHMICommand(result)) { LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); } } @@ -372,15 +373,15 @@ bool CommandRequestImpl::CheckAllowedParameters() { return true; } - ApplicationManagerImpl::ApplicationListAccessor accessor; + const ApplicationSet& accessor = + application_manager_.applications().GetData(); ApplicationSetConstIt it_app_list = accessor.begin(); ApplicationSetConstIt it_app_list_end = accessor.end(); for (; it_app_list != it_app_list_end; ++it_app_list) { if (connection_key() == (*it_app_list).get()->app_id()) { RPCParams params; - const smart_objects::SmartObject& s_map = - (*message_)[strings::msg_params]; + const smart_objects::SmartObject& s_map = (*message_)[strings::msg_params]; if (smart_objects::SmartType_Map == s_map.getType()) { smart_objects::SmartMap::iterator iter = s_map.map_begin(); smart_objects::SmartMap::iterator iter_end = s_map.map_end(); @@ -395,13 +396,13 @@ bool CommandRequestImpl::CheckAllowedParameters() { CommandParametersPermissions params_permissions; mobile_apis::Result::eType check_result = - application_manager::ApplicationManagerImpl::instance() - ->CheckPolicyPermissions( - (*it_app_list).get()->mobile_app_id(), - (*it_app_list).get()->hmi_level(), - static_cast<mobile_api::FunctionID::eType>(function_id()), - params, - ¶ms_permissions); + application_manager_. + CheckPolicyPermissions( + (*it_app_list).get()->policy_app_id(), + (*it_app_list).get()->hmi_level(), + static_cast<mobile_api::FunctionID::eType>(function_id()), + params, + ¶ms_permissions); // Check, if RPC is allowed by policy if (mobile_apis::Result::SUCCESS != check_result) { @@ -412,7 +413,7 @@ bool CommandRequestImpl::CheckAllowedParameters() { correlation_id(), (*it_app_list)->app_id()); - ApplicationManagerImpl::instance()->SendMessageToMobile(response); + application_manager_.SendMessageToMobile(response); return false; } @@ -441,13 +442,13 @@ void CommandRequestImpl::RemoveDisallowedParameters( params_permissions.disallowed_params.begin(); std::vector<std::string>::const_iterator it_disallowed_end = params_permissions.disallowed_params.end(); - for (; it_disallowed != it_disallowed_end; ++it_disallowed) { + for (;it_disallowed != it_disallowed_end; ++it_disallowed) { if (params.keyExists(*it_disallowed)) { params.erase(*it_disallowed); - parameters_permissions_.disallowed_params.push_back(*it_disallowed); - LOG4CXX_INFO( - logger_, - "Following parameter is disallowed by user: " << *it_disallowed); + parameters_permissions_.disallowed_params.push_back( + *it_disallowed); + LOG4CXX_INFO(logger_, "Following parameter is disallowed by user: " + << *it_disallowed); } } @@ -456,13 +457,13 @@ void CommandRequestImpl::RemoveDisallowedParameters( params_permissions.undefined_params.begin(); std::vector<std::string>::const_iterator it_undefined_end = params_permissions.undefined_params.end(); - for (; it_undefined != it_undefined_end; ++it_undefined) { + for (;it_undefined != it_undefined_end; ++it_undefined) { if (params.keyExists(*it_undefined)) { params.erase(*it_undefined); - parameters_permissions_.undefined_params.push_back(*it_undefined); - LOG4CXX_INFO( - logger_, - "Following parameter is disallowed by policy: " << *it_undefined); + parameters_permissions_.undefined_params.push_back( + *it_undefined); + LOG4CXX_INFO(logger_, "Following parameter is disallowed by policy: " + << *it_undefined); } } @@ -472,19 +473,19 @@ void CommandRequestImpl::RemoveDisallowedParameters( VehicleData::const_iterator it_vehicle_data = vehicle_data.begin(); VehicleData::const_iterator it_vehicle_data_end = vehicle_data.end(); - for (; it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) { + for (;it_vehicle_data != it_vehicle_data_end; ++it_vehicle_data) { const std::string key = it_vehicle_data->first; if (params.keyExists(key) && params_permissions.allowed_params.end() == - std::find(params_permissions.allowed_params.begin(), - params_permissions.allowed_params.end(), - key)) { + std::find(params_permissions.allowed_params.begin(), + params_permissions.allowed_params.end(), + key)) { params.erase(key); parameters_permissions_.undefined_params.push_back(key); LOG4CXX_INFO(logger_, "Following parameter is not found among allowed parameters '" - << key - << "' and will be treated as disallowed."); + << key + << "' and will be treated as disallowed."); } } } @@ -530,13 +531,15 @@ void CommandRequestImpl::AddDisallowedParametersToInfo( void CommandRequestImpl::AddDisallowedParameters( smart_objects::SmartObject& response) { DisallowedParamsInserter disallowed_inserter( - response, mobile_apis::VehicleDataResultCode::VDRC_USER_DISALLOWED); + response, + mobile_apis::VehicleDataResultCode::VDRC_USER_DISALLOWED); std::for_each(parameters_permissions_.disallowed_params.begin(), parameters_permissions_.disallowed_params.end(), disallowed_inserter); DisallowedParamsInserter undefined_inserter( - response, mobile_apis::VehicleDataResultCode::VDRC_DISALLOWED); + response, + mobile_apis::VehicleDataResultCode::VDRC_DISALLOWED); std::for_each(parameters_permissions_.undefined_params.begin(), parameters_permissions_.undefined_params.end(), undefined_inserter); @@ -544,7 +547,7 @@ void CommandRequestImpl::AddDisallowedParameters( bool CommandRequestImpl::HasDisallowedParams() const { return ((!parameters_permissions_.disallowed_params.empty()) || - (!parameters_permissions_.undefined_params.empty())); + (!parameters_permissions_.undefined_params.empty())); } } // namespace commands diff --git a/src/components/application_manager/src/commands/command_response_impl.cc b/src/components/application_manager/src/commands/command_response_impl.cc index d7bd9133bf..ab027083fc 100644 --- a/src/components/application_manager/src/commands/command_response_impl.cc +++ b/src/components/application_manager/src/commands/command_response_impl.cc @@ -31,15 +31,15 @@ */ #include "application_manager/commands/command_response_impl.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" namespace application_manager { namespace commands { -CommandResponseImpl::CommandResponseImpl(const MessageSharedPtr& message) - : CommandImpl(message) { -} +CommandResponseImpl::CommandResponseImpl( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : CommandImpl(message, application_manager) {} CommandResponseImpl::~CommandResponseImpl() { } @@ -80,7 +80,7 @@ void CommandResponseImpl::SendResponse( } } - ApplicationManagerImpl::instance()->SendMessageToMobile(message_, final_message); + application_manager_.SendMessageToMobile(message_, final_message); } } // namespace commands diff --git a/src/components/application_manager/src/event_engine/event.cc b/src/components/application_manager/src/event_engine/event.cc index 874716cc9c..cc180ca950 100644 --- a/src/components/application_manager/src/event_engine/event.cc +++ b/src/components/application_manager/src/event_engine/event.cc @@ -31,21 +31,17 @@ */ #include "application_manager/event_engine/event.h" -#include "application_manager/event_engine/event_dispatcher_impl.h" +#include "application_manager/event_engine/event_dispatcher.h" namespace application_manager { namespace event_engine { -Event::Event(const EventID& id) -: id_(id) -, response_so_() { -} +Event::Event(const EventID& id) : id_(id), response_so_() {} -Event::~Event() { -} +Event::~Event() {} -void Event::raise() { - EventDispatcherImpl::instance()->raise_event(*this); +void Event::raise(EventDispatcher& event_dispatcher) { + event_dispatcher.raise_event(*this); } void Event::set_smart_object(const smart_objects::SmartObject& so) { diff --git a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc index cb7b822246..f00dc06c00 100644 --- a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc +++ b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc @@ -72,7 +72,7 @@ void EventDispatcherImpl::raise_event(const Event& event) { void EventDispatcherImpl::add_observer(const Event::EventID& event_id, int32_t hmi_correlation_id, - EventObserver* const observer) { + EventObserver* observer) { AutoLock auto_lock(state_lock_); observers_event_[event_id][hmi_correlation_id].push_back(observer); } diff --git a/src/components/application_manager/src/event_engine/event_observer.cc b/src/components/application_manager/src/event_engine/event_observer.cc index bb29eea3b2..9e6e0a1fed 100644 --- a/src/components/application_manager/src/event_engine/event_observer.cc +++ b/src/components/application_manager/src/event_engine/event_observer.cc @@ -32,31 +32,31 @@ #include "application_manager/event_engine/event_observer.h" #include "application_manager/event_engine/event.h" +#include "application_manager/event_engine/event_dispatcher.h" namespace application_manager { namespace event_engine { -EventObserver::EventObserver() - : id_(0) { - //Get unique id based on this +EventObserver::EventObserver(EventDispatcher& event_dispatcher) + : id_(0), event_dispatcher_(event_dispatcher) { + // Get unique id based on this id_ = reinterpret_cast<unsigned long>(this); } -EventObserver::~EventObserver() { - unsubscribe_from_all_events(); -} +EventObserver::~EventObserver() { unsubscribe_from_all_events(); } void EventObserver::subscribe_on_event(const Event::EventID& event_id, int32_t hmi_correlation_id) { - EventDispatcherImpl::instance()->add_observer(event_id, hmi_correlation_id, this); + event_dispatcher_.add_observer(event_id, hmi_correlation_id, + this); } void EventObserver::unsubscribe_from_event(const Event::EventID& event_id) { - EventDispatcherImpl::instance()->remove_observer(event_id, this); + event_dispatcher_.remove_observer(event_id, this); } void EventObserver::unsubscribe_from_all_events() { - EventDispatcherImpl::instance()->remove_observer(this); + event_dispatcher_.remove_observer(this); } } // namespace event_engine diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities.cc index d5c2d24eda..0f15d7ea6b 100644 --- a/src/components/application_manager/src/hmi_capabilities.cc +++ b/src/components/application_manager/src/hmi_capabilities.cc @@ -37,11 +37,11 @@ #include "json/json.h" #include "utils/file_system.h" #include "interfaces/HMI_API.h" -#include "config_profile/profile.h" #include "smart_objects/smart_object.h" #include "application_manager/smart_object_keys.h" #include "application_manager/message_helper.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" #include "formatters/CFormatterJsonBase.h" @@ -201,7 +201,7 @@ const std::map<std::string, hmi_apis::Common_CharacterSet::eType> {"CID1SET", hmi_apis::Common_CharacterSet::CID1SET}, {"CID2SET", hmi_apis::Common_CharacterSet::CID2SET}}; -HMICapabilities::HMICapabilities(ApplicationManagerImpl* const app_mngr) +HMICapabilities::HMICapabilities(ApplicationManager& app_mngr) : is_vr_cooperating_(false) , is_tts_cooperating_(false) , is_ui_cooperating_(false) @@ -231,8 +231,9 @@ HMICapabilities::HMICapabilities(ApplicationManagerImpl* const app_mngr) , prerecorded_speech_(NULL) , is_navigation_supported_(false) , is_phone_call_supported_(false) - , app_mngr_(app_mngr) { - if (false == profile::Profile::instance()->launch_hmi()) { + , app_mngr_(app_mngr) + , hmi_language_handler_(app_mngr_){ + if (false == app_mngr_.get_settings().launch_hmi()) { is_vr_ready_response_recieved_ = true; is_tts_ready_response_recieved_ = true; is_ui_ready_response_recieved_ = true; @@ -261,7 +262,6 @@ HMICapabilities::~HMICapabilities() { delete speech_capabilities_; delete audio_pass_thru_capabilities_; delete prerecorded_speech_; - app_mngr_ = NULL; } bool HMICapabilities::is_hmi_capabilities_initialized() const { @@ -326,17 +326,15 @@ void HMICapabilities::set_is_vr_cooperating(bool value) { is_vr_cooperating_ = value; if (is_vr_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_language( - MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage)); + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, app_mngr_)); hmi_language_handler_.set_handle_response_for(*get_language); - app_mngr_->ManageHMICommand(get_language); + app_mngr_.ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VR_GetSupportedLanguages)); - app_mngr_->ManageHMICommand(get_all_languages); + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages, app_mngr_)); + app_mngr_.ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VR_GetCapabilities)); - app_mngr_->ManageHMICommand(get_capabilities); + MessageHelper::CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities, app_mngr_)); + app_mngr_.ManageHMICommand(get_capabilities); } } @@ -346,17 +344,17 @@ void HMICapabilities::set_is_tts_cooperating(bool value) { if (is_tts_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_language( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::TTS_GetLanguage)); + hmi_apis::FunctionID::TTS_GetLanguage, app_mngr_)); hmi_language_handler_.set_handle_response_for(*get_language); - app_mngr_->ManageHMICommand(get_language); + app_mngr_.ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::TTS_GetSupportedLanguages)); - app_mngr_->ManageHMICommand(get_all_languages); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetSupportedLanguages, app_mngr_)); + app_mngr_.ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::TTS_GetCapabilities)); - app_mngr_->ManageHMICommand(get_capabilities); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::TTS_GetCapabilities, app_mngr_)); + app_mngr_.ManageHMICommand(get_capabilities); } } @@ -366,17 +364,17 @@ void HMICapabilities::set_is_ui_cooperating(bool value) { if (is_ui_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_language( MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::UI_GetLanguage)); + hmi_apis::FunctionID::UI_GetLanguage, app_mngr_)); hmi_language_handler_.set_handle_response_for(*get_language); - app_mngr_->ManageHMICommand(get_language); + app_mngr_.ManageHMICommand(get_language); utils::SharedPtr<smart_objects::SmartObject> get_all_languages( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::UI_GetSupportedLanguages)); - app_mngr_->ManageHMICommand(get_all_languages); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetSupportedLanguages, app_mngr_)); + app_mngr_.ManageHMICommand(get_all_languages); utils::SharedPtr<smart_objects::SmartObject> get_capabilities( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::UI_GetCapabilities)); - app_mngr_->ManageHMICommand(get_capabilities); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::UI_GetCapabilities, app_mngr_)); + app_mngr_.ManageHMICommand(get_capabilities); } } @@ -390,9 +388,9 @@ void HMICapabilities::set_is_ivi_cooperating(bool value) { is_ivi_cooperating_ = value; if (is_ivi_cooperating_) { utils::SharedPtr<smart_objects::SmartObject> get_type( - MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VehicleInfo_GetVehicleType)); - app_mngr_->ManageHMICommand(get_type); + MessageHelper::CreateModuleInfoSO( + hmi_apis::FunctionID::VehicleInfo_GetVehicleType, app_mngr_)); + app_mngr_.ManageHMICommand(get_type); } } @@ -580,8 +578,7 @@ void HMICapabilities::Init(resumption::LastState *last_state) { bool HMICapabilities::load_capabilities_from_file() { std::string json_string; - std::string file_name = - profile::Profile::instance()->hmi_capabilities_file_name(); + std::string file_name = app_mngr_.get_settings().hmi_capabilities_file_name(); if (!file_system::FileExists(file_name)) { return false; @@ -592,6 +589,7 @@ bool HMICapabilities::load_capabilities_from_file() { } try { + Json::Reader reader_; Json::Value root_json; diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index e691538804..f1e2733222 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -277,14 +277,15 @@ namespace application_manager { CommandSharedPtr HMICommandFactory::CreateCommand( - const commands::MessageSharedPtr& message) { + const commands::MessageSharedPtr& message, + ApplicationManager& application_manager) { const int function_id = (*message)[strings::params][strings::function_id] .asInt(); LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand function_id: " << function_id); CommandSharedPtr command( - new application_manager::commands::CommandImpl(message)); + new application_manager::commands::CommandImpl(message, application_manager)); bool is_response = false; const int msg_type = (*message)[strings::params][strings::message_type].asInt(); @@ -301,414 +302,414 @@ CommandSharedPtr HMICommandFactory::CreateCommand( switch (function_id) { case hmi_apis::FunctionID::BasicCommunication_OnStartDeviceDiscovery: { - command.reset(new commands::OnStartDeviceDiscovery(message)); + command.reset(new commands::OnStartDeviceDiscovery(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList: { if (is_response) { - command.reset(new commands::UpdateDeviceListResponse(message)); + command.reset(new commands::UpdateDeviceListResponse(message, application_manager)); } else { - command.reset(new commands::UpdateDeviceListRequest(message)); + command.reset(new commands::UpdateDeviceListRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_ActivateApp: { if (is_response) { - command.reset(new commands::ActivateAppResponse(message)); + command.reset(new commands::ActivateAppResponse(message, application_manager)); } else { - command.reset(new commands::ActivateAppRequest(message)); + command.reset(new commands::ActivateAppRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_GetSystemInfo: { if (is_response) { - command.reset(new commands::GetSystemInfoResponse(message)); + command.reset(new commands::GetSystemInfoResponse(message, application_manager)); } else { - command.reset(new commands::GetSystemInfoRequest(message)); + command.reset(new commands::GetSystemInfoRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_ActivateApp: { if (is_response) { - command.reset(new commands::SDLActivateAppResponse(message)); + command.reset(new commands::SDLActivateAppResponse(message, application_manager)); } else { - command.reset(new commands::SDLActivateAppRequest(message)); + command.reset(new commands::SDLActivateAppRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_PolicyUpdate: { if (is_response) { - command.reset(new commands::SDLPolicyUpdateResponse(message)); + command.reset(new commands::SDLPolicyUpdateResponse(message, application_manager)); } else { - command.reset(new commands::SDLPolicyUpdate(message)); + command.reset(new commands::SDLPolicyUpdate(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_GetURLS: { if (is_response) { - command.reset(new commands::GetUrlsResponse(message)); + command.reset(new commands::GetUrlsResponse(message, application_manager)); } else { - command.reset(new commands::GetUrls(message)); + command.reset(new commands::GetUrls(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_OnAppPermissionChanged: { - command.reset(new commands::OnAppPermissionChangedNotification(message)); + command.reset(new commands::OnAppPermissionChangedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_GetListOfPermissions: { if (is_response) { - command.reset(new commands::SDLGetListOfPermissionsResponse(message)); + command.reset(new commands::SDLGetListOfPermissionsResponse(message, application_manager)); } else { - command.reset(new commands::SDLGetListOfPermissionsRequest(message)); + command.reset(new commands::SDLGetListOfPermissionsRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_GetUserFriendlyMessage: { if (is_response) { - command.reset(new commands::SDLGetUserFriendlyMessageResponse(message)); + command.reset(new commands::SDLGetUserFriendlyMessageResponse(message, application_manager)); } else { - command.reset(new commands::SDLGetUserFriendlyMessageRequest(message)); + command.reset(new commands::SDLGetUserFriendlyMessageRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_GetStatusUpdate: { if (is_response) { - command.reset(new commands::SDLGetStatusUpdateResponse(message)); + command.reset(new commands::SDLGetStatusUpdateResponse(message, application_manager)); } else { - command.reset(new commands::SDLGetStatusUpdateRequest(message)); + command.reset(new commands::SDLGetStatusUpdateRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_OnStatusUpdate: { - command.reset(new commands::OnStatusUpdateNotification(message)); + command.reset(new commands::OnStatusUpdateNotification(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_OnAppPermissionConsent: { - command.reset(new commands::OnAppPermissionConsentNotification(message)); + command.reset(new commands::OnAppPermissionConsentNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_MixingAudioSupported: { if (is_response) { - command.reset(new commands::MixingAudioSupportedResponse(message)); + command.reset(new commands::MixingAudioSupportedResponse(message, application_manager)); } else { - command.reset(new commands::MixingAudioSupportedRequest(message)); + command.reset(new commands::MixingAudioSupportedRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_OnExitAllApplications: { - command.reset(new commands::OnExitAllApplicationsNotification(message)); + command.reset(new commands::OnExitAllApplicationsNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_AddCommand: { if (is_response) { - command.reset(new commands::UIAddCommandResponse(message)); + command.reset(new commands::UIAddCommandResponse(message, application_manager)); } else { - command.reset(new commands::UIAddCommandRequest(message)); + command.reset(new commands::UIAddCommandRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_DeleteCommand: { if (is_response) { - command.reset(new commands::UIDeleteCommandResponse(message)); + command.reset(new commands::UIDeleteCommandResponse(message, application_manager)); } else { - command.reset(new commands::UIDeleteCommandRequest(message)); + command.reset(new commands::UIDeleteCommandRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_AddSubMenu: { if (is_response) { - command.reset(new commands::UIAddSubmenuResponse(message)); + command.reset(new commands::UIAddSubmenuResponse(message, application_manager)); } else { - command.reset(new commands::UIAddSubmenuRequest(message)); + command.reset(new commands::UIAddSubmenuRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_DeleteSubMenu: { if (is_response) { - command.reset(new commands::UIDeleteSubmenuResponse(message)); + command.reset(new commands::UIDeleteSubmenuResponse(message, application_manager)); } else { - command.reset(new commands::UIDeleteSubmenuRequest(message)); + command.reset(new commands::UIDeleteSubmenuRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_SetMediaClockTimer: { if (is_response) { - command.reset(new commands::UISetMediaClockTimerResponse(message)); + command.reset(new commands::UISetMediaClockTimerResponse(message, application_manager)); } else { - command.reset(new commands::UISetMediaClockTimerRequest(message)); + command.reset(new commands::UISetMediaClockTimerRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_PerformInteraction: { if (is_response) { - command.reset(new commands::UIPerformInteractionResponse(message)); + command.reset(new commands::UIPerformInteractionResponse(message, application_manager)); } else { - command.reset(new commands::UIPerformInteractionRequest(message)); + command.reset(new commands::UIPerformInteractionRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_SetGlobalProperties: { if (is_response) { - command.reset(new commands::UISetGlobalPropertiesResponse(message)); + command.reset(new commands::UISetGlobalPropertiesResponse(message, application_manager)); } else { - command.reset(new commands::UISetGlobalPropertiesRequest(message)); + command.reset(new commands::UISetGlobalPropertiesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_ScrollableMessage: { if (is_response) { - command.reset(new commands::UIScrollableMessageResponse(message)); + command.reset(new commands::UIScrollableMessageResponse(message, application_manager)); } else { - command.reset(new commands::UIScrollableMessageRequest(message)); + command.reset(new commands::UIScrollableMessageRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_SetAppIcon: { if (is_response) { - command.reset(new commands::UISetAppIconResponse(message)); + command.reset(new commands::UISetAppIconResponse(message, application_manager)); } else { - command.reset(new commands::UISetAppIconRequest(message)); + command.reset(new commands::UISetAppIconRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_GetSupportedLanguages: { if (is_response) { - command.reset(new commands::UIGetSupportedLanguagesResponse(message)); + command.reset(new commands::UIGetSupportedLanguagesResponse(message, application_manager)); } else { - command.reset(new commands::UIGetSupportedLanguagesRequest(message)); + command.reset(new commands::UIGetSupportedLanguagesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_GetLanguage: { if (is_response) { - command.reset(new commands::UIGetLanguageResponse(message)); + command.reset(new commands::UIGetLanguageResponse(message, application_manager)); } else { - command.reset(new commands::UIGetLanguageRequest(message)); + command.reset(new commands::UIGetLanguageRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_GetCapabilities: { if (is_response) { - command.reset(new commands::UIGetCapabilitiesResponse(message)); + command.reset(new commands::UIGetCapabilitiesResponse(message, application_manager)); } else { - command.reset(new commands::UIGetCapabilitiesRequest(message)); + command.reset(new commands::UIGetCapabilitiesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_ChangeRegistration: { if (is_response) { - command.reset(new commands::UIChangeRegistratioResponse(message)); + command.reset(new commands::UIChangeRegistratioResponse(message, application_manager)); } else { - command.reset(new commands::UIChangeRegistrationRequest(message)); + command.reset(new commands::UIChangeRegistrationRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_PerformAudioPassThru: { if (is_response) { - command.reset(new commands::UIPerformAudioPassThruResponse(message)); + command.reset(new commands::UIPerformAudioPassThruResponse(message, application_manager)); } else { - command.reset(new commands::UIPerformAudioPassThruRequest(message)); + command.reset(new commands::UIPerformAudioPassThruRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_EndAudioPassThru: { if (is_response) { - command.reset(new commands::UIEndAudioPassThruResponse(message)); + command.reset(new commands::UIEndAudioPassThruResponse(message, application_manager)); } else { - command.reset(new commands::UIEndAudioPassThruRequest(message)); + command.reset(new commands::UIEndAudioPassThruRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_Alert: { if (is_response) { - command.reset(new commands::UIAlertResponse(message)); + command.reset(new commands::UIAlertResponse(message, application_manager)); } else { - command.reset(new commands::UIAlertRequest(message)); + command.reset(new commands::UIAlertRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_IsReady: { if (is_response) { - command.reset(new commands::VRIsReadyResponse(message)); + command.reset(new commands::VRIsReadyResponse(message, application_manager)); } else { - command.reset(new commands::VRIsReadyRequest(message)); + command.reset(new commands::VRIsReadyRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_AddCommand: { if (is_response) { - command.reset(new commands::VRAddCommandResponse(message)); + command.reset(new commands::VRAddCommandResponse(message, application_manager)); } else { - command.reset(new commands::VRAddCommandRequest(message)); + command.reset(new commands::VRAddCommandRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_DeleteCommand: { if (is_response) { - command.reset(new commands::VRDeleteCommandResponse(message)); + command.reset(new commands::VRDeleteCommandResponse(message, application_manager)); } else { - command.reset(new commands::VRDeleteCommandRequest(message)); + command.reset(new commands::VRDeleteCommandRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_ChangeRegistration: { if (is_response) { - command.reset(new commands::VRChangeRegistrationResponse(message)); + command.reset(new commands::VRChangeRegistrationResponse(message, application_manager)); } else { - command.reset(new commands::VRChangeRegistrationRequest(message)); + command.reset(new commands::VRChangeRegistrationRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_GetSupportedLanguages: { if (is_response) { - command.reset(new commands::VRGetSupportedLanguagesResponse(message)); + command.reset(new commands::VRGetSupportedLanguagesResponse(message, application_manager)); } else { - command.reset(new commands::VRGetSupportedLanguagesRequest(message)); + command.reset(new commands::VRGetSupportedLanguagesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_GetLanguage: { if (is_response) { - command.reset(new commands::VRGetLanguageResponse(message)); + command.reset(new commands::VRGetLanguageResponse(message, application_manager)); } else { - command.reset(new commands::VRGetLanguageRequest(message)); + command.reset(new commands::VRGetLanguageRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_GetCapabilities: { if (is_response) { - command.reset(new commands::VRGetCapabilitiesResponse(message)); + command.reset(new commands::VRGetCapabilitiesResponse(message, application_manager)); } else { - command.reset(new commands::VRGetCapabilitiesRequest(message)); + command.reset(new commands::VRGetCapabilitiesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_IsReady: { if (is_response) { - command.reset(new commands::TTSIsReadyResponse(message)); + command.reset(new commands::TTSIsReadyResponse(message, application_manager)); } else { - command.reset(new commands::TTSIsReadyRequest(message)); + command.reset(new commands::TTSIsReadyRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_ChangeRegistration: { if (is_response) { - command.reset(new commands::TTSChangeRegistratioResponse(message)); + command.reset(new commands::TTSChangeRegistratioResponse(message, application_manager)); } else { - command.reset(new commands::TTSChangeRegistrationRequest(message)); + command.reset(new commands::TTSChangeRegistrationRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_GetSupportedLanguages: { if (is_response) { - command.reset(new commands::TTSGetSupportedLanguagesResponse(message)); + command.reset(new commands::TTSGetSupportedLanguagesResponse(message, application_manager)); } else { - command.reset(new commands::TTSGetSupportedLanguagesRequest(message)); + command.reset(new commands::TTSGetSupportedLanguagesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_StopSpeaking: { if (is_response) { - command.reset(new commands::TTSStopSpeakingResponse(message)); + command.reset(new commands::TTSStopSpeakingResponse(message, application_manager)); } else { - command.reset(new commands::TTSStopSpeakingRequest(message)); + command.reset(new commands::TTSStopSpeakingRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_GetLanguage: { if (is_response) { - command.reset(new commands::TTSGetLanguageResponse(message)); + command.reset(new commands::TTSGetLanguageResponse(message, application_manager)); } else { - command.reset(new commands::TTSGetLanguageRequest(message)); + command.reset(new commands::TTSGetLanguageRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_Speak: { if (is_response) { - command.reset(new commands::TTSSpeakResponse(message)); + command.reset(new commands::TTSSpeakResponse(message, application_manager)); } else { - command.reset(new commands::TTSSpeakRequest(message)); + command.reset(new commands::TTSSpeakRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { if (is_response) { - command.reset(new commands::TTSSetGlobalPropertiesResponse(message)); + command.reset(new commands::TTSSetGlobalPropertiesResponse(message, application_manager)); } else { - command.reset(new commands::TTSSetGlobalPropertiesRequest(message)); + command.reset(new commands::TTSSetGlobalPropertiesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_GetCapabilities: { if (is_response) { - command.reset(new commands::TTSGetCapabilitiesResponse(message)); + command.reset(new commands::TTSGetCapabilitiesResponse(message, application_manager)); } else { - command.reset(new commands::TTSGetCapabilitiesRequest(message)); + command.reset(new commands::TTSGetCapabilitiesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::TTS_Started: { - command.reset(new commands::OnTTSStartedNotification(message)); + command.reset(new commands::OnTTSStartedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::TTS_Stopped: { - command.reset(new commands::OnTTSStoppedNotification(message)); + command.reset(new commands::OnTTSStoppedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnAppActivated: { - command.reset(new commands::OnAppActivatedNotification(message)); + command.reset(new commands::OnAppActivatedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnExitApplication: { - command.reset(new commands::OnExitApplicationNotification(message)); + command.reset(new commands::OnExitApplicationNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_Show: { if (is_response) { - command.reset(new commands::UIShowResponse(message)); + command.reset(new commands::UIShowResponse(message, application_manager)); } else { - command.reset(new commands::UIShowRequest(message)); + command.reset(new commands::UIShowRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_Slider: { if (is_response) { - command.reset(new commands::UISliderResponse(message)); + command.reset(new commands::UISliderResponse(message, application_manager)); } else { - command.reset(new commands::UISliderRequest(message)); + command.reset(new commands::UISliderRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_ClosePopUp: { if (is_response) { - command.reset(new commands::ClosePopupResponse(message)); + command.reset(new commands::ClosePopupResponse(message, application_manager)); } else { - command.reset(new commands::ClosePopupRequest(message)); + command.reset(new commands::ClosePopupRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::UI_IsReady: { if (is_response) { - command.reset(new commands::UIIsReadyResponse(message)); + command.reset(new commands::UIIsReadyResponse(message, application_manager)); } else { - command.reset(new commands::UIIsReadyRequest(message)); + command.reset(new commands::UIIsReadyRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VehicleInfo_IsReady: { if (is_response) { - command.reset(new commands::VIIsReadyResponse(message)); + command.reset(new commands::VIIsReadyResponse(message, application_manager)); } else { - command.reset(new commands::VIIsReadyRequest(message)); + command.reset(new commands::VIIsReadyRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VehicleInfo_ReadDID: { if (is_response) { - command.reset(new commands::VIReadDIDResponse(message)); + command.reset(new commands::VIReadDIDResponse(message, application_manager)); } else { - command.reset(new commands::VIReadDIDRequest(message)); + command.reset(new commands::VIReadDIDRequest(message, application_manager)); } break; } @@ -717,55 +718,55 @@ CommandSharedPtr HMICommandFactory::CreateCommand( if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetGpsData > (message)); + hmi_apis::FunctionID::VehicleInfo_GetGpsData > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetGpsData > (message)); + hmi_apis::FunctionID::VehicleInfo_GetGpsData > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetSpeed: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetSpeed > (message)); + hmi_apis::FunctionID::VehicleInfo_GetSpeed > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetSpeed > (message)); + hmi_apis::FunctionID::VehicleInfo_GetSpeed > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetRpm: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetRpm > (message)); + hmi_apis::FunctionID::VehicleInfo_GetRpm > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetRpm > (message)); + hmi_apis::FunctionID::VehicleInfo_GetRpm > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetFuelLevel: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetFuelLevel > (message)); + hmi_apis::FunctionID::VehicleInfo_GetFuelLevel > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetFuelLevel > (message)); + hmi_apis::FunctionID::VehicleInfo_GetFuelLevel > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState > (message)); + hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState > (message)); + hmi_apis::FunctionID::VehicleInfo_GetFuelLevelState > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption: { @@ -773,12 +774,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIGetVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption > ( - message)); + message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_GetInstantFuelConsumption > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature: { @@ -786,133 +787,133 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIGetVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature > ( - message)); + message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_GetExternalTemperature > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetPrndl: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetPrndl > (message)); + hmi_apis::FunctionID::VehicleInfo_GetPrndl > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetPrndl > (message)); + hmi_apis::FunctionID::VehicleInfo_GetPrndl > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetVin: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetVin > (message)); + hmi_apis::FunctionID::VehicleInfo_GetVin > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetVin > (message)); + hmi_apis::FunctionID::VehicleInfo_GetVin > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetTirePressure: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetTirePressure > (message)); + hmi_apis::FunctionID::VehicleInfo_GetTirePressure > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetTirePressure > (message)); + hmi_apis::FunctionID::VehicleInfo_GetTirePressure > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetOdometer: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetOdometer > (message)); + hmi_apis::FunctionID::VehicleInfo_GetOdometer > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetOdometer > (message)); + hmi_apis::FunctionID::VehicleInfo_GetOdometer > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetBeltStatus: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetBeltStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetBeltStatus > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetBeltStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetBeltStatus > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetBodyInformation: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetBodyInformation > (message)); + hmi_apis::FunctionID::VehicleInfo_GetBodyInformation > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetBodyInformation > (message)); + hmi_apis::FunctionID::VehicleInfo_GetBodyInformation > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetDeviceStatus > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetDriverBraking: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetDriverBraking > (message)); + hmi_apis::FunctionID::VehicleInfo_GetDriverBraking > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetDriverBraking > (message)); + hmi_apis::FunctionID::VehicleInfo_GetDriverBraking > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetWiperStatus: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetWiperStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetWiperStatus > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetWiperStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetWiperStatus > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetHeadLampStatus > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetEngineTorque: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetEngineTorque > (message)); + hmi_apis::FunctionID::VehicleInfo_GetEngineTorque > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetEngineTorque > (message)); + hmi_apis::FunctionID::VehicleInfo_GetEngineTorque > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition: { @@ -920,12 +921,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIGetVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition > ( - message)); + message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_GetAccPedalPosition > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle: { @@ -933,45 +934,45 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIGetVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle > ( - message)); + message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_GetSteeringWheelAngle > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetECallInfo: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetECallInfo > (message)); + hmi_apis::FunctionID::VehicleInfo_GetECallInfo > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetECallInfo > (message)); + hmi_apis::FunctionID::VehicleInfo_GetECallInfo > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus > (message)); + hmi_apis::FunctionID::VehicleInfo_GetAirbagStatus > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent > (message)); + hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent > (message)); + hmi_apis::FunctionID::VehicleInfo_GetEmergencyEvent > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus: { @@ -979,230 +980,230 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIGetVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_GetClusterModeStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_GetMyKey: { if (is_response) command.reset( new commands::VIGetVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_GetMyKey > (message)); + hmi_apis::FunctionID::VehicleInfo_GetMyKey > (message, application_manager)); else command.reset( new commands::VIGetVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_GetMyKey > (message)); + hmi_apis::FunctionID::VehicleInfo_GetMyKey > (message, application_manager)); break; } #else case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { if (is_response) { - command.reset(new commands::VIGetVehicleDataResponse(message)); + command.reset(new commands::VIGetVehicleDataResponse(message, application_manager)); } else { - command.reset(new commands::VIGetVehicleDataRequest(message)); + command.reset(new commands::VIGetVehicleDataRequest(message, application_manager)); } break; } #endif // #ifdef HMI_DBUS_API case hmi_apis::FunctionID::VehicleInfo_GetDTCs: { if (is_response) { - command.reset(new commands::VIGetDTCsResponse(message)); + command.reset(new commands::VIGetDTCsResponse(message, application_manager)); } else { - command.reset(new commands::VIGetDTCsRequest(message)); + command.reset(new commands::VIGetDTCsRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: { if (is_response) { - command.reset(new commands::VIDiagnosticMessageResponse(message)); + command.reset(new commands::VIDiagnosticMessageResponse(message, application_manager)); } else { - command.reset(new commands::VIDiagnosticMessageRequest(message)); + command.reset(new commands::VIDiagnosticMessageRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VehicleInfo_GetVehicleType: { if (is_response) { - command.reset(new commands::VIGetVehicleTypeResponse(message)); + command.reset(new commands::VIGetVehicleTypeResponse(message, application_manager)); } else { - command.reset(new commands::VIGetVehicleTypeRequest(message)); + command.reset(new commands::VIGetVehicleTypeRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_IsReady: { if (is_response) { - command.reset(new commands::NaviIsReadyResponse(message)); + command.reset(new commands::NaviIsReadyResponse(message, application_manager)); } else { - command.reset(new commands::NaviIsReadyRequest(message)); + command.reset(new commands::NaviIsReadyRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_AlertManeuver: { if (is_response) { - command.reset(new commands::NaviAlertManeuverResponse(message)); + command.reset(new commands::NaviAlertManeuverResponse(message, application_manager)); } else { - command.reset(new commands::NaviAlertManeuverRequest(message)); + command.reset(new commands::NaviAlertManeuverRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_GetWayPoints: { if (is_response) { - command.reset(new commands::NaviGetWayPointsResponse(message)); + command.reset(new commands::NaviGetWayPointsResponse(message, application_manager)); } else { - command.reset(new commands::NaviGetWayPointsRequest(message)); + command.reset(new commands::NaviGetWayPointsRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_UpdateTurnList: { if (is_response) { - command.reset(new commands::NaviUpdateTurnListResponse(message)); + command.reset(new commands::NaviUpdateTurnListResponse(message, application_manager)); } else { - command.reset(new commands::NaviUpdateTurnListRequest(message)); + command.reset(new commands::NaviUpdateTurnListRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_ShowConstantTBT: { if (is_response) { - command.reset(new commands::NaviShowConstantTBTResponse(message)); + command.reset(new commands::NaviShowConstantTBTResponse(message, application_manager)); } else { - command.reset(new commands::NaviShowConstantTBTRequest(message)); + command.reset(new commands::NaviShowConstantTBTRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { if (is_response) { - command.reset(new commands::NaviSubscribeWayPointsResponse(message)); + command.reset(new commands::NaviSubscribeWayPointsResponse(message, application_manager)); } else { - command.reset(new commands::NaviSubscribeWayPointsRequest(message)); + command.reset(new commands::NaviSubscribeWayPointsRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { if (is_response) { - command.reset(new commands::NaviUnsubscribeWayPointsResponse(message)); + command.reset(new commands::NaviUnsubscribeWayPointsResponse(message, application_manager)); } else { - command.reset(new commands::NaviUnSubscribeWayPointsRequest(message)); + command.reset(new commands::NaviUnSubscribeWayPointsRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Buttons_GetCapabilities: { if (is_response) { - command.reset(new commands::ButtonGetCapabilitiesResponse(message)); + command.reset(new commands::ButtonGetCapabilitiesResponse(message, application_manager)); } else { - command.reset(new commands::ButtonGetCapabilitiesRequest(message)); + command.reset(new commands::ButtonGetCapabilitiesRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_OnAllowSDLFunctionality: { - command.reset(new commands::OnAllowSDLFunctionalityNotification(message)); + command.reset(new commands::OnAllowSDLFunctionalityNotification(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_OnSDLConsentNeeded: { - command.reset(new commands::OnSDLConsentNeededNotification(message)); + command.reset(new commands::OnSDLConsentNeededNotification(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_UpdateSDL: { if (is_response) { - command.reset(new commands::UpdateSDLResponse(message)); + command.reset(new commands::UpdateSDLResponse(message, application_manager)); } else { - command.reset(new commands::UpdateSDLRequest(message)); + command.reset(new commands::UpdateSDLRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_OnIgnitionCycleOver: { - command.reset(new commands::OnIgnitionCycleOverNotification(message)); + command.reset(new commands::OnIgnitionCycleOverNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnSystemInfoChanged: { - command.reset(new commands::OnSystemInfoChangedNotification(message)); + command.reset(new commands::OnSystemInfoChangedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnReady: { - command.reset(new commands::OnReadyNotification(message)); + command.reset(new commands::OnReadyNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnDeviceChosen: { - command.reset(new commands::OnDeviceChosenNotification(message)); + command.reset(new commands::OnDeviceChosenNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnSystemContext: { - command.reset(new commands::OnSystemContextNotification(message)); + command.reset(new commands::OnSystemContextNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnDriverDistraction: { command.reset( - new commands::hmi::OnDriverDistractionNotification(message)); + new commands::hmi::OnDriverDistractionNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnUpdateDeviceList: { - command.reset(new commands::OnUpdateDeviceList(message)); + command.reset(new commands::OnUpdateDeviceList(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnAppRegistered: { - command.reset(new commands::OnAppRegisteredNotification(message)); + command.reset(new commands::OnAppRegisteredNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered: { - command.reset(new commands::OnAppUnregisteredNotification(message)); + command.reset(new commands::OnAppUnregisteredNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnFindApplications: { - command.reset(new commands::OnFindApplications(message)); + command.reset(new commands::OnFindApplications(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_UpdateAppList: { if (is_response) { - command.reset(new commands::UpdateAppListResponse(message)); + command.reset(new commands::UpdateAppListResponse(message, application_manager)); } else { - command.reset(new commands::UpdateAppListRequest(message)); + command.reset(new commands::UpdateAppListRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::VR_Started: { - command.reset(new commands::OnVRStartedNotification(message)); + command.reset(new commands::OnVRStartedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VR_Stopped: { - command.reset(new commands::OnVRStoppedNotification(message)); + command.reset(new commands::OnVRStoppedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VR_OnCommand: { - command.reset(new commands::OnVRCommandNotification(message)); + command.reset(new commands::OnVRCommandNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnCommand: { - command.reset(new commands::OnUICommandNotification(message)); + command.reset(new commands::OnUICommandNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated: { - command.reset(new commands::OnAppDeactivatedNotification(message)); + command.reset(new commands::OnAppDeactivatedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnLanguageChange: { - command.reset(new commands::OnUILanguageChangeNotification(message)); + command.reset(new commands::OnUILanguageChangeNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VR_OnLanguageChange: { - command.reset(new commands::OnVRLanguageChangeNotification(message)); + command.reset(new commands::OnVRLanguageChangeNotification(message, application_manager)); break; } case hmi_apis::FunctionID::TTS_OnLanguageChange: { - command.reset(new commands::OnTTSLanguageChangeNotification(message)); + command.reset(new commands::OnTTSLanguageChangeNotification(message, application_manager)); break; } case hmi_apis::FunctionID::Buttons_OnButtonEvent: { - command.reset(new commands::hmi::OnButtonEventNotification(message)); + command.reset(new commands::hmi::OnButtonEventNotification(message, application_manager)); break; } case hmi_apis::FunctionID::Buttons_OnButtonPress: { - command.reset(new commands::hmi::OnButtonPressNotification(message)); + command.reset(new commands::hmi::OnButtonPressNotification(message, application_manager)); break; } case hmi_apis::FunctionID::Buttons_OnButtonSubscription: { - command.reset(new commands::hmi::OnButtonSubscriptionNotification(message)); + command.reset(new commands::hmi::OnButtonSubscriptionNotification(message, application_manager)); break; } #ifdef HMI_DBUS_API @@ -1210,44 +1211,44 @@ CommandSharedPtr HMICommandFactory::CreateCommand( if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeGps > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeGps > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeGps > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeGps > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeSpeed > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeRpm: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeRpm > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeRpm > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeRpm > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeRpm > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State: { @@ -1255,12 +1256,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeFuelLevel_State > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption: { @@ -1268,12 +1269,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeInstantFuelConsumption > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature: { @@ -1281,34 +1282,34 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeExternalTemperature > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribePrndl: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribePrndl > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribePrndl > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribePrndl > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribePrndl > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeVin: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeVin > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeVin > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeVin > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeVin > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure: { @@ -1316,23 +1317,23 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeTirePressure > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeOdometer > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus: { @@ -1340,12 +1341,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeBeltStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation: { @@ -1353,12 +1354,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeBodyInformation > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus: { @@ -1366,12 +1367,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeDeviceStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking: { @@ -1379,12 +1380,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeDriverBraking > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus: { @@ -1392,12 +1393,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeWiperStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus: { @@ -1405,12 +1406,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeHeadLampStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque: { @@ -1418,12 +1419,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeEngineTorque > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition: { @@ -1431,12 +1432,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeAccPedalPosition > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle: { @@ -1444,23 +1445,23 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeSteeringWheelAngle > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeECallInfo > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus: { @@ -1468,12 +1469,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeAirbagStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent: { @@ -1481,12 +1482,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeEmergencyEvent > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus: { @@ -1494,31 +1495,31 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VISubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_SubscribeClusterModeStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey: { if (is_response) command.reset( new commands::VISubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey > (message, application_manager)); else command.reset( new commands::VISubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey > (message)); + hmi_apis::FunctionID::VehicleInfo_SubscribeMyKey > (message, application_manager)); break; } #else case hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData: { if (is_response) { - command.reset(new commands::VISubscribeVehicleDataResponse(message)); + command.reset(new commands::VISubscribeVehicleDataResponse(message, application_manager)); } else { - command.reset(new commands::VISubscribeVehicleDataRequest(message)); + command.reset(new commands::VISubscribeVehicleDataRequest(message, application_manager)); } break; } @@ -1528,33 +1529,33 @@ CommandSharedPtr HMICommandFactory::CreateCommand( if (is_response) command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps > (message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeGps > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed: { if (is_response) command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed > (message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeSpeed > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm: { if (is_response) command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm > (message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeRpm > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel: { @@ -1562,12 +1563,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State: { @@ -1575,12 +1576,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeFuelLevel_State > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption: { @@ -1588,12 +1589,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeInstantFuelConsumption > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature: { @@ -1601,34 +1602,34 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeExternalTemperature > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl: { if (is_response) command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl > (message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribePrndl > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin: { if (is_response) command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin > (message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeVin > (message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure: { @@ -1636,12 +1637,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeTirePressure > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer: { @@ -1649,12 +1650,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeOdometer > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus: { @@ -1662,12 +1663,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeBeltStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation: { @@ -1675,12 +1676,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeBodyInformation > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus: { @@ -1688,12 +1689,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeDeviceStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking: { @@ -1701,12 +1702,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeDriverBraking > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus: { @@ -1714,12 +1715,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeWiperStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus: { @@ -1727,12 +1728,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeHeadLampStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque: { @@ -1740,12 +1741,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeEngineTorque > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition: { @@ -1753,12 +1754,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeAccPedalPosition > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle: { @@ -1766,12 +1767,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeSteeringWheelAngle > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo: { @@ -1779,12 +1780,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeECallInfo > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus: { @@ -1792,12 +1793,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeAirbagStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent: { @@ -1805,12 +1806,12 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeEmergencyEvent > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus: { @@ -1818,285 +1819,284 @@ CommandSharedPtr HMICommandFactory::CreateCommand( command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus > ( - message)); + message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < hmi_apis::FunctionID::VehicleInfo_UnsubscribeClusterModeStatus > ( - message)); + message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey: { if (is_response) command.reset( new commands::VIUnsubscribeVehicleDataResponseTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey > (message, application_manager)); else command.reset( new commands::VIUnsubscribeVehicleDataRequestTemplate < - hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey > (message)); + hmi_apis::FunctionID::VehicleInfo_UnsubscribeMyKey > (message, application_manager)); break; } #else case hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData: { if (is_response) { - command.reset(new commands::VIUnsubscribeVehicleDataResponse(message)); + command.reset(new commands::VIUnsubscribeVehicleDataResponse(message, application_manager)); } else { - command.reset(new commands::VIUnsubscribeVehicleDataRequest(message)); + command.reset(new commands::VIUnsubscribeVehicleDataRequest(message, application_manager)); } break; } #endif // #ifdef HMI_DBUS_API #ifdef HMI_DBUS_API case hmi_apis::FunctionID::VehicleInfo_OnGpsData: { - command.reset(new commands::OnVIGpsDataNotification(message)); + command.reset(new commands::OnVIGpsDataNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnSpeed: { - command.reset(new commands::OnVISpeedNotification(message)); + command.reset(new commands::OnVISpeedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnRpm: { - command.reset(new commands::OnVIRpmNotification(message)); + command.reset(new commands::OnVIRpmNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnFuelLevel: { - command.reset(new commands::OnVIFuelLevelNotification(message)); + command.reset(new commands::OnVIFuelLevelNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnFuelLevelState: { - command.reset(new commands::OnVIFuelLevelStateNotification(message)); + command.reset(new commands::OnVIFuelLevelStateNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnInstantFuelConsumption: { command.reset( - new commands::OnVIInstantFuelConsumptionNotification(message)); + new commands::OnVIInstantFuelConsumptionNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnExternalTemperature: { - command.reset(new commands::OnVIExternalTemperatureNotification(message)); + command.reset(new commands::OnVIExternalTemperatureNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnVin: { - command.reset(new commands::OnVIVinNotification(message)); + command.reset(new commands::OnVIVinNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnPrndl: { - command.reset(new commands::OnVIPrndlNotification(message)); + command.reset(new commands::OnVIPrndlNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnTirePressure: { - command.reset(new commands::OnVITirePressureNotification(message)); + command.reset(new commands::OnVITirePressureNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnOdometer: { - command.reset(new commands::OnVIOdometerNotification(message)); + command.reset(new commands::OnVIOdometerNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnBeltStatus: { - command.reset(new commands::OnVIBeltStatusNotification(message)); + command.reset(new commands::OnVIBeltStatusNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnBodyInformation: { - command.reset(new commands::OnVIBodyInformationNotification(message)); + command.reset(new commands::OnVIBodyInformationNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnDeviceStatus: { - command.reset(new commands::OnVIDeviceStatusNotification(message)); + command.reset(new commands::OnVIDeviceStatusNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnDriverBraking: { - command.reset(new commands::OnVIDriverBrakingNotification(message)); + command.reset(new commands::OnVIDriverBrakingNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnWiperStatus: { - command.reset(new commands::OnVIWiperStatusNotification(message)); + command.reset(new commands::OnVIWiperStatusNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnHeadLampStatus: { - command.reset(new commands::OnVIHeadLampStatusNotification(message)); + command.reset(new commands::OnVIHeadLampStatusNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnEngineTorque: { - command.reset(new commands::OnVIEngineTorqueNotification(message)); + command.reset(new commands::OnVIEngineTorqueNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnAccPedalPosition: { - command.reset(new commands::OnVIAccPedalPositionNotification(message)); + command.reset(new commands::OnVIAccPedalPositionNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnSteeringWheelAngle: { - command.reset(new commands::OnVISteeringWheelAngleNotification(message)); + command.reset(new commands::OnVISteeringWheelAngleNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VehicleInfo_OnMyKey: { - command.reset(new commands::OnVIMyKeyNotification(message)); + command.reset(new commands::OnVIMyKeyNotification(message, application_manager)); break; } #else case hmi_apis::FunctionID::VehicleInfo_OnVehicleData: { - command.reset(new commands::OnVIVehicleDataNotification(message)); + command.reset(new commands::OnVIVehicleDataNotification(message, application_manager)); break; } #endif // #ifdef HMI_DBUS_API case hmi_apis::FunctionID::Navigation_OnTBTClientState: { - command.reset(new commands::OnNaviTBTClientStateNotification(message)); + command.reset(new commands::OnNaviTBTClientStateNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnKeyboardInput: { - command.reset(new commands::hmi::OnUIKeyBoardInputNotification(message)); + command.reset(new commands::hmi::OnUIKeyBoardInputNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnTouchEvent: { - command.reset(new commands::hmi::OnUITouchEventNotification(message)); + command.reset(new commands::hmi::OnUITouchEventNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnResetTimeout: { - command.reset(new commands::hmi::OnUIResetTimeoutNotification(message)); + command.reset(new commands::hmi::OnUIResetTimeoutNotification(message, application_manager)); break; } case hmi_apis::FunctionID::Navigation_StartStream: { if (is_response) { - command.reset(new commands::NaviStartStreamResponse(message)); + command.reset(new commands::NaviStartStreamResponse(message, application_manager)); } else { - command.reset(new commands::NaviStartStreamRequest(message)); + command.reset(new commands::NaviStartStreamRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_StopStream: { if (is_response) { - command.reset(new commands::NaviStopStreamResponse(message)); + command.reset(new commands::NaviStopStreamResponse(message, application_manager)); } else { - command.reset(new commands::NaviStopStreamRequest(message)); + command.reset(new commands::NaviStopStreamRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_StartAudioStream: { if (is_response) { - command.reset(new commands::AudioStartStreamResponse(message)); + command.reset(new commands::AudioStartStreamResponse(message, application_manager)); } else { - command.reset(new commands::AudioStartStreamRequest(message)); + command.reset(new commands::AudioStartStreamRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_StopAudioStream: { if (is_response) { - command.reset(new commands::AudioStopStreamResponse(message)); + command.reset(new commands::AudioStopStreamResponse(message, application_manager)); } else { - command.reset(new commands::AudioStopStreamRequest(message)); + command.reset(new commands::AudioStopStreamRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_OnAudioDataStreaming: { - command.reset(new commands::OnAudioDataStreamingNotification(message)); + command.reset(new commands::OnAudioDataStreamingNotification(message, application_manager)); break; } case hmi_apis::FunctionID::Navigation_OnVideoDataStreaming: { - command.reset(new commands::OnVideoDataStreamingNotification(message)); + command.reset(new commands::OnVideoDataStreamingNotification(message, application_manager)); break; } case hmi_apis::FunctionID::VR_PerformInteraction: { if (is_response) { - command.reset(new commands::VRPerformInteractionResponse(message)); + command.reset(new commands::VRPerformInteractionResponse(message, application_manager)); } else { - command.reset(new commands::VRPerformInteractionRequest(message)); + command.reset(new commands::VRPerformInteractionRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_OnSystemRequest: { - command.reset(new commands::OnSystemRequestNotification(message)); + command.reset(new commands::OnSystemRequestNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnPutFile: { - command.reset(new commands::OnPutFileNotification(message)); + command.reset(new commands::OnPutFileNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnResumeAudioSource: { - command.reset(new commands::OnResumeAudioSourceNotification(message)); + command.reset(new commands::OnResumeAudioSourceNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_SetDisplayLayout: { if (is_response) { - command.reset(new commands::UiSetDisplayLayoutResponse(message)); + command.reset(new commands::UiSetDisplayLayoutResponse(message, application_manager)); } else { - command.reset(new commands::UiSetDisplayLayoutRequest(message)); + command.reset(new commands::UiSetDisplayLayoutRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::BasicCommunication_OnSDLClose: { - command.reset(new commands::OnSDLCloseNotification(message)); + command.reset(new commands::OnSDLCloseNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete: { - command.reset(new commands::OnSDLPersistenceCompleteNotification(message)); + command.reset(new commands::OnSDLPersistenceCompleteNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnFileRemoved: { - command.reset(new commands::OnFileRemovedNotification(message)); + command.reset(new commands::OnFileRemovedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::UI_OnRecordStart: { - command.reset(new commands::OnRecordStartdNotification(message)); + command.reset(new commands::OnRecordStartdNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_SystemRequest: { if (is_response) { - command.reset(new commands::BasicCommunicationSystemResponse(message)); + command.reset(new commands::BasicCommunicationSystemResponse(message, application_manager)); } else { - command.reset(new commands::BasicCommunicationSystemRequest(message)); + command.reset(new commands::BasicCommunicationSystemRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_SendLocation: { if (is_response) { - command.reset(new commands::NaviSendLocationResponse(message)); + command.reset(new commands::NaviSendLocationResponse(message, application_manager)); } else { - command.reset(new commands::NaviSendLocationRequest(message)); + command.reset(new commands::NaviSendLocationRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::SDL_AddStatisticsInfo: { - command.reset(new commands::AddStatisticsInfoNotification(message)); + command.reset(new commands::AddStatisticsInfoNotification(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_OnSystemError: { - command.reset(new commands::OnSystemErrorNotification(message)); + command.reset(new commands::OnSystemErrorNotification(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_OnReceivedPolicyUpdate: { - command.reset(new commands::OnReceivedPolicyUpdate(message)); + command.reset(new commands::OnReceivedPolicyUpdate(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_OnPolicyUpdate: { - command.reset(new commands::OnPolicyUpdate(message)); + command.reset(new commands::OnPolicyUpdate(message, application_manager)); break; } case hmi_apis::FunctionID::SDL_OnDeviceStateChanged: { - command.reset(new commands::OnDeviceStateChangedNotification(message)); + command.reset(new commands::OnDeviceStateChangedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::TTS_OnResetTimeout: { - command.reset(new commands::hmi::OnTTSResetTimeoutNotification(message)); + command.reset(new commands::hmi::OnTTSResetTimeoutNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_OnEventChanged: { - command.reset(new commands::OnEventChangedNotification(message)); + command.reset(new commands::OnEventChangedNotification(message, application_manager)); break; } case hmi_apis::FunctionID::BasicCommunication_DialNumber: { if (is_response) { - command.reset(new commands::hmi::DialNumberResponse(message)); + command.reset(new commands::hmi::DialNumberResponse(message, application_manager)); } else { - command.reset(new commands::hmi::DialNumberRequest(message)); + command.reset(new commands::hmi::DialNumberRequest(message, application_manager)); } break; } case hmi_apis::FunctionID::Navigation_OnWayPointChange: { - command.reset(new commands::OnNaviWayPointChangeNotification(message)); + command.reset(new commands::OnNaviWayPointChangeNotification(message, application_manager)); break; } } - return command; } diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index e6a58889a7..f62c130c42 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -31,7 +31,7 @@ */ #include "application_manager/hmi_language_handler.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/message_helper.h" #include "application_manager/hmi_capabilities.h" #include "utils/helpers.h" @@ -43,16 +43,17 @@ static const std::string VRKey = "VR"; static const std::string TTSKey = "TTS"; CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") - namespace application_manager { -HMILanguageHandler::HMILanguageHandler() - : capabilities_ui_language_(hmi_apis::Common_Language::INVALID_ENUM) +HMILanguageHandler::HMILanguageHandler(ApplicationManager& application_manager) + : event_engine::EventObserver(application_manager.event_dispatcher()) + , capabilities_ui_language_(hmi_apis::Common_Language::INVALID_ENUM) , capabilities_vr_language_(hmi_apis::Common_Language::INVALID_ENUM) , capabilities_tts_language_(hmi_apis::Common_Language::INVALID_ENUM) , is_ui_language_received_(false) , is_vr_language_received_(false) - , is_tts_language_received_(false) { + , is_tts_language_received_(false) + , application_manager_(application_manager) { subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); } @@ -117,25 +118,24 @@ void HMILanguageHandler::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObject msg = event.smart_object(); switch (event.id()) { - case hmi_apis::FunctionID::UI_GetLanguage: - LOG4CXX_DEBUG(logger_, "Got UI language response."); - is_ui_language_received_ = true; - break; - case hmi_apis::FunctionID::VR_GetLanguage: - LOG4CXX_DEBUG(logger_, "Got VR language response."); - is_vr_language_received_ = true; - break; - case hmi_apis::FunctionID::TTS_GetLanguage: - LOG4CXX_DEBUG(logger_, "Got TTS language response."); - is_tts_language_received_ = true; - break; - case hmi_apis::FunctionID::BasicCommunication_OnAppRegistered: - CheckApplication(std::make_pair( - msg[strings::params][strings::app_id].asUInt(), - true)); - return; - default: - return; + case hmi_apis::FunctionID::UI_GetLanguage: + LOG4CXX_DEBUG(logger_, "Got UI language response."); + is_ui_language_received_ = true; + break; + case hmi_apis::FunctionID::VR_GetLanguage: + LOG4CXX_DEBUG(logger_, "Got VR language response."); + is_vr_language_received_ = true; + break; + case hmi_apis::FunctionID::TTS_GetLanguage: + LOG4CXX_DEBUG(logger_, "Got TTS language response."); + is_tts_language_received_ = true; + break; + case hmi_apis::FunctionID::BasicCommunication_OnAppRegistered: + CheckApplication( + std::make_pair(msg[strings::params][strings::app_id].asUInt(), true)); + return; + default: + return; } if (is_ui_language_received_ && is_vr_language_received_ && @@ -150,32 +150,32 @@ void HMILanguageHandler::set_handle_response_for( LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; if (!request.keyExists(strings::params)) { - LOG4CXX_ERROR(logger_, "Object does not have " << strings::params - << " key."); + LOG4CXX_ERROR(logger_, + "Object does not have " << strings::params << " key."); return; } if (!request[strings::params].keyExists(strings::function_id)) { - LOG4CXX_ERROR(logger_, "Object does not have " << strings::function_id - << " key."); + LOG4CXX_ERROR(logger_, + "Object does not have " << strings::function_id << " key."); return; } if (!request[strings::params].keyExists(strings::correlation_id)) { - LOG4CXX_ERROR(logger_, "Object does not have " << strings::correlation_id - << " key."); + LOG4CXX_ERROR( + logger_, "Object does not have " << strings::correlation_id << " key."); return; } hmi_apis::FunctionID::eType function_id = static_cast<hmi_apis::FunctionID::eType>( - request[strings::params][strings::function_id].asInt()); + request[strings::params][strings::function_id].asInt()); if (!Compare<hmi_apis::FunctionID::eType, EQ, ONE>( - function_id, - hmi_apis::FunctionID::UI_GetLanguage, - hmi_apis::FunctionID::VR_GetLanguage, - hmi_apis::FunctionID::TTS_GetLanguage)) { + function_id, + hmi_apis::FunctionID::UI_GetLanguage, + hmi_apis::FunctionID::VR_GetLanguage, + hmi_apis::FunctionID::TTS_GetLanguage)) { LOG4CXX_ERROR(logger_, "Only *GetLanguage request are allowed to be subscribed."); return; @@ -223,13 +223,12 @@ void HMILanguageHandler::SendOnLanguageChangeToMobile( static_cast<int32_t>(kNotification); message[strings::params][strings::connection_key] = connection_key; - HMICapabilities& hmi_capabilities = - ApplicationManagerImpl::instance()->hmi_capabilities(); + HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); message[strings::msg_params][strings::hmi_display_language] = hmi_capabilities.active_ui_language(); message[strings::msg_params][strings::language] = hmi_capabilities.active_vr_language(); - if (ApplicationManagerImpl::instance()->ManageMobileCommand( + if (application_manager_.ManageMobileCommand( notification, commands::Command::ORIGIN_SDL)) { LOG4CXX_INFO(logger_, "Mobile command sent"); } else { @@ -240,8 +239,7 @@ void HMILanguageHandler::SendOnLanguageChangeToMobile( void HMILanguageHandler::VerifyWithPersistedLanguages() { LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; - const HMICapabilities& hmi_capabilities = - ApplicationManagerImpl::instance()->hmi_capabilities(); + const HMICapabilities& hmi_capabilities = application_manager_.hmi_capabilities(); // Updated values compared with persisted if (hmi_capabilities.active_ui_language() == persisted_ui_language_ && @@ -255,7 +253,7 @@ void HMILanguageHandler::VerifyWithPersistedLanguages() { LOG4CXX_INFO(logger_, "Some languages gotten from HMI have " "mismatch with persisted values."); - ApplicationManagerImpl::ApplicationListAccessor accessor; + const ApplicationSet& accessor = application_manager_.applications().GetData(); ApplicationSetIt it = accessor.begin(); for (; accessor.end() != it;) { ApplicationConstSharedPtr app = *it++; @@ -288,11 +286,10 @@ void HMILanguageHandler::HandleWrongLanguageApp(const Apps::value_type& app) { << app.first << " because of HMI language(s) mismatch."); SendOnLanguageChangeToMobile(app.first); - MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - app.first, - mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); - ApplicationManagerImpl::instance()-> - UnregisterApplication(app.first, mobile_apis::Result::SUCCESS, false); + application_manager_.ManageMobileCommand(MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app.first, mobile_api::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE), commands::Command::ORIGIN_SDL); + application_manager_.UnregisterApplication( + app.first, mobile_apis::Result::SUCCESS, false); apps_.erase(it); if (0 == apps_.size()) { LOG4CXX_DEBUG(logger_, diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 0ae3b2c981..721eb9b063 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -37,7 +37,7 @@ namespace application_manager { HmiState::HmiState(uint32_t app_id, - ApplicationManager* app_mngr, + const ApplicationManager& app_mngr, StateID state_id) : app_id_(app_id) , state_id_(state_id) @@ -46,7 +46,7 @@ HmiState::HmiState(uint32_t app_id, , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} -HmiState::HmiState(uint32_t app_id, ApplicationManager* app_mngr) +HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr) : app_id_(app_id) , state_id_(STATE_ID_REGULAR) , app_mngr_(app_mngr) @@ -60,22 +60,19 @@ void HmiState::set_parent(HmiStatePtr parent) { } bool HmiState::is_navi_app(const uint32_t app_id) const { - DCHECK_OR_RETURN(app_mngr_, false); - const ApplicationSharedPtr app = app_mngr_->application(app_id); + const ApplicationSharedPtr app = app_mngr_.application(app_id); DCHECK_OR_RETURN(app, false); return app ? app->is_navi() : false; } bool HmiState::is_media_app(const uint32_t app_id) const { - DCHECK_OR_RETURN(app_mngr_, false); - const ApplicationSharedPtr app = app_mngr_->application(app_id); + const ApplicationSharedPtr app = app_mngr_.application(app_id); DCHECK_OR_RETURN(app, false); return app ? app->is_media_application() : false; } bool HmiState::is_voice_communication_app(const uint32_t app_id) const { - DCHECK_OR_RETURN(app_mngr_, false); - const ApplicationSharedPtr app = app_mngr_->application(app_id); + const ApplicationSharedPtr app = app_mngr_.application(app_id); DCHECK_OR_RETURN(app, false); return app ? app->is_voice_communication_supported() : false; } @@ -86,10 +83,10 @@ mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state() return AudioStreamingState::NOT_AUDIBLE; } -VRHmiState::VRHmiState(uint32_t app_id, ApplicationManager* app_mngr) +VRHmiState::VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {} -TTSHmiState::TTSHmiState(uint32_t app_id, ApplicationManager* app_mngr) +TTSHmiState::TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {} mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() @@ -98,17 +95,17 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() using namespace mobile_apis; AudioStreamingState::eType expected_state = AudioStreamingState::NOT_AUDIBLE; - if (app_mngr_->is_attenuated_supported() && + if (app_mngr_.is_attenuated_supported() && AudioStreamingState::NOT_AUDIBLE != parent()->audio_streaming_state() && - Compare<HMILevel::eType, EQ, ONE>( - hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + Compare<HMILevel::eType, EQ, ONE>(hmi_level(), HMILevel::HMI_FULL, + HMILevel::HMI_LIMITED)) { expected_state = AudioStreamingState::ATTENUATED; } return expected_state; } NaviStreamingHmiState::NaviStreamingHmiState(uint32_t app_id, - ApplicationManager* app_mngr) + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} mobile_apis::AudioStreamingState::eType @@ -118,7 +115,7 @@ NaviStreamingHmiState::audio_streaming_state() const { AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); if (!is_navi_app(app_id_) && AudioStreamingState::AUDIBLE == expected_state) { - if (app_mngr_->is_attenuated_supported()) { + if (app_mngr_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; } else { expected_state = AudioStreamingState::NOT_AUDIBLE; @@ -128,7 +125,7 @@ NaviStreamingHmiState::audio_streaming_state() const { } PhoneCallHmiState::PhoneCallHmiState(uint32_t app_id, - ApplicationManager* app_mngr) + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {} mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { @@ -149,11 +146,12 @@ mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const { } SafetyModeHmiState::SafetyModeHmiState(uint32_t app_id, - ApplicationManager* app_mngr) + const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {} -DeactivateHMI::DeactivateHMI(uint32_t app_id, ApplicationManager* app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {} +DeactivateHMI::DeactivateHMI(uint32_t app_id, + const ApplicationManager& app_mngr) +: HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {} mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { using namespace helpers; @@ -166,8 +164,8 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { return HMILevel::HMI_BACKGROUND; } -AudioSource::AudioSource(uint32_t app_id, ApplicationManager* app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} +AudioSource::AudioSource(uint32_t app_id, const ApplicationManager& app_mngr) + : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} mobile_apis::HMILevel::eType AudioSource::hmi_level() const { using namespace mobile_apis; @@ -186,7 +184,7 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const { return HMILevel::HMI_BACKGROUND; } -EmbeddedNavi::EmbeddedNavi(uint32_t app_id, ApplicationManager* app_mngr) +EmbeddedNavi::EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr) : HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {} mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 78d47869e2..1be6bb6a24 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -43,11 +43,11 @@ #include <map> #include "application_manager/application.h" -#include "application_manager/application_manager_impl.h" +#include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" #include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler_interface.h" -#include "config_profile/profile.h" +#include "application_manager/resumption/resume_ctrl.h" #include "connection_handler/connection_handler_impl.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/enum_schema_item.h" @@ -63,6 +63,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") namespace application_manager { + namespace { typedef std::map<std::string, hmi_apis::Common_AppPriority::eType> @@ -219,11 +220,10 @@ hmi_apis::Common_Language::eType MessageHelper::CommonLanguageFromString( return hmi_apis::Common_Language::INVALID_ENUM; } -smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject() { +smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject(const uint32_t correlation_id) { using namespace smart_objects; - SmartObjectSPtr request(new SmartObject(SmartType_Map)); - if (request) { + SmartObjectSPtr request = utils::MakeShared<SmartObject>(SmartType_Map); SmartObject& ref = *request; ref[strings::params][strings::message_type] = @@ -232,23 +232,16 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject() { commands::CommandImpl::protocol_version_; ref[strings::params][strings::protocol_type] = commands::CommandImpl::hmi_protocol_type_; - ref[strings::params][strings::correlation_id] = - ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); - } + ref[strings::params][strings::correlation_id] = correlation_id; return request; } -smart_objects::SmartObjectSPtr MessageHelper::GetHashUpdateNotification( +smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( const uint32_t app_id) { - LOG4CXX_INFO(logger_, "GetHashUpdateNotification" << app_id); - ApplicationSharedPtr app = - ApplicationManagerImpl::instance()->application(app_id); - - if (!app) { - return NULL; - } + LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*message)[strings::params][strings::function_id] = mobile_apis::FunctionID::OnHashChangeID; (*message)[strings::params][strings::connection_key] = app_id; @@ -257,13 +250,28 @@ smart_objects::SmartObjectSPtr MessageHelper::GetHashUpdateNotification( return message; } -void MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( - int32_t connection_key, +void MessageHelper::SendHashUpdateNotification(const uint32_t app_id, ApplicationManager& app_mngr) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = app_mngr.application(app_id); + if (!app) { + LOG4CXX_ERROR(logger_, "Application not found by appID"); + return; + } + smart_objects::SmartObjectSPtr so = CreateHashUpdateNotification(app_id); + PrintSmartObject(*so); + if (!app_mngr.ManageMobileCommand( + so, commands::Command::ORIGIN_SDL)) { + LOG4CXX_ERROR(logger_, "Failed to send HashUpdate notification."); + return; + } + app_mngr.resume_controller().ApplicationsDataUpdated(); +} + +smart_objects::SmartObjectSPtr MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(int32_t connection_key, mobile_api::AppInterfaceUnregisteredReason::eType reason) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr notification = new smart_objects::SmartObject; - DCHECK(notification); + smart_objects::SmartObjectSPtr notification = utils::MakeShared<smart_objects::SmartObject>(); smart_objects::SmartObject& message = *notification; message[strings::params][strings::function_id] = static_cast<int32_t>( @@ -276,11 +284,7 @@ void MessageHelper::SendOnAppInterfaceUnregisteredNotificationToMobile( message[strings::msg_params][strings::reason] = static_cast<int32_t>(reason); - if (ApplicationManagerImpl::instance()->ManageMobileCommand(notification)) { - LOG4CXX_DEBUG(logger_, "Mobile command sent"); - } else { - LOG4CXX_WARN(logger_, "Cannot send mobile command"); - } + return notification; } const VehicleData& MessageHelper::vehicle_data() { @@ -458,13 +462,15 @@ static std::map<std::string, uint16_t> vehicle_data_args = #endif void MessageHelper::CreateGetVehicleDataRequest( - uint32_t correlation_id, const std::vector<std::string>& params) { + const uint32_t correlation_id, const std::vector<std::string>& params, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); #ifdef HMI_DBUS_API for (std::vector<std::string>::const_iterator it = params.begin(); it != params.end(); it++) { - smart_objects::SmartObjectSPtr request = new smart_objects::SmartObject; + smart_objects::SmartObjectSPtr request = + utils::MakeShared<smart_objects::SmartObject>(); (*request)[strings::params][strings::message_type] = static_cast<int>(kRequest); @@ -475,10 +481,12 @@ void MessageHelper::CreateGetVehicleDataRequest( commands::CommandImpl::hmi_protocol_type_; (*request)[strings::params][strings::function_id] = static_cast<int>(vehicle_data_args[*it]); - ApplicationManagerImpl::instance()->ManageHMICommand(request); + app_mngr.ManageHMICommand(request); } #else - smart_objects::SmartObjectSPtr request = new smart_objects::SmartObject; + + smart_objects::SmartObjectSPtr request = + utils::MakeShared<smart_objects::SmartObject>(); (*request)[strings::params][strings::message_type] = static_cast<int>(kRequest); @@ -496,17 +504,18 @@ void MessageHelper::CreateGetVehicleDataRequest( it++) { (*request)[strings::msg_params][*it] = true; } - ApplicationManagerImpl::instance()->ManageHMICommand(request); + app_mngr.ManageHMICommand(request); #endif } smart_objects::SmartObjectSPtr MessageHelper::CreateBlockedByPoliciesResponse( mobile_apis::FunctionID::eType function_id, mobile_apis::Result::eType result, - uint32_t correlation_id, + const uint32_t correlation_id, uint32_t connection_key) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr response = new smart_objects::SmartObject; + smart_objects::SmartObjectSPtr response = + utils::MakeShared<smart_objects::SmartObject>(); (*response)[strings::params][strings::function_id] = static_cast<int>(function_id); @@ -526,10 +535,12 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateBlockedByPoliciesResponse( smart_objects::SmartObjectSPtr MessageHelper::CreateDeviceListSO( const connection_handler::DeviceMap& devices, - const policy::PolicyHandlerInterface& policy_handler) { + const policy::PolicyHandlerInterface& policy_handler, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr device_list_so = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*device_list_so)[strings::device_list] = smart_objects::SmartObject(smart_objects::SmartType_Array); @@ -549,7 +560,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateDeviceListSO( list_so[index][strings::isSDLAllowed] = policy::DeviceConsent::kDeviceAllowed == device_consent; list_so[index][strings::transport_type] = - ApplicationManagerImpl::instance()->GetDeviceTransportType( + app_mngr.GetDeviceTransportType( d.connection_type()); ++index; } @@ -557,15 +568,16 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateDeviceListSO( } smart_objects::SmartObjectSPtr MessageHelper::CreateModuleInfoSO( - uint32_t function_id) { + uint32_t function_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr module_info = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); smart_objects::SmartObject& object = *module_info; object[strings::params][strings::message_type] = static_cast<int>(kRequest); object[strings::params][strings::function_id] = static_cast<int>(function_id); object[strings::params][strings::correlation_id] = - ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + app_mngr.GetNextHMICorrelationID(); object[strings::msg_params] = smart_objects::SmartObject(smart_objects::SmartType_Map); return module_info; @@ -575,7 +587,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateSetAppIcon( const std::string& path_to_icon, uint32_t app_id) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr set_icon = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); if (!set_icon) { return NULL; @@ -591,23 +604,22 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateSetAppIcon( return set_icon; } -bool MessageHelper::SendIVISubscribtions(const uint32_t app_id) { +bool MessageHelper::SendIVISubscribtions(const uint32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); bool result = true; - ApplicationSharedPtr app = - ApplicationManagerImpl::instance()->application(app_id); + ApplicationSharedPtr app = app_mngr.application(app_id); if (!app.valid()) { LOG4CXX_ERROR(logger_, "Invalid application " << app_id); return result; } - smart_objects::SmartObjectList requests = GetIVISubscriptionRequests(app); + smart_objects::SmartObjectList requests = GetIVISubscriptionRequests(app, app_mngr); for (smart_objects::SmartObjectList::const_iterator it = requests.begin(); it != requests.end(); ++it) { - if (!ApplicationManagerImpl::instance()->ManageHMICommand(*it)) { + if (!app_mngr.ManageHMICommand(*it)) { result = false; } } @@ -615,7 +627,7 @@ bool MessageHelper::SendIVISubscribtions(const uint32_t app_id) { } smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( - ApplicationSharedPtr app) { + ApplicationSharedPtr app, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectList hmi_requests; @@ -642,7 +654,7 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( #ifdef HMI_JSON_API smart_objects::SmartObjectSPtr request = MessageHelper::CreateModuleInfoSO( - hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData); + hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData, app_mngr); (*request)[strings::msg_params] = msg_params; hmi_requests.push_back(request); #endif // #ifdef HMI_JSON_API @@ -664,9 +676,9 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( } void MessageHelper::SendOnButtonSubscriptionNotification( - const uint32_t app_id, - const hmi_apis::Common_ButtonName::eType button, - const bool is_subscribed) { + uint32_t app_id, + hmi_apis::Common_ButtonName::eType button, + bool is_subscribed, ApplicationManager& app_mngr) { using namespace smart_objects; using namespace hmi_apis; LOG4CXX_AUTO_TRACE(logger_); @@ -694,13 +706,13 @@ void MessageHelper::SendOnButtonSubscriptionNotification( hmi_apis::FunctionID::Buttons_OnButtonSubscription; notification[strings::msg_params] = msg_params; - if (!ApplicationManagerImpl::instance()->ManageHMICommand(notification_ptr)) { + if (!app_mngr.ManageHMICommand(notification_ptr)) { LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); } } void MessageHelper::SendAllOnButtonSubscriptionNotificationsForApp( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { using namespace smart_objects; using namespace hmi_apis; using namespace mobile_apis; @@ -716,14 +728,20 @@ void MessageHelper::SendAllOnButtonSubscriptionNotificationsForApp( ButtonSubscriptions::iterator it = subscriptions.begin(); for (; subscriptions.end() != it; ++it) { SendOnButtonSubscriptionNotification( - app->hmi_app_id(), static_cast<Common_ButtonName::eType>(*it), true); + app->hmi_app_id(), + static_cast<Common_ButtonName::eType>(*it), + true, + app_mngr); } } void MessageHelper::SendSetAppIcon(const uint32_t app_id, - const std::string& icon_path) { + const std::string& icon_path, + application_manager::ApplicationManager& application_manager) { using namespace smart_objects; - SmartObjectSPtr set_app_icon = CreateRequestObject(); + + SmartObjectSPtr set_app_icon = + CreateRequestObject(application_manager.GetNextHMICorrelationID()); if (set_app_icon) { SmartObject& so_to_send = *set_app_icon; so_to_send[strings::params][strings::function_id] = @@ -737,37 +755,37 @@ void MessageHelper::SendSetAppIcon(const uint32_t app_id, if (msg_params) { so_to_send[strings::msg_params] = *msg_params; } - ApplicationManagerImpl::instance()->ManageHMICommand(set_app_icon); + application_manager.ManageHMICommand(set_app_icon); } } -void MessageHelper::SendAppDataToHMI(ApplicationConstSharedPtr app) { +void MessageHelper::SendAppDataToHMI(ApplicationConstSharedPtr app, ApplicationManager& app_man) { LOG4CXX_AUTO_TRACE(logger_); if (app) { - SendSetAppIcon(app, app->app_icon_path()); - SendGlobalPropertiesToHMI(app); - SendShowRequestToHMI(app); + SendSetAppIcon(app, app->app_icon_path(), app_man); + SendGlobalPropertiesToHMI(app, app_man); + SendShowRequestToHMI(app, app_man); } } -void MessageHelper::SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app) { +void MessageHelper::SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { if (!app.valid()) { LOG4CXX_ERROR(logger_, "Invalid application"); return; } smart_objects::SmartObjectList requests = - CreateGlobalPropertiesRequestsToHMI(app); + CreateGlobalPropertiesRequestsToHMI(app, app_mngr.GetNextHMICorrelationID()); for (smart_objects::SmartObjectList::const_iterator it = requests.begin(); it != requests.end(); ++it) { - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(*it)); + DCHECK(app_mngr.ManageHMICommand(*it)); } } smart_objects::SmartObjectList -MessageHelper::CreateGlobalPropertiesRequestsToHMI( - ApplicationConstSharedPtr app) { +MessageHelper::CreateGlobalPropertiesRequestsToHMI(ApplicationConstSharedPtr app, + const uint32_t correlation_id) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectList requests; @@ -779,7 +797,8 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( // UI global properties if (app->vr_help_title() || app->vr_help()) { - smart_objects::SmartObjectSPtr ui_global_properties = CreateRequestObject(); + smart_objects::SmartObjectSPtr ui_global_properties = + CreateRequestObject(correlation_id); if (!ui_global_properties) { return requests; } @@ -814,7 +833,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( // TTS global properties if (app->help_prompt() || app->timeout_prompt()) { smart_objects::SmartObjectSPtr tts_global_properties = - CreateRequestObject(); + CreateRequestObject(correlation_id); if (!tts_global_properties) { return requests; } @@ -840,12 +859,13 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( } void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app, - const bool default_help_prompt) { + bool default_help_prompt, + ApplicationManager& app_man) { LOG4CXX_AUTO_TRACE(logger_); if (!app) { return; } - smart_objects::SmartObjectSPtr tts_global_properties = CreateRequestObject(); + smart_objects::SmartObjectSPtr tts_global_properties = CreateRequestObject(app_man.GetNextHMICorrelationID()); if (tts_global_properties) { smart_objects::SmartObject& so_to_send = *tts_global_properties; so_to_send[strings::params][strings::function_id] = @@ -876,14 +896,15 @@ void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app, app->set_help_prompt(msg_params[strings::help_prompt]); msg_params[strings::app_id] = app->app_id(); so_to_send[strings::msg_params] = msg_params; - ApplicationManagerImpl::instance()->ManageHMICommand(tts_global_properties); + app_man.ManageHMICommand(tts_global_properties); } } smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp( ApplicationConstSharedPtr app) { smart_objects::SmartObjectSPtr result = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); if (!result) { return NULL; } @@ -913,7 +934,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAppVrHelp( } smart_objects::SmartObjectList MessageHelper::CreateShowRequestToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, const uint32_t correlation_id) { smart_objects::SmartObjectList requests; if (!app) { LOG4CXX_ERROR(logger_, "Invalid application"); @@ -921,7 +942,7 @@ smart_objects::SmartObjectList MessageHelper::CreateShowRequestToHMI( } if (app->show_command()) { - smart_objects::SmartObjectSPtr ui_show = CreateRequestObject(); + smart_objects::SmartObjectSPtr ui_show = CreateRequestObject(correlation_id); (*ui_show)[strings::params][strings::function_id] = static_cast<int>(hmi_apis::FunctionID::UI_Show); @@ -931,27 +952,28 @@ smart_objects::SmartObjectList MessageHelper::CreateShowRequestToHMI( return requests; } -void MessageHelper::SendShowRequestToHMI(ApplicationConstSharedPtr app) { +void MessageHelper::SendShowRequestToHMI(ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { if (!app) { return; } - smart_objects::SmartObjectList shows = CreateShowRequestToHMI(app); + smart_objects::SmartObjectList shows = CreateShowRequestToHMI(app, app_mngr.GetNextHMICorrelationID()); for (smart_objects::SmartObjectList::const_iterator it = shows.begin(); it != shows.end(); ++it) { - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(*it)); + DCHECK(app_mngr.ManageHMICommand(*it)); } } void MessageHelper::SendShowConstantTBTRequestToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, ApplicationManager& app_man) { if (!app) { return; } if (app->tbt_show_command()) { - smart_objects::SmartObjectSPtr navi_show_tbt = CreateRequestObject(); + smart_objects::SmartObjectSPtr navi_show_tbt = + CreateRequestObject(app_man.GetNextHMICorrelationID()); if (!navi_show_tbt) { return; } @@ -959,24 +981,25 @@ void MessageHelper::SendShowConstantTBTRequestToHMI( static_cast<int>(hmi_apis::FunctionID::Navigation_ShowConstantTBT); (*navi_show_tbt)[strings::msg_params] = (*app->tbt_show_command()); - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(navi_show_tbt)); + DCHECK(app_man.ManageHMICommand(navi_show_tbt)); } } -void MessageHelper::SendAddCommandRequestToHMI(ApplicationConstSharedPtr app) { +void MessageHelper::SendAddCommandRequestToHMI(ApplicationConstSharedPtr app, + ApplicationManager& app_man) { if (!app) { return; } - smart_objects::SmartObjectList requests = CreateAddCommandRequestToHMI(app); + smart_objects::SmartObjectList requests = CreateAddCommandRequestToHMI(app, app_man); for (smart_objects::SmartObjectList::iterator it = requests.begin(); it != requests.end(); ++it) { - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(*it)); + DCHECK(app_man.ManageHMICommand(*it)); } } smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { smart_objects::SmartObjectList requests; if (!app) { LOG4CXX_ERROR(logger_, "Invalid application"); @@ -989,7 +1012,7 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( for (; commands.end() != i; ++i) { // UI Interface if ((*i->second).keyExists(strings::menu_params)) { - smart_objects::SmartObjectSPtr ui_command = CreateRequestObject(); + smart_objects::SmartObjectSPtr ui_command = CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!ui_command) { return requests; } @@ -1015,8 +1038,10 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( // VR Interface if ((*i->second).keyExists(strings::vr_commands)) { - SendAddVRCommandToHMI( - i->first, (*i->second)[strings::vr_commands], app->app_id()); + SendAddVRCommandToHMI(i->first, + (*i->second)[strings::vr_commands], + app->app_id(), + app_mngr); } } return requests; @@ -1024,7 +1049,7 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( smart_objects::SmartObjectList MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { smart_objects::SmartObjectList requests; if (!app) { LOG4CXX_ERROR(logger_, "Invalid application"); @@ -1039,7 +1064,7 @@ MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( (*(it->second))[strings::grammar_id].asUInt(); const size_t size = (*(it->second))[strings::choice_set].length(); for (size_t j = 0; j < size; ++j) { - smart_objects::SmartObjectSPtr vr_command = CreateRequestObject(); + smart_objects::SmartObjectSPtr vr_command = CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!vr_command) { return requests; } @@ -1070,8 +1095,10 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateChangeRegistration( const int32_t function_id, const int32_t language, const uint32_t app_id, - const smart_objects::SmartObject* app_types) { - smart_objects::SmartObjectSPtr command = CreateRequestObject(); + const smart_objects::SmartObject* app_types, + ApplicationManager& app_mngr) { + smart_objects::SmartObjectSPtr command = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!command) { return NULL; } @@ -1092,7 +1119,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateChangeRegistration( } void MessageHelper::SendUIChangeRegistrationRequestToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { if (!app.valid()) { LOG4CXX_ERROR(logger_, "Application is not valid"); return; @@ -1103,16 +1130,17 @@ void MessageHelper::SendUIChangeRegistrationRequestToHMI( CreateChangeRegistration(hmi_apis::FunctionID::UI_ChangeRegistration, app->ui_language(), app->app_id(), - app->app_types()); + app->app_types(), + app_mngr); if (ui_command) { - ApplicationManagerImpl::instance()->ManageHMICommand(ui_command); + app_mngr.ManageHMICommand(ui_command); } } } void MessageHelper::SendChangeRegistrationRequestToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { if (!app.valid()) { return; } @@ -1120,10 +1148,10 @@ void MessageHelper::SendChangeRegistrationRequestToHMI( smart_objects::SmartObjectSPtr vr_command = CreateChangeRegistration(hmi_apis::FunctionID::VR_ChangeRegistration, app->language(), - app->app_id()); + app->app_id(), NULL, app_mngr); if (vr_command) { - ApplicationManagerImpl::instance()->ManageHMICommand(vr_command); + app_mngr.ManageHMICommand(vr_command); } } @@ -1131,10 +1159,10 @@ void MessageHelper::SendChangeRegistrationRequestToHMI( smart_objects::SmartObjectSPtr tts_command = CreateChangeRegistration(hmi_apis::FunctionID::TTS_ChangeRegistration, app->language(), - app->app_id()); + app->app_id(), NULL, app_mngr); if (tts_command) { - ApplicationManagerImpl::instance()->ManageHMICommand(tts_command); + app_mngr.ManageHMICommand(tts_command); } } @@ -1142,10 +1170,10 @@ void MessageHelper::SendChangeRegistrationRequestToHMI( smart_objects::SmartObjectSPtr ui_command = CreateChangeRegistration(hmi_apis::FunctionID::UI_ChangeRegistration, app->ui_language(), - app->app_id()); + app->app_id(), NULL, app_mngr); if (ui_command) { - ApplicationManagerImpl::instance()->ManageHMICommand(ui_command); + app_mngr.ManageHMICommand(ui_command); } } } @@ -1153,17 +1181,18 @@ void MessageHelper::SendChangeRegistrationRequestToHMI( void MessageHelper::SendAddVRCommandToHMI( const uint32_t cmd_id, const smart_objects::SmartObject& vr_commands, - const uint32_t app_id) { + const uint32_t app_id, + ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr request = - CreateAddVRCommandToHMI(cmd_id, vr_commands, app_id); - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(request)); + CreateAddVRCommandToHMI(cmd_id, vr_commands, app_id, app_mngr); + DCHECK(app_mngr.ManageHMICommand(request)); } smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI( const uint32_t cmd_id, const smart_objects::SmartObject& vr_commands, - const uint32_t app_id) { - smart_objects::SmartObjectSPtr vr_command = CreateRequestObject(); + uint32_t app_id, ApplicationManager& app_mngr) { + smart_objects::SmartObjectSPtr vr_command = CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!vr_command) { return NULL; } @@ -1180,8 +1209,7 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI( if (0 < app_id) { msg_params[strings::app_id] = app_id; } - msg_params[strings::grammar_id] = - ApplicationManagerImpl::instance()->application(app_id)->get_grammar_id(); + msg_params[strings::grammar_id] = app_mngr.application(app_id)->get_grammar_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; (*vr_command)[strings::msg_params] = msg_params; @@ -1193,20 +1221,21 @@ bool MessageHelper::CreateHMIApplicationStruct( ApplicationConstSharedPtr app, const protocol_handler::SessionObserver& session_observer, const policy::PolicyHandlerInterface& policy_handler, - NsSmartDeviceLink::NsSmartObjects::SmartObject* output) { + NsSmartDeviceLink::NsSmartObjects::SmartObject* output, + ApplicationManager& app_mngr) { using NsSmartDeviceLink::NsSmartObjects::SmartObject; DCHECK_OR_RETURN(output, false); SmartObject& message = *output; + if (!app) { LOG4CXX_WARN(logger_, "Application is not valid"); return false; } - const SmartObject* app_types = app->app_types(); - const SmartObject* ngn_media_screen_name = app->ngn_media_screen_name(); - const connection_handler::DeviceHandle handle = app->device(); - std::string device_name = - ApplicationManagerImpl::instance()->GetDeviceName(handle); + const smart_objects::SmartObject* app_types = app->app_types(); + const smart_objects::SmartObject* ngn_media_screen_name = + app->ngn_media_screen_name(); + std::string device_name; std::string mac_address; std::string transport_type; if (-1 == @@ -1216,7 +1245,7 @@ bool MessageHelper::CreateHMIApplicationStruct( "Failed to extract information for device " << app->device()); } - message = SmartObject(smart_objects::SmartType_Map); + message = smart_objects::SmartObject(smart_objects::SmartType_Map); message[strings::app_name] = app->name(); message[strings::app_id] = app->hmi_app_id(); const std::string icon_path = app->app_icon_path(); @@ -1253,33 +1282,36 @@ bool MessageHelper::CreateHMIApplicationStruct( policy::DeviceConsent::kDeviceAllowed == device_consent; message[strings::device_info][strings::transport_type] = - ApplicationManagerImpl::instance()->GetDeviceTransportType( + app_mngr.GetDeviceTransportType( transport_type); return true; } -void MessageHelper::SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app) { +void MessageHelper::SendAddSubMenuRequestToHMI(ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { if (!app.valid()) { LOG4CXX_ERROR(logger_, "Invalid application"); return; } - smart_objects::SmartObjectList requests = CreateAddSubMenuRequestToHMI(app); + smart_objects::SmartObjectList requests = + CreateAddSubMenuRequestToHMI(app, app_mngr.GetNextHMICorrelationID()); for (smart_objects::SmartObjectList::iterator it = requests.begin(); it != requests.end(); ++it) { - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(*it)); + DCHECK(app_mngr.ManageHMICommand(*it)); } } smart_objects::SmartObjectList MessageHelper::CreateAddSubMenuRequestToHMI( - ApplicationConstSharedPtr app) { + ApplicationConstSharedPtr app, const uint32_t correlation_id) { smart_objects::SmartObjectList requsets; const DataAccessor<SubMenuMap> accessor = app->sub_menu_map(); const SubMenuMap& sub_menu = accessor.GetData(); SubMenuMap::const_iterator i = sub_menu.begin(); for (; sub_menu.end() != i; ++i) { - smart_objects::SmartObjectSPtr ui_sub_menu = CreateRequestObject(); + smart_objects::SmartObjectSPtr ui_sub_menu = + CreateRequestObject(correlation_id); if (!ui_sub_menu) { return requsets; } @@ -1303,12 +1335,13 @@ smart_objects::SmartObjectList MessageHelper::CreateAddSubMenuRequestToHMI( } void MessageHelper::SendOnAppUnregNotificationToHMI( - ApplicationConstSharedPtr app, const bool is_unexpected_disconnect) { + ApplicationConstSharedPtr app, + bool is_unexpected_disconnect, + ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr notification = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - if (!notification) { - return; - } + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + smart_objects::SmartObject& message = *notification; message[strings::params][strings::function_id] = @@ -1322,18 +1355,19 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( message[strings::msg_params][strings::app_id] = app->hmi_app_id(); message[strings::msg_params][strings::unexpected_disconnect] = is_unexpected_disconnect; - ApplicationManagerImpl::instance()->ManageHMICommand(notification); + app_mngr.ManageHMICommand(notification); } -smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI(ApplicationConstSharedPtr app, +smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI( + ApplicationConstSharedPtr app, const protocol_handler::SessionObserver& session_observer, - const policy::PolicyHandlerInterface &policy_handler, + const policy::PolicyHandlerInterface& policy_handler, hmi_apis::Common_HMILevel::eType level, - bool send_policy_priority) { + bool send_policy_priority, + ApplicationManager& app_mngr) { DCHECK_OR_RETURN(app, smart_objects::SmartObjectSPtr()); - const uint32_t correlation_id = - ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + const uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); smart_objects::SmartObjectSPtr message = utils::MakeShared<smart_objects::SmartObject>( smart_objects::SmartType_Map); @@ -1347,14 +1381,14 @@ smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI(Appli std::string priority; // TODO(KKolodiy): need remove method policy_manager - policy_handler.GetPriority(app->mobile_app_id(), + policy_handler.GetPriority(app->policy_app_id(), &priority); // According SDLAQ-CRS-2794 // SDL have to send ActivateApp without "proirity" parameter to HMI. // in case of unconsented device const std::string& mac_adress = app->mac_address(); - const policy::DeviceConsent& consent = policy_handler.GetUserConsentForDevice(mac_adress); + policy::DeviceConsent consent = policy_handler.GetUserConsentForDevice(mac_adress); if (!priority.empty() && (policy::DeviceConsent::kDeviceAllowed == consent)) { (*message)[strings::msg_params][strings::priority] = @@ -1370,10 +1404,10 @@ smart_objects::SmartObjectSPtr MessageHelper::GetBCActivateAppRequestToHMI(Appli return message; } -void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id) { +void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id, + ApplicationManager& app_mngr) { LOG4CXX_WARN(logger_, "SendOnResumeAudioSourceToHMI app_id: " << app_id); - application_manager::ApplicationConstSharedPtr app = - application_manager::ApplicationManagerImpl::instance()->application( + application_manager::ApplicationConstSharedPtr app = app_mngr.application( app_id); if (!app) { LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id); @@ -1381,26 +1415,27 @@ void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id) { } utils::SharedPtr<smart_objects::SmartObject> message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_OnResumeAudioSource; (*message)[strings::params][strings::message_type] = MessageType::kNotification; (*message)[strings::params][strings::correlation_id] = - ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + app_mngr.GetNextHMICorrelationID(); (*message)[strings::msg_params][strings::app_id] = app_id; - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } void MessageHelper::SendSDLActivateAppResponse( - policy::AppPermissions& permissions, const uint32_t correlation_id) { + policy::AppPermissions& permissions, + const uint32_t correlation_id, + ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - if (!message) { - return; - } + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_ActivateApp; @@ -1436,21 +1471,20 @@ void MessageHelper::SendSDLActivateAppResponse( GetPriorityCode(permissions.priority); } - ApplicationManagerImpl::instance()->ManageHMICommand(message); - // If application is revoked it should not be activated if (permissions.appRevoked || !permissions.isSDLAllowed) { return; } + + app_mngr.ManageHMICommand(message); } void MessageHelper::SendOnSDLConsentNeeded( - const policy::DeviceParams& device_info) { + const policy::DeviceParams& device_info, + ApplicationManager& app_man) { smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - if (!message) { - return; - } + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_OnSDLConsentNeeded; @@ -1461,13 +1495,15 @@ void MessageHelper::SendOnSDLConsentNeeded( device_info.device_mac_address; (*message)[strings::msg_params]["device"]["name"] = device_info.device_name; - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_man.ManageHMICommand(message); } void MessageHelper::SendPolicyUpdate(const std::string& file_path, const int timeout, - const std::vector<int>& retries) { - smart_objects::SmartObjectSPtr message = CreateRequestObject(); + const std::vector<int>& retries, + ApplicationManager& app_mngr) { + smart_objects::SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); smart_objects::SmartObject& object = *message; object[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_PolicyUpdate; @@ -1479,18 +1515,17 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path, for (size_t i = 0; i < retries.size(); ++i) { object[strings::msg_params][hmi_request::retry][i] = retries[i]; } - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } void MessageHelper::SendGetUserFriendlyMessageResponse( const std::vector<policy::UserFriendlyMessage>& msg, - const uint32_t correlation_id) { + uint32_t correlation_id, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - if (!message) { - return; - } + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_GetUserFriendlyMessage; @@ -1500,7 +1535,7 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( // If no any messages found - skip sending of "messages" param if (msg.empty()) { - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); return; } @@ -1523,30 +1558,27 @@ void MessageHelper::SendGetUserFriendlyMessageResponse( obj[message_code] = it->message_code; } - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } void MessageHelper::SendGetListOfPermissionsResponse( const std::vector<policy::FunctionalGroupPermission>& permissions, - const uint32_t correlation_id) { - smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - if (!message) { - return; - } + const uint32_t correlation_id, + ApplicationManager& app_mngr) { + smart_objects::SmartObject message(smart_objects::SmartType_Map); - (*message)[strings::params][strings::function_id] = + message[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_GetListOfPermissions; - (*message)[strings::params][strings::message_type] = MessageType::kResponse; - (*message)[strings::params][strings::correlation_id] = correlation_id; - (*message)[strings::params][hmi_response::code] = 0; + message[strings::params][strings::message_type] = MessageType::kResponse; + message[strings::params][strings::correlation_id] = correlation_id; + message[strings::params][hmi_response::code] = 0; const std::string allowed_functions = "allowedFunctions"; - (*message)[strings::msg_params][allowed_functions] = + message[strings::msg_params][allowed_functions] = smart_objects::SmartObject(smart_objects::SmartType_Array); smart_objects::SmartObject& allowed_functions_array = - (*message)[strings::msg_params][allowed_functions]; + message[strings::msg_params][allowed_functions]; std::vector<policy::FunctionalGroupPermission>::const_iterator it = permissions.begin(); @@ -1566,17 +1598,16 @@ void MessageHelper::SendGetListOfPermissionsResponse( } } - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand( + utils::MakeShared<smart_objects::SmartObject>(message)); } smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse( uint32_t connection_key, int32_t function_id, - uint32_t correlation_id, + const uint32_t correlation_id, int32_t result_code) { - smart_objects::SmartObjectSPtr response = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject& response_data = *response; + smart_objects::SmartObject response_data(smart_objects::SmartType_Map); response_data[strings::params][strings::function_id] = function_id; response_data[strings::params][strings::message_type] = mobile_apis::messageType::response; @@ -1589,12 +1620,14 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateNegativeResponse( response_data[strings::msg_params][strings::success] = false; response_data[strings::params][strings::connection_key] = connection_key; - return response; + return utils::MakeShared<smart_objects::SmartObject>(response_data); } -void MessageHelper::SendNaviStartStream(const int32_t app_id) { +void MessageHelper::SendNaviStartStream(const int32_t app_id, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr start_stream = CreateRequestObject(); + smart_objects::SmartObjectSPtr start_stream = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!start_stream) { return; } @@ -1602,41 +1635,38 @@ void MessageHelper::SendNaviStartStream(const int32_t app_id) { (*start_stream)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_StartStream; - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - char url[100] = {'\0'}; - if ("socket" == profile::Profile::instance()->video_server_type()) { + if ("socket" == app_mngr.get_settings().video_server_type()) { snprintf(url, sizeof(url) / sizeof(url[0]), "http://%s:%d", - profile::Profile::instance()->server_address().c_str(), - profile::Profile::instance()->video_streaming_port()); - } else if ("pipe" == profile::Profile::instance()->video_server_type()) { + app_mngr.get_settings().server_address().c_str(), + app_mngr.get_settings().video_streaming_port()); + } else if ("pipe" == app_mngr.get_settings().video_server_type()) { snprintf(url, sizeof(url) / sizeof(url[0]), "%s", - profile::Profile::instance()->named_video_pipe_path().c_str()); + app_mngr.get_settings().named_video_pipe_path().c_str()); } else { - int snprintf_result; - snprintf_result = + int snprintf_result = snprintf(url, sizeof(url) / sizeof(url[0]), "%s", - profile::Profile::instance()->video_stream_file().c_str()); + app_mngr.get_settings().video_stream_file().c_str()); DCHECK(snprintf_result); } - msg_params[strings::app_id] = app_id; - msg_params[strings::url] = url; - (*start_stream)[strings::msg_params] = msg_params; + (*start_stream)[strings::msg_params][strings::app_id] = app_id; + (*start_stream)[strings::msg_params][strings::url] = url; - ApplicationManagerImpl::instance()->ManageHMICommand(start_stream); + app_mngr.ManageHMICommand(start_stream); } -void MessageHelper::SendNaviStopStream(const int32_t app_id) { +void MessageHelper::SendNaviStopStream(const int32_t app_id, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr stop_stream = CreateRequestObject(); + smart_objects::SmartObjectSPtr stop_stream = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!stop_stream) { return; } @@ -1644,19 +1674,17 @@ void MessageHelper::SendNaviStopStream(const int32_t app_id) { (*stop_stream)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_StopStream; - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - msg_params[strings::app_id] = app_id; - - (*stop_stream)[strings::msg_params] = msg_params; + (*stop_stream)[strings::msg_params][strings::app_id] = app_id; - ApplicationManagerImpl::instance()->ManageHMICommand(stop_stream); + app_mngr.ManageHMICommand(stop_stream); } -void MessageHelper::SendAudioStartStream(const int32_t app_id) { +void MessageHelper::SendAudioStartStream(const int32_t app_id, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr start_stream = CreateRequestObject(); + smart_objects::SmartObjectSPtr start_stream = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + if (!start_stream) { return; } @@ -1664,42 +1692,39 @@ void MessageHelper::SendAudioStartStream(const int32_t app_id) { (*start_stream)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_StartAudioStream; - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - char url[100] = {'\0'}; - if ("socket" == profile::Profile::instance()->audio_server_type()) { + if ("socket" == app_mngr.get_settings().audio_server_type()) { snprintf(url, sizeof(url) / sizeof(url[0]), "http://%s:%d", - profile::Profile::instance()->server_address().c_str(), - profile::Profile::instance()->audio_streaming_port()); - } else if ("pipe" == profile::Profile::instance()->audio_server_type()) { + app_mngr.get_settings().server_address().c_str(), + app_mngr.get_settings().audio_streaming_port()); + } else if ("pipe" == app_mngr.get_settings().audio_server_type()) { snprintf(url, sizeof(url) / sizeof(url[0]), "%s", - profile::Profile::instance()->named_audio_pipe_path().c_str()); + app_mngr.get_settings().named_audio_pipe_path().c_str()); } else { - int snprintf_result; - snprintf_result = + int snprintf_result = snprintf(url, sizeof(url) / sizeof(url[0]), "%s", - profile::Profile::instance()->audio_stream_file().c_str()); + app_mngr.get_settings().audio_stream_file().c_str()); DCHECK(snprintf_result); } - msg_params[strings::app_id] = app_id; - msg_params[strings::url] = url; - - (*start_stream)[strings::msg_params] = msg_params; + (*start_stream)[strings::msg_params][strings::app_id] = app_id; + (*start_stream)[strings::msg_params][strings::url] = url; - DCHECK(ApplicationManagerImpl::instance()->ManageHMICommand(start_stream)); + DCHECK(app_mngr.ManageHMICommand(start_stream)); } -void MessageHelper::SendAudioStopStream(const int32_t app_id) { +void MessageHelper::SendAudioStopStream(const int32_t app_id, + ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr stop_stream = CreateRequestObject(); + smart_objects::SmartObjectSPtr stop_stream = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); + if (!stop_stream) { return; } @@ -1707,29 +1732,25 @@ void MessageHelper::SendAudioStopStream(const int32_t app_id) { (*stop_stream)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_StopAudioStream; - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - msg_params[strings::app_id] = app_id; - - (*stop_stream)[strings::msg_params] = msg_params; + (*stop_stream)[strings::msg_params][strings::app_id] = app_id; - ApplicationManagerImpl::instance()->ManageHMICommand(stop_stream); + app_mngr.ManageHMICommand(stop_stream); } void MessageHelper::SendOnDataStreaming(const protocol_handler::ServiceType service, - const bool available) { + const bool available, + ApplicationManager& app_mngr) { using namespace protocol_handler; - smart_objects::SmartObjectSPtr notification = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + using namespace helpers; - if (!notification) { + if (!Compare<ServiceType, EQ, ONE>( + service, ServiceType::kAudio, ServiceType::kMobileNav)) { return; } - if (ServiceType::kAudio != service && ServiceType::kMobileNav != service) { - return; - } + smart_objects::SmartObjectSPtr notification = + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); (*notification)[strings::params][strings::function_id] = ServiceType::kAudio == service @@ -1744,121 +1765,118 @@ void MessageHelper::SendOnDataStreaming(const protocol_handler::ServiceType serv (*notification)[strings::msg_params]["available"] = available; - ApplicationManagerImpl::instance()->ManageHMICommand(notification); + app_mngr.ManageHMICommand(notification); } -bool MessageHelper::SendStopAudioPathThru() { +bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) { LOG4CXX_INFO(logger_, "MessageHelper::SendAudioStopAudioPathThru"); - smart_objects::SmartObjectSPtr result = CreateRequestObject(); + smart_objects::SmartObjectSPtr result = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); - smart_objects::SmartObject& request = *result; - request[strings::params][strings::function_id] = + (*result)[strings::params][strings::function_id] = hmi_apis::FunctionID::UI_EndAudioPassThru; - return ApplicationManagerImpl::instance()->ManageHMICommand(result); + return app_mngr.ManageHMICommand(result); } -bool MessageHelper::SendUnsubscribedWayPoints() { +bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) { LOG4CXX_INFO(logger_, "MessageHelper::SendUnsubscribedWayPoints"); - smart_objects::SmartObjectSPtr result = CreateRequestObject(); + smart_objects::SmartObjectSPtr result = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); - smart_objects::SmartObject& request = *result; - request[strings::params][strings::function_id] = + (*result)[strings::params][strings::function_id] = hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints; - return ApplicationManagerImpl::instance()->ManageHMICommand(result); + return app_mngr.ManageHMICommand(result); } void MessageHelper::SendPolicySnapshotNotification( - const unsigned int connection_key, + uint32_t connection_key, const std::vector<uint8_t>& policy_data, - const std::string& url) { - ApplicationSharedPtr app = - ApplicationManagerImpl::instance()->application(connection_key); - DCHECK(app.get()); + const std::string& url, + ApplicationManager& app_mngr) { - smart_objects::SmartObject* content = - new smart_objects::SmartObject(smart_objects::SmartType_Map); // AKirov: possible memory leak here + smart_objects::SmartObject content(smart_objects::SmartType_Map); if (!url.empty()) { - (*content)[strings::msg_params][strings::url] = url; // Doesn't work with mobile_notification::syncp_url ("URL") + content[strings::msg_params][strings::url] = url; // Doesn't work with mobile_notification::syncp_url ("URL") } else { LOG4CXX_WARN(logger_, "No service URLs"); } - (*content)[strings::msg_params][strings::request_type] = + content[strings::msg_params][strings::request_type] = mobile_apis::RequestType::PROPRIETARY; - (*content)[strings::params][strings::binary_data] = + content[strings::params][strings::binary_data] = smart_objects::SmartObject(policy_data); - (*content)[strings::msg_params][strings::file_type] = + content[strings::msg_params][strings::file_type] = mobile_apis::FileType::BINARY; - SendSystemRequestNotification(connection_key, content); + SendSystemRequestNotification(connection_key, content, app_mngr); } void MessageHelper::SendSystemRequestNotification( - const uint32_t connection_key, smart_objects::SmartObject*& content) { - using namespace mobile_apis; - using namespace commands; - (*content)[strings::params][strings::function_id] = + const uint32_t connection_key, + smart_objects::SmartObject& content, + ApplicationManager& app_mngr) { + content[strings::params][strings::function_id] = mobile_apis::FunctionID::OnSystemRequestID; - (*content)[strings::params][strings::message_type] = + content[strings::params][strings::message_type] = mobile_apis::messageType::notification; - (*content)[strings::params][strings::protocol_type] = + content[strings::params][strings::protocol_type] = commands::CommandImpl::mobile_protocol_type_; - (*content)[strings::params][strings::protocol_version] = + content[strings::params][strings::protocol_version] = commands::CommandImpl::protocol_version_; - (*content)[strings::params][strings::connection_key] = connection_key; + content[strings::params][strings::connection_key] = connection_key; - smart_objects::SmartObject* so = new smart_objects::SmartObject(*content); #ifdef DEBUG - PrintSmartObject(*so); + PrintSmartObject(content); #endif - DCHECK(ApplicationManagerImpl::instance()->ManageMobileCommand(so)); + DCHECK(app_mngr.ManageMobileCommand( + utils::MakeShared<smart_objects::SmartObject>(content), + commands::Command::ORIGIN_SDL)); } void MessageHelper::SendLaunchApp(const uint32_t connection_key, const std::string& urlSchema, - const std::string& packageName) { + const std::string& packageName, + ApplicationManager& app_mngr) { using namespace mobile_apis; using namespace smart_objects; - SmartObject* content = new SmartObject(SmartType_Map); - (*content)[strings::msg_params][strings::request_type] = + SmartObject content(SmartType_Map); + content[strings::msg_params][strings::request_type] = RequestType::LAUNCH_APP; - (*content)[strings::msg_params][strings::app_id] = connection_key; + content[strings::msg_params][strings::app_id] = connection_key; if (!urlSchema.empty()) { - (*content)[strings::msg_params][strings::url] = urlSchema; + content[strings::msg_params][strings::url] = urlSchema; } else if (!packageName.empty()) { - (*content)[strings::msg_params][strings::url] = packageName; + content[strings::msg_params][strings::url] = packageName; } - SendSystemRequestNotification(connection_key, content); + SendSystemRequestNotification(connection_key, content, app_mngr); } -void application_manager::MessageHelper::SendQueryApps( - const uint32_t connection_key) { +void MessageHelper::SendQueryApps( + const uint32_t connection_key, + ApplicationManager& app_mngr) { using namespace mobile_apis; - using namespace smart_objects; policy::PolicyHandlerInterface& policy_handler = - ApplicationManagerImpl::instance()->GetPolicyHandler(); + app_mngr.GetPolicyHandler(); - SmartObject* content = new SmartObject(SmartType_Map); - (*content)[strings::msg_params][strings::request_type] = + smart_objects::SmartObject content(smart_objects::SmartType_Map); + content[strings::msg_params][strings::request_type] = RequestType::QUERY_APPS; - (*content)[strings::msg_params][strings::url] = + content[strings::msg_params][strings::url] = policy_handler.RemoteAppsUrl(); - (*content)[strings::msg_params][strings::timeout] = + content[strings::msg_params][strings::timeout] = policy_handler.TimeoutExchange(); - Json::Value http; - Json::Value& http_header = - http[http_request::httpRequest][http_request::headers]; + Json::Value http_header; const int timeout = policy_handler.TimeoutExchange(); @@ -1876,51 +1894,17 @@ void application_manager::MessageHelper::SendQueryApps( std::string data = http_header.toStyledString(); std::vector<uint8_t> binary_data(data.begin(), data.end()); - (*content)[strings::params][strings::binary_data] = SmartObject(binary_data); - (*content)[strings::msg_params][strings::file_type] = FileType::BINARY; - - SendSystemRequestNotification(connection_key, content); -} - -smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification( - const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObjectSPtr message = - utils::MakeShared<smart_objects::SmartObject>( - smart_objects::SmartType_Map); - (*message)[strings::params][strings::function_id] = - mobile_apis::FunctionID::OnHashChangeID; - (*message)[strings::params][strings::connection_key] = app_id; - (*message)[strings::params][strings::message_type] = - static_cast<int32_t>(kNotification); - return message; -} + content[strings::params][strings::binary_data] = + smart_objects::SmartObject(binary_data); + content[strings::msg_params][strings::file_type] = FileType::BINARY; -void MessageHelper::SendHashUpdateNotification(const uint32_t app_id) { - LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = - ApplicationManagerImpl::instance()->application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, "Application not found by appID"); - return; - } - smart_objects::SmartObjectSPtr so = CreateHashUpdateNotification(app_id); - PrintSmartObject(*so); - if (!ApplicationManagerImpl::instance()->ManageMobileCommand( - so, commands::Command::ORIGIN_SDL)) { - LOG4CXX_ERROR(logger_, "Failed to send HashUpdate notification."); - } else { - ApplicationManagerImpl::instance() - ->resume_controller() - .ApplicationsDataUpdated(); - } + SendSystemRequestNotification(connection_key, content, app_mngr); } void MessageHelper::SendOnPermissionsChangeNotification( - uint32_t connection_key, const policy::Permissions& permissions) { - utils::SharedPtr<smart_objects::SmartObject> notification = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject& content = *notification; + uint32_t connection_key, const policy::Permissions& permissions, ApplicationManager& app_mngr) { + + smart_objects::SmartObject content(smart_objects::SmartType_Map); content[strings::params][strings::function_id] = mobile_apis::FunctionID::OnPermissionsChangeID; @@ -1932,12 +1916,8 @@ void MessageHelper::SendOnPermissionsChangeNotification( commands::CommandImpl::protocol_version_; content[strings::params][strings::connection_key] = connection_key; - utils::SharedPtr<smart_objects::SmartObject> p_msg_params = - new smart_objects::SmartObject(smart_objects::SmartType_Map); - - smart_objects::SmartObject& msg_params = *p_msg_params; - - content[strings::msg_params] = msg_params; + content[strings::msg_params] = + smart_objects::SmartObject(smart_objects::SmartType_Map); // content[strings::msg_params][strings::app_id] = connection_key; @@ -2028,7 +2008,9 @@ void MessageHelper::SendOnPermissionsChangeNotification( } } - ApplicationManagerImpl::instance()->ManageMobileCommand(notification); + app_mngr.ManageMobileCommand( + utils::MakeShared<smart_objects::SmartObject>(content), + commands::Command::ORIGIN_SDL); } void MessageHelper::FillAppRevokedPermissions( @@ -2056,14 +2038,11 @@ void MessageHelper::FillAppRevokedPermissions( } void MessageHelper::SendOnAppPermissionsChangedNotification( - const uint32_t connection_key, const policy::AppPermissions& permissions) { - using namespace smart_objects; - SmartObjectSPtr notification = new SmartObject(SmartType_Map); - if (!notification) { - return; - } + const uint32_t connection_key, + const policy::AppPermissions& permissions, + ApplicationManager& app_mngr) { - SmartObject& message = *notification; + smart_objects::SmartObject message(smart_objects::SmartType_Map); message[strings::params][strings::function_id] = hmi_apis::FunctionID::SDL_OnAppPermissionChanged; @@ -2095,20 +2074,24 @@ void MessageHelper::SendOnAppPermissionsChangedNotification( GetPriorityCode(permissions.priority); } if (permissions.requestTypeChanged) { - SmartObject request_types_array = SmartObject(SmartType_Array); + smart_objects::SmartObject request_types_array( + smart_objects::SmartType_Array);; for (uint16_t index = 0; index < permissions.requestType.size(); ++index) { request_types_array[index] = permissions.requestType[index]; } message[strings::msg_params][strings::request_type] = request_types_array; } - ApplicationManagerImpl::instance()->ManageHMICommand(notification); + app_mngr.ManageHMICommand( + utils::MakeShared<smart_objects::SmartObject>(message)); } void MessageHelper::SendGetStatusUpdateResponse(const std::string& status, - const uint32_t correlation_id) { + const uint32_t correlation_id, + ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); if (!message) { return; } @@ -2121,13 +2104,15 @@ void MessageHelper::SendGetStatusUpdateResponse(const std::string& status, (*message)[strings::msg_params]["status"] = status; - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } void MessageHelper::SendUpdateSDLResponse(const std::string& result, - const uint32_t correlation_id) { + const uint32_t correlation_id, + ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); DCHECK(message); (*message)[strings::params][strings::function_id] = @@ -2138,12 +2123,14 @@ void MessageHelper::SendUpdateSDLResponse(const std::string& result, (*message)[strings::msg_params]["result"] = result; - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } -void MessageHelper::SendOnStatusUpdate(const std::string& status) { +void MessageHelper::SendOnStatusUpdate(const std::string& status, + ApplicationManager& app_mngr) { smart_objects::SmartObjectSPtr message = - new smart_objects::SmartObject(smart_objects::SmartType_Map); + utils::MakeShared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); if (!message) { return; } @@ -2155,11 +2142,12 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status) { (*message)[strings::msg_params]["status"] = status; - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } -void MessageHelper::SendGetSystemInfoRequest() { - smart_objects::SmartObjectSPtr message = CreateRequestObject(); +void MessageHelper::SendGetSystemInfoRequest(ApplicationManager& app_mngr) { + smart_objects::SmartObjectSPtr message = + CreateRequestObject(app_mngr.GetNextHMICorrelationID()); if (!message) { return; } @@ -2167,14 +2155,15 @@ void MessageHelper::SendGetSystemInfoRequest() { (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_GetSystemInfo; - ApplicationManagerImpl::instance()->ManageHMICommand(message); + app_mngr.ManageHMICommand(message); } mobile_apis::Result::eType MessageHelper::VerifyImageFiles( - smart_objects::SmartObject& message, ApplicationConstSharedPtr app) { + smart_objects::SmartObject& message, ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { if (NsSmartDeviceLink::NsSmartObjects::SmartType_Array == message.getType()) { for (uint32_t i = 0; i < message.length(); ++i) { - mobile_apis::Result::eType res = VerifyImageFiles(message[i], app); + mobile_apis::Result::eType res = VerifyImageFiles(message[i], app, app_mngr); if (mobile_apis::Result::SUCCESS != res) { LOG4CXX_DEBUG(logger_, "VerifyImageFiles result:" << res); return res; @@ -2184,7 +2173,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( message.getType()) { if (message.keyExists(strings::image_type)) { mobile_apis::Result::eType verification_result = - VerifyImage(message, app); + VerifyImage(message, app, app_mngr); if (mobile_apis::Result::SUCCESS != verification_result) { LOG4CXX_DEBUG(logger_, @@ -2198,7 +2187,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( key != keys.end(); ++key) { if (strings::soft_buttons != (*key)) { - mobile_apis::Result::eType res = VerifyImageFiles(message[*key], app); + mobile_apis::Result::eType res = VerifyImageFiles(message[*key], app, app_mngr); if (mobile_apis::Result::SUCCESS != res) { LOG4CXX_DEBUG(logger_, "VerifyImageFiles result:" << res); return res; @@ -2212,7 +2201,8 @@ mobile_apis::Result::eType MessageHelper::VerifyImageFiles( } mobile_apis::Result::eType MessageHelper::VerifyImage( - smart_objects::SmartObject& image, ApplicationConstSharedPtr app) { + smart_objects::SmartObject& image, + ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { // Checking image type first: if STATIC - skip existence check, since it is // HMI related file and it should know it location const uint32_t image_type = image[strings::image_type].asUInt(); @@ -2223,7 +2213,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( } const std::string& file_name = image[strings::value].asString(); - + std::string str = file_name; str.erase(remove(str.begin(), str.end(), ' '), str.end()); if (0 == str.size()) { @@ -2235,7 +2225,7 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( full_file_path = file_name; } else { const std::string& app_storage_folder = - profile::Profile::instance()->app_storage_folder(); + app_mngr.get_settings().app_storage_folder(); if (!app_storage_folder.empty()) { // TODO(nvaganov@luxoft.com): APPLINK-11293 if (app_storage_folder[0] == '/') { // absolute path @@ -2263,12 +2253,12 @@ mobile_apis::Result::eType MessageHelper::VerifyImage( } mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems( - smart_objects::SmartObject& message, ApplicationConstSharedPtr app) { + smart_objects::SmartObject& message, ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { mobile_apis::Result::eType verification_result_image = mobile_apis::Result::SUCCESS; for (uint32_t i = 0; i < message.length(); ++i) { if (message[i].keyExists(strings::image)) { - verification_result_image = VerifyImage(message[i][strings::image], app); + verification_result_image = VerifyImage(message[i][strings::image], app, app_mngr); if (mobile_apis::Result::SUCCESS != verification_result_image) { return verification_result_image; } @@ -2303,7 +2293,8 @@ bool CheckWithPolicy(mobile_api::SystemAction::eType system_action, mobile_apis::Result::eType MessageHelper::ProcessSoftButtons(smart_objects::SmartObject& message_params, ApplicationConstSharedPtr app, - const policy::PolicyHandlerInterface &policy_handler) { + const policy::PolicyHandlerInterface& policy_handler, + ApplicationManager& app_mngr) { using namespace mobile_apis; using namespace smart_objects; @@ -2327,7 +2318,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons(smart_objects::Smar request_soft_buttons[i][strings::system_action].asInt(); if (!CheckWithPolicy(static_cast<SystemAction::eType>(system_action), - app->mobile_app_id(), policy_handler)) { + app->policy_app_id(), policy_handler)) { return Result::DISALLOWED; } @@ -2340,7 +2331,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons(smart_objects::Smar if ((!request_soft_buttons[i].keyExists(strings::image) || (Result::SUCCESS != - VerifyImage(request_soft_buttons[i][strings::image], app)))) { + VerifyImage(request_soft_buttons[i][strings::image], app, app_mngr)))) { return Result::INVALID_DATA; } break; @@ -2363,7 +2354,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons(smart_objects::Smar if ((!request_soft_buttons[i].keyExists(strings::image) || (Result::SUCCESS != - VerifyImage(request_soft_buttons[i][strings::image], app)))) { + VerifyImage(request_soft_buttons[i][strings::image], app, app_mngr)))) { return Result::INVALID_DATA; } break; diff --git a/src/components/application_manager/src/mobile_command_factory.cc b/src/components/application_manager/src/mobile_command_factory.cc index 0f1fcefe48..dd00a80557 100644 --- a/src/components/application_manager/src/mobile_command_factory.cc +++ b/src/components/application_manager/src/mobile_command_factory.cc @@ -140,461 +140,460 @@ namespace application_manager { CommandSharedPtr MobileCommandFactory::CreateCommand( const commands::MessageSharedPtr& message, - commands::Command::CommandOrigin origin) { - - CommandSharedPtr command; + commands::Command::CommandOrigin origin, + ApplicationManager& application_manager) { + CommandSharedPtr command; switch ((*message)[strings::params][strings::function_id].asInt()) { case mobile_apis::FunctionID::RegisterAppInterfaceID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kRequest)) { - command = utils::MakeShared<commands::RegisterAppInterfaceRequest>(message); + command.reset(new commands::RegisterAppInterfaceRequest(message, application_manager)); + } else { - command = utils::MakeShared<commands::RegisterAppInterfaceResponse>(message); + command.reset(new commands::RegisterAppInterfaceResponse(message, application_manager)); } break; } case mobile_apis::FunctionID::UnregisterAppInterfaceID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kRequest)) { - command = utils::MakeShared<commands::UnregisterAppInterfaceRequest>(message); + command.reset(new commands::UnregisterAppInterfaceRequest(message, application_manager)); } else { - command = utils::MakeShared<commands::UnregisterAppInterfaceResponse>(message); + command.reset(new commands::UnregisterAppInterfaceResponse(message, application_manager)); } break; } case mobile_apis::FunctionID::SetGlobalPropertiesID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SetGlobalPropertiesResponse>(message); + command.reset(new commands::SetGlobalPropertiesResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SetGlobalPropertiesRequest>(message); + command.reset(new commands::SetGlobalPropertiesRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::ResetGlobalPropertiesID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ResetGlobalPropertiesResponse>(message); + command.reset(new commands::ResetGlobalPropertiesResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ResetGlobalPropertiesRequest>(message); + command.reset(new commands::ResetGlobalPropertiesRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::AddCommandID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::AddCommandResponse>(message); + command.reset(new commands::AddCommandResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::AddCommandRequest>(message); + command.reset(new commands::AddCommandRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::DeleteCommandID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::DeleteCommandResponse>(message); + command.reset(new commands::DeleteCommandResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::DeleteCommandRequest>(message); + command.reset(new commands::DeleteCommandRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::AddSubMenuID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::AddSubMenuResponse>(message); + command.reset(new commands::AddSubMenuResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::AddSubMenuRequest>(message); + command.reset(new commands::AddSubMenuRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::DeleteSubMenuID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::DeleteSubMenuResponse>(message); + command.reset(new commands::DeleteSubMenuResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::DeleteSubMenuRequest>(message); + command.reset(new commands::DeleteSubMenuRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::DeleteInteractionChoiceSetID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::DeleteInteractionChoiceSetResponse>(message); + command.reset(new commands::DeleteInteractionChoiceSetResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::DeleteInteractionChoiceSetRequest>(message); + command.reset(new commands::DeleteInteractionChoiceSetRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::AlertID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::AlertResponse>(message); + command.reset(new commands::AlertResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::AlertRequest>(message); + command.reset(new commands::AlertRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SpeakID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SpeakResponse>(message); + command.reset(new commands::SpeakResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SpeakRequest>(message); + command.reset(new commands::SpeakRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SliderID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SliderResponse>(message); + command.reset(new commands::SliderResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SliderRequest>(message); + command.reset(new commands::SliderRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::PerformAudioPassThruID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::PerformAudioPassThruResponse>(message); + command.reset(new commands::PerformAudioPassThruResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::PerformAudioPassThruRequest>(message); + command.reset(new commands::PerformAudioPassThruRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::CreateInteractionChoiceSetID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::CreateInteractionChoiceSetResponse>(message); + command.reset(new commands::CreateInteractionChoiceSetResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::CreateInteractionChoiceSetRequest>(message); + command.reset(new commands::CreateInteractionChoiceSetRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::PerformInteractionID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::PerformInteractionResponse>(message); + command.reset(new commands::PerformInteractionResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::PerformInteractionRequest>(message); + command.reset(new commands::PerformInteractionRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::EndAudioPassThruID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::EndAudioPassThruResponse>(message); + command.reset(new commands::EndAudioPassThruResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::EndAudioPassThruRequest>(message); + command.reset(new commands::EndAudioPassThruRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::PutFileID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::PutFileResponse>(message); + command.reset(new commands::PutFileResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::PutFileRequest>(message); + command.reset(new commands::PutFileRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::DeleteFileID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::DeleteFileResponse>(message); + command.reset(new commands::DeleteFileResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::DeleteFileRequest>(message); + command.reset(new commands::DeleteFileRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::ListFilesID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ListFilesResponse>(message); + command.reset(new commands::ListFilesResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ListFilesRequest>(message); + command.reset(new commands::ListFilesRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SubscribeButtonID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SubscribeButtonResponse>(message); + command.reset(new commands::SubscribeButtonResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SubscribeButtonRequest>(message); + command.reset(new commands::SubscribeButtonRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::UnsubscribeButtonID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::UnsubscribeButtonResponse>(message); + command.reset(new commands::UnsubscribeButtonResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::UnsubscribeButtonRequest>(message); + command.reset(new commands::UnsubscribeButtonRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::ShowConstantTBTID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ShowConstantTBTResponse>(message); + command.reset(new commands::ShowConstantTBTResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ShowConstantTBTRequest>(message); + command.reset(new commands::ShowConstantTBTRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::ShowID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ShowResponse>(message); + command.reset(new commands::ShowResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ShowRequest>(message); + command.reset(new commands::ShowRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::GetWayPointsID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::GetWayPointsResponse>(message); + command = utils::MakeShared<commands::GetWayPointsResponse>(message, application_manager); } else { - command = utils::MakeShared<commands::GetWayPointsRequest>(message); + command = utils::MakeShared<commands::GetWayPointsRequest>(message, application_manager); } break; } case mobile_apis::FunctionID::SubscribeVehicleDataID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SubscribeVehicleDataResponse>(message); + command.reset(new commands::SubscribeVehicleDataResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SubscribeVehicleDataRequest>(message); + command.reset(new commands::SubscribeVehicleDataRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::UnsubscribeVehicleDataID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::UnsubscribeVehicleDataResponse>(message); + command.reset(new commands::UnsubscribeVehicleDataResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::UnsubscribeVehicleDataRequest>(message); + command.reset(new commands::UnsubscribeVehicleDataRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SubscribeWayPointsID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SubscribeWayPointsResponse>(message); + command = utils::MakeShared<commands::SubscribeWayPointsResponse>(message, application_manager); } else { - command = utils::MakeShared<commands::SubscribeWayPointsRequest>(message); + command = utils::MakeShared<commands::SubscribeWayPointsRequest>(message, application_manager); } break; } case mobile_apis::FunctionID::UnsubscribeWayPointsID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::UnsubscribeWayPointsResponse>(message); + command = utils::MakeShared<commands::UnsubscribeWayPointsResponse>(message, application_manager); } else { - command = utils::MakeShared<commands::UnSubscribeWayPointsRequest>(message); + command = utils::MakeShared<commands::UnSubscribeWayPointsRequest>(message, application_manager); } break; } case mobile_apis::FunctionID::ReadDIDID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ReadDIDResponse>(message); + command.reset(new commands::ReadDIDResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ReadDIDRequest>(message); + command.reset(new commands::ReadDIDRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::GetVehicleDataID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::GetVehicleDataResponse>(message); + command.reset(new commands::GetVehicleDataResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::GetVehicleDataRequest>(message); + command.reset(new commands::GetVehicleDataRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::ScrollableMessageID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ScrollableMessageResponse>(message); + command.reset(new commands::ScrollableMessageResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ScrollableMessageRequest>(message); + command.reset(new commands::ScrollableMessageRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::AlertManeuverID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::AlertManeuverResponse>(message); + command.reset(new commands::AlertManeuverResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::AlertManeuverRequest>(message); + command.reset(new commands::AlertManeuverRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SetAppIconID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SetAppIconResponse>(message); + command.reset(new commands::SetAppIconResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SetAppIconRequest>(message); + command.reset(new commands::SetAppIconRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SetDisplayLayoutID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SetDisplayLayoutResponse>(message); + command.reset(new commands::SetDisplayLayoutResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SetDisplayLayoutRequest>(message); + command.reset(new commands::SetDisplayLayoutRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::UpdateTurnListID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::UpdateTurnListResponse>(message); + command.reset(new commands::UpdateTurnListResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::UpdateTurnListRequest>(message); + command.reset(new commands::UpdateTurnListRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::ChangeRegistrationID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::ChangeRegistrationResponse>(message); + command.reset(new commands::ChangeRegistrationResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::ChangeRegistrationRequest>(message); + command.reset(new commands::ChangeRegistrationRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::GetDTCsID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::GetDTCsResponse>(message); + command.reset(new commands::GetDTCsResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::GetDTCsRequest>(message); + command.reset(new commands::GetDTCsRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::DiagnosticMessageID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::DiagnosticMessageResponse>(message); + command.reset(new commands::DiagnosticMessageResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::DiagnosticMessageRequest>(message); + command.reset(new commands::DiagnosticMessageRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SetMediaClockTimerID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SetMediaClockTimerResponse>(message); + command.reset(new commands::SetMediaClockTimerResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SetMediaClockRequest>(message); + command.reset(new commands::SetMediaClockRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SystemRequestID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SystemResponse>(message); + command.reset(new commands::SystemResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SystemRequest>(message); + command.reset(new commands::SystemRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::SendLocationID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - command = utils::MakeShared<commands::SendLocationResponse>(message); + command.reset(new commands::SendLocationResponse(message, application_manager)); } else { - command = utils::MakeShared<commands::SendLocationRequest>(message); + command.reset(new commands::SendLocationRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::DialNumberID: { if ((*message)[strings::params][strings::message_type] == static_cast<int>(application_manager::MessageType::kResponse)) { - return new commands::DialNumberResponse(message); + command.reset(new commands::DialNumberResponse(message, application_manager)); } else { - return new commands::DialNumberRequest(message); + command.reset(new commands::DialNumberRequest(message, application_manager)); } break; } case mobile_apis::FunctionID::OnButtonEventID: { - command = utils::MakeShared<commands::mobile::OnButtonEventNotification>(message); + command.reset(new commands::mobile::OnButtonEventNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnButtonPressID: { - command = utils::MakeShared<commands::mobile::OnButtonPressNotification>(message); + command.reset(new commands::mobile::OnButtonPressNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnAudioPassThruID: { - command = utils::MakeShared<commands::OnAudioPassThruNotification>(message); + command.reset(new commands::OnAudioPassThruNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnVehicleDataID: { - command = utils::MakeShared<commands::OnVehicleDataNotification>(message); + command.reset(new commands::OnVehicleDataNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnAppInterfaceUnregisteredID: { - command = utils::MakeShared<commands::OnAppInterfaceUnregisteredNotification>(message); + command.reset(new commands::OnAppInterfaceUnregisteredNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnCommandID: { - command = utils::MakeShared<commands::OnCommandNotification>(message); + command.reset(new commands::OnCommandNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnTBTClientStateID: { - command = utils::MakeShared<commands::OnTBTClientStateNotification>(message); + command.reset(new commands::OnTBTClientStateNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnDriverDistractionID: { - command = utils::MakeShared<commands::mobile::OnDriverDistractionNotification>(message); + command.reset(new commands::mobile::OnDriverDistractionNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnLanguageChangeID: { - command = utils::MakeShared<commands::OnLanguageChangeNotification>(message); + command.reset(new commands::OnLanguageChangeNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnPermissionsChangeID: { - command = utils::MakeShared<commands::OnPermissionsChangeNotification>(message); + command.reset(new commands::OnPermissionsChangeNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnHMIStatusID: { - if (origin == commands::Command::ORIGIN_MOBILE) { - command = utils::MakeShared<commands::OnHMIStatusNotificationFromMobile>(message); - } else { - command = utils::MakeShared<commands::OnHMIStatusNotification>(message); + if (commands::Command::ORIGIN_SDL == origin) { + command.reset(new commands::OnHMIStatusNotification(message, application_manager)); } break; } case mobile_apis::FunctionID::OnKeyboardInputID: { - command = utils::MakeShared<commands::mobile::OnKeyBoardInputNotification>(message); + command.reset(new commands::mobile::OnKeyBoardInputNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnTouchEventID: { - command = utils::MakeShared<commands::mobile::OnTouchEventNotification>(message); + command.reset(new commands::mobile::OnTouchEventNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnSystemRequestID: { - command = utils::MakeShared<commands::mobile::OnSystemRequestNotification>(message); + command.reset(new commands::mobile::OnSystemRequestNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnHashChangeID: { - command = utils::MakeShared<commands::mobile::OnHashChangeNotification>(message); + command.reset(new commands::mobile::OnHashChangeNotification(message, application_manager)); break; } case mobile_apis::FunctionID::OnWayPointChangeID: { - command = utils::MakeShared<commands::OnWayPointChangeNotification>(message); + command = utils::MakeShared<commands::OnWayPointChangeNotification>(message, application_manager); break; } default: { (*message)[strings::params][strings::function_id] = static_cast<int32_t>(mobile_apis::FunctionID::GenericResponseID); - command = utils::MakeShared<commands::GenericResponse>(message); + command.reset(new commands::GenericResponse(message, application_manager)); } } return command; diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index cd23248b7c..4c014e203b 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -31,7 +31,7 @@ */ #include "utils/logger.h" -#include "config_profile/profile.h" + #include "application_manager/request_controller.h" #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/hmi/request_to_hmi.h" @@ -46,14 +46,14 @@ using namespace sync_primitives; CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController") -RequestController::RequestController() - : pool_state_(UNDEFINED), - pool_size_(profile::Profile::instance()->thread_pool_size()), - timer_("AM RequestCtrlTimer", +RequestController::RequestController(const RequestControlerSettings& settings) + : pool_state_(UNDEFINED) + , pool_size_(settings.thread_pool_size()) + , timer_("AM RequestCtrlTimer", new timer::TimerTaskImpl<RequestController>( - this, - &RequestController::onTimer)), - is_low_voltage_(false) { + this, &RequestController::onTimer)) + , is_low_voltage_(false) + , settings_(settings) { LOG4CXX_AUTO_TRACE(logger_); InitializeThreadpool(); } @@ -99,20 +99,20 @@ RequestController::TResult RequestController::CheckPosibilitytoAdd( const RequestPtr request) { LOG4CXX_AUTO_TRACE(logger_); const uint32_t& app_hmi_level_none_time_scale = - profile::Profile::instance()->app_hmi_level_none_time_scale(); + settings_.app_hmi_level_none_time_scale(); // app_hmi_level_none_max_request_per_time_scale const uint32_t& hmi_level_none_count = - profile::Profile::instance()->app_hmi_level_none_time_scale_max_requests(); + settings_.app_hmi_level_none_time_scale_max_requests(); const uint32_t& app_time_scale = - profile::Profile::instance()->app_time_scale(); + settings_.app_time_scale(); const uint32_t& max_request_per_time_scale = - profile::Profile::instance()->app_time_scale_max_requests(); + settings_.app_time_scale_max_requests(); const uint32_t& pending_requests_amount = - profile::Profile::instance()->pending_requests_amount(); + settings_.pending_requests_amount(); if (!CheckPendingRequestsAmount(pending_requests_amount)) { LOG4CXX_ERROR(logger_, "Too many pending request"); diff --git a/src/components/application_manager/src/state_context.cc b/src/components/application_manager/src/state_context.cc deleted file mode 100644 index ae3b40e094..0000000000 --- a/src/components/application_manager/src/state_context.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2013, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "application_manager/state_context.h" -#include "application_manager/application_manager_impl.h" -#include "config_profile/profile.h" - -namespace application_manager { - - -bool StateContext::is_navi_app(const uint32_t app_id) const { - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); - DCHECK_OR_RETURN(app, false); - return app ? app->is_navi() : false; -} - -bool StateContext::is_meida_app(const uint32_t app_id) const { - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); - return app ? app->is_media_application() : false; -} - -bool StateContext::is_voice_comunication_app(const uint32_t app_id) const { - ApplicationSharedPtr app = ApplicationManagerImpl::instance()->application(app_id); - return app ? app->is_voice_communication_supported() : false; -} - -bool StateContext::is_attenuated_supported() const{ - const HMICapabilities& hmi_capabilities = - ApplicationManagerImpl::instance()->hmi_capabilities(); - return hmi_capabilities.attenuated_supported() && - profile::Profile::instance()->is_mixing_audio_supported(); -} - -} diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller_impl.cc index 800ce285e8..2460005397 100644 --- a/src/components/application_manager/src/state_controller.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -1,4 +1,4 @@ - /* +/* Copyright (c) 2015, Ford Motor Company All rights reserved. @@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "application_manager/state_controller.h" +#include "application_manager/state_controller_impl.h" #include "application_manager/usage_statistics.h" #include "utils/helpers.h" #include "utils/make_shared.h" @@ -38,7 +38,7 @@ namespace application_manager { -CREATE_LOGGERPTR_GLOBAL(logger_, "StateController"); +CREATE_LOGGERPTR_GLOBAL(logger_, "StateControllerImpl") bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) { if (old_state->hmi_level() != new_state->hmi_level() || @@ -50,8 +50,8 @@ bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) { return false; } -StateController::StateController(ApplicationManager* app_mngr) - : EventObserver(), app_mngr_(app_mngr) { +StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) + : EventObserver(app_mngr.event_dispatcher()), app_mngr_(app_mngr) { subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnAppActivated); subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated); subscribe_on_event(hmi_apis::FunctionID::TTS_Started); @@ -61,7 +61,193 @@ StateController::StateController(ApplicationManager* app_mngr) subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnEventChanged); } -void StateController::HmiLevelConflictResolver::operator()( + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, HmiStatePtr state, const bool SendActivateApp) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + DCHECK_OR_RETURN_VOID(state); + DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); + + if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || + state->audio_streaming_state() == + mobile_apis::AudioStreamingState::INVALID_ENUM || + state->system_context() == mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_ERROR(logger_, "Get invalid state"); + return; + } + + if (app->is_resuming() && !IsResumptionAllowed(app, state)) { + return; + } + + HmiStatePtr resolved_state = ResolveHmiState(app, state); + if (!resolved_state) { + state->set_state_id(HmiState::STATE_ID_POSTPONED); + app->SetPostponedState(state); + return; + } + hmi_apis::Common_HMILevel::eType hmi_level = + static_cast<hmi_apis::Common_HMILevel::eType>( + resolved_state->hmi_level()); + + const bool is_full_allowed = hmi_apis::Common_HMILevel::FULL == hmi_level; + + if (SendActivateApp && is_full_allowed) { + int64_t corr_id = SendBCActivateApp(app, hmi_level, true); + if (-1 != corr_id) { + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, + corr_id); + waiting_for_activate[app->app_id()] = resolved_state; + return; + } + LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); + return; + } + ApplyRegularState(app, resolved_state); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const bool SendActivateApp) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + HmiStatePtr prev_regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state = + CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(hmi_level); + hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_system_context(prev_regular->system_context()); + SetRegularState(app, hmi_state, SendActivateApp); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level, + const bool SendActivateApp) { + using namespace mobile_apis; + using namespace helpers; + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + const HmiStatePtr hmi_state = + CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + + DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(hmi_level); + hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); + hmi_state->set_system_context(SystemContext::SYSCTXT_MAIN); + SetRegularState(app, hmi_state, SendActivateApp); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::SystemContext::eType system_context, + const bool SendActivateApp) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + HmiStatePtr hmi_state = + CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(hmi_level); + hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_system_context(system_context); + SetRegularState(app, hmi_state, SendActivateApp); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + HmiStatePtr prev_state = app->RegularHmiState(); + HmiStatePtr hmi_state = + CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(hmi_level); + hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); + hmi_state->set_system_context( + prev_state ? prev_state->system_context() + : mobile_apis::SystemContext::SYSCTXT_MAIN); + SetRegularState(app, hmi_state); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const mobile_apis::SystemContext::eType system_context) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + HmiStatePtr prev_regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state = + CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(prev_regular->hmi_level()); + hmi_state->set_audio_streaming_state( + CalcAudioState(app, prev_regular->hmi_level())); + hmi_state->set_system_context(system_context); + SetRegularState(app, hmi_state, false); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + const mobile_apis::AudioStreamingState::eType audio_state) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + HmiStatePtr prev_state = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_state); + HmiStatePtr hmi_state = + CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(hmi_state); + hmi_state->set_hmi_level(prev_state->hmi_level()); + hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_system_context(prev_state->system_context()); + SetRegularState(app, hmi_state, false); +} + +void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, + HmiStatePtr state) { + CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + LOG4CXX_AUTO_TRACE(logger_); + if (!app) { + LOG4CXX_ERROR(logger_, "Invalid application pointer"); + return; + } + DCHECK_OR_RETURN_VOID(state); + if (mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { + SetRegularState(app, state, true); + } else { + SetRegularState(app, state, false); + } +} + +void StateControllerImpl::HmiLevelConflictResolver::operator()( ApplicationSharedPtr to_resolve) { using namespace mobile_apis; using namespace helpers; @@ -123,7 +309,7 @@ void StateController::HmiLevelConflictResolver::operator()( } } -HmiStatePtr StateController::ResolveHmiState(ApplicationSharedPtr app, +HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, HmiStatePtr state) const { using namespace mobile_apis; using namespace helpers; @@ -153,7 +339,7 @@ HmiStatePtr StateController::ResolveHmiState(ApplicationSharedPtr app, : HmiStatePtr(); } -bool StateController::IsResumptionAllowed(ApplicationSharedPtr app, +bool StateControllerImpl::IsResumptionAllowed(ApplicationSharedPtr app, HmiStatePtr state) const { LOG4CXX_AUTO_TRACE(logger_); using namespace helpers; @@ -184,7 +370,7 @@ bool StateController::IsResumptionAllowed(ApplicationSharedPtr app, return true; } -mobile_apis::HMILevel::eType StateController::GetAvailableHmiLevel( +mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( ApplicationSharedPtr app, mobile_apis::HMILevel::eType hmi_level) const { using namespace mobile_apis; using namespace helpers; @@ -198,18 +384,18 @@ mobile_apis::HMILevel::eType StateController::GetAvailableHmiLevel( const bool is_audio_app = app->IsAudioApplication(); const bool does_audio_app_with_same_type_exist = - app_mngr_->IsAppTypeExistsInFullOrLimited(app); + app_mngr_.IsAppTypeExistsInFullOrLimited(app); if (HMILevel::HMI_LIMITED == hmi_level) { if (!is_audio_app || does_audio_app_with_same_type_exist) { - result = app_mngr_->GetDefaultHmiLevel(app); + result = app_mngr_.GetDefaultHmiLevel(app); } return result; } - const bool is_active_app_exist = app_mngr_->active_application(); + const bool is_active_app_exist = app_mngr_.active_application(); if (is_audio_app) { if (does_audio_app_with_same_type_exist) { - result = app_mngr_->GetDefaultHmiLevel(app); + result = app_mngr_.GetDefaultHmiLevel(app); } else if (is_active_app_exist) { result = mobile_apis::HMILevel::HMI_LIMITED; } else if (app->is_navi() && @@ -226,23 +412,22 @@ mobile_apis::HMILevel::eType StateController::GetAvailableHmiLevel( result = mobile_apis::HMILevel::HMI_LIMITED; } } else if (is_active_app_exist) { - result = app_mngr_->GetDefaultHmiLevel(app); + result = app_mngr_.GetDefaultHmiLevel(app); } return result; } -bool StateController::IsStateAvailable(ApplicationSharedPtr app, +bool StateControllerImpl::IsStateAvailable(ApplicationSharedPtr app, HmiStatePtr state) const { using namespace mobile_apis; using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, - "Checking state: hmi_level " << state->hmi_level() - << ", audio_state " - << state->audio_streaming_state() - << ", system_context " - << state->system_context()); + "Checking state: hmi_level " + << state->hmi_level() << ", audio_state " + << state->audio_streaming_state() << ", system_context " + << state->system_context()); if (app->is_resuming()) { return IsStateAvailableForResumption(app, state); @@ -262,7 +447,7 @@ bool StateController::IsStateAvailable(ApplicationSharedPtr app, return true; } -bool StateController::IsStateAvailableForResumption(ApplicationSharedPtr app, +bool StateControllerImpl::IsStateAvailableForResumption(ApplicationSharedPtr app, HmiStatePtr state) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; @@ -302,7 +487,7 @@ bool StateController::IsStateAvailableForResumption(ApplicationSharedPtr app, return true; } -void StateController::SetupRegularHmiState(ApplicationSharedPtr app, +void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; @@ -311,8 +496,7 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app, LOG4CXX_DEBUG(logger_, "hmi_level " << state->hmi_level() << ", audio_state " << state->audio_streaming_state() - << ", system_context " - << state->system_context()); + << ", system_context " << state->system_context()); HmiStatePtr curr_state = app->CurrentHmiState(); HmiStatePtr old_state = CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR); @@ -326,7 +510,7 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app, LOG4CXX_DEBUG(logger_, "Resuming to LIMITED level. " << "Send OnResumeAudioSource notification"); - MessageHelper::SendOnResumeAudioSourceToHMI(app->app_id()); + MessageHelper::SendOnResumeAudioSourceToHMI(app->app_id(), app_mngr_); } app->set_is_resuming(false); @@ -334,7 +518,7 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app, OnStateChanged(app, old_state, new_state); } -void StateController::SetupRegularHmiState( +void StateControllerImpl::SetupRegularHmiState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state) { @@ -354,7 +538,7 @@ void StateController::SetupRegularHmiState( SetupRegularHmiState(app, new_state); } -void StateController::ApplyRegularState(ApplicationSharedPtr app, +void StateControllerImpl::ApplyRegularState(ApplicationSharedPtr app, HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); @@ -365,7 +549,7 @@ void StateController::ApplyRegularState(ApplicationSharedPtr app, HmiLevelConflictResolver(app, state, this)); } -bool StateController::IsSameAppType(ApplicationConstSharedPtr app1, +bool StateControllerImpl::IsSameAppType(ApplicationConstSharedPtr app1, ApplicationConstSharedPtr app2) { const bool both_media = app1->is_media_application() && app2->is_media_application(); @@ -377,7 +561,7 @@ bool StateController::IsSameAppType(ApplicationConstSharedPtr app1, return both_simple || both_media || both_navi || both_vc; } -void StateController::on_event(const event_engine::Event& event) { +void StateControllerImpl::on_event(const event_engine::Event& event) { using smart_objects::SmartObject; using event_engine::Event; using namespace hmi_apis; @@ -420,7 +604,7 @@ void StateController::on_event(const event_engine::Event& event) { message[strings::msg_params][hmi_notification::is_active].asBool(); const uint32_t id = message[strings::msg_params][hmi_notification::event_name].asUInt(); - //TODO(AOleynik): Add verification/conversion check here + // TODO(AOleynik): Add verification/conversion check here Common_EventTypes::eType state_id = static_cast<Common_EventTypes::eType>(id); if (is_active) { @@ -473,7 +657,7 @@ void StateController::on_event(const event_engine::Event& event) { } } -void StateController::OnStateChanged(ApplicationSharedPtr app, +void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, HmiStatePtr old_state, HmiStatePtr new_state) { LOG4CXX_AUTO_TRACE(logger_); @@ -491,11 +675,11 @@ void StateController::OnStateChanged(ApplicationSharedPtr app, << ", system_context " << new_state->system_context()); if (IsStatusChanged(old_state, new_state)) { - app_mngr_->SendHMIStatusNotification(app); + app_mngr_.SendHMIStatusNotification(app); if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { app->ResetDataInNone(); } - app_mngr_->OnHMILevelChanged( + app_mngr_.OnHMILevelChanged( app->app_id(), old_state->hmi_level(), new_state->hmi_level()); app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); } else { @@ -503,14 +687,14 @@ void StateController::OnStateChanged(ApplicationSharedPtr app, } } -bool StateController::IsTempStateActive(HmiState::StateID ID) const { +bool StateControllerImpl::IsTempStateActive(HmiState::StateID ID) const { sync_primitives::AutoLock autolock(active_states_lock_); StateIDList::const_iterator itr = std::find(active_states_.begin(), active_states_.end(), ID); return active_states_.end() != itr; } -void StateController::OnApplicationRegistered( +void StateControllerImpl::OnApplicationRegistered( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType default_level) { namespace HMILevel = mobile_apis::HMILevel; @@ -547,27 +731,23 @@ void StateController::OnApplicationRegistered( OnStateChanged(app, initial_state, new_state); } -int64_t StateController::SendBCActivateApp( +int64_t StateControllerImpl::SendBCActivateApp( ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority) { LOG4CXX_AUTO_TRACE(logger_); - connection_handler::ConnectionHandler& conn_handler = - app_mngr_->connection_handler(); smart_objects::SmartObjectSPtr bc_activate_app_request = MessageHelper::GetBCActivateAppRequestToHMI( app, - conn_handler.get_session_observer(), - app_mngr_->GetPolicyHandler(), + app_mngr_.connection_handler().get_session_observer(), + app_mngr_.GetPolicyHandler(), level, - send_policy_priority); + send_policy_priority, app_mngr_); if (!bc_activate_app_request) { - std::cout << "Unable to create BC.ActivateAppRequest" << std::endl; LOG4CXX_ERROR(logger_, "Unable to create BC.ActivateAppRequest"); return -1; } - if (!app_mngr_->ManageHMICommand(bc_activate_app_request)) { - std::cout << "Unable to send BC.ActivateAppRequest" << std::endl; + if (!app_mngr_.ManageHMICommand(bc_activate_app_request)) { LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateAppRequest"); return -1; } @@ -577,7 +757,7 @@ int64_t StateController::SendBCActivateApp( return corr_id; } -void StateController::ApplyPostponedStateForApp(ApplicationSharedPtr app) { +void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); HmiStatePtr state = app->PostponedHmiState(); if (state) { @@ -587,7 +767,7 @@ void StateController::ApplyPostponedStateForApp(ApplicationSharedPtr app) { } } -void StateController::TempStateStarted(HmiState::StateID ID) { +void StateControllerImpl::TempStateStarted(HmiState::StateID ID) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(active_states_lock_); StateIDList::iterator it = @@ -599,17 +779,17 @@ void StateController::TempStateStarted(HmiState::StateID ID) { } } -void StateController::TempStateStopped(HmiState::StateID ID) { +void StateControllerImpl::TempStateStopped(HmiState::StateID ID) { LOG4CXX_AUTO_TRACE(logger_); { sync_primitives::AutoLock autolock(active_states_lock_); active_states_.remove(ID); } ForEachApplication(std::bind1st( - std::mem_fun(&StateController::ApplyPostponedStateForApp), this)); + std::mem_fun(&StateControllerImpl::ApplyPostponedStateForApp), this)); } -void StateController::DeactivateApp(ApplicationSharedPtr app) { +void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); @@ -626,19 +806,19 @@ void StateController::DeactivateApp(ApplicationSharedPtr app) { new_regular->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); } - SetRegularState<false>(app, new_regular); + SetRegularState(app, new_regular, false); } -void StateController::OnActivateAppResponse( +void StateControllerImpl::OnActivateAppResponse( const smart_objects::SmartObject& message) { const hmi_apis::Common_Result::eType code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); const int32_t correlation_id = message[strings::params][strings::correlation_id].asInt(); - const uint32_t hmi_app_id = app_mngr_->application_id(correlation_id); + const uint32_t hmi_app_id = app_mngr_.application_id(correlation_id); ApplicationSharedPtr application = - app_mngr_->application_by_hmi_app(hmi_app_id); + app_mngr_.application_by_hmi_app(hmi_app_id); if (application && hmi_apis::Common_Result::SUCCESS == code) { HmiStatePtr pending_state = waiting_for_activate[application->app_id()]; DCHECK_OR_RETURN_VOID(pending_state); @@ -646,22 +826,22 @@ void StateController::OnActivateAppResponse( } } -void StateController::OnAppActivated( +void StateControllerImpl::OnAppActivated( const smart_objects::SmartObject& message) { using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = message[strings::msg_params][strings::app_id].asUInt(); - ApplicationSharedPtr app = app_mngr_->application(app_id); + ApplicationSharedPtr app = app_mngr_.application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "Application with id " << app_id << " not found"); return; } - SetRegularState<true>(app, HMILevel::HMI_FULL); + SetRegularState(app, HMILevel::HMI_FULL, true); } -void StateController::OnAppDeactivated( +void StateControllerImpl::OnAppDeactivated( const smart_objects::SmartObject& message) { using namespace hmi_apis; using namespace mobile_apis; @@ -669,8 +849,7 @@ void StateController::OnAppDeactivated( LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = message[strings::msg_params][strings::app_id].asUInt(); - ApplicationSharedPtr app = app_mngr_->application(app_id); - + ApplicationSharedPtr app = app_mngr_.application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "Application with id " << app_id << " not found"); return; @@ -680,28 +859,20 @@ void StateController::OnAppDeactivated( return; } - //TODO(AOleynik): Need to delete DeactivateReason and modify OnAppDeactivated + // TODO(AOleynik): Need to delete DeactivateReason and modify OnAppDeactivated // when HMI will support that, otherwise won't be testable DeactivateApp(app); } -void StateController::SetAplicationManager(ApplicationManager* app_mngr) { - app_mngr_ = app_mngr; -} - -void StateController::OnNaviStreamingStarted() { +void StateControllerImpl::OnNaviStreamingStarted() { ApplyTempState<HmiState::STATE_ID_NAVI_STREAMING>(); } -void StateController::OnNaviStreamingStopped() { +void StateControllerImpl::OnNaviStreamingStopped() { CancelTempState<HmiState::STATE_ID_NAVI_STREAMING>(); } -bool StateController::IsDeactivateHMIStateActive() const { - return IsTempStateActive(HmiState::StateID::STATE_ID_DEACTIVATE_HMI); -} - -bool StateController::IsStateActive(HmiState::StateID state_id) const { +bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { LOG4CXX_AUTO_TRACE(logger_); switch (state_id) { case HmiState::STATE_ID_CURRENT: @@ -713,7 +884,7 @@ bool StateController::IsStateActive(HmiState::StateID state_id) const { return false; } -HmiStatePtr StateController::CreateHmiState(uint32_t app_id, +HmiStatePtr StateControllerImpl::CreateHmiState(uint32_t app_id, HmiState::StateID state_id) const { using namespace utils; LOG4CXX_AUTO_TRACE(logger_); @@ -767,7 +938,7 @@ HmiStatePtr StateController::CreateHmiState(uint32_t app_id, return new_state; } -mobile_apis::AudioStreamingState::eType StateController::CalcAudioState( +mobile_apis::AudioStreamingState::eType StateControllerImpl::CalcAudioState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) const { namespace HMILevel = mobile_apis::HMILevel; diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index d9665b8abb..f6e86e3400 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -834,7 +834,7 @@ class StateControllerTest : public ::testing::Test { SetConnection(); } - virtual void TearDown() OVERRIDE { + void TearDown() OVERRIDE { delete conn_handler; } diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h new file mode 100644 index 0000000000..ae6f6930c1 --- /dev/null +++ b/src/components/include/application_manager/application_manager_settings.h @@ -0,0 +1,67 @@ +#ifndef APPLICATION_MANAGER_SETTINGS +#define APPLICATION_MANAGER_SETTINGS + +#include "application_manager/request_controller_settings.h" + +#include <stdint.h> +#include <string> + +namespace application_manager { +class ApplicationManagerSettings : public RequestControlerSettings { + public: + virtual const uint32_t video_data_stopped_timeout() const = 0; + virtual const std::uint32_t audio_data_stopped_timeout() const = 0; + virtual const std::pair<uint32_t, int32_t>& read_did_frequency() const = 0; + virtual const std::pair<uint32_t, int32_t>& get_vehicle_data_frequency() + const = 0; + virtual uint32_t hash_string_size() const = 0; + virtual const std::string& app_storage_folder() const = 0; + virtual const uint32_t& app_dir_quota() const = 0; + virtual uint32_t stop_streaming_timeout() const = 0; + virtual uint32_t application_list_update_timeout() const = 0; + virtual uint32_t heart_beat_timeout() const = 0; + virtual const std::string& recording_file_name() const = 0; + virtual const std::string& system_files_path() const = 0; + virtual bool is_mixing_audio_supported() const = 0; + virtual uint16_t tts_global_properties_timeout() const = 0; + virtual uint16_t max_supported_protocol_version() const = 0; + virtual const uint32_t& default_timeout() const = 0; + virtual const uint32_t& max_cmd_id() const = 0; + virtual bool launch_hmi() const = 0; + virtual const uint32_t& delete_file_in_none() const = 0; + virtual const std::vector<uint32_t>& supported_diag_modes() const = 0; + virtual const uint32_t& list_files_in_none() const = 0; + virtual const std::string& tts_delimiter() const = 0; + virtual const uint32_t& put_file_in_none() const = 0; + virtual const std::string& sdl_version() const = 0; + virtual const std::vector<std::string>& time_out_promt() const = 0; + virtual const std::string& hmi_capabilities_file_name() const = 0; + virtual const std::string& video_server_type() const = 0; + virtual const std::string& audio_server_type() const = 0; + virtual const std::string& server_address() const = 0; + virtual const uint16_t video_streaming_port() const = 0; + virtual const uint16_t audio_streaming_port() const = 0; + virtual const std::string& named_video_pipe_path() const = 0; + virtual const std::string& named_audio_pipe_path() const = 0; + virtual const std::string& video_stream_file() const = 0; + virtual const std::string& audio_stream_file() const = 0; + + virtual bool use_db_for_resumption() const = 0; + virtual const uint32_t& app_resumption_save_persistent_data_timeout() + const = 0; + virtual uint32_t resumption_delay_before_ign() const = 0; + virtual uint32_t resumption_delay_after_ign() const = 0; + virtual const uint32_t& app_resuming_timeout() const = 0; + virtual uint16_t attempts_to_open_resumption_db() const = 0; + virtual uint16_t open_attempt_timeout_ms_resumption_db() const = 0; + virtual void config_file_name(const std::string& fileName) = 0; + virtual const std::pair<uint32_t, int32_t>& start_stream_retry_amount() + const = 0; + virtual const std::string& app_icons_folder() const = 0; + virtual const uint32_t& app_icons_folder_max_size() const = 0; + virtual const uint32_t& app_icons_amount_to_remove() const = 0; + virtual const uint32_t& list_files_response_size() const = 0; +}; +} + +#endif // APPLICATION_MANAGER_SETTINGS diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 1298350718..197a4cc0a7 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -99,6 +99,10 @@ class PolicyHandlerInterface { virtual utils::SharedPtr<usage_statistics::StatisticsManager> GetStatisticManager() const = 0; + virtual void SendOnAppPermissionsChanged( + const AppPermissions& permissions, + const std::string& policy_app_id) const = 0; + /** * @brief CheckSystemAction allows to check whether certain system * action is enabled. diff --git a/src/components/include/application_manager/request_controller_settings.h b/src/components/include/application_manager/request_controller_settings.h new file mode 100644 index 0000000000..45871f6ca2 --- /dev/null +++ b/src/components/include/application_manager/request_controller_settings.h @@ -0,0 +1,15 @@ +#ifndef REQUEST_CONTROLLER_SETTINGS_H +#define REQUEST_CONTROLLER_SETTINGS_H +namespace application_manager { +class RequestControlerSettings { +public: + virtual uint32_t thread_pool_size() const = 0; + virtual const uint32_t& app_hmi_level_none_time_scale() const = 0; + virtual const uint32_t& app_hmi_level_none_time_scale_max_requests() + const = 0; + virtual const uint32_t& app_time_scale() const = 0; + virtual const uint32_t& app_time_scale_max_requests() const = 0; + virtual const uint32_t& pending_requests_amount() const = 0; +}; +} +#endif // REQUEST_CONTROLLER_SETTINGS_H diff --git a/src/components/include/application_manager/state_controller.h b/src/components/include/application_manager/state_controller.h new file mode 100644 index 0000000000..9cec3eb639 --- /dev/null +++ b/src/components/include/application_manager/state_controller.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ +#define SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ + +#include "stdint.h" +#include "application_manager/request_controller_settings.h" +#include "application_manager/application_manager.h" +#include "application_manager/application.h" + +namespace application_manager { +class StateController { + public: + virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state, + const bool SendActivateApp) = 0; + + virtual void SetRegularState( + ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const bool SendActivateApp) = 0; + + virtual void SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level, + const bool SendActivateApp) = 0; + virtual void SetRegularState( + ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::SystemContext::eType system_context, + const bool SendActivateApp) = 0; + + virtual void SetRegularState( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) = 0; + + virtual void SetRegularState( + ApplicationSharedPtr app, + const mobile_apis::AudioStreamingState::eType audio_state) = 0; + + virtual void SetRegularState( + ApplicationSharedPtr app, + const mobile_apis::SystemContext::eType system_context) = 0; + + virtual void SetRegularState(ApplicationSharedPtr app, HmiStatePtr state) = 0; + + virtual void OnApplicationRegistered( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType default_level) = 0; + + virtual int64_t SendBCActivateApp(ApplicationConstSharedPtr app, + hmi_apis::Common_HMILevel::eType level, + bool send_policy_priority) = 0; + + virtual void OnNaviStreamingStarted() = 0; + virtual void OnNaviStreamingStopped() = 0; + virtual void OnStateChanged(ApplicationSharedPtr app, HmiStatePtr old_state, + HmiStatePtr new_state) = 0; + + virtual bool IsStateActive(HmiState::StateID state_id) const = 0; +}; +} // namespace application_manager + +#endif // SRC_COMPONENTS_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_H_ |