From cc681f444642b7ff7cd9a6ff9ed7dfd192fd0f5c Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Mon, 29 Jan 2018 15:22:19 +0200 Subject: Fix A/V streaming starting for PROJECTION apps --- src/components/application_manager/src/application_manager_impl.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 248b54fee5..630815bf1b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4060,6 +4060,8 @@ mobile_apis::AppHMIType::eType ApplicationManagerImpl::StringToAppHMIType( return mobile_apis::AppHMIType::MESSAGING; } else if ("NAVIGATION" == str) { return mobile_apis::AppHMIType::NAVIGATION; + } else if ("PROJECTION" == str) { + return mobile_apis::AppHMIType::PROJECTION; } else if ("INFORMATION" == str) { return mobile_apis::AppHMIType::INFORMATION; } else if ("SOCIAL" == str) { -- cgit v1.2.1 From 9e76a1f8eb86f3851b6cff6379f2ed8531a0e4d6 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Tue, 30 Jan 2018 17:05:27 +0200 Subject: Treat projection app as audio app Add projection app to audio app list as it can stream audio This is done to enable HMI leve switching to LIMITED level. --- src/components/application_manager/src/application_impl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index ac21219d7d..3d3a541508 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -230,7 +230,8 @@ void ApplicationImpl::set_voice_communication_supported( } bool ApplicationImpl::IsAudioApplication() const { - return is_media_ || is_voice_communication_application_ || is_navi_; + return is_media_ || is_voice_communication_application_ || is_navi_ || + mobile_projection_enabled_; } void ApplicationImpl::SetRegularState(HmiStatePtr state) { -- cgit v1.2.1 From 6b43ffcdc661eb97a973c3a028af10076dd5e927 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Fri, 16 Mar 2018 11:18:26 +0200 Subject: Initial implementation --- .../application_manager/src/application_impl.cc | 4 + .../src/application_manager_impl.cc | 11 ++- .../hmi/on_exit_application_notification.cc | 6 +- .../application_manager/src/hmi_state.cc | 14 ++++ .../src/policies/policy_handler.cc | 11 ++- .../application_manager/src/smart_object_keys.cc | 1 + .../src/state_controller_impl.cc | 92 +++++++++++++++++----- 7 files changed, 114 insertions(+), 25 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 3d3a541508..ace7d55860 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -234,6 +234,10 @@ bool ApplicationImpl::IsAudioApplication() const { mobile_projection_enabled_; } +bool ApplicationImpl::IsVideoApplication() const { + return is_navi_ || mobile_projection_enabled_; +} + void ApplicationImpl::SetRegularState(HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); state_.AddState(state); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 630815bf1b..4bf45e2637 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -549,6 +549,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( CreateRegularState(utils::SharedPtr(application), mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, mobile_api::SystemContext::SYSCTXT_MAIN); application->SetInitialState(initial_state); @@ -661,9 +662,12 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { resume_controller().OnAppActivated(app); HMILevel::eType hmi_level = HMILevel::HMI_FULL; AudioStreamingState::eType audio_state; + VideoStreamingState::eType video_state; app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE : audio_state = AudioStreamingState::NOT_AUDIBLE; - state_ctrl_.SetRegularState(app, hmi_level, audio_state, false); + app->IsVideoApplication() ? video_state = VideoStreamingState::STREAMABLE + : video_state = VideoStreamingState::NOT_STREAMABLE; + state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, false); return true; } @@ -840,10 +844,12 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( utils::SharedPtr app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const { HmiStatePtr state(new HmiState(app, *this)); state->set_hmi_level(hmi_level); state->set_audio_streaming_state(audio_state); + state->set_video_streaming_state(video_state); state->set_system_context(system_context); return state; } @@ -3738,6 +3744,9 @@ void ApplicationManagerImpl::SendHMIStatusNotification( message[strings::msg_params][strings::audio_streaming_state] = static_cast(app->audio_streaming_state()); + message[strings::msg_params][strings::video_streaming_state] = + static_cast(app->video_streaming_state()); + message[strings::msg_params][strings::system_context] = static_cast(app->system_context()); 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 efdfaf8f3e..df9dc01eab 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 @@ -105,7 +105,11 @@ void OnExitApplicationNotification::Run() { } application_manager_.state_controller().SetRegularState( - app_impl, HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, false); + app_impl, + HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + false); } } // namespace commands diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index bc1ccd8f42..17cbdb429d 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -45,6 +45,7 @@ HmiState::HmiState(utils::SharedPtr app, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} HmiState::HmiState(utils::SharedPtr app, @@ -54,6 +55,7 @@ HmiState::HmiState(utils::SharedPtr app, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} DEPRECATED HmiState::HmiState(uint32_t app_id, @@ -159,6 +161,18 @@ NaviStreamingHmiState::audio_streaming_state() const { return expected_state; } +mobile_apis::VideoStreamingState::eType +NaviStreamingHmiState::video_streaming_state() const { + using namespace helpers; + using namespace mobile_apis; + + VideoStreamingState::eType expected_state = parent()->video_streaming_state(); + if (!is_navi_app() && VideoStreamingState::STREAMABLE == expected_state) { + expected_state = VideoStreamingState::NOT_STREAMABLE; + } + return expected_state; +} + PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 559b9c0035..77281f5a72 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -162,10 +162,12 @@ struct DeactivateApplication { void operator()(const ApplicationSharedPtr& app) { if (device_id_ == app->device()) { - state_ctrl_.SetRegularState(app, - mobile_apis::HMILevel::HMI_NONE, - mobile_apis::AudioStreamingState::NOT_AUDIBLE, - true); + state_ctrl_.SetRegularState( + app, + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + true); } } @@ -974,6 +976,7 @@ void PolicyHandler::OnPendingPermissionChange( app, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, true); policy_manager_->RemovePendingPermissionChanges(policy_app_id); return; diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index c3aba90dd5..f56fd23c84 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -128,6 +128,7 @@ const char* trigger_source = "triggerSource"; const char* hmi_level = "hmiLevel"; const char* activate_app_hmi_level = "level"; const char* audio_streaming_state = "audioStreamingState"; +const char* video_streaming_state = "videoStreamingState"; const char* system_context = "systemContext"; const char* speech_capabilities = "speechCapabilities"; const char* vr_capabilities = "vrCapabilities"; diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 84081a3830..073c36aa51 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -41,10 +41,15 @@ namespace application_manager { CREATE_LOGGERPTR_GLOBAL(logger_, "StateControllerImpl") bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) { - if (old_state->hmi_level() != new_state->hmi_level() || - old_state->audio_streaming_state() != - new_state->audio_streaming_state() || - old_state->system_context() != new_state->system_context()) { + bool level_changed = old_state->hmi_level() != new_state->hmi_level(); + bool audio_streaming_state_changed = + old_state->audio_streaming_state() != new_state->audio_streaming_state(); + bool video_streaming_state_changed = + old_state->video_streaming_state() != new_state->video_streaming_state(); + bool system_context_changed = + old_state->system_context() != new_state->system_context(); + if (level_changed || audio_streaming_state_changed || + video_streaming_state_changed || system_context_changed) { return true; } return false; @@ -76,6 +81,8 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || state->audio_streaming_state() == mobile_apis::AudioStreamingState::INVALID_ENUM || + state->video_streaming_state() == + mobile_apis::VideoStreamingState::INVALID_ENUM || state->system_context() == mobile_apis::SystemContext::INVALID_ENUM) { LOG4CXX_ERROR(logger_, "Get invalid state"); return; @@ -113,6 +120,7 @@ void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const bool send_activate_app) { CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); @@ -127,6 +135,7 @@ void StateControllerImpl::SetRegularState( DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_regular->system_context()); SetRegularState(app, hmi_state, send_activate_app); } @@ -149,6 +158,7 @@ void StateControllerImpl::SetRegularState( 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_video_streaming_state(CalcVideoState(app, hmi_level)); hmi_state->set_system_context(SystemContext::SYSCTXT_MAIN); SetRegularState(app, hmi_state, send_activate_app); } @@ -157,6 +167,7 @@ void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, const bool send_activate_app) { CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); @@ -170,6 +181,7 @@ void StateControllerImpl::SetRegularState( DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(system_context); SetRegularState(app, hmi_state, send_activate_app); } @@ -188,6 +200,7 @@ void StateControllerImpl::SetRegularState( 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_video_streaming_state(CalcVideoState(app, hmi_level)); hmi_state->set_system_context(prev_state ? prev_state->system_context() : mobile_apis::SystemContext::SYSCTXT_MAIN); @@ -211,13 +224,16 @@ void StateControllerImpl::SetRegularState( hmi_state->set_hmi_level(prev_regular->hmi_level()); hmi_state->set_audio_streaming_state( CalcAudioState(app, prev_regular->hmi_level())); + hmi_state->set_video_streaming_state( + CalcVideoState(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) { + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state) { CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); if (!app) { @@ -231,6 +247,7 @@ void StateControllerImpl::SetRegularState( 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_video_streaming_state(video_state); hmi_state->set_system_context(prev_state->system_context()); SetRegularState(app, hmi_state, false); } @@ -301,11 +318,17 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( "Application " << to_resolve->app_id() << " will change HMI level to " << result_hmi_level); - state_ctrl_->SetupRegularHmiState(to_resolve, - result_hmi_level, - result_hmi_level == HMILevel::HMI_LIMITED - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE); + VideoStreamingState::eType video_state = + result_hmi_level == HMILevel::HMI_LIMITED + ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; + AudioStreamingState::eType audio_state = + result_hmi_level == HMILevel::HMI_LIMITED + ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + + state_ctrl_->SetupRegularHmiState( + to_resolve, result_hmi_level, audio_state, video_state); } else { LOG4CXX_DEBUG(logger_, "Application " << to_resolve->app_id() @@ -321,6 +344,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, LOG4CXX_DEBUG(logger_, "State to resolve: hmi_level " << state->hmi_level() << ", audio_state " + << state->video_streaming_state() << ", video_state " << state->audio_streaming_state() << ", system_context " << state->system_context()); @@ -329,6 +353,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, DCHECK_OR_RETURN(available_state, HmiStatePtr()); available_state->set_hmi_level(state->hmi_level()); available_state->set_audio_streaming_state(state->audio_streaming_state()); + available_state->set_video_streaming_state(state->video_streaming_state()); available_state->set_system_context(state->system_context()); if (app->is_resuming()) { @@ -337,6 +362,8 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, available_state->set_hmi_level(available_level); available_state->set_audio_streaming_state( CalcAudioState(app, available_level)); + available_state->set_video_streaming_state( + CalcVideoState(app, available_level)); } return IsStateAvailable(app, available_state) ? available_state : HmiStatePtr(); @@ -506,6 +533,7 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(old_state); old_state->set_hmi_level(curr_state->hmi_level()); old_state->set_audio_streaming_state(curr_state->audio_streaming_state()); + old_state->set_video_streaming_state(curr_state->video_streaming_state()); old_state->set_system_context(curr_state->system_context()); app->SetRegularState(state); @@ -524,7 +552,8 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, void StateControllerImpl::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::VideoStreamingState::eType video_state) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; using helpers::Compare; @@ -537,6 +566,7 @@ void StateControllerImpl::SetupRegularHmiState( DCHECK_OR_RETURN_VOID(new_state); new_state->set_hmi_level(hmi_level); new_state->set_audio_streaming_state(audio_state); + new_state->set_video_streaming_state(video_state); new_state->set_system_context(prev_state->system_context()); SetupRegularHmiState(app, new_state); } @@ -675,15 +705,17 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(old_state); DCHECK_OR_RETURN_VOID(new_state); LOG4CXX_DEBUG(logger_, - "old: hmi_level " << old_state->hmi_level() << ", audio_state " - << old_state->audio_streaming_state() - << ", system_context " - << old_state->system_context()); + "old: hmi_level " + << old_state->hmi_level() << ", audio_state " + << old_state->audio_streaming_state() << ", video_state " + << old_state->video_streaming_state() << ", system_context " + << old_state->system_context()); LOG4CXX_DEBUG(logger_, - "new: hmi_level " << new_state->hmi_level() << ", audio_state " - << new_state->audio_streaming_state() - << ", system_context " - << new_state->system_context()); + "new: hmi_level " + << new_state->hmi_level() << ", audio_state " + << new_state->audio_streaming_state() << ", video_state " + << old_state->video_streaming_state() << ", system_context " + << new_state->system_context()); if (IsStatusChanged(old_state, new_state)) { app_mngr_.SendHMIStatusNotification(app); if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { @@ -730,6 +762,7 @@ void StateControllerImpl::OnApplicationRegistered( DCHECK_OR_RETURN_VOID(default_state); default_state->set_hmi_level(default_level); default_state->set_audio_streaming_state(CalcAudioState(app, default_level)); + default_state->set_video_streaming_state(CalcVideoState(app, default_level)); default_state->set_system_context(SystemContext::SYSCTXT_MAIN); HmiStatePtr initial_state = app->RegularHmiState(); @@ -812,9 +845,11 @@ void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { if (app->IsAudioApplication()) { new_regular->set_hmi_level(HMILevel::HMI_LIMITED); new_regular->set_audio_streaming_state(AudioStreamingState::AUDIBLE); + new_regular->set_video_streaming_state(VideoStreamingState::STREAMABLE); } else { new_regular->set_hmi_level(HMILevel::HMI_BACKGROUND); new_regular->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); + new_regular->set_video_streaming_state(VideoStreamingState::NOT_STREAMABLE); } SetRegularState(app, new_regular, false); @@ -968,4 +1003,23 @@ mobile_apis::AudioStreamingState::eType StateControllerImpl::CalcAudioState( return audio_state; } +mobile_apis::VideoStreamingState::eType StateControllerImpl::CalcVideoState( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) const { + namespace HMILevel = mobile_apis::HMILevel; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; + using helpers::Compare; + using helpers::EQ; + using helpers::ONE; + + VideoStreamingState::eType video_state = VideoStreamingState::NOT_STREAMABLE; + if (Compare( + hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (app->IsVideoApplication()) { + video_state = VideoStreamingState::STREAMABLE; + } + } + return video_state; +} + } // namespace application_manager -- cgit v1.2.1 From b9f4fc26364c2c5de9df5754b711fcd2392c69b6 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Mon, 19 Mar 2018 13:24:56 +0200 Subject: Remove unused code --- src/components/application_manager/src/application_manager_impl.cc | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4bf45e2637..822807a5ae 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -866,12 +866,6 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( return state; } -bool ApplicationManagerImpl::IsStateActive(HmiState::StateID state_id) const { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Checking for active state id " << state_id); - return state_ctrl_.IsStateActive(state_id); -} - void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key, int32_t correlation_id, int32_t max_duration, -- cgit v1.2.1 From 859f1401b9915a29ed1973bd2efe2c1ee35ef9df Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 19:13:30 +0300 Subject: Guarantee mutex release in StateControllerImpl::OnApplicationRegistered method --- .../src/state_controller_impl.cc | 39 ++++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 073c36aa51..321de77d8d 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -745,17 +745,18 @@ void StateControllerImpl::OnApplicationRegistered( LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - active_states_lock_.Acquire(); - StateIDList::iterator it = active_states_.begin(); - for (; it != active_states_.end(); ++it) { - HmiStatePtr new_state = CreateHmiState(app, *it); - DCHECK_OR_RETURN_VOID(new_state); - DCHECK_OR_RETURN_VOID(new_state->state_id() != HmiState::STATE_ID_REGULAR); - HmiStatePtr old_hmi_state = app->CurrentHmiState(); - new_state->set_parent(old_hmi_state); - app->AddHMIState(new_state); + { + sync_primitives::AutoLock lck(active_states_lock_); + for (const auto state_id : active_states_) { + HmiStatePtr new_state = CreateHmiState(app, state_id); + DCHECK_OR_RETURN_VOID(new_state); + DCHECK_OR_RETURN_VOID(new_state->state_id() != + HmiState::STATE_ID_REGULAR); + HmiStatePtr old_hmi_state = app->CurrentHmiState(); + new_state->set_parent(old_hmi_state); + app->AddHMIState(new_state); + } } - active_states_lock_.Release(); HmiStatePtr default_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -811,16 +812,18 @@ void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { } } -void StateControllerImpl::TempStateStarted(HmiState::StateID ID) { +void StateControllerImpl::TempStateStarted(HmiState::StateID id) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock autolock(active_states_lock_); - StateIDList::iterator it = - std::find(active_states_.begin(), active_states_.end(), ID); - if (it == active_states_.end()) { - active_states_.push_back(ID); - } else { - LOG4CXX_ERROR(logger_, "StateID " << ID << " is already active"); + + { + sync_primitives::AutoLock autolock(active_states_lock_); + if (!helpers::in_range(active_states_, id)) { + active_states_.push_back(id); + return; + } } + + LOG4CXX_ERROR(logger_, "StateID '" << id << "' is already active"); } void StateControllerImpl::TempStateStopped(HmiState::StateID ID) { -- cgit v1.2.1 From 594be81b947e6554171b43df6e3e5075a39f5bc2 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 22:14:41 +0300 Subject: Fix HMI state resolver according to requirments of 'Mobile Projection Phase 2' --- .../application_manager/src/application_impl.cc | 20 +- .../application_manager/src/hmi_state.cc | 95 +++-- .../src/state_controller_impl.cc | 403 ++++++++++++--------- 3 files changed, 314 insertions(+), 204 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index ace7d55860..8fb88ad5ff 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -230,12 +230,26 @@ void ApplicationImpl::set_voice_communication_supported( } bool ApplicationImpl::IsAudioApplication() const { - return is_media_ || is_voice_communication_application_ || is_navi_ || - mobile_projection_enabled_; + const bool is_audio_app = + is_media_application() || is_voice_communication_supported() || is_navi(); + LOG4CXX_DEBUG(logger_, + std::boolalpha << "is audio app --> ((is_media_app: " + << is_media_application() << ")" + << " || (is_voice_communication_app: " + << is_voice_communication_supported() << ")" + << " || (is_navi: " << is_navi() << ")) --> " + << is_audio_app); + return is_audio_app; } bool ApplicationImpl::IsVideoApplication() const { - return is_navi_ || mobile_projection_enabled_; + const bool is_video_app = is_navi() || mobile_projection_enabled(); + LOG4CXX_DEBUG(logger_, + std::boolalpha + << "is video app --> ((is_navi: " << is_navi() << ")" + << " || (mobile_projection: " << mobile_projection_enabled() + << ")) --> " << is_video_app); + return is_video_app; } void ApplicationImpl::SetRegularState(HmiStatePtr state) { diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 17cbdb429d..14cee28f91 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -32,6 +32,9 @@ */ #include "application_manager/hmi_state.h" +#include +#include +#include #include "application_manager/application_manager.h" #include "utils/helpers.h" @@ -65,6 +68,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); } @@ -75,6 +79,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); } @@ -134,43 +139,46 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { expected_state = AudioStreamingState::ATTENUATED; } + return expected_state; } -NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr app, - const ApplicationManager& app_mngr) - : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {} +VideoStreamingHmiState::VideoStreamingHmiState( + utils::SharedPtr app, const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_VIDEO_STREAMING) {} -DEPRECATED NaviStreamingHmiState::NaviStreamingHmiState( +DEPRECATED VideoStreamingHmiState::VideoStreamingHmiState( uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} + : HmiState(app_id, app_mngr, STATE_ID_VIDEO_STREAMING) {} mobile_apis::AudioStreamingState::eType -NaviStreamingHmiState::audio_streaming_state() const { +VideoStreamingHmiState::audio_streaming_state() const { using namespace helpers; using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (!is_navi_app() && AudioStreamingState::AUDIBLE == expected_state) { + if (!app_->IsVideoApplication() && + Compare( + expected_state, + AudioStreamingState::AUDIBLE, + AudioStreamingState::ATTENUATED)) { if (app_mngr_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; } else { expected_state = AudioStreamingState::NOT_AUDIBLE; } } + return expected_state; } mobile_apis::VideoStreamingState::eType -NaviStreamingHmiState::video_streaming_state() const { - using namespace helpers; - using namespace mobile_apis; - - VideoStreamingState::eType expected_state = parent()->video_streaming_state(); - if (!is_navi_app() && VideoStreamingState::STREAMABLE == expected_state) { - expected_state = VideoStreamingState::NOT_STREAMABLE; +VideoStreamingHmiState::video_streaming_state() const { + if (app_->IsVideoApplication()) { + return parent()->video_streaming_state(); } - return expected_state; + + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; } PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, @@ -222,6 +230,7 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -234,20 +243,13 @@ DEPRECATED AudioSource::AudioSource(uint32_t app_id, : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} mobile_apis::HMILevel::eType AudioSource::hmi_level() const { - using namespace mobile_apis; - using namespace helpers; - // TODO(AOleynik): That NONE check is necessary to avoid issue during + // Checking for NONE is necessary to avoid issue during // calculation of HMI level during setting default HMI level - // Should be investigated (used in multiple places here), since looks weird - if (Compare(parent()->hmi_level(), - HMILevel::HMI_BACKGROUND, - HMILevel::HMI_NONE)) { - return parent()->hmi_level(); - } - if (is_navi_app() || is_voice_communication_app()) { - return HMILevel::HMI_LIMITED; + if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { + return mobile_apis::HMILevel::HMI_NONE; } - return HMILevel::HMI_BACKGROUND; + + return mobile_apis::HMILevel::HMI_BACKGROUND; } EmbeddedNavi::EmbeddedNavi(utils::SharedPtr app, @@ -271,4 +273,43 @@ mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { } return HMILevel::HMI_BACKGROUND; } + +namespace { +typedef boost::bimap StateID2StrMap; +const StateID2StrMap kStateID2StrMap = + boost::assign::list_of( + HmiState::StateID::STATE_ID_CURRENT, "CURRENT")( + HmiState::StateID::STATE_ID_REGULAR, "REGULAR")( + HmiState::StateID::STATE_ID_POSTPONED, "POSTPONED")( + HmiState::StateID::STATE_ID_PHONE_CALL, "PHONE_CALL")( + HmiState::StateID::STATE_ID_SAFETY_MODE, "SAFETY_MODE")( + HmiState::StateID::STATE_ID_VR_SESSION, "VR_SESSION")( + HmiState::StateID::STATE_ID_TTS_SESSION, "TTS_SESSION")( + HmiState::StateID::STATE_ID_VIDEO_STREAMING, "VIDEO_STREAMING")( + HmiState::StateID::STATE_ID_DEACTIVATE_HMI, "DEACTIVATE_HMI")( + HmiState::StateID::STATE_ID_AUDIO_SOURCE, "AUDIO_SOURCE")( + HmiState::StateID::STATE_ID_EMBEDDED_NAVI, "EMBEDDED_NAVI"); +} // anonymous namespace + +std::ostream& operator<<(std::ostream& os, const HmiState::StateID src) { + try { + os << kStateID2StrMap.left.at(src); + } catch (const std::exception&) { + // specified element have NOT been found + os << "UNRECOGNIZED(" << static_cast(src) << ")"; + } + + return os; +} + +std::ostream& operator<<(std::ostream& os, const HmiState& src) { + os << "HMIState(app id:" << src.app_->app_id() << ", state:" << src.state_id() + << ", hmi_level:" << src.hmi_level() + << ", audio:" << src.audio_streaming_state() + << ", video:" << src.video_streaming_state() + << ", context:" << src.system_context() << ')'; + + return os; } + +} // namespace application_manager diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 321de77d8d..9ca8680d09 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -31,6 +31,7 @@ */ #include "application_manager/state_controller_impl.h" +#include #include "application_manager/usage_statistics.h" #include "utils/helpers.h" #include "utils/make_shared.h" @@ -40,20 +41,18 @@ namespace application_manager { CREATE_LOGGERPTR_GLOBAL(logger_, "StateControllerImpl") -bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) { - bool level_changed = old_state->hmi_level() != new_state->hmi_level(); - bool audio_streaming_state_changed = - old_state->audio_streaming_state() != new_state->audio_streaming_state(); - bool video_streaming_state_changed = - old_state->video_streaming_state() != new_state->video_streaming_state(); - bool system_context_changed = - old_state->system_context() != new_state->system_context(); - if (level_changed || audio_streaming_state_changed || - video_streaming_state_changed || system_context_changed) { - return true; - } - return false; +namespace { +bool IsStateChanged(const HmiState& old_state, const HmiState& new_state) { + return std::make_tuple(old_state.hmi_level(), + old_state.audio_streaming_state(), + old_state.video_streaming_state(), + old_state.system_context()) != + std::make_tuple(new_state.hmi_level(), + new_state.audio_streaming_state(), + new_state.video_streaming_state(), + new_state.system_context()); } +} // unnamed namespace StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) : EventObserver(app_mngr.event_dispatcher()), app_mngr_(app_mngr) { @@ -107,7 +106,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, if (-1 != corr_id) { subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, corr_id); - waiting_for_activate[app->app_id()] = resolved_state; + waiting_for_activate_[app->app_id()] = resolved_state; return; } LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); @@ -268,85 +267,177 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, } } -void StateControllerImpl::HmiLevelConflictResolver::operator()( - ApplicationSharedPtr to_resolve) { - using namespace mobile_apis; +namespace { + +/** + * @brief IsStreamableHMILevel checks whether the HMI level + * supports audio/video streaming. + * @param val HMI level + * @return true if streamable, false otherwise + */ +bool IsStreamableHMILevel(mobile_apis::HMILevel::eType val) { using namespace helpers; + return Compare( + val, mobile_apis::HMILevel::HMI_FULL, mobile_apis::HMILevel::HMI_LIMITED); +} + +/** + * @brief IsSameAudioAppType checks whether the both applications: + * 1) belongs to exact HMI type that may stream audio without + * 'isMediaApplication' parameter set to true ('NAVIGATION', 'COMMUNICATION') + * 2) belongs to other HMI types with parameter 'isMediaApplication' + * is set to true. + * 3) are not media. + * @param app1 1st application + * @param app2 2nd application + * @return true if audio applications have same application HMI type + */ +bool IsSameAudioAppType(const Application& app1, const Application& app2) { + const auto is_only_media_app_type = [](const Application& app) { + return app.is_media_application() && !app.is_navi() && + !app.is_voice_communication_supported(); + }; + + const bool both_navi = app1.is_navi() && app2.is_navi(); + const bool both_vc = app1.is_voice_communication_supported() && + app2.is_voice_communication_supported(); + const bool both_media = + is_only_media_app_type(app1) && is_only_media_app_type(app2); + const bool both_other = + !app1.IsAudioApplication() && !app2.IsAudioApplication(); + const bool same_app_audio_type = + both_navi || both_vc || both_media || both_other; + + return same_app_audio_type; +} +} // unnamed namespace + +void StateControllerImpl::HmiLevelConflictResolver::operator()( + ApplicationSharedPtr app_to_resolve) { + DCHECK_OR_RETURN_VOID(app_to_resolve); DCHECK_OR_RETURN_VOID(state_ctrl_); - if (to_resolve == applied_) + DCHECK_OR_RETURN_VOID(applied_); + DCHECK_OR_RETURN_VOID(state_); + + if (applied_ == app_to_resolve) { + // Same app. Nothing to resolve return; - HmiStatePtr cur_state = to_resolve->RegularHmiState(); - - const bool applied_grabs_audio = - Compare( - state_->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED) && - applied_->IsAudioApplication(); - const bool applied_grabs_full = state_->hmi_level() == HMILevel::HMI_FULL; - const bool to_resolve_handles_full = - cur_state->hmi_level() == HMILevel::HMI_FULL; - const bool to_resolve_handles_audio = - Compare( - cur_state->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED) && - to_resolve->IsAudioApplication(); - const bool same_app_type = state_ctrl_->IsSameAppType(applied_, to_resolve); - - // If applied Hmi state is FULL: - // all not audio applications will get BACKGROUND - // all applications with same HMI type will get BACKGROUND - // all audio applications with other HMI type(navi, vc, media) in FULL will - // get LIMMITED HMI level - - // If applied Hmi state is LIMITED: - // all applications with other HMI types will save HMI states - // all not audio applications will save HMI states - // all applications with same HMI type will get BACKGROUND - - // If applied Hmi state is BACKGROUND: - // all applications will save HMI states - - HMILevel::eType result_hmi_level = cur_state->hmi_level(); - if (applied_grabs_full && to_resolve_handles_audio && !same_app_type) - result_hmi_level = HMILevel::HMI_LIMITED; - - if ((applied_grabs_full && to_resolve_handles_full && - !to_resolve->IsAudioApplication()) || - (applied_grabs_audio && to_resolve_handles_audio && same_app_type)) - result_hmi_level = HMILevel::HMI_BACKGROUND; - - if (cur_state->hmi_level() != result_hmi_level) { + } + + const HmiStatePtr state_to_resolve = app_to_resolve->RegularHmiState(); + DCHECK_OR_RETURN_VOID(state_to_resolve); + + // If applied HMI state is FULL: + // - all NOT audio/video applications becomes BACKGROUND + // - all audio/video applications with other app type + // (navi, vc, media, projection) in FULL becomes LIMMITED + // - all audio/video applications with same app type becomes BACKGROUND + // + // If applied HMI state is LIMITED: + // - all NOT audio/video applications saves their's HMI states + // - all applications with other app types saves their's HMI states + // - all audio/video applications with same app type becomes BACKGROUND + + if (!IsStreamableHMILevel(state_->hmi_level())) { + LOG4CXX_DEBUG(logger_, + "Applied for app " << applied_->app_id() << " HMI level " + << state_->hmi_level() + << " is NOT streamable. Exit."); + return; + } + + if (!IsStreamableHMILevel(state_to_resolve->hmi_level())) { + LOG4CXX_DEBUG(logger_, + "To resolve app " << app_to_resolve->app_id() << " HMI level " + << state_to_resolve->hmi_level() + << " is NOT streamable. Exit."); + return; + } + + // Applied app constants + const auto applied_hmi_level = state_->hmi_level(); + + const bool applied_grabs_video = + IsStreamableHMILevel(applied_hmi_level) && applied_->IsVideoApplication(); + + // App to resolve constants + const auto to_resolve_hmi_level = state_to_resolve->hmi_level(); + + const bool to_resolve_grabs_audio = + IsStreamableHMILevel(to_resolve_hmi_level) && + app_to_resolve->IsAudioApplication(); + + const bool to_resolve_grabs_video = + IsStreamableHMILevel(to_resolve_hmi_level) && + app_to_resolve->IsVideoApplication(); + + // Compatibility constants + const bool same_app_audio_type = + IsSameAudioAppType(*applied_, *app_to_resolve); + + // Result variables + mobile_apis::VideoStreamingState::eType result_video_state = + mobile_apis::VideoStreamingState::NOT_STREAMABLE; + mobile_apis::AudioStreamingState::eType result_audio_state = + mobile_apis::AudioStreamingState::NOT_AUDIBLE; + + if (to_resolve_grabs_audio && !same_app_audio_type) { + result_audio_state = mobile_apis::AudioStreamingState::AUDIBLE; + } + + if (to_resolve_grabs_video && !applied_grabs_video) { + result_video_state = mobile_apis::VideoStreamingState::STREAMABLE; + } + + mobile_apis::HMILevel::eType result_hmi_level = state_to_resolve->hmi_level(); + + if (mobile_apis::HMILevel::HMI_FULL == applied_hmi_level) { + using namespace helpers; + if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || + Compare( + result_audio_state, + mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::AudioStreamingState::ATTENUATED)) { + result_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; + } else { + result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; + } + } else if (mobile_apis::HMILevel::HMI_LIMITED == applied_hmi_level) { + if (to_resolve_hmi_level == applied_hmi_level) { + result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; + } + } + + if (std::make_tuple(to_resolve_hmi_level, + state_to_resolve->audio_streaming_state(), + state_to_resolve->video_streaming_state()) != + std::make_tuple( + result_hmi_level, result_audio_state, result_video_state)) { LOG4CXX_DEBUG(logger_, - "Application " << to_resolve->app_id() - << " will change HMI level to " - << result_hmi_level); - VideoStreamingState::eType video_state = - result_hmi_level == HMILevel::HMI_LIMITED - ? VideoStreamingState::STREAMABLE - : VideoStreamingState::NOT_STREAMABLE; - AudioStreamingState::eType audio_state = - result_hmi_level == HMILevel::HMI_LIMITED - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE; - - state_ctrl_->SetupRegularHmiState( - to_resolve, result_hmi_level, audio_state, video_state); + "Application " + << app_to_resolve->app_id() << " will change state to: " + << "HMI level " << to_resolve_hmi_level << " --> " + << result_hmi_level << ", audio " + << state_to_resolve->audio_streaming_state() << " --> " + << result_audio_state << ", video " + << state_to_resolve->video_streaming_state() << " --> " + << result_video_state); + state_ctrl_->SetupRegularHmiState(app_to_resolve, + result_hmi_level, + result_audio_state, + result_video_state); } else { LOG4CXX_DEBUG(logger_, - "Application " << to_resolve->app_id() - << " will not change HMI level"); + "Application " << app_to_resolve->app_id() + << " will NOT change HMI level"); } } HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, HmiStatePtr state) const { using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "State to resolve: hmi_level " - << state->hmi_level() << ", audio_state " - << state->video_streaming_state() << ", video_state " - << state->audio_streaming_state() << ", system_context " - << state->system_context()); + LOG4CXX_DEBUG(logger_, "State to resolve: " << *state); HmiStatePtr available_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -372,11 +463,8 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, bool StateControllerImpl::IsResumptionAllowed(ApplicationSharedPtr app, HmiStatePtr state) const { LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; using namespace mobile_apis; - if (!app->is_resuming() || - !Compare( - state->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (!app->is_resuming() || !IsStreamableHMILevel(state->hmi_level())) { LOG4CXX_DEBUG(logger_, "Application is not in resuming mode."); return true; } @@ -402,20 +490,17 @@ bool StateControllerImpl::IsResumptionAllowed(ApplicationSharedPtr app, mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( ApplicationSharedPtr app, mobile_apis::HMILevel::eType hmi_level) const { - using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); mobile_apis::HMILevel::eType result = hmi_level; - if (!Compare( - hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (!IsStreamableHMILevel(hmi_level)) { return result; } const bool is_audio_app = app->IsAudioApplication(); const bool does_audio_app_with_same_type_exist = app_mngr_.IsAppTypeExistsInFullOrLimited(app); - if (HMILevel::HMI_LIMITED == hmi_level) { + if (mobile_apis::HMILevel::HMI_LIMITED == hmi_level) { if (!is_audio_app || does_audio_app_with_same_type_exist) { result = app_mngr_.GetDefaultHmiLevel(app); } @@ -451,13 +536,8 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( 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()); + LOG4CXX_DEBUG(logger_, "Checking state: " << *state); if (app->is_resuming()) { return IsStateAvailableForResumption(app, state); @@ -481,11 +561,8 @@ bool StateControllerImpl::IsStateAvailableForResumption( ApplicationSharedPtr app, HmiStatePtr state) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - using namespace helpers; - if (!app->is_resuming() || - !Compare( - state->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (!app->is_resuming() || !IsStreamableHMILevel(state->hmi_level())) { LOG4CXX_DEBUG(logger_, "Application is not in resuming mode." << " Requested state is available"); @@ -519,14 +596,10 @@ bool StateControllerImpl::IsStateAvailableForResumption( void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state) { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; + using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - LOG4CXX_DEBUG(logger_, - "hmi_level " << state->hmi_level() << ", audio_state " - << state->audio_streaming_state() - << ", system_context " << state->system_context()); + LOG4CXX_DEBUG(logger_, "Setup regular state: " << *state); HmiStatePtr curr_state = app->CurrentHmiState(); HmiStatePtr old_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -577,28 +650,12 @@ void StateControllerImpl::ApplyRegularState(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); + LOG4CXX_DEBUG(logger_, + "Applying to app " << app->app_id() << " state " << *state); SetupRegularHmiState(app, state); - ForEachApplication( - HmiLevelConflictResolver(app, state, this)); -} - -bool StateControllerImpl::IsSameAppType(ApplicationConstSharedPtr app1, - ApplicationConstSharedPtr app2) { - const bool both_media = - app1->is_media_application() && app2->is_media_application(); - - const bool both_navi = app1->is_navi() && app2->is_navi(); - - const bool both_vc = app1->is_voice_communication_supported() && - app2->is_voice_communication_supported(); - - const bool both_simple = - !app1->IsAudioApplication() && !app2->IsAudioApplication(); - - const bool both_projection = - app1->mobile_projection_enabled() && app2->mobile_projection_enabled(); - - return both_simple || both_media || both_navi || both_vc || both_projection; + LOG4CXX_DEBUG(logger_, + "Resolving HMI level conflicts for app " << app->app_id()); + ForEachApplication(HmiLevelConflictResolver(app, state, this)); } void StateControllerImpl::on_event(const event_engine::Event& event) { @@ -704,19 +761,9 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(old_state); DCHECK_OR_RETURN_VOID(new_state); - LOG4CXX_DEBUG(logger_, - "old: hmi_level " - << old_state->hmi_level() << ", audio_state " - << old_state->audio_streaming_state() << ", video_state " - << old_state->video_streaming_state() << ", system_context " - << old_state->system_context()); - LOG4CXX_DEBUG(logger_, - "new: hmi_level " - << new_state->hmi_level() << ", audio_state " - << new_state->audio_streaming_state() << ", video_state " - << old_state->video_streaming_state() << ", system_context " - << new_state->system_context()); - if (IsStatusChanged(old_state, new_state)) { + LOG4CXX_DEBUG(logger_, "Old state: " << *old_state); + LOG4CXX_DEBUG(logger_, "New state: " << *new_state); + if (IsStateChanged(*old_state, *new_state)) { app_mngr_.SendHMIStatusNotification(app); if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { app->ResetDataInNone(); @@ -841,14 +888,30 @@ void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr regular = app->RegularHmiState(); + const HmiStatePtr regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(regular); HmiStatePtr new_regular = utils::MakeShared(*regular); - if (app->IsAudioApplication()) { + LOG4CXX_DEBUG(logger_, "Current HMI level: '" << app->hmi_level() << "'"); + const bool is_audio_app = app->IsAudioApplication(); + const bool is_video_app = app->IsVideoApplication(); + + if (is_audio_app || is_video_app) { + // audio or video app move to HMI level limited new_regular->set_hmi_level(HMILevel::HMI_LIMITED); - new_regular->set_audio_streaming_state(AudioStreamingState::AUDIBLE); - new_regular->set_video_streaming_state(VideoStreamingState::STREAMABLE); + + if (is_audio_app) { + new_regular->set_audio_streaming_state(AudioStreamingState::AUDIBLE); + } else { + new_regular->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); + } + + if (is_video_app) { + new_regular->set_video_streaming_state(VideoStreamingState::STREAMABLE); + } else { + new_regular->set_video_streaming_state( + VideoStreamingState::NOT_STREAMABLE); + } } else { new_regular->set_hmi_level(HMILevel::HMI_BACKGROUND); new_regular->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); @@ -869,7 +932,7 @@ void StateControllerImpl::OnActivateAppResponse( ApplicationSharedPtr application = app_mngr_.application_by_hmi_app(hmi_app_id); if (application && hmi_apis::Common_Result::SUCCESS == code) { - HmiStatePtr pending_state = waiting_for_activate[application->app_id()]; + HmiStatePtr pending_state = waiting_for_activate_[application->app_id()]; DCHECK_OR_RETURN_VOID(pending_state); ApplyRegularState(application, pending_state); } @@ -914,11 +977,11 @@ void StateControllerImpl::OnAppDeactivated( } void StateControllerImpl::OnNaviStreamingStarted() { - ApplyTempState(); + ApplyTempState(); } void StateControllerImpl::OnNaviStreamingStopped() { - CancelTempState(); + CancelTempState(); } bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { @@ -955,8 +1018,8 @@ HmiStatePtr StateControllerImpl::CreateHmiState( new_state = MakeShared(app, app_mngr_); break; } - case HmiState::STATE_ID_NAVI_STREAMING: { - new_state = MakeShared(app, app_mngr_); + case HmiState::STATE_ID_VIDEO_STREAMING: { + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_REGULAR: { @@ -990,39 +1053,31 @@ HmiStatePtr StateControllerImpl::CreateHmiState( mobile_apis::AudioStreamingState::eType StateControllerImpl::CalcAudioState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) const { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; - using helpers::Compare; - using helpers::EQ; - using helpers::ONE; - - AudioStreamingState::eType audio_state = AudioStreamingState::NOT_AUDIBLE; - if (Compare( - hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { - if (app->IsAudioApplication()) { - audio_state = AudioStreamingState::AUDIBLE; - } + auto state = mobile_apis::AudioStreamingState::NOT_AUDIBLE; + if (IsStreamableHMILevel(hmi_level) && app->IsAudioApplication()) { + state = mobile_apis::AudioStreamingState::AUDIBLE; } - return audio_state; + + LOG4CXX_DEBUG(logger_, + "Calculated audio state of app " + << app->app_id() << " for " << hmi_level << " HMI level is " + << state); + return state; } mobile_apis::VideoStreamingState::eType StateControllerImpl::CalcVideoState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) const { - namespace HMILevel = mobile_apis::HMILevel; - namespace VideoStreamingState = mobile_apis::VideoStreamingState; - using helpers::Compare; - using helpers::EQ; - using helpers::ONE; - - VideoStreamingState::eType video_state = VideoStreamingState::NOT_STREAMABLE; - if (Compare( - hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { - if (app->IsVideoApplication()) { - video_state = VideoStreamingState::STREAMABLE; - } + auto state = mobile_apis::VideoStreamingState::NOT_STREAMABLE; + if (IsStreamableHMILevel(hmi_level) && app->IsVideoApplication()) { + state = mobile_apis::VideoStreamingState::STREAMABLE; } - return video_state; + + LOG4CXX_DEBUG(logger_, + "Calculated video state of app " + << app->app_id() << " for " << hmi_level << " HMI level is " + << state); + return state; } } // namespace application_manager -- cgit v1.2.1 From 1ce9e8a37b5d33f4d92bd658e42fdb9b8fa1cbae Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 23:11:32 +0300 Subject: Minor changes: extend logs, fix methods descriptions --- .../src/application_manager_impl.cc | 28 ++++---- .../application_manager/src/application_state.cc | 1 - .../application_manager/src/hmi_state.cc | 12 +++- .../src/state_controller_impl.cc | 76 ++++++---------------- 4 files changed, 45 insertions(+), 72 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 822807a5ae..3dc529a26e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -658,15 +658,17 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN(app, false); + LOG4CXX_DEBUG(logger_, "Activating application with id:" << app->app_id()); + // remove from resumption if app was activated by user resume_controller().OnAppActivated(app); - HMILevel::eType hmi_level = HMILevel::HMI_FULL; - AudioStreamingState::eType audio_state; - VideoStreamingState::eType video_state; - app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE - : audio_state = AudioStreamingState::NOT_AUDIBLE; - app->IsVideoApplication() ? video_state = VideoStreamingState::STREAMABLE - : video_state = VideoStreamingState::NOT_STREAMABLE; + const HMILevel::eType hmi_level = HMILevel::HMI_FULL; + const AudioStreamingState::eType audio_state = + app->IsAudioApplication() ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + const VideoStreamingState::eType video_state = + app->IsVideoApplication() ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, false); return true; } @@ -679,10 +681,10 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed( NOTREACHED(); return mobile_api::HMILevel::INVALID_ENUM; } - bool is_audio_app = app->IsAudioApplication(); - bool does_audio_app_with_same_type_exist = + const bool is_audio_app = app->IsAudioApplication(); + const bool does_audio_app_with_same_type_exist = IsAppTypeExistsInFullOrLimited(app); - bool is_active_app_exist = active_application().valid(); + const bool is_active_app_exist = active_application().valid(); mobile_api::HMILevel::eType result = mobile_api::HMILevel::HMI_FULL; if (is_audio_app && does_audio_app_with_same_type_exist) { @@ -4528,7 +4530,6 @@ std::vector ApplicationManagerImpl::devices( void ApplicationManagerImpl::ChangeAppsHMILevel( uint32_t app_id, mobile_apis::HMILevel::eType level) { - using namespace mobile_apis::HMILevel; LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "AppID to change: " << app_id << " -> " << level); ApplicationSharedPtr app = application(app_id); @@ -4536,14 +4537,13 @@ void ApplicationManagerImpl::ChangeAppsHMILevel( LOG4CXX_ERROR(logger_, "There is no app with id: " << app_id); return; } - eType old_level = app->hmi_level(); + const mobile_apis::HMILevel::eType old_level = app->hmi_level(); if (old_level != level) { app->set_hmi_level(level); OnHMILevelChanged(app_id, old_level, level); - plugin_manager_.OnAppHMILevelChanged(app, old_level); } else { - LOG4CXX_WARN(logger_, "Redudant changing HMI level : " << level); + LOG4CXX_WARN(logger_, "Redundant changing HMI level: " << level); } } diff --git a/src/components/application_manager/src/application_state.cc b/src/components/application_manager/src/application_state.cc index 101a565a8e..3f775ee4e2 100644 --- a/src/components/application_manager/src/application_state.cc +++ b/src/components/application_manager/src/application_state.cc @@ -101,7 +101,6 @@ void ApplicationState::RemoveState(HmiState::StateID state) { } HmiStatePtr ApplicationState::GetState(HmiState::StateID state_id) const { - LOG4CXX_AUTO_TRACE(logger_); switch (state_id) { case HmiState::StateID::STATE_ID_REGULAR: LOG4CXX_DEBUG(logger_, "Getting regular state."); diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 14cee28f91..8e93f278f0 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -40,6 +40,8 @@ namespace application_manager { +CREATE_LOGGERPTR_GLOBAL(logger_, "HmiState") + HmiState::HmiState(utils::SharedPtr app, const ApplicationManager& app_mngr, StateID state_id) @@ -49,7 +51,9 @@ HmiState::HmiState(utils::SharedPtr app, , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_DEBUG(logger_, *this); +} HmiState::HmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) @@ -59,7 +63,9 @@ HmiState::HmiState(utils::SharedPtr app, , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_DEBUG(logger_, *this); +} DEPRECATED HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr, @@ -71,6 +77,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); + LOG4CXX_DEBUG(logger_, *this); } DEPRECATED HmiState::HmiState(uint32_t app_id, @@ -82,6 +89,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); + LOG4CXX_DEBUG(logger_, *this); } void HmiState::set_parent(HmiStatePtr parent) { diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 9ca8680d09..942f9f0e3f 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -68,14 +68,12 @@ StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, HmiStatePtr state, const bool send_activate_app) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); - DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(HmiState::STATE_ID_REGULAR == state->state_id()); + + LOG4CXX_DEBUG(logger_, "Set regular state " << *state); if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || state->audio_streaming_state() == @@ -83,7 +81,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, state->video_streaming_state() == mobile_apis::VideoStreamingState::INVALID_ENUM || state->system_context() == mobile_apis::SystemContext::INVALID_ENUM) { - LOG4CXX_ERROR(logger_, "Get invalid state"); + LOG4CXX_ERROR(logger_, "Got invalid state"); return; } @@ -97,7 +95,8 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, app->SetPostponedState(state); return; } - hmi_apis::Common_HMILevel::eType hmi_level = + LOG4CXX_DEBUG(logger_, "Resolved state: " << *resolved_state); + const hmi_apis::Common_HMILevel::eType hmi_level = static_cast( resolved_state->hmi_level()); @@ -121,12 +120,8 @@ void StateControllerImpl::SetRegularState( const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state, const bool send_activate_app) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = @@ -144,13 +139,8 @@ void StateControllerImpl::SetRegularState( const mobile_apis::HMILevel::eType hmi_level, const bool send_activate_app) { 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; - } + DCHECK_OR_RETURN_VOID(app); const HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -169,12 +159,8 @@ void StateControllerImpl::SetRegularState( const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, const bool send_activate_app) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); @@ -187,12 +173,8 @@ void StateControllerImpl::SetRegularState( 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; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); @@ -209,12 +191,8 @@ void StateControllerImpl::SetRegularState( 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; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = @@ -233,12 +211,8 @@ void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr hmi_state = @@ -253,12 +227,8 @@ void StateControllerImpl::SetRegularState( 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(app); DCHECK_OR_RETURN_VOID(state); if (mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { SetRegularState(app, state, true); @@ -627,9 +597,6 @@ void StateControllerImpl::SetupRegularHmiState( const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; - using helpers::Compare; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); @@ -702,7 +669,7 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { const uint32_t id = message[strings::msg_params][hmi_notification::event_name].asUInt(); // TODO(AOleynik): Add verification/conversion check here - Common_EventTypes::eType state_id = + const Common_EventTypes::eType state_id = static_cast(id); if (is_active) { if (Common_EventTypes::AUDIO_SOURCE == state_id) { @@ -747,6 +714,9 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { break; } } + + LOG4CXX_WARN(logger_, + "Couldn't recognize state id (val='" << state_id << "')"); break; } default: @@ -772,15 +742,13 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, app->app_id(), old_state->hmi_level(), new_state->hmi_level()); app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); } else { - LOG4CXX_ERROR(logger_, "Status not changed"); + LOG4CXX_ERROR(logger_, "State has NOT been changed."); } } -bool StateControllerImpl::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; + return helpers::in_range(active_states_, id); } void StateControllerImpl::OnApplicationRegistered( @@ -955,9 +923,7 @@ void StateControllerImpl::OnAppActivated( void StateControllerImpl::OnAppDeactivated( const smart_objects::SmartObject& message) { - using namespace hmi_apis; using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = message[strings::msg_params][strings::app_id].asUInt(); -- cgit v1.2.1 From aa68e6b05d540c176ed9cd01f3914d6d98dcc5e0 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Fri, 18 May 2018 17:23:04 +0300 Subject: Change behavior for EmbeddedNavi event --- src/components/application_manager/src/hmi_state.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 8e93f278f0..826b8ec6b7 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -276,9 +276,6 @@ mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } - if (is_media_app()) { - return HMILevel::HMI_LIMITED; - } return HMILevel::HMI_BACKGROUND; } -- cgit v1.2.1 From cf144fc1509f8baf77496d181b91791a2f5e3380 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Mon, 21 May 2018 12:03:08 +0300 Subject: Review issues: remove deprecated VideoSourceHmiState constructor --- src/components/application_manager/src/hmi_state.cc | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 826b8ec6b7..ebc5a67143 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -155,10 +155,6 @@ VideoStreamingHmiState::VideoStreamingHmiState( utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_VIDEO_STREAMING) {} -DEPRECATED VideoStreamingHmiState::VideoStreamingHmiState( - uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_VIDEO_STREAMING) {} - mobile_apis::AudioStreamingState::eType VideoStreamingHmiState::audio_streaming_state() const { using namespace helpers; -- cgit v1.2.1 From e76fd11ca12f6d36f408977ab3c506ba9568a7a8 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Thu, 24 May 2018 14:45:28 +0300 Subject: Fix HMI conflict resolving for applied app in LIMITED state --- .../src/state_controller_impl.cc | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 942f9f0e3f..1eb75c4451 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -361,21 +361,15 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( mobile_apis::HMILevel::eType result_hmi_level = state_to_resolve->hmi_level(); - if (mobile_apis::HMILevel::HMI_FULL == applied_hmi_level) { - using namespace helpers; - if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || - Compare( - result_audio_state, - mobile_apis::AudioStreamingState::AUDIBLE, - mobile_apis::AudioStreamingState::ATTENUATED)) { - result_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; - } else { - result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; - } - } else if (mobile_apis::HMILevel::HMI_LIMITED == applied_hmi_level) { - if (to_resolve_hmi_level == applied_hmi_level) { - result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; - } + using namespace helpers; + if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || + Compare( + result_audio_state, + mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::AudioStreamingState::ATTENUATED)) { + result_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; + } else { + result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; } if (std::make_tuple(to_resolve_hmi_level, -- cgit v1.2.1 From 6e9ce7fedfd363a51fa3ac7fb31ccdf00defd201 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Fri, 25 May 2018 14:03:29 +0300 Subject: Provide specific behavior for navigation streaming HMI state --- .../src/application_manager_impl.cc | 5 ++- .../application_manager/src/hmi_state.cc | 36 +++++++++++++--------- .../src/state_controller_impl.cc | 22 ++++++++++--- 3 files changed, 41 insertions(+), 22 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 3dc529a26e..408dcbf1da 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -3562,7 +3562,6 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { void ApplicationManagerImpl::OnAppStreaming( uint32_t app_id, protocol_handler::ServiceType service_type, bool state) { - using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application(app_id); @@ -3575,11 +3574,11 @@ void ApplicationManagerImpl::OnAppStreaming( DCHECK_OR_RETURN_VOID(media_manager_); if (state) { - state_ctrl_.OnNaviStreamingStarted(); + state_ctrl_.OnVideoStreamingStarted(app); media_manager_->StartStreaming(app_id, service_type); } else { media_manager_->StopStreaming(app_id, service_type); - state_ctrl_.OnNaviStreamingStopped(); + state_ctrl_.OnVideoStreamingStarted(app); } } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index ebc5a67143..73d4b80a55 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -155,17 +155,31 @@ VideoStreamingHmiState::VideoStreamingHmiState( utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_VIDEO_STREAMING) {} +mobile_apis::VideoStreamingState::eType +VideoStreamingHmiState::video_streaming_state() const { + if (app_->IsVideoApplication()) { + return parent()->video_streaming_state(); + } + + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; +} + +NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr app, + const ApplicationManager& app_mngr) + : VideoStreamingHmiState(app, app_mngr) { + set_state_id(STATE_ID_NAVI_STREAMING); +} + mobile_apis::AudioStreamingState::eType -VideoStreamingHmiState::audio_streaming_state() const { +NaviStreamingHmiState::audio_streaming_state() const { using namespace helpers; using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (!app_->IsVideoApplication() && - Compare( - expected_state, - AudioStreamingState::AUDIBLE, - AudioStreamingState::ATTENUATED)) { + if (!is_navi_app() && Compare( + expected_state, + AudioStreamingState::AUDIBLE, + AudioStreamingState::ATTENUATED)) { if (app_mngr_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; } else { @@ -176,15 +190,6 @@ VideoStreamingHmiState::audio_streaming_state() const { return expected_state; } -mobile_apis::VideoStreamingState::eType -VideoStreamingHmiState::video_streaming_state() const { - if (app_->IsVideoApplication()) { - return parent()->video_streaming_state(); - } - - return mobile_apis::VideoStreamingState::NOT_STREAMABLE; -} - PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} @@ -287,6 +292,7 @@ const StateID2StrMap kStateID2StrMap = HmiState::StateID::STATE_ID_VR_SESSION, "VR_SESSION")( HmiState::StateID::STATE_ID_TTS_SESSION, "TTS_SESSION")( HmiState::StateID::STATE_ID_VIDEO_STREAMING, "VIDEO_STREAMING")( + HmiState::StateID::STATE_ID_NAVI_STREAMING, "NAVI_STREAMING")( HmiState::StateID::STATE_ID_DEACTIVATE_HMI, "DEACTIVATE_HMI")( HmiState::StateID::STATE_ID_AUDIO_SOURCE, "AUDIO_SOURCE")( HmiState::StateID::STATE_ID_EMBEDDED_NAVI, "EMBEDDED_NAVI"); diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 1eb75c4451..9615656675 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -936,12 +936,22 @@ void StateControllerImpl::OnAppDeactivated( DeactivateApp(app); } -void StateControllerImpl::OnNaviStreamingStarted() { - ApplyTempState(); +void StateControllerImpl::OnVideoStreamingStarted( + ApplicationConstSharedPtr app) { + if (app->is_navi()) { + ApplyTempState(); + } else { + ApplyTempState(); + } } -void StateControllerImpl::OnNaviStreamingStopped() { - CancelTempState(); +void StateControllerImpl::OnVideoStreamingStopped( + ApplicationConstSharedPtr app) { + if (app->is_navi()) { + CancelTempState(); + } else { + CancelTempState(); + } } bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { @@ -982,6 +992,10 @@ HmiStatePtr StateControllerImpl::CreateHmiState( new_state = MakeShared(app, app_mngr_); break; } + case HmiState::STATE_ID_NAVI_STREAMING: { + new_state = MakeShared(app, app_mngr_); + break; + } case HmiState::STATE_ID_REGULAR: { new_state = MakeShared(app, app_mngr_); break; -- cgit v1.2.1 From 3cec3966343d95fff2626ce11a46aedd42d0eea8 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Wed, 6 Jun 2018 19:39:23 +0300 Subject: Review issues: Remove changes from DEPRECATED HmiState methods --- src/components/application_manager/src/hmi_state.cc | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 73d4b80a55..e1bc2b5125 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -74,10 +74,8 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); - LOG4CXX_DEBUG(logger_, *this); } DEPRECATED HmiState::HmiState(uint32_t app_id, @@ -86,10 +84,8 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); - LOG4CXX_DEBUG(logger_, *this); } void HmiState::set_parent(HmiStatePtr parent) { @@ -147,7 +143,6 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { expected_state = AudioStreamingState::ATTENUATED; } - return expected_state; } -- cgit v1.2.1