summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Nosach <ANosach@luxoft.com>2015-04-08 14:03:29 +0300
committerArtem Nosach <ANosach@luxoft.com>2015-04-23 15:33:24 +0300
commit860c23b5c72eae7db1b10a4265060d5e19e4a299 (patch)
treecc53372d3d81d64d9ac46be55a142e8bd58149b6
parent80479b98c5254ca2c4d5de983a734d8f4e9ab957 (diff)
downloadsdl_core-860c23b5c72eae7db1b10a4265060d5e19e4a299.tar.gz
Add hmi state for case if app stream from limited.
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h7
-rw-r--r--src/components/application_manager/include/application_manager/hmi_state.h10
-rw-r--r--src/components/application_manager/include/application_manager/state_controller.h11
-rw-r--r--src/components/application_manager/src/application_impl.cc4
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc12
-rw-r--r--src/components/application_manager/src/hmi_state.cc19
-rw-r--r--src/components/application_manager/src/state_context.cc5
-rw-r--r--src/components/application_manager/src/state_controller.cc24
8 files changed, 91 insertions, 1 deletions
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 084a136000..e1acf9ca16 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
@@ -689,6 +689,13 @@ class ApplicationManagerImpl : public ApplicationManager,
void ForbidStreaming(uint32_t app_id);
/**
+ * @brief Callback calls when application starts/stops data streaming
+ * @param app_id Streaming application id
+ * @param state Shows if streaming started or stopped
+ */
+ void OnAppStreaming(uint32_t app_id, bool state);
+
+ /**
* @brief OnHMILevelChanged the callback that allows SDL to react when
* application's HMILeval has been changed.
*
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 5a715dc099..4451fb6857 100644
--- a/src/components/application_manager/include/application_manager/hmi_state.h
+++ b/src/components/application_manager/include/application_manager/hmi_state.h
@@ -31,6 +31,7 @@ class HmiState {
STATE_ID_SAFETY_MODE,
STATE_ID_VR_SESSION,
STATE_ID_TTS_SESSION,
+ STATE_ID_NAVI_STREAMING,
};
HmiState(uint32_t app_id, const StateContext& state_context_);
@@ -150,6 +151,15 @@ class TTSHmiState : public HmiState {
};
/**
+ * @brief The NaviStreamingState class impement logic of NaviStreaming temporary state
+ */
+class NaviStreamingHmiState : public HmiState {
+ public:
+ NaviStreamingHmiState(uint32_t app_id, StateContext& state_context);
+ virtual mobile_apis::AudioStreamingState::eType audio_streaming_state() const;
+};
+
+/**
* @brief The PhoneCallHmiState class impement logic of PhoneCall temporary state
*/
class PhoneCallHmiState : public HmiState {
diff --git a/src/components/application_manager/include/application_manager/state_controller.h b/src/components/application_manager/include/application_manager/state_controller.h
index 79fbaf1da0..b57070c35e 100644
--- a/src/components/application_manager/include/application_manager/state_controller.h
+++ b/src/components/application_manager/include/application_manager/state_controller.h
@@ -189,6 +189,17 @@ class StateController : public event_engine::EventObserver {
* @param app application to apply states
*/
void ApplyStatesForApp(ApplicationSharedPtr app);
+
+ /**
+ * @brief OnNaviStreamingStarted process Navi streaming started
+ */
+ void OnNaviStreamingStarted();
+
+ /**
+ * @brief OnNaviStreamingStopped process Navi streaming stopped
+ */
+ void OnNaviStreamingStopped();
+
private:
/**
* Execute Unary punction for each application
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 06eee5a875..03f39d6844 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -484,10 +484,12 @@ void ApplicationImpl::SuspendStreaming(ServiceType service_type) {
if (ServiceType::kMobileNav == service_type) {
video_stream_suspend_timer_->suspend();
+ ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), false);
sync_primitives::AutoLock lock(video_streaming_suspended_lock_);
video_streaming_suspended_ = true;
} else if (ServiceType::kAudio == service_type) {
audio_stream_suspend_timer_->suspend();
+ ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), false);
sync_primitives::AutoLock lock(audio_streaming_suspended_lock_);
audio_streaming_suspended_ = true;
}
@@ -500,6 +502,7 @@ void ApplicationImpl::WakeUpStreaming(ServiceType service_type) {
if (ServiceType::kMobileNav == service_type) {
sync_primitives::AutoLock lock(video_streaming_suspended_lock_);
if (video_streaming_suspended_) {
+ ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), true);
MessageHelper::SendOnDataStreaming(ServiceType::kMobileNav, true);
video_streaming_suspended_ = false;
}
@@ -507,6 +510,7 @@ void ApplicationImpl::WakeUpStreaming(ServiceType service_type) {
} else if (ServiceType::kAudio == service_type) {
sync_primitives::AutoLock lock(audio_streaming_suspended_lock_);
if (audio_streaming_suspended_) {
+ ApplicationManagerImpl::instance()->OnAppStreaming(app_id(), true);
MessageHelper::SendOnDataStreaming(ServiceType::kAudio, true);
audio_streaming_suspended_ = false;
}
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 722ddd6e7e..6e277f7760 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2540,6 +2540,18 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) {
EndNaviServices(app_id);
}
+void ApplicationManagerImpl::OnAppStreaming(uint32_t app_id, bool state) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ ApplicationSharedPtr app = application(app_id);
+ if (!app || !app->is_navi()) {
+ LOG4CXX_DEBUG(logger_, " There is no application with id: " << app_id);
+ return;
+ }
+ state ? state_ctrl_.OnNaviStreamingStarted() :
+ state_ctrl_.OnNaviStreamingStopped();
+}
+
void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) {
using namespace protocol_handler;
diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc
index bc23e501de..ea54057aa6 100644
--- a/src/components/application_manager/src/hmi_state.cc
+++ b/src/components/application_manager/src/hmi_state.cc
@@ -55,6 +55,25 @@ TTSHmiState::audio_streaming_state() const {
return expected_state;
}
+NaviStreamingHmiState::NaviStreamingHmiState(uint32_t app_id, StateContext& state_context):
+ HmiState(app_id, state_context, STATE_ID_NAVI_STREAMING) {
+}
+
+mobile_apis::AudioStreamingState::eType
+NaviStreamingHmiState::audio_streaming_state() const {
+ using namespace helpers;
+ using namespace mobile_apis;
+ AudioStreamingState::eType expected_state = parent()->audio_streaming_state();
+ if (Compare<HMILevel::eType, EQ, ONE> (hmi_level(), HMILevel::HMI_FULL)) {
+ if (state_context_.is_attenuated_supported()) {
+ expected_state = AudioStreamingState::ATTENUATED;
+ } else {
+ expected_state = AudioStreamingState::NOT_AUDIBLE;
+ }
+ }
+ return expected_state;
+}
+
PhoneCallHmiState::PhoneCallHmiState(uint32_t app_id, StateContext& state_context):
HmiState(app_id, state_context, STATE_ID_PHONE_CALL) {
}
diff --git a/src/components/application_manager/src/state_context.cc b/src/components/application_manager/src/state_context.cc
index 37f53977df..ae3b40e094 100644
--- a/src/components/application_manager/src/state_context.cc
+++ b/src/components/application_manager/src/state_context.cc
@@ -31,6 +31,8 @@
*/
#include "application_manager/state_context.h"
#include "application_manager/application_manager_impl.h"
+#include "config_profile/profile.h"
+
namespace application_manager {
@@ -53,7 +55,8 @@ bool StateContext::is_voice_comunication_app(const uint32_t app_id) const {
bool StateContext::is_attenuated_supported() const{
const HMICapabilities& hmi_capabilities =
ApplicationManagerImpl::instance()->hmi_capabilities();
- return hmi_capabilities.attenuated_supported();
+ return hmi_capabilities.attenuated_supported() &&
+ profile::Profile::instance()->is_mixing_audio_supported();
}
}
diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller.cc
index 9be20362b8..d43050978d 100644
--- a/src/components/application_manager/src/state_controller.cc
+++ b/src/components/application_manager/src/state_controller.cc
@@ -359,6 +359,26 @@ void StateController::OnTTSStopped() {
TempStateStopped(HmiState::STATE_ID_TTS_SESSION);
}
+void StateController::OnNaviStreamingStarted() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ForEachApplication(std::bind1st(
+ std::mem_fun(
+ &StateController::HMIStateStarted<HmiState::STATE_ID_NAVI_STREAMING>),
+ this)
+ );
+ TempStateStarted(HmiState::STATE_ID_NAVI_STREAMING);
+}
+
+void StateController::OnNaviStreamingStopped() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ForEachApplication(std::bind1st(
+ std::mem_fun(
+ &StateController::HMIStateStopped<HmiState::STATE_ID_NAVI_STREAMING>),
+ this)
+ );
+ TempStateStopped(HmiState::STATE_ID_NAVI_STREAMING);
+}
+
HmiStatePtr StateController::CreateHmiState(uint32_t app_id, HmiState::StateID state_id) {
LOG4CXX_AUTO_TRACE(logger_);
HmiStatePtr new_state;
@@ -379,6 +399,10 @@ HmiStatePtr StateController::CreateHmiState(uint32_t app_id, HmiState::StateID s
new_state.reset(new TTSHmiState(app_id, state_context_));
break;
}
+ case HmiState::STATE_ID_NAVI_STREAMING: {
+ new_state.reset(new NaviStreamingHmiState(app_id, state_context_));
+ break;
+ }
case HmiState::STATE_ID_REGULAR: {
new_state.reset(new HmiState(app_id, state_context_));
break;