diff options
author | Ira Lytvynenko <ILytvynenko@luxoft.com> | 2018-03-16 11:18:26 +0200 |
---|---|---|
committer | Elvis Kuliiev <ekuliiev@luxoft.com> | 2018-05-17 18:00:42 +0300 |
commit | 6b43ffcdc661eb97a973c3a028af10076dd5e927 (patch) | |
tree | 02719679109d9cf52c4ef4a4eafcd21bd618d870 /src/components/application_manager | |
parent | 859fc6c0fcb4d659c55034c41476a55fd7e259ad (diff) | |
download | sdl_core-6b43ffcdc661eb97a973c3a028af10076dd5e927.tar.gz |
Initial implementation
Diffstat (limited to 'src/components/application_manager')
17 files changed, 196 insertions, 33 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 0c93f7447b..668c0a1720 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -530,6 +530,8 @@ class Application : public virtual InitialApplicationData, virtual const mobile_api::SystemContext::eType system_context() const = 0; virtual const mobile_api::AudioStreamingState::eType audio_streaming_state() const = 0; + virtual const mobile_api::VideoStreamingState::eType video_streaming_state() + const = 0; virtual const std::string& app_icon_path() const = 0; virtual connection_handler::DeviceHandle device() const = 0; @@ -721,6 +723,13 @@ class Application : public virtual InitialApplicationData, virtual bool IsAudioApplication() const = 0; /** + * @brief Check's if it is projection or navigation application + * + * @return true if application is projection or navigation + */ + virtual bool IsVideoApplication() const = 0; + + /** * DEPRECATED * @brief GetDeviceId allows to obtain device id which posseses * by this application. 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 50e0a209cf..5cf44a6c94 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -167,6 +167,8 @@ class ApplicationImpl : public virtual Application, const mobile_api::SystemContext::eType system_context() const; inline const mobile_apis::AudioStreamingState::eType audio_streaming_state() const; + inline const mobile_apis::VideoStreamingState::eType video_streaming_state() + const; const std::string& app_icon_path() const; connection_handler::DeviceHandle device() const; const std::string& mac_address() const OVERRIDE; @@ -265,6 +267,8 @@ class ApplicationImpl : public virtual Application, */ virtual bool IsAudioApplication() const; + bool IsVideoApplication() const OVERRIDE; + /** * @brief SetInitialState sets initial HMI state for application on * registration @@ -542,6 +546,14 @@ ApplicationImpl::audio_streaming_state() const { : AudioStreamingState::INVALID_ENUM; } +const mobile_api::VideoStreamingState::eType +ApplicationImpl::video_streaming_state() const { + using namespace mobile_apis; + const HmiStatePtr hmi_state = CurrentHmiState(); + return hmi_state ? hmi_state->video_streaming_state() + : VideoStreamingState::INVALID_ENUM; +} + bool ApplicationImpl::app_allowed() const { return is_app_allowed_; } 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 286ad87018..6f295afea3 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 @@ -565,6 +565,7 @@ class ApplicationManagerImpl utils::SharedPtr<Application> app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const OVERRIDE; /** @@ -588,14 +589,15 @@ class ApplicationManagerImpl * @param audio_state aaudio streaming state */ void SetState(uint32_t app_id, - mobile_apis::AudioStreamingState::eType audio_state) { + mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state) { ApplicationSharedPtr app = application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "Application with appID=" << app_id << " does not exist"); return; } - state_ctrl_.SetRegularState(app, audio_state); + state_ctrl_.SetRegularState(app, audio_state, video_state); } /** @@ -702,14 +704,15 @@ class ApplicationManagerImpl template <bool SendActivateApp> void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state) { + mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state) { ApplicationSharedPtr app = application(app_id); if (!app) { LOG4CXX_ERROR(logger_, "Application with appID=" << app_id << " does not exist"); return; } - state_ctrl_.SetRegularState(app, hmi_level, audio_state, SendActivateApp); + state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, SendActivateApp); } /** @@ -723,6 +726,7 @@ class ApplicationManagerImpl void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) { ApplicationSharedPtr app = application(app_id); if (!app) { @@ -731,7 +735,7 @@ class ApplicationManagerImpl return; } state_ctrl_.SetRegularState( - app, hmi_level, audio_state, system_context, SendActivateApp); + app, hmi_level, audio_state, video_state, system_context, SendActivateApp); } /** 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 f2d665d998..250dd19fcc 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -154,6 +154,28 @@ class HmiState { } return audio_streaming_state_; } + + /** + * @brief video_streaming_state + * @return return video streaming state member + */ + virtual mobile_apis::VideoStreamingState::eType video_streaming_state() + const { + if (parent_) { + return parent_->video_streaming_state(); + } + return video_streaming_state_; + } + + /** + * @brief set_video_streaming_state set set_video_streaming_state member + * @param video_state video_state to setup + */ + virtual void set_video_streaming_state( + mobile_apis::VideoStreamingState::eType video_state) { + video_streaming_state_ = video_state; + } + /** * @brief set_audio_streaming_state set audio_streaming_state member * @param audio_state audio_state to setup @@ -206,6 +228,7 @@ class HmiState { HmiStatePtr parent_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; + mobile_apis::VideoStreamingState::eType video_streaming_state_; mobile_apis::SystemContext::eType system_context_; protected: @@ -279,6 +302,8 @@ class NaviStreamingHmiState : public HmiState { mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE; + mobile_apis::VideoStreamingState::eType video_streaming_state() + const OVERRIDE; }; /** 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 32a2315f23..3a54d66906 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 @@ -164,6 +164,7 @@ extern const char* trigger_source; extern const char* hmi_level; extern const char* activate_app_hmi_level; extern const char* audio_streaming_state; +extern const char* video_streaming_state; extern const char* system_context; extern const char* speech_capabilities; extern const char* vr_capabilities; diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 1b2033f5a8..70a7cc2520 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -67,12 +67,14 @@ class StateControllerImpl : public event_engine::EventObserver, * @param app appication to setup regular State * @param hmi_level of new regular state * @param audio_state of new regular state + * @paran video_state of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ virtual void 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 SendActivateApp); /** @@ -91,6 +93,7 @@ class StateControllerImpl : public event_engine::EventObserver, * @param app appication to setup regular State * @param hmi_level of new regular state * @param audio_state of new regular state + * @param video_state of new regular state * @param system_context of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ @@ -98,6 +101,7 @@ class StateControllerImpl : public event_engine::EventObserver, 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 SendActivateApp); @@ -114,10 +118,12 @@ class StateControllerImpl : public event_engine::EventObserver, * @brief SetRegularState Change regular audio state * @param app appication to setup regular State * @param audio_state of new regular state + * @param video_state of new regular state */ virtual void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::AudioStreamingState::eType audio_state); + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state); /** * @brief SetRegularState Change regular system context @@ -330,6 +336,7 @@ class StateControllerImpl : public event_engine::EventObserver, DCHECK_OR_RETURN_VOID(old_hmi_state); old_hmi_state->set_hmi_level(cur->hmi_level()); old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state()); + old_hmi_state->set_video_streaming_state(cur->video_streaming_state()); old_hmi_state->set_system_context(cur->system_context()); app->RemoveHMIState(ID); HmiStatePtr new_hmi_state = app->CurrentHmiState(); @@ -367,12 +374,14 @@ class StateControllerImpl : public event_engine::EventObserver, * @param app application * @param hmi_level of new regular state * @param audio_state of new regular state + * @param video_state of new regular state * @param system_context of new regular state */ void SetupRegularHmiState( 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); /** @@ -381,11 +390,13 @@ class StateControllerImpl : public event_engine::EventObserver, * @param app application * @param hmi_level of new regular state * @param audio_state of new regular state + * @param video_state of new regular state */ void SetupRegularHmiState( ApplicationSharedPtr app, const 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); /** * @brief OnActivateAppResponse calback for activate app response @@ -438,6 +449,10 @@ class StateControllerImpl : public event_engine::EventObserver, ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) const; + mobile_apis::VideoStreamingState::eType CalcVideoState( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) const; + typedef std::list<HmiState::StateID> StateIDList; StateIDList active_states_; mutable sync_primitives::Lock active_states_lock_; 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>(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<Application> app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const { 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<int32_t>(app->audio_streaming_state()); + message[strings::msg_params][strings::video_streaming_state] = + static_cast<int32_t>(app->video_streaming_state()); + message[strings::msg_params][strings::system_context] = static_cast<int32_t>(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<Application> 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<Application> app, @@ -54,6 +55,7 @@ HmiState::HmiState(utils::SharedPtr<Application> 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<Application> 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<HMILevel::eType, EQ, ONE>( + hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (app->IsVideoApplication()) { + video_state = VideoStreamingState::STREAMABLE; + } + } + return video_state; +} + } // namespace application_manager diff --git a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc index ffedf1b4f6..4b805f4006 100644 --- a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc +++ b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc @@ -1191,6 +1191,7 @@ TEST_F(HMICommandsNotificationsTest, SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, false)); command->Run(); } @@ -1219,6 +1220,7 @@ TEST_F(HMICommandsNotificationsTest, SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, false)); command->Run(); } diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 5bf2f2368e..d0c34b3392 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -106,6 +106,8 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(system_context, const mobile_apis::SystemContext::eType()); MOCK_CONST_METHOD0(audio_streaming_state, const mobile_apis::AudioStreamingState::eType()); + MOCK_CONST_METHOD0(video_streaming_state, + const mobile_apis::VideoStreamingState::eType()); MOCK_CONST_METHOD0(app_icon_path, const std::string&()); MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle()); MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr()); @@ -170,6 +172,7 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id)); MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id)); MOCK_CONST_METHOD0(IsAudioApplication, bool()); + MOCK_CONST_METHOD0(IsVideoApplication, bool()); MOCK_METHOD0(LoadPersistentFiles, void()); // InitialApplicationData methods MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*()); diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index d9e1cefa01..6425f7a255 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -954,6 +954,7 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppLimitedAndRevoked) { SetRegularState(_, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, true)); EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index fe4d1d2ee8..c30dc3035c 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -2404,7 +2404,9 @@ TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { EXPECT_CALL(*simple_app_ptr_, SetRegularState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, AudioStreamingState::AUDIBLE); + state_ctrl_->SetRegularState(simple_app_, + AudioStreamingState::AUDIBLE, + VideoStreamingState::STREAMABLE); } TEST_F(StateControllerImplTest, |