diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2015-03-03 18:51:10 +0200 |
---|---|---|
committer | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-04-15 14:12:50 +0300 |
commit | 7d947f4424d5470a8a4c8bdc9717859e6aea140f (patch) | |
tree | 5f14c3bc7ed01eeeb92e6ed91f6577ae80256e9a /src/components/application_manager | |
parent | 037abef1e1aae30661d94af4173a28acae4f0ea8 (diff) | |
download | sdl_core-7d947f4424d5470a8a4c8bdc9717859e6aea140f.tar.gz |
APPLINK-11447 Remove set_audio_streaming_state from AM
Move ActivateAppLogic to State Ctrl
Conflicts:
src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
src/components/application_manager/src/policies/policy_handler.cc
Diffstat (limited to 'src/components/application_manager')
24 files changed, 263 insertions, 397 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 395f93defb..c64f150c66 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -434,7 +434,7 @@ class Application : public virtual InitialApplicationData, virtual const uint32_t delete_file_in_none_count() const = 0; virtual const uint32_t list_files_in_none_count() const = 0; virtual const mobile_api::SystemContext::eType& system_context() const = 0; - virtual const mobile_api::AudioStreamingState::eType& + virtual const mobile_api::AudioStreamingState::eType audio_streaming_state() const = 0; virtual const std::string& app_icon_path() const = 0; virtual connection_handler::DeviceHandle device() const = 0; @@ -506,8 +506,6 @@ class Application : public virtual InitialApplicationData, virtual void increment_list_files_in_none_count() = 0; virtual void set_system_context( const mobile_api::SystemContext::eType& system_context) = 0; - virtual void set_audio_streaming_state( - const mobile_api::AudioStreamingState::eType& state) = 0; virtual bool set_app_icon_path(const std::string& file_name) = 0; virtual void set_app_allowed(const bool& allowed) = 0; virtual void set_device(connection_handler::DeviceHandle device) = 0; 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 7d354a2ff5..29b765d45f 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -107,8 +107,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, const uint32_t delete_file_in_none_count() const; const uint32_t list_files_in_none_count() const; const mobile_api::SystemContext::eType& system_context() const; - inline const mobile_api::AudioStreamingState::eType& - audio_streaming_state() const; + inline const mobile_apis::AudioStreamingState::eType audio_streaming_state() const; const std::string& app_icon_path() const; connection_handler::DeviceHandle device() const; void set_tts_speak_state(bool state_tts_speak); @@ -125,8 +124,6 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void increment_list_files_in_none_count(); void set_system_context( const mobile_api::SystemContext::eType& system_context); - void set_audio_streaming_state( - const mobile_api::AudioStreamingState::eType& state); bool set_app_icon_path(const std::string& path); void set_app_allowed(const bool& allowed); void set_device(connection_handler::DeviceHandle device); @@ -259,7 +256,6 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, uint32_t delete_file_in_none_count_; uint32_t list_files_in_none_count_; mobile_api::SystemContext::eType system_context_; - mobile_api::AudioStreamingState::eType audio_streaming_state_; std::string app_icon_path_; connection_handler::DeviceHandle device_; @@ -309,9 +305,14 @@ uint32_t ApplicationImpl::app_id() const { return app_id_; } -const mobile_api::AudioStreamingState::eType& +const mobile_api::AudioStreamingState::eType ApplicationImpl::audio_streaming_state() const { - return audio_streaming_state_; + using namespace mobile_apis; + const HmiStatePtr hmi_state = CurrentHmiState(); + AudioStreamingState::eType audio_state; + hmi_state.valid() ? audio_state = CurrentHmiState()->audio_streaming_state() : + audio_state = AudioStreamingState::INVALID_ENUM; + return audio_state; } bool ApplicationImpl::app_allowed() const { 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 3d09e494f6..ff4d4daeda 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 @@ -406,8 +406,43 @@ class ApplicationManagerImpl : public ApplicationManager, void set_all_apps_allowed(const bool& allowed); void SetState(uint32_t app_id, - mobile_api::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType ass); + mobile_apis::AudioStreamingState::eType ass) { + ApplicationSharedPtr app = application(app_id); + state_ctrl_.SetRegularState(app, ass); + } + + template <bool SendActivateApp> + void SetState(uint32_t app_id, + HmiStatePtr new_state) { + ApplicationSharedPtr app = application(app_id); + state_ctrl_.SetRegularState<SendActivateApp>(app, new_state); + } + + template <bool SendActivateApp> + void SetState(uint32_t app_id, + mobile_apis::HMILevel::eType hmi_level){ + ApplicationSharedPtr app = application(app_id); + state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level); + } + + + template <bool SendActivateApp> + void SetState(uint32_t app_id, + mobile_apis::HMILevel::eType hmi_level, + mobile_apis::AudioStreamingState::eType audio_state){ + ApplicationSharedPtr app = application(app_id); + state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level, audio_state); + } + + template <bool SendActivateApp> + void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level, + mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::SystemContext::eType system_context) { + ApplicationSharedPtr app = application(app_id); + state_ctrl_.SetRegularState<SendActivateApp>(app, hmi_level, + audio_state, system_context); + } + #ifdef CUSTOMER_PASA /** @@ -581,25 +616,6 @@ class ApplicationManagerImpl : public ApplicationManager, void RemovePolicyObserver(PolicyHandlerObserver* listener); /* - * @brief Change AudioStreamingState for all application according to - * system audio-mixing capabilities (NOT_AUDIBLE/ATTENUATED) and - * send notification for this changes - * @param If changing_state == kVRSessionChanging function is used by - * on_vr_started_notification, if changing_state == kTTSSessionChanging - * function is used by on_tts_started_notification - */ - void Mute(VRTTSSessionChanging changing_state); - - /* - * @brief Change AudioStreamingState for all application to AUDIBLE and - * send notification for this changes - * @param If changing_state == kVRSessionChanging function is used by - * on_vr_stopped_notification, if changing_state == kTTSSessionChanging - * function is used by on_tts_stopped_notification - */ - void Unmute(VRTTSSessionChanging changing_state); - - /* * @brief Checks HMI level and returns true if audio streaming is allowed */ bool IsAudioStreamingAllowed(uint32_t connection_key) const; @@ -754,23 +770,6 @@ class ApplicationManagerImpl : public ApplicationManager, void ChangeAppsHMILevel(uint32_t app_id, mobile_apis::HMILevel::eType level); /** - * @brief MakeAppNotAudible allows to make certain application not audible. - * - * @param app_id applicatin's id whose audible state should be changed. - */ - void MakeAppNotAudible(uint32_t app_id); - - /** - * @brief MakeAppFullScreen allows ti change application's properties - * in order to make it full screen. - * - * @param app_id the id of application which should be in full screen mode. - * - * @return true if operation was success, false otherwise. - */ - bool MakeAppFullScreen(uint32_t app_id); - - /** * 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 @@ -1257,27 +1256,6 @@ class ApplicationManagerImpl : public ApplicationManager, */ std::map<uint32_t, TimevalStruct> tts_global_properties_app_list_; - - struct AppState { - AppState(const mobile_apis::HMILevel::eType& level, - const mobile_apis::AudioStreamingState::eType& streaming_state, - const mobile_apis::SystemContext::eType& context) - : hmi_level(level), - audio_streaming_state(streaming_state), - system_context(context) { } - - mobile_apis::HMILevel::eType hmi_level; - mobile_apis::AudioStreamingState::eType audio_streaming_state; - mobile_apis::SystemContext::eType system_context; - }; - - /** - * @brief Map contains apps with HMI state before incoming call - * After incoming call ends previous HMI state must restore - * - */ - std::map<uint32_t, AppState> on_phone_call_app_list_; - bool audio_pass_thru_active_; sync_primitives::Lock audio_pass_thru_lock_; sync_primitives::Lock tts_global_properties_app_list_lock_; diff --git a/src/components/application_manager/include/application_manager/commands/hmi/activate_app_request.h b/src/components/application_manager/include/application_manager/commands/hmi/activate_app_request.h index 7d1b294c86..5122a0856b 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/activate_app_request.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/activate_app_request.h @@ -42,7 +42,7 @@ namespace commands { /** * @brief ActivateAppRequest command class **/ -class ActivateAppRequest : public RequestToHMI, event_engine::EventObserver { +class ActivateAppRequest : public RequestToHMI { public: /** * @brief ActivateAppRequest class constructor @@ -52,13 +52,6 @@ class ActivateAppRequest : public RequestToHMI, event_engine::EventObserver { explicit ActivateAppRequest(const MessageSharedPtr& message); /** - * @brief Callback for response - * - * @param event - event response - **/ - virtual void on_event(const event_engine::Event& event); - - /** * @brief ActivateAppRequest class destructor **/ virtual ~ActivateAppRequest(); 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 109c2942d7..a213ae6003 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -68,7 +68,7 @@ class HmiState { return audio_streaming_state_; } - virtual void set_audio_streaming_state(mobile_apis::AudioStreamingState::eType ass){ + virtual void set_audio_streaming_state(mobile_apis::AudioStreamingState::eType ass) { audio_streaming_state_ = ass; } 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 8ee8256001..68b7aac672 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -224,7 +224,7 @@ class MessageHelper { */ static void SendOnAppUnregNotificationToHMI(ApplicationConstSharedPtr app, bool is_unexpected_disconnect = false); - static void SendActivateAppToHMI( + static uint32_t SendActivateAppToHMI( uint32_t const app_id, hmi_apis::Common_HMILevel::eType level = hmi_apis::Common_HMILevel::FULL, bool send_policy_priority = true); diff --git a/src/components/application_manager/include/application_manager/state_controller.h b/src/components/application_manager/include/application_manager/state_controller.h index 84d3123039..8859094504 100644 --- a/src/components/application_manager/include/application_manager/state_controller.h +++ b/src/components/application_manager/include/application_manager/state_controller.h @@ -45,16 +45,6 @@ class StateController : public event_engine::EventObserver { public: StateController(); - /** - * @brief SetRegularState setup original hmi state, that will appear - * if no specific events are active - * @param app appication to setup default State` - * @param hmi_level hmi level of default state - * @param audio_state audio streaming state of default state - */ - void SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level, - const mobile_apis::AudioStreamingState::eType audio_state); /** * @brief SetRegularState setup regular hmi state, tha will appear if no @@ -62,14 +52,58 @@ class StateController : public event_engine::EventObserver { * @param app appication to setup default State * @param state state of new defailt state */ + template <bool SendActivateApp> void SetRegularState(ApplicationSharedPtr app, - HmiStatePtr state); + HmiStatePtr state) { + DCHECK_OR_RETURN_VOID(app); + DCHECK_OR_RETURN_VOID(state); + DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); + + if (SendActivateApp) { + uint32_t corr_id = MessageHelper::SendActivateAppToHMI(app->app_id()); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, + corr_id); + waiting_for_activate[app->app_id()] = state; + } else { + ApplyRegularState(app, state); + } + } - /** - * @brief setSystemContext setup new system_context for all applications - * @param system_context system context to setup - */ - void SetSystemContext(const mobile_apis::SystemContext::eType system_context); + void SetRegularState(ApplicationSharedPtr app, + const mobile_apis::AudioStreamingState::eType audio_state); + + template <bool SendActivateApp> + void SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state) { + DCHECK_OR_RETURN_VOID(app); + HmiStatePtr prev_regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state(new HmiState(hmi_level, audio_state, + prev_regular->system_context())); + SetRegularState<SendActivateApp>(app, hmi_state); + } + + template <bool SendActivateApp> + void SetRegularState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) { + DCHECK_OR_RETURN_VOID(app); + HmiStatePtr prev_regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state(new HmiState(hmi_level, prev_regular->audio_streaming_state(), + prev_regular->system_context())); + SetRegularState<SendActivateApp>(app, hmi_state); + } + + template <bool SendActivateApp> + 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) { + HmiStatePtr hmi_state(new HmiState(hmi_level, audio_state, + system_context)); + SetRegularState<SendActivateApp>(app, hmi_state); + } // EventObserver interface void on_event(const event_engine::Event& event); @@ -136,9 +170,15 @@ class StateController : public event_engine::EventObserver { void SetupRegularHmiState(ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, - const mobile_apis::AudioStreamingState::eType audio_state); + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::SystemContext::eType system_context); + + void SetupRegularHmiState(ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level, + const mobile_apis::AudioStreamingState::eType audio_state); void OnActivateAppResponse(const smart_objects::SmartObject& message); + /** * @brief OnPhoneCallStarted process Phone Call Started event */ @@ -179,11 +219,11 @@ class StateController : public event_engine::EventObserver { */ void OnTTSStopped(); + /** * @brief Active states of application */ std::list<HmiState::StateID> current_state_; - mobile_apis::SystemContext::eType system_context_; std::map<uint32_t, HmiStatePtr> waiting_for_activate; }; diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 8d3fb00bef..25b841048f 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -97,7 +97,6 @@ ApplicationImpl::ApplicationImpl(uint32_t application_id, delete_file_in_none_count_(0), list_files_in_none_count_(0), system_context_(mobile_api::SystemContext::SYSCTXT_MAIN), - audio_streaming_state_(mobile_api::AudioStreamingState::NOT_AUDIBLE), device_(0), usage_report_(mobile_app_id, statistics_manager), protocol_version_(ProtocolVersion::kV3), @@ -483,17 +482,6 @@ void ApplicationImpl::set_system_context( system_context_ = system_context; } -void ApplicationImpl::set_audio_streaming_state( - const mobile_api::AudioStreamingState::eType& state) { - if (!(is_media_application() || is_navi()) - && state != mobile_api::AudioStreamingState::NOT_AUDIBLE) { - LOG4CXX_WARN(logger_, "Trying to set audio streaming state" - " for non-media application to different from NOT_AUDIBLE"); - return; - } - audio_streaming_state_ = state; -} - bool ApplicationImpl::set_app_icon_path(const std::string& path) { if (app_files_.find(path) != app_files_.end()) { app_icon_path_ = path; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 44c5b560c1..5037a58873 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -499,7 +499,7 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { AudioStreamingState::eType ass; app->IsAudioApplication() ? ass = AudioStreamingState::AUDIBLE : AudioStreamingState::NOT_AUDIBLE; - state_ctrl_.SetRegularState(app, hmi_level, ass); + state_ctrl_.SetRegularState<false>(app, hmi_level, ass); return true; } @@ -624,14 +624,6 @@ void ApplicationManagerImpl::set_all_apps_allowed(const bool& allowed) { is_all_apps_allowed_ = allowed; } -void ApplicationManagerImpl::SetState(uint32_t app_id, - mobile_api::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType ass) { - LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = application(app_id); - state_ctrl_.SetRegularState(app, hmi_level, ass); -} - void ApplicationManagerImpl::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) { @@ -2479,11 +2471,9 @@ void ApplicationManagerImpl::NaviAppStreamStatus(bool stream_active) { using namespace mobile_apis; if(active_app && active_app->is_media_application()) { LOG4CXX_DEBUG(logger_, "Stream status: " << active_app->app_id()); - - active_app->set_audio_streaming_state(stream_active ? - AudioStreamingState::ATTENUATED : - AudioStreamingState::AUDIBLE); - MessageHelper::SendHMIStatusNotification(*active_app); + SetState(active_app, + stream_active ? AudioStreamingState::ATTENUATED : + AudioStreamingState::AUDIBLE); } } @@ -2625,65 +2615,65 @@ void ApplicationManagerImpl::OnWakeUp() { request_ctrl_.OnWakeUp(); } -void ApplicationManagerImpl::Mute(VRTTSSessionChanging changing_state) { - mobile_apis::AudioStreamingState::eType state = - mobile_apis::AudioStreamingState::NOT_AUDIBLE; - - // ATTENUATED state applicable only for TTS - if ((kTTSSessionChanging == changing_state) && - hmi_capabilities_.attenuated_supported()) { - state = mobile_apis::AudioStreamingState::ATTENUATED; - } - - ApplicationManagerImpl::ApplicationListAccessor accessor; - - ApplicationManagerImpl::ApplictionSetConstIt it = - accessor.begin(); - ApplicationManagerImpl::ApplictionSetConstIt - itEnd = accessor.end(); - for (; it != itEnd; ++it) { - if ((*it).valid()) { - if ((*it)->is_media_application()) { - if (kTTSSessionChanging == changing_state) { - (*it)->set_tts_speak_state(true); - } - if ((*it)->audio_streaming_state() != state && - (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) && - (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) { - (*it)->set_audio_streaming_state(state); - MessageHelper::SendHMIStatusNotification(*(*it)); - } - } - } - } -} - -void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) { - - ApplicationManagerImpl::ApplicationListAccessor accessor; - ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin(); - ApplicationManagerImpl::ApplictionSetConstIt itEnd = accessor.end(); - - for (; it != itEnd; ++it) { - if ((*it).valid()) { - if ((*it)->is_media_application()) { - if (kTTSSessionChanging == changing_state) { - (*it)->set_tts_speak_state(false); - } - if ((!(vr_session_started())) && - (!((*it)->tts_speak_state())) && - ((*it)->audio_streaming_state() != - mobile_apis::AudioStreamingState::AUDIBLE) && - (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) && - (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) { - (*it)->set_audio_streaming_state( - mobile_apis::AudioStreamingState::AUDIBLE); - MessageHelper::SendHMIStatusNotification(*(*it)); - } - } - } - } -} +//void ApplicationManagerImpl::Mute(VRTTSSessionChanging changing_state) { +// mobile_apis::AudioStreamingState::eType state = +// mobile_apis::AudioStreamingState::NOT_AUDIBLE; + +// // ATTENUATED state applicable only for TTS +// if ((kTTSSessionChanging == changing_state) && +// hmi_capabilities_.attenuated_supported()) { +// state = mobile_apis::AudioStreamingState::ATTENUATED; +// } + +// ApplicationManagerImpl::ApplicationListAccessor accessor; + +// ApplicationManagerImpl::ApplictionSetConstIt it = +// accessor.begin(); +// ApplicationManagerImpl::ApplictionSetConstIt +// itEnd = accessor.end(); +// for (; it != itEnd; ++it) { +// if ((*it).valid()) { +// if ((*it)->is_media_application()) { +// if (kTTSSessionChanging == changing_state) { +// (*it)->set_tts_speak_state(true); +// } +// if ((*it)->audio_streaming_state() != state && +// (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) && +// (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) { +// (*it)->set_audio_streaming_state(state); +// MessageHelper::SendHMIStatusNotification(*(*it)); +// } +// } +// } +// } +//} + +//void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) { + +// ApplicationManagerImpl::ApplicationListAccessor accessor; +// ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin(); +// ApplicationManagerImpl::ApplictionSetConstIt itEnd = accessor.end(); + +// for (; it != itEnd; ++it) { +// if ((*it).valid()) { +// if ((*it)->is_media_application()) { +// if (kTTSSessionChanging == changing_state) { +// (*it)->set_tts_speak_state(false); +// } +// if ((!(vr_session_started())) && +// (!((*it)->tts_speak_state())) && +// ((*it)->audio_streaming_state() != +// mobile_apis::AudioStreamingState::AUDIBLE) && +// (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) && +// (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) { +// (*it)->set_audio_streaming_state( +// mobile_apis::AudioStreamingState::AUDIBLE); +// MessageHelper::SendHMIStatusNotification(*(*it)); +// } +// } +// } +// } +//} mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary( const std::vector<uint8_t>& binary_data, const std::string& file_path, @@ -2846,39 +2836,7 @@ void ApplicationManagerImpl::ChangeAppsHMILevel(uint32_t app_id, } HmiStatePtr new_state( new HmiState(*(app->RegularHmiState()))); new_state->set_hmi_level(level); - state_ctrl_.SetRegularState(app, new_state); -} - -void ApplicationManagerImpl::MakeAppNotAudible(uint32_t app_id) { - using namespace mobile_apis; - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_DEBUG(logger_, "There is no app with id: " << app_id); - return; - } - ChangeAppsHMILevel(app_id, HMILevel::HMI_BACKGROUND); - app->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); -} - -bool ApplicationManagerImpl::MakeAppFullScreen(uint32_t app_id) { - using namespace mobile_apis; - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_DEBUG(logger_, "There is no app with id: " << app_id); - return false; - } - - ChangeAppsHMILevel(app_id, HMILevel::HMI_FULL); - if (app->is_media_application() || app->is_navi()) { - app->set_audio_streaming_state(AudioStreamingState::AUDIBLE); - } - app->set_system_context(SystemContext::SYSCTXT_MAIN); - - if(!app->has_been_activated()) { - app->set_activated(true); - } - - return true; + //state_ctrl_.SetRegularState(app, new_state); } @@ -2980,12 +2938,10 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( } else if (((*it)->hmi_level() == mobile_api::HMILevel::HMI_FULL) || ((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) { - MessageHelper::SendActivateAppToHMI((*it)->app_id(), - hmi_apis::Common_HMILevel::BACKGROUND, - false); MessageHelper::SendUIChangeRegistrationRequestToHMI(*it); - ChangeAppsHMILevel((*it)->app_id(), mobile_api::HMILevel::HMI_BACKGROUND); - MessageHelper::SendHMIStatusNotification(*(*it)); + ApplicationManagerImpl::instance()->SetState<true>((*it)->app_id(), + mobile_apis::HMILevel::HMI_BACKGROUND + ); } } } diff --git a/src/components/application_manager/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/src/commands/hmi/activate_app_request.cc index 4b07a5dcfa..c8258bd74a 100644 --- a/src/components/application_manager/src/commands/hmi/activate_app_request.cc +++ b/src/components/application_manager/src/commands/hmi/activate_app_request.cc @@ -62,54 +62,9 @@ namespace application_manager { } #endif SendRequest(); - subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, - correlation_id()); LOG4CXX_TRACE(logger_, "exit"); } - - void ActivateAppRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& response = event.smart_object(); - const hmi_apis::Common_Result::eType code = - static_cast<hmi_apis::Common_Result::eType>( - response[strings::params][hmi_response::code].asInt()); - if (hmi_apis::Common_Result::SUCCESS != code) { - LOG4CXX_ERROR(logger_, "Error ActivateApp result code " << code); - return; - } - int32_t correlation_id = RequestToHMI::correlation_id(); - // Mobile id is converted to HMI id for HMI requests - const uint32_t hmi_app_id = ApplicationManagerImpl::instance()-> - application_id(correlation_id); - - mobile_apis::HMILevel::eType requested_hmi_level = mobile_apis::HMILevel::HMI_FULL; - if ((*message_)[strings::msg_params].keyExists( - strings::activate_app_hmi_level)) { - requested_hmi_level = static_cast<mobile_apis::HMILevel::eType>( - (*message_)[strings::msg_params][strings::activate_app_hmi_level].asInt()); - LOG4CXX_INFO(logger_, "requested_hmi_level = " << requested_hmi_level); - } - - if (0 == hmi_app_id) { - LOG4CXX_ERROR(logger_, "Error hmi_app_id = "<< hmi_app_id); - return; - } - - ApplicationSharedPtr application = ApplicationManagerImpl::instance()-> - application_by_hmi_app(hmi_app_id); - if (!application.valid()) { - LOG4CXX_ERROR(logger_, "Application can't be activated."); - return; - } - - if (mobile_apis::HMILevel::HMI_FULL == requested_hmi_level) { - if (ApplicationManagerImpl::instance()->ActivateApplication(application)) { - LOG4CXX_DEBUG(logger_, "Put Application in FULL succes"); - MessageHelper::SendHMIStatusNotification(*(application.get())); - } - } - } } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc index 7e60eaadaf..0ff76a45f5 100644 --- a/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc @@ -50,7 +50,9 @@ OnAppActivatedNotification::~OnAppActivatedNotification() { void OnAppActivatedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = ((*message_)[strings::msg_params][strings::app_id]).asUInt(); - MessageHelper::SendActivateAppToHMI(app_id); + ApplicationManagerImpl::instance()->SetState<true>(app_id, + mobile_apis::HMILevel::HMI_FULL + ); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc index 1d55044f7a..5f369d44aa 100644 --- a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc @@ -80,51 +80,29 @@ void OnAppDeactivatedNotification::Run() { if (HMI_NONE == app->hmi_level()) { return; } + HmiStatePtr regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(regular); + HmiStatePtr new_regular(new HmiState(*regular)); - eType new_hmi_level = app->hmi_level(); switch ((*message_)[strings::msg_params][hmi_request::reason].asInt()) { case hmi_apis::Common_DeactivateReason::AUDIO: { - if (app->is_media_application()) { - if (profile::Profile::instance()->is_mixing_audio_supported() && - (ApplicationManagerImpl::instance()->vr_session_started() || - app->tts_speak_state())) { - app->set_audio_streaming_state(mobile_api::AudioStreamingState::ATTENUATED); - } else { - app->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE); - } - } - // HMI must send this notification for each active app - if (app.valid()) { - if (Compare<eType, EQ, ONE>(app->hmi_level(), HMI_FULL, HMI_LIMITED)) { - new_hmi_level = HMI_BACKGROUND; - } - } + new_regular->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE); + new_regular->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND); break; } case hmi_apis::Common_DeactivateReason::NAVIGATIONMAP: case hmi_apis::Common_DeactivateReason::PHONEMENU: case hmi_apis::Common_DeactivateReason::SYNCSETTINGS: case hmi_apis::Common_DeactivateReason::GENERAL: { - if ((!app->IsAudioApplication()) || - ApplicationManagerImpl::instance()-> - DoesAudioAppWithSameHMITypeExistInFullOrLimited(app)) { - new_hmi_level = HMI_BACKGROUND; + if (app->IsAudioApplication()) { + new_regular->set_hmi_level(mobile_api::HMILevel::HMI_LIMITED); } else { - new_hmi_level = HMI_LIMITED; + new_regular->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND); } - break; - } - default: { - LOG4CXX_ERROR_EXT(logger_, "Unknown reason of app deactivation"); - return; } } + ApplicationManagerImpl::instance()->SetState<false>(app, new_regular); - if (new_hmi_level != app->hmi_level()) { - ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(), - new_hmi_level); - MessageHelper::SendHMIStatusNotification(*app); - } } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc index 9cb40bd645..d64ba3adf9 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc @@ -70,13 +70,11 @@ void OnExitApplicationNotification::Run() { break; } } - - ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app_impl->app_id(), - mobile_apis::HMILevel::HMI_NONE); - - app_impl->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE); - app_impl->set_system_context(mobile_api::SystemContext::SYSCTXT_MAIN); - MessageHelper::SendHMIStatusNotification(*app_impl); + using namespace mobile_apis; + ApplicationManagerImpl::instance()->SetState<false>(app_impl->app_id(), + HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + SystemContext::SYSCTXT_MAIN); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc index 8cbafda68e..dc69246d5c 100644 --- a/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc @@ -50,7 +50,6 @@ void OnTTSStartedNotification::Run() { event_engine::Event event(hmi_apis::FunctionID::TTS_Started); event.set_smart_object(*message_); event.raise(); - ApplicationManagerImpl::instance()->Mute(kTTSSessionChanging); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc index c812c84af5..8d429ed179 100644 --- a/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc @@ -52,8 +52,6 @@ void OnTTSStoppedNotification::Run() { event_engine::Event event(hmi_apis::FunctionID::TTS_Stopped); event.set_smart_object(*message_); event.raise(); - ApplicationManagerImpl::instance()->Unmute(kTTSSessionChanging); - } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc index bcd02196a8..f8f9b4dfad 100644 --- a/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc @@ -62,7 +62,10 @@ void OnVRCommandNotification::Run() { // Check if this is one of standart VR commands (i.e. "Help") if (cmd_id > max_cmd_id + 1) { LOG4CXX_INFO(logger_, "Switched App"); - MessageHelper::SendActivateAppToHMI(cmd_id - max_cmd_id); + const uint32_t app_id = cmd_id - max_cmd_id; + ApplicationManagerImpl::instance()->SetState<true>(app_id, + mobile_apis::HMILevel::HMI_FULL + ); return; } diff --git a/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc index 6e56dd29c0..8ab63ca61e 100644 --- a/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc @@ -49,7 +49,7 @@ void OnVRStartedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->set_vr_session_started(true); - ApplicationManagerImpl::instance()->Mute(kVRSessionChanging); + //ApplicationManagerImpl::instance()->Mute(kVRSessionChanging); } } // namespace commands diff --git a/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc index 442968ea1e..02c2c165a1 100644 --- a/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc @@ -49,7 +49,7 @@ void OnVRStoppedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); ApplicationManagerImpl::instance()->set_vr_session_started(false); - ApplicationManagerImpl::instance()->Unmute(kVRSessionChanging); + //ApplicationManagerImpl::instance()->Unmute(kVRSessionChanging); } } // namespace commands diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 2e97b5a2f3..4cd5e771f9 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -29,7 +29,6 @@ HmiState::HmiState(const HmiState& copy_from): } - HmiState::HmiState(mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_streaming_state, mobile_apis::SystemContext::eType system_context): @@ -43,7 +42,6 @@ void HmiState::setParent(HmiStatePtr parent) { parent_ = parent; } - VRHmiState::VRHmiState(HmiStatePtr previous): HmiState(previous) { } diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index 829c894b2e..36954a50dc 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -1303,25 +1303,26 @@ void MessageHelper::SendOnAppUnregNotificationToHMI( ApplicationManagerImpl::instance()->ManageHMICommand(notification); } -void MessageHelper::SendActivateAppToHMI(uint32_t const app_id, +uint32_t MessageHelper::SendActivateAppToHMI(uint32_t const app_id, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority) { + u_int32_t correlation_id = 0; application_manager::ApplicationConstSharedPtr app = application_manager::ApplicationManagerImpl::instance() ->application(app_id); if (!app) { LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id); - return; + return correlation_id; } + correlation_id = + ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); utils::SharedPtr<smart_objects::SmartObject> message = new smart_objects::SmartObject( smart_objects::SmartType_Map); - (*message)[strings::params][strings::function_id] = hmi_apis::FunctionID::BasicCommunication_ActivateApp; (*message)[strings::params][strings::message_type] = MessageType::kRequest; - (*message)[strings::params][strings::correlation_id] = - ApplicationManagerImpl::instance()->GetNextHMICorrelationID(); + (*message)[strings::params][strings::correlation_id] = correlation_id; (*message)[strings::msg_params][strings::app_id] = app_id; if (send_policy_priority) { @@ -1352,6 +1353,7 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id, } ApplicationManagerImpl::instance()->ManageHMICommand(message); + return correlation_id; } void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id) { diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index fe9d14df16..5316aaec7c 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -103,14 +103,9 @@ struct DeactivateApplication { void operator()(const ApplicationSharedPtr& app) { if (device_id_ == app->device()) { - if (mobile_api::HMILevel::HMI_NONE != app->hmi_level()) { - ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(), - mobile_apis::HMILevel::HMI_NONE); - app->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE); - MessageHelper::SendActivateAppToHMI( - app->app_id(), hmi_apis::Common_HMILevel::NONE); - MessageHelper::SendHMIStatusNotification(*app.get()); - } + ApplicationManagerImpl::instance()->SetState<true>(app->app_id(), + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE); } } @@ -130,32 +125,22 @@ struct SDLAlowedNotification { } if (device_id_ == app->device()) { std::string hmi_level; - hmi_apis::Common_HMILevel::eType default_hmi; mobile_apis::HMILevel::eType default_mobile_hmi; policy_manager_->GetDefaultHmi(app->mobile_app_id(), &hmi_level); if ("BACKGROUND" == hmi_level) { - default_hmi = hmi_apis::Common_HMILevel::BACKGROUND; default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND; } else if ("FULL" == hmi_level) { - default_hmi = hmi_apis::Common_HMILevel::FULL; default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL; } else if ("LIMITED" == hmi_level) { - default_hmi = hmi_apis::Common_HMILevel::LIMITED; default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED; } else if ("NONE" == hmi_level) { - default_hmi = hmi_apis::Common_HMILevel::NONE; default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE; } else { return ; } - if (app->hmi_level() == default_mobile_hmi) { - LOG4CXX_DEBUG(logger_, "Application already in default hmi state."); - } else { - ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(), - default_mobile_hmi); - MessageHelper::SendHMIStatusNotification(*app); - } - MessageHelper::SendActivateAppToHMI(app->app_id(), default_hmi); + ApplicationManagerImpl::instance()->SetState<true>(app->app_id(), + default_mobile_hmi + ); } } private: @@ -645,27 +630,23 @@ void PolicyHandler::OnPendingPermissionChange( const uint32_t app_id = app->app_id(); - using mobile_apis::HMILevel::eType; + namespace ma = mobile_apis; if (permissions.appRevoked) { application_manager::MessageHelper::SendOnAppPermissionsChangedNotification( app_id, permissions); - - ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(), - eType::HMI_NONE); - app->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE); - application_manager::MessageHelper::SendActivateAppToHMI( - app_id, hmi_apis::Common_HMILevel::NONE); - application_manager::MessageHelper::SendHMIStatusNotification(*app); + ApplicationManagerImpl::instance()->SetState<false>(app->app_id(), + ma::HMILevel::HMI_NONE, + ma::AudioStreamingState::NOT_AUDIBLE); policy_manager_->RemovePendingPermissionChanges(policy_app_id); return; } - eType app_hmi_level = app->hmi_level(); + ma::HMILevel::eType app_hmi_level = app->hmi_level(); switch (app_hmi_level) { - case eType::HMI_FULL: - case eType::HMI_LIMITED: { + case ma::HMILevel::eType::HMI_FULL: + case ma::HMILevel::eType::HMI_LIMITED: { if (permissions.appPermissionsConsentNeeded) { MessageHelper:: SendOnAppPermissionsChangedNotification(app->app_id(), permissions); @@ -674,7 +655,7 @@ void PolicyHandler::OnPendingPermissionChange( } break; } - case eType::HMI_BACKGROUND: { + case ma::HMILevel::eType::HMI_BACKGROUND: { if (permissions.isAppPermissionsRevoked) { MessageHelper:: SendOnAppPermissionsChangedNotification(app->app_id(), permissions); @@ -947,17 +928,9 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, LOG4CXX_INFO(logger_, "Changing hmi level of application " << policy_app_id << " to default hmi level " << default_hmi); - // If default is FULL, send request to HMI. Notification to mobile will be - // sent on response receiving. - if (mobile_apis::HMILevel::HMI_FULL == hmi_level) { - MessageHelper::SendActivateAppToHMI(app->app_id()); - } else { - // Set application hmi level - ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(), - hmi_level); - // If hmi Level is full, it will be seted after ActivateApp response - MessageHelper::SendHMIStatusNotification(*app.get()); - } + ApplicationManagerImpl::instance()->SetState<true>(app->app_id(), + mobile_apis::HMILevel::HMI_FULL + ); break; } default: diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp index fab14f8819..ff4415a164 100644 --- a/src/components/application_manager/src/resume_ctrl.cpp +++ b/src/components/application_manager/src/resume_ctrl.cpp @@ -233,9 +233,15 @@ bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application, HMILevel::HMI_LIMITED == restored_hmi_level ? AudioStreamingState::AUDIBLE: AudioStreamingState::NOT_AUDIBLE; - ApplicationManagerImpl::instance()->SetState(application->app_id(), - restored_hmi_level, - restored_audio_state); + if (restored_hmi_level == HMILevel::HMI_FULL) { + ApplicationManagerImpl::instance()->SetState<true>(application->app_id(), + restored_hmi_level, + restored_audio_state); + } else { + ApplicationManagerImpl::instance()->SetState<false>(application->app_id(), + restored_hmi_level, + restored_audio_state); + } LOG4CXX_INFO(logger_, "Set up application " << application->mobile_app_id() << " to HMILevel " << hmi_level); diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller.cc index c4fe6f9a97..b567aa9cd0 100644 --- a/src/components/application_manager/src/state_controller.cc +++ b/src/components/application_manager/src/state_controller.cc @@ -59,27 +59,17 @@ StateController::StateController():EventObserver() { } void StateController::SetRegularState(ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state) { - HmiStatePtr hmi_state(new HmiState(hmi_level, audio_state, system_context_)); - SetRegularState(app, hmi_state); + DCHECK_OR_RETURN_VOID(app); + HmiStatePtr prev_regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state(new HmiState(prev_regular->hmi_level(), + audio_state, + prev_regular->system_context())); + SetRegularState<false>(app, hmi_state); } -void StateController::SetRegularState(ApplicationSharedPtr app, - HmiStatePtr state) { - DCHECK_OR_RETURN_VOID(app); - DCHECK_OR_RETURN_VOID(state); - DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); - HmiStatePtr old_state(new HmiState(*(app->RegularHmiState()))); - if (state->hmi_level() == mobile_api::HMILevel::HMI_FULL - && old_state->hmi_level() != mobile_api::HMILevel::HMI_FULL) { - MessageHelper::SendActivateAppToHMI(app->app_id()); - waiting_for_activate[app->app_id()] = state; - } else { - ApplyRegularState(app, state); - } -} void StateController::HmiLevelConflictResolver::operator () (ApplicationSharedPtr to_resolve) { @@ -105,26 +95,28 @@ void StateController::HmiLevelConflictResolver::operator () } void StateController::SetupRegularHmiState(ApplicationSharedPtr app, + HmiStatePtr state) { + HmiStatePtr old_state(new HmiState(*(app->CurrentHmiState()))); + app->SetRegularState(state); + HmiStatePtr new_state = app->RegularHmiState(); + OnStateChanged(app, old_state, new_state); +} + +void StateController::SetupRegularHmiState(ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state) { using namespace mobile_apis; using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); + HmiStatePtr prev_state = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr new_state(new HmiState(hmi_level, audio_state, - system_context_)); + prev_state->system_context())); SetupRegularHmiState(app, new_state); } -void StateController::SetupRegularHmiState(ApplicationSharedPtr app, - HmiStatePtr state) { - HmiStatePtr old_state(new HmiState(*(app->CurrentHmiState()))); - app->SetRegularState(state); - HmiStatePtr new_state = app->RegularHmiState(); - OnStateChanged(app, old_state, new_state); -} - void StateController::ApplyRegularState(ApplicationSharedPtr app, HmiStatePtr state) { DCHECK_OR_RETURN_VOID(app); @@ -142,11 +134,6 @@ bool StateController::IsSameAppType(ApplicationConstSharedPtr app1, app1->is_voice_communication_supported() == app2->is_voice_communication_supported(); } -void StateController::SetSystemContext(const mobile_apis::SystemContext::eType system_context) { - system_context_ = system_context; - //TODO (APPLINK-8555) Need to setup system context for app applications -} - void StateController::on_event(const event_engine::Event& event) { using namespace smart_objects; using namespace event_engine; @@ -156,6 +143,10 @@ void StateController::on_event(const event_engine::Event& event) { const SmartObject& message = event.smart_object(); const FunctionID::eType id = static_cast<FunctionID::eType> (event.id()); switch (id) { + case FunctionID::BasicCommunication_ActivateApp: { + OnActivateAppResponse(message); + break; + } case FunctionID::BasicCommunication_OnEmergencyEvent: { bool is_active = message[strings::msg_params][hmi_notification::is_active].asBool(); diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index 5ab5e8c6ba..949dc58534 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -255,8 +255,19 @@ class ApplicationManagerImpl : public ApplicationManager, MOCK_METHOD0(StartDevicesDiscovery, void()); MOCK_METHOD2(SendAudioPassThroughNotification, void(uint32_t, std::vector<uint8_t>&)); MOCK_METHOD1(set_all_apps_allowed, void(const bool)); + template<bool SendActivateApp> + MOCK_METHOD2(SetState, void(uint32_t, HmiState)); + template<bool SendActivateApp> + MOCK_METHOD2(SetState, void(uint32_t, mobile_api::HMILevel::eType)); + template<bool SendActivateApp> MOCK_METHOD3(SetState, void(uint32_t, mobile_api::HMILevel::eType, mobile_apis::AudioStreamingState::eType)); + template<bool SendActivateApp> + MOCK_METHOD4(SetState, void(uint32_t, mobile_api::HMILevel::eType, + mobile_apis::AudioStreamingState::eType, + mobile_apis::SystemContext::eType)); + MOCK_METHOD2(SetState, void(uint32_t, + mobile_apis::AudioStreamingState::eType)); MOCK_CONST_METHOD0(all_apps_allowed, bool()); MOCK_METHOD1(set_vr_session_started, void(const bool)); @@ -271,8 +282,6 @@ class ApplicationManagerImpl : public ApplicationManager, MOCK_METHOD0(CreatePhoneCallAppList, void()); MOCK_METHOD0(ResetPhoneCallAppList, void()); MOCK_METHOD2(ChangeAppsHMILevel, void(uint32_t, mobile_apis::HMILevel::eType)); - MOCK_METHOD1(MakeAppNotAudible, void(uint32_t app_id)); - MOCK_METHOD1(MakeAppFullScreen, bool(uint32_t app_id)); MOCK_METHOD1(AddAppToTTSGlobalPropertiesList, void(const uint32_t)); MOCK_METHOD1(RemoveAppFromTTSGlobalPropertiesList, void(const uint32_t)); MOCK_METHOD1(application_by_hmi_app, ApplicationSharedPtr(uint32_t)); |