diff options
author | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-03-04 10:20:31 +0200 |
---|---|---|
committer | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-04-15 14:12:50 +0300 |
commit | ff5b7a59411fee50eac83274eb73c9477fcdf8df (patch) | |
tree | b3e6005353246a8b8fc3c16070f222cad6a97e12 | |
parent | 7d947f4424d5470a8a4c8bdc9717859e6aea140f (diff) | |
download | sdl_core-ff5b7a59411fee50eac83274eb73c9477fcdf8df.tar.gz |
APPLINK-11444 APPLINK-11448 APPLINK-11445 APPLINK-8555
Add usage of StateController in SDL
Conflicts:
src/components/application_manager/include/application_manager/application_impl.h
src/components/application_manager/src/application_manager_impl.cc
src/components/hmi_message_handler/src/messagebroker_adapter.cc
20 files changed, 172 insertions, 94 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index c64f150c66..7e7ebc570d 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -433,7 +433,7 @@ class Application : public virtual InitialApplicationData, virtual const uint32_t put_file_in_none_count() const = 0; virtual const uint32_t delete_file_in_none_count() const = 0; virtual const uint32_t list_files_in_none_count() const = 0; - virtual const mobile_api::SystemContext::eType& system_context() const = 0; + virtual const mobile_api::SystemContext::eType system_context() const = 0; virtual const mobile_api::AudioStreamingState::eType audio_streaming_state() const = 0; virtual const std::string& app_icon_path() const = 0; @@ -449,6 +449,11 @@ class Application : public virtual InitialApplicationData, sync_primitives::AutoLock auto_lock(hmi_states_lock_); DCHECK_OR_RETURN_VOID(!hmi_states_.empty()); hmi_states_.erase(hmi_states_.begin()); + if (hmi_states_.begin() != hmi_states_.end()) { + HmiStatePtr first_temp = *(hmi_states_.begin()); + DCHECK_OR_RETURN_VOID(first_temp); + first_temp->setParent(state); + } hmi_states_.push_front(state); } /** @@ -504,14 +509,12 @@ class Application : public virtual InitialApplicationData, virtual void increment_put_file_in_none_count() = 0; virtual void increment_delete_file_in_none_count() = 0; virtual void increment_list_files_in_none_count() = 0; - virtual void set_system_context( - const mobile_api::SystemContext::eType& system_context) = 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; virtual uint32_t get_grammar_id() const = 0 ; virtual void set_grammar_id(uint32_t value) = 0; - + virtual void reset_data_in_none() = 0; virtual void set_protocol_version( const ProtocolVersion& protocol_version) = 0; virtual ProtocolVersion protocol_version() const = 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 29b765d45f..28487791c9 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -106,7 +106,7 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, const uint32_t put_file_in_none_count() const; const uint32_t delete_file_in_none_count() const; const uint32_t list_files_in_none_count() const; - const mobile_api::SystemContext::eType& system_context() const; + const mobile_api::SystemContext::eType system_context() const; inline const mobile_apis::AudioStreamingState::eType audio_streaming_state() const; const std::string& app_icon_path() const; connection_handler::DeviceHandle device() const; @@ -122,13 +122,12 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void increment_put_file_in_none_count(); void increment_delete_file_in_none_count(); void increment_list_files_in_none_count(); - void set_system_context( - const mobile_api::SystemContext::eType& system_context); bool set_app_icon_path(const std::string& path); void set_app_allowed(const bool& allowed); void set_device(connection_handler::DeviceHandle device); virtual uint32_t get_grammar_id() const; virtual void set_grammar_id(uint32_t value); + virtual void reset_data_in_none(); virtual void set_protocol_version(const ProtocolVersion& protocol_version); virtual ProtocolVersion protocol_version() const; @@ -250,12 +249,10 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, bool tts_speak_state_; bool tts_properties_in_none_; bool tts_properties_in_full_; - mobile_api::HMILevel::eType hmi_level_; bool is_foreground_; uint32_t put_file_in_none_count_; uint32_t delete_file_in_none_count_; uint32_t list_files_in_none_count_; - mobile_api::SystemContext::eType system_context_; std::string app_icon_path_; connection_handler::DeviceHandle device_; 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 ff4d4daeda..a04764ebe5 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 @@ -443,6 +443,12 @@ class ApplicationManagerImpl : public ApplicationManager, audio_state, system_context); } + void SetState(uint32_t app_id, + mobile_apis::SystemContext::eType system_context) { + ApplicationSharedPtr app = application(app_id); + state_ctrl_.SetRegularState(app, system_context); + } + #ifdef CUSTOMER_PASA /** 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 a213ae6003..72088e80bf 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -32,7 +32,8 @@ class HmiState { STATE_ID_TTS_SESSION, }; - HmiState(HmiStatePtr parent); + HmiState(HmiStatePtr parent, StateID state_id); + HmiState(); HmiState(const HmiState& copy_from); @@ -54,8 +55,12 @@ class HmiState { * @return return hmi level member */ virtual mobile_apis::HMILevel::eType hmi_level() const { + if (parent_) { + return parent_->hmi_level(); + } return hmi_level_; } + void set_hmi_level(mobile_apis::HMILevel::eType hmi_level) { hmi_level_ = hmi_level; } @@ -65,6 +70,9 @@ class HmiState { * @return return audio streaming state member */ virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const { + if (parent_) { + return parent_->audio_streaming_state(); + } return audio_streaming_state_; } @@ -77,6 +85,9 @@ class HmiState { * @return return system context member */ virtual mobile_apis::SystemContext::eType system_context() const { + if (parent_) { + return parent_->system_context(); + } return system_context_; } @@ -88,8 +99,8 @@ class HmiState { return state_id_; } protected: - StateID state_id_; HmiStatePtr parent_; + StateID state_id_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; mobile_apis::SystemContext::eType system_context_; @@ -101,13 +112,16 @@ class HmiState { class VRHmiState : public HmiState { public: VRHmiState(HmiStatePtr parent); + virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const { + return audio_streaming_state_; + } }; class TTSHmiState : public HmiState { public: TTSHmiState(HmiStatePtr parent); mobile_apis::AudioStreamingState::eType audio_streaming_state() const { - return parent()->audio_streaming_state(); + return audio_streaming_state_; } }; @@ -123,14 +137,6 @@ class PhoneCallHmiState : public HmiState { class SafetyModeHmiState : public HmiState { public: SafetyModeHmiState(HmiStatePtr parent); - - mobile_apis::SystemContext::eType system_context() const { - return parent()->system_context(); - } - - mobile_apis::HMILevel::eType hmi_level() const { - return parent()->hmi_level(); - } }; } #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMISTATE_H diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index 1285300f15..1e465ac348 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -389,6 +389,8 @@ const char screen_params[] = "screenParams"; const char num_custom_presets_available[] = "numCustomPresetsAvailable"; const char urls[] = "urls"; const char policy_app_id[] = "policyAppId"; +const char enabled[] = "enabled"; + } // namespace hmi_response namespace hmi_notification { 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 8859094504..e68723a46e 100644 --- a/src/components/application_manager/include/application_manager/state_controller.h +++ b/src/components/application_manager/include/application_manager/state_controller.h @@ -38,6 +38,7 @@ #include "application_manager/application.h" #include "event_engine/event_observer.h" #include "application_manager/message_helper.h" +#include "interfaces/MOBILE_API.h" namespace application_manager { class ApplicationManagerImpl; @@ -105,6 +106,17 @@ class StateController : public event_engine::EventObserver { SetRegularState<SendActivateApp>(app, hmi_state); } + void SetRegularState(ApplicationSharedPtr app, + const mobile_apis::SystemContext::eType system_context) { + DCHECK_OR_RETURN_VOID(app); + HmiStatePtr prev_regular = app->RegularHmiState(); + DCHECK_OR_RETURN_VOID(prev_regular); + HmiStatePtr hmi_state(new HmiState(app->hmi_level(), + prev_regular->audio_streaming_state(), + system_context)); + SetRegularState<false>(app, hmi_state); + } + // EventObserver interface void on_event(const event_engine::Event& event); @@ -148,11 +160,17 @@ class StateController : public event_engine::EventObserver { void HMIStateStopped(ApplicationSharedPtr app) { DCHECK_OR_RETURN_VOID(app); HmiStatePtr old_hmi_state(new HmiState(*(app->CurrentHmiState()))); + if(app->tts_speak_state()) { + app->set_tts_speak_state(false); + } app->RemoveHMIState(ID); HmiStatePtr new_hmi_state = app->CurrentHmiState(); OnStateChanged(app,old_hmi_state, new_hmi_state); } + mobile_apis::AudioStreamingState::eType + TTSVRCalcAudioSS(mobile_apis::HMILevel::eType level) const; + /** * @brief ProcessApplyingRegularState setup regular hmi state, tha will appear if no * specific events are active, without sending ActivateApp diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 25b841048f..799ce8e868 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -92,11 +92,9 @@ ApplicationImpl::ApplicationImpl(uint32_t application_id, tts_speak_state_(false), tts_properties_in_none_(false), tts_properties_in_full_(false), - hmi_level_(mobile_api::HMILevel::HMI_NONE), put_file_in_none_count_(0), delete_file_in_none_count_(0), list_files_in_none_count_(0), - system_context_(mobile_api::SystemContext::SYSCTXT_MAIN), device_(0), usage_report_(mobile_app_id, statistics_manager), protocol_version_(ProtocolVersion::kV3), @@ -123,7 +121,7 @@ ApplicationImpl::ApplicationImpl(uint32_t application_id, LoadPersistentFiles(); hmi_states_.push_back(new HmiState(mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, - mobile_apis::SystemContext::INVALID_ENUM)); + mobile_api::SystemContext::SYSCTXT_MAIN)); } ApplicationImpl::~ApplicationImpl() { @@ -149,7 +147,7 @@ void ApplicationImpl::CloseActiveMessage() { } bool ApplicationImpl::IsFullscreen() const { - return mobile_api::HMILevel::HMI_FULL == hmi_level_; + return mobile_api::HMILevel::HMI_FULL == hmi_level(); } void ApplicationImpl::ChangeSupportingAppHMIType() { @@ -298,9 +296,14 @@ const uint32_t ApplicationImpl::list_files_in_none_count() const { return list_files_in_none_count_; } -const mobile_api::SystemContext::eType& +const mobile_api::SystemContext::eType ApplicationImpl::system_context() const { - return system_context_; + using namespace mobile_apis; + const HmiStatePtr hmi_state = CurrentHmiState(); + SystemContext::eType system_context; + hmi_state.valid() ? system_context = CurrentHmiState()->system_context() : + system_context = SystemContext::INVALID_ENUM; + return system_context; } const std::string& ApplicationImpl::app_icon_path() const { @@ -356,19 +359,6 @@ bool ApplicationImpl::tts_properties_in_full() { return tts_properties_in_full_; } -//void ApplicationImpl::set_hmi_level( -// const mobile_api::HMILevel::eType& hmi_level) { -// if (mobile_api::HMILevel::HMI_NONE != hmi_level_ && -// mobile_api::HMILevel::HMI_NONE == hmi_level) { -// put_file_in_none_count_ = 0; -// delete_file_in_none_count_ = 0; -// list_files_in_none_count_ = 0; -// } -// LOG4CXX_INFO(logger_, "hmi_level = " << hmi_level); -// hmi_level_ = hmi_level; -// usage_report_.RecordHmiStateChanged(hmi_level); -//} - void ApplicationImpl::set_hmi_supports_navi_video_streaming(bool supports) { hmi_supports_navi_video_streaming_ = supports; @@ -477,11 +467,6 @@ void ApplicationImpl::increment_list_files_in_none_count() { ++list_files_in_none_count_; } -void ApplicationImpl::set_system_context( - const mobile_api::SystemContext::eType& system_context) { - system_context_ = system_context; -} - bool ApplicationImpl::set_app_icon_path(const std::string& path) { if (app_files_.find(path) != app_files_.end()) { app_icon_path_ = path; @@ -506,6 +491,12 @@ void ApplicationImpl::set_grammar_id(uint32_t value) { grammar_id_ = value; } +void ApplicationImpl::reset_data_in_none() { + put_file_in_none_count_ = 0; + delete_file_in_none_count_ = 0; + list_files_in_none_count_ = 0; +} + bool ApplicationImpl::has_been_activated() const { return has_been_activated_; } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 5037a58873..749c19939a 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -488,17 +488,13 @@ bool ApplicationManagerImpl::LoadAppDataToHMI(ApplicationSharedPtr app) { bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { using namespace mobile_api; LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Null-pointer application received."); - NOTREACHED(); - return false; - } + DCHECK_OR_RETURN(app, false); // remove from resumption if app was activated by user resume_controller().OnAppActivated(app); HMILevel::eType hmi_level = HMILevel::HMI_FULL; AudioStreamingState::eType ass; app->IsAudioApplication() ? ass = AudioStreamingState::AUDIBLE : - AudioStreamingState::NOT_AUDIBLE; + ass = AudioStreamingState::NOT_AUDIBLE; state_ctrl_.SetRegularState<false>(app, hmi_level, ass); return true; } 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 5f369d44aa..c70b28589d 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 @@ -101,7 +101,7 @@ void OnAppDeactivatedNotification::Run() { } } } - ApplicationManagerImpl::instance()->SetState<false>(app, new_regular); + ApplicationManagerImpl::instance()->SetState<false>(app->app_id(), new_regular); } diff --git a/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc index 8dbd1e13e4..aa334d8259 100644 --- a/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_system_context_notification.cc @@ -77,8 +77,8 @@ void OnSystemContextNotification::Run() { void OnSystemContextNotification::SendSystemContextNotification(ApplicationSharedPtr app, mobile_api::SystemContext::eType system_context) { - app->set_system_context(system_context); - MessageHelper::SendHMIStatusNotification(*app); + ApplicationManagerImpl::instance()->SetState(app->app_id(), + system_context); } } // namespace commands 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 8ab63ca61e..85994ad80e 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 @@ -48,8 +48,9 @@ OnVRStartedNotification::~OnVRStartedNotification() { void OnVRStartedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl::instance()->set_vr_session_started(true); - //ApplicationManagerImpl::instance()->Mute(kVRSessionChanging); + event_engine::Event event(hmi_apis::FunctionID::VR_Started); + event.set_smart_object(*message_); + event.raise(); } } // 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 02c2c165a1..89bdc18eb3 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 @@ -48,8 +48,9 @@ OnVRStoppedNotification::~OnVRStoppedNotification() { void OnVRStoppedNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl::instance()->set_vr_session_started(false); - //ApplicationManagerImpl::instance()->Unmute(kVRSessionChanging); + event_engine::Event event(hmi_apis::FunctionID::VR_Stopped); + event.set_smart_object(*message_); + event.raise(); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc index 62cf11d76d..54575080cf 100644 --- a/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_event_notification.cc @@ -115,7 +115,7 @@ void OnButtonEventNotification::Run() { //Send ButtonEvent notification for OK button only in HMI_FULL mode if ((static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) && - (mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level())) { + (subscribed_app->IsFullscreen())) { continue; } diff --git a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc index 6db54289eb..8780ab1b6a 100644 --- a/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_touch_event_notification.cc @@ -58,7 +58,7 @@ void OnTouchEventNotification::Run() { std::vector<ApplicationSharedPtr>::const_iterator it = applications.begin(); for (; applications.end() != it; ++it) { ApplicationSharedPtr app = *it; - if (mobile_apis::HMILevel::HMI_FULL == app->hmi_level()) { + if (app->IsFullscreen()) { (*message_)[strings::params][strings::connection_key] = app->app_id(); SendNotification(); } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 4cd5e771f9..87ee4f9304 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -3,30 +3,26 @@ namespace application_manager { -// GAL some thing wrong heres -HmiState::HmiState(HmiStatePtr prev): +HmiState::HmiState(HmiStatePtr prev, StateID state_id): parent_(prev), + state_id_(state_id), hmi_level_(mobile_apis::HMILevel::INVALID_ENUM), audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM), system_context_(mobile_apis::SystemContext::INVALID_ENUM) { - } HmiState::HmiState(): state_id_(STATE_ID_REGULAR), - parent_(NULL), hmi_level_(mobile_apis::HMILevel::INVALID_ENUM), audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM), system_context_(mobile_apis::SystemContext::INVALID_ENUM) { - } HmiState::HmiState(const HmiState& copy_from): state_id_(STATE_ID_REGULAR), - parent_(copy_from.parent()), hmi_level_(copy_from.hmi_level()), + hmi_level_(copy_from.hmi_level()), audio_streaming_state_(copy_from.audio_streaming_state()), system_context_(copy_from.system_context()) { - } HmiState::HmiState(mobile_apis::HMILevel::eType hmi_level, @@ -43,29 +39,21 @@ void HmiState::setParent(HmiStatePtr parent) { } VRHmiState::VRHmiState(HmiStatePtr previous): - HmiState(previous) { + HmiState(previous, STATE_ID_VR_SESSION) { } TTSHmiState::TTSHmiState(HmiStatePtr previous): - HmiState(previous) { - using namespace mobile_apis; - state_id_ = STATE_ID_TTS_SESSION; - if (HMILevel::HMI_NONE != hmi_level() && - HMILevel::HMI_BACKGROUND!= hmi_level()) { - audio_streaming_state_ = AudioStreamingState::ATTENUATED; - } else { - audio_streaming_state_ = previous->audio_streaming_state(); - } + HmiState(previous, STATE_ID_TTS_SESSION) { } PhoneCallHmiState::PhoneCallHmiState(HmiStatePtr previous): - HmiState(previous) { - state_id_ = STATE_ID_PHONE_CALL; + HmiState(previous, STATE_ID_PHONE_CALL) { } SafetyModeHmiState::SafetyModeHmiState(HmiStatePtr previous): - HmiState(previous) { - state_id_ = STATE_ID_SAFETY_MODE; + HmiState(previous, STATE_ID_SAFETY_MODE) { + using namespace mobile_apis; + audio_streaming_state_ = AudioStreamingState::NOT_AUDIBLE; } } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 5316aaec7c..3a8036cbf0 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -868,7 +868,6 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, if (false == permissions.appRevoked && true == permissions.isSDLAllowed) { LOG4CXX_INFO(logger_, "Application will be activated"); if (ApplicationManagerImpl::instance()->ActivateApplication(app)) { - MessageHelper::SendHMIStatusNotification(*(app.get())); last_activated_app_id_ = 0; } } else { diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp index ff4415a164..0b2528ec09 100644 --- a/src/components/application_manager/src/resume_ctrl.cpp +++ b/src/components/application_manager/src/resume_ctrl.cpp @@ -160,12 +160,10 @@ bool ResumeCtrl::RestoreAppHMIState(ApplicationSharedPtr application) { } bool ResumeCtrl::SetupDefaultHMILevel(ApplicationSharedPtr application) { - if (false == application.valid()) { - LOG4CXX_ERROR(logger_, "SetupDefaultHMILevel application pointer is invalid"); - return false; - } - LOG4CXX_TRACE(logger_, "ENTER app_id : " << application->app_id()); - mobile_apis::HMILevel::eType default_hmi = ApplicationManagerImpl::instance()-> GetDefaultHmiLevel(application); + DCHECK_OR_RETURN_VOID(application); + LOG4CXX_AUTO_TRACE(logger_); + mobile_apis::HMILevel::eType default_hmi = + ApplicationManagerImpl::instance()-> GetDefaultHmiLevel(application); bool result = SetAppHMIState(application, default_hmi, false); return result; } @@ -179,9 +177,9 @@ bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application, LOG4CXX_ERROR(logger_, "Application pointer in invalid"); return false; } - LOG4CXX_TRACE(logger_, " ENTER Params : ( " << application->app_id() - << "," << hmi_level - << "," << check_policy << " )"); + LOG4CXX_TRACE(logger_, " app_id : ( " << application->app_id() + << ", hmi_level : " << hmi_level + << ", check_policy : " << check_policy << " )"); const std::string device_id = MessageHelper::GetDeviceMacAddressForHandle(application->device()); diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller.cc index b567aa9cd0..467516e9f5 100644 --- a/src/components/application_manager/src/state_controller.cc +++ b/src/components/application_manager/src/state_controller.cc @@ -76,6 +76,8 @@ void StateController::HmiLevelConflictResolver::operator () using namespace mobile_apis; using namespace helpers; DCHECK_OR_RETURN_VOID(state_ctrl_); + if (to_resolve == applied_) + return; if (Compare<HMILevel::eType, EQ, ONE>(state_->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { @@ -98,7 +100,10 @@ void StateController::SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state) { HmiStatePtr old_state(new HmiState(*(app->CurrentHmiState()))); app->SetRegularState(state); - HmiStatePtr new_state = app->RegularHmiState(); + if (state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { + app->reset_data_in_none(); + } + HmiStatePtr new_state = app->CurrentHmiState(); OnStateChanged(app, old_state, new_state); } @@ -149,7 +154,7 @@ void StateController::on_event(const event_engine::Event& event) { } case FunctionID::BasicCommunication_OnEmergencyEvent: { bool is_active = - message[strings::msg_params][hmi_notification::is_active].asBool(); + message[strings::msg_params][hmi_response::enabled].asBool(); if (is_active) { OnSafetyModeEnabled(); } else { @@ -196,6 +201,9 @@ void StateController::OnStateChanged(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(new_state); if (IsStatusChanged(old_state, new_state)) { MessageHelper::SendHMIStatusNotification(*app); + if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { + app->reset_data_in_none(); + } } else { LOG4CXX_ERROR(logger_, "Status not changed"); } @@ -204,17 +212,69 @@ void StateController::OnStateChanged(ApplicationSharedPtr app, template<> void StateController::HMIStateStarted<PhoneCallHmiState>(ApplicationSharedPtr app) { using namespace mobile_apis; + using namespace helpers; HmiStatePtr old_hmi_state = app->CurrentHmiState(); HmiStatePtr new_hmi_state(new PhoneCallHmiState(old_hmi_state)); - new_hmi_state->set_hmi_level(app->is_navi() ? HMILevel::HMI_LIMITED : - HMILevel::HMI_BACKGROUND); + HMILevel::eType expected_level(HMILevel::HMI_BACKGROUND); + if (old_hmi_state->hmi_level() == HMILevel::HMI_FULL && app->is_navi()) { + expected_level = HMILevel::HMI_LIMITED; + } + + new_hmi_state->set_hmi_level(expected_level); new_hmi_state->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); app->AddHMIState(new_hmi_state); OnStateChanged(app,old_hmi_state, new_hmi_state); } +template<> +void StateController::HMIStateStarted<VRHmiState>(ApplicationSharedPtr app) { + using namespace mobile_apis; + using namespace helpers; + HmiStatePtr old_hmi_state = app->CurrentHmiState(); + HmiStatePtr new_hmi_state(new VRHmiState(old_hmi_state)); + + new_hmi_state->set_audio_streaming_state( + TTSVRCalcAudioSS(old_hmi_state->hmi_level())); + + app->AddHMIState(new_hmi_state); + OnStateChanged(app,old_hmi_state, new_hmi_state); +} + + +template<> +void StateController::HMIStateStarted<TTSHmiState>(ApplicationSharedPtr app) { + using namespace mobile_apis; + using namespace helpers; + HmiStatePtr old_hmi_state = app->CurrentHmiState(); + HmiStatePtr new_hmi_state(new VRHmiState(old_hmi_state)); + + app->set_tts_speak_state(true); + + new_hmi_state->set_audio_streaming_state( + TTSVRCalcAudioSS(old_hmi_state->hmi_level())); + + app->AddHMIState(new_hmi_state); + OnStateChanged(app,old_hmi_state, new_hmi_state); +} + +mobile_apis::AudioStreamingState::eType +StateController::TTSVRCalcAudioSS(mobile_apis::HMILevel::eType level) const { + using namespace helpers; + using namespace mobile_apis; + + const HMICapabilities& hc = ApplicationManagerImpl::instance()->hmi_capabilities(); + if (Compare<HMILevel::eType, NEQ, ALL> (level, + HMILevel::HMI_NONE, + HMILevel::HMI_BACKGROUND)) { + if (hc.attenuated_supported()) { + return AudioStreamingState::ATTENUATED; + } + } + return AudioStreamingState::NOT_AUDIBLE; +} + void StateController::OnActivateAppResponse( const smart_objects::SmartObject& message) { const hmi_apis::Common_Result::eType code = @@ -277,10 +337,20 @@ void StateController::OnSafetyModeDisabled() { void StateController::OnVRStarted() { LOG4CXX_AUTO_TRACE(logger_); + ForEachApplication(std::bind1st( + std::mem_fun( + &StateController::HMIStateStarted<VRHmiState>), + this) + ); } void StateController::OnVREnded() { LOG4CXX_AUTO_TRACE(logger_); + ForEachApplication(std::bind1st( + std::mem_fun( + &StateController::HMIStateStopped<HmiState::STATE_ID_VR_SESSION>), + this) + ); } void StateController::OnTTSStarted() { diff --git a/src/components/hmi_message_handler/src/dbus_message_adapter.cc b/src/components/hmi_message_handler/src/dbus_message_adapter.cc index c08f090f1d..7c540ad0c2 100644 --- a/src/components/hmi_message_handler/src/dbus_message_adapter.cc +++ b/src/components/hmi_message_handler/src/dbus_message_adapter.cc @@ -119,6 +119,7 @@ void DBusMessageAdapter::SubscribeTo() { DBusMessageController::SubscribeTo("BasicCommunication", "OnSystemRequest"); DBusMessageController::SubscribeTo("BasicCommunication", "OnSystemInfoChanged"); DBusMessageController::SubscribeTo("BasicCommunication", "OnPhoneCall"); + DBusMessageController::SubscribeTo("BasicCommunication", "OnEmergencyEvent"); DBusMessageController::SubscribeTo("TTS", "Started"); DBusMessageController::SubscribeTo("TTS", "Stopped"); DBusMessageController::SubscribeTo("TTS", "OnLanguageChange"); diff --git a/src/components/hmi_message_handler/src/messagebroker_adapter.cc b/src/components/hmi_message_handler/src/messagebroker_adapter.cc index d0dd5c09ba..bab934c070 100644 --- a/src/components/hmi_message_handler/src/messagebroker_adapter.cc +++ b/src/components/hmi_message_handler/src/messagebroker_adapter.cc @@ -112,6 +112,7 @@ void MessageBrokerAdapter::SubscribeTo() { MessageBrokerController::subscribeTo("BasicCommunication.OnExitAllApplications"); MessageBrokerController::subscribeTo("BasicCommunication.OnDeviceChosen"); MessageBrokerController::subscribeTo("BasicCommunication.OnPhoneCall"); + MessageBrokerController::subscribeTo("BasicCommunication.OnEmergencyEvent"); MessageBrokerController::subscribeTo("UI.OnLanguageChange"); MessageBrokerController::subscribeTo("VR.OnLanguageChange"); MessageBrokerController::subscribeTo("TTS.OnLanguageChange"); |