summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r--src/components/application_manager/src/application_impl.cc12
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc178
-rw-r--r--src/components/application_manager/src/commands/hmi/activate_app_request.cc45
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc4
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc40
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc12
-rw-r--r--src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc1
-rw-r--r--src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc5
-rw-r--r--src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc2
-rw-r--r--src/components/application_manager/src/hmi_state.cc2
-rw-r--r--src/components/application_manager/src/message_helper.cc12
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc61
-rw-r--r--src/components/application_manager/src/resume_ctrl.cpp12
-rw-r--r--src/components/application_manager/src/state_controller.cc53
16 files changed, 145 insertions, 298 deletions
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 8d3fb00bef..25b841048f 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -97,7 +97,6 @@ ApplicationImpl::ApplicationImpl(uint32_t application_id,
delete_file_in_none_count_(0),
list_files_in_none_count_(0),
system_context_(mobile_api::SystemContext::SYSCTXT_MAIN),
- audio_streaming_state_(mobile_api::AudioStreamingState::NOT_AUDIBLE),
device_(0),
usage_report_(mobile_app_id, statistics_manager),
protocol_version_(ProtocolVersion::kV3),
@@ -483,17 +482,6 @@ void ApplicationImpl::set_system_context(
system_context_ = system_context;
}
-void ApplicationImpl::set_audio_streaming_state(
- const mobile_api::AudioStreamingState::eType& state) {
- if (!(is_media_application() || is_navi())
- && state != mobile_api::AudioStreamingState::NOT_AUDIBLE) {
- LOG4CXX_WARN(logger_, "Trying to set audio streaming state"
- " for non-media application to different from NOT_AUDIBLE");
- return;
- }
- audio_streaming_state_ = state;
-}
-
bool ApplicationImpl::set_app_icon_path(const std::string& path) {
if (app_files_.find(path) != app_files_.end()) {
app_icon_path_ = path;
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 44c5b560c1..5037a58873 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -499,7 +499,7 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) {
AudioStreamingState::eType ass;
app->IsAudioApplication() ? ass = AudioStreamingState::AUDIBLE :
AudioStreamingState::NOT_AUDIBLE;
- state_ctrl_.SetRegularState(app, hmi_level, ass);
+ state_ctrl_.SetRegularState<false>(app, hmi_level, ass);
return true;
}
@@ -624,14 +624,6 @@ void ApplicationManagerImpl::set_all_apps_allowed(const bool& allowed) {
is_all_apps_allowed_ = allowed;
}
-void ApplicationManagerImpl::SetState(uint32_t app_id,
- mobile_api::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType ass) {
- LOG4CXX_AUTO_TRACE(logger_);
- ApplicationSharedPtr app = application(app_id);
- state_ctrl_.SetRegularState(app, hmi_level, ass);
-}
-
void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key,
int32_t correlation_id, int32_t max_duration, int32_t sampling_rate,
int32_t bits_per_sample, int32_t audio_type) {
@@ -2479,11 +2471,9 @@ void ApplicationManagerImpl::NaviAppStreamStatus(bool stream_active) {
using namespace mobile_apis;
if(active_app && active_app->is_media_application()) {
LOG4CXX_DEBUG(logger_, "Stream status: " << active_app->app_id());
-
- active_app->set_audio_streaming_state(stream_active ?
- AudioStreamingState::ATTENUATED :
- AudioStreamingState::AUDIBLE);
- MessageHelper::SendHMIStatusNotification(*active_app);
+ SetState(active_app,
+ stream_active ? AudioStreamingState::ATTENUATED :
+ AudioStreamingState::AUDIBLE);
}
}
@@ -2625,65 +2615,65 @@ void ApplicationManagerImpl::OnWakeUp() {
request_ctrl_.OnWakeUp();
}
-void ApplicationManagerImpl::Mute(VRTTSSessionChanging changing_state) {
- mobile_apis::AudioStreamingState::eType state =
- mobile_apis::AudioStreamingState::NOT_AUDIBLE;
-
- // ATTENUATED state applicable only for TTS
- if ((kTTSSessionChanging == changing_state) &&
- hmi_capabilities_.attenuated_supported()) {
- state = mobile_apis::AudioStreamingState::ATTENUATED;
- }
-
- ApplicationManagerImpl::ApplicationListAccessor accessor;
-
- ApplicationManagerImpl::ApplictionSetConstIt it =
- accessor.begin();
- ApplicationManagerImpl::ApplictionSetConstIt
- itEnd = accessor.end();
- for (; it != itEnd; ++it) {
- if ((*it).valid()) {
- if ((*it)->is_media_application()) {
- if (kTTSSessionChanging == changing_state) {
- (*it)->set_tts_speak_state(true);
- }
- if ((*it)->audio_streaming_state() != state &&
- (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) &&
- (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) {
- (*it)->set_audio_streaming_state(state);
- MessageHelper::SendHMIStatusNotification(*(*it));
- }
- }
- }
- }
-}
-
-void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) {
-
- ApplicationManagerImpl::ApplicationListAccessor accessor;
- ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin();
- ApplicationManagerImpl::ApplictionSetConstIt itEnd = accessor.end();
-
- for (; it != itEnd; ++it) {
- if ((*it).valid()) {
- if ((*it)->is_media_application()) {
- if (kTTSSessionChanging == changing_state) {
- (*it)->set_tts_speak_state(false);
- }
- if ((!(vr_session_started())) &&
- (!((*it)->tts_speak_state())) &&
- ((*it)->audio_streaming_state() !=
- mobile_apis::AudioStreamingState::AUDIBLE) &&
- (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) &&
- (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) {
- (*it)->set_audio_streaming_state(
- mobile_apis::AudioStreamingState::AUDIBLE);
- MessageHelper::SendHMIStatusNotification(*(*it));
- }
- }
- }
- }
-}
+//void ApplicationManagerImpl::Mute(VRTTSSessionChanging changing_state) {
+// mobile_apis::AudioStreamingState::eType state =
+// mobile_apis::AudioStreamingState::NOT_AUDIBLE;
+
+// // ATTENUATED state applicable only for TTS
+// if ((kTTSSessionChanging == changing_state) &&
+// hmi_capabilities_.attenuated_supported()) {
+// state = mobile_apis::AudioStreamingState::ATTENUATED;
+// }
+
+// ApplicationManagerImpl::ApplicationListAccessor accessor;
+
+// ApplicationManagerImpl::ApplictionSetConstIt it =
+// accessor.begin();
+// ApplicationManagerImpl::ApplictionSetConstIt
+// itEnd = accessor.end();
+// for (; it != itEnd; ++it) {
+// if ((*it).valid()) {
+// if ((*it)->is_media_application()) {
+// if (kTTSSessionChanging == changing_state) {
+// (*it)->set_tts_speak_state(true);
+// }
+// if ((*it)->audio_streaming_state() != state &&
+// (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) &&
+// (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) {
+// (*it)->set_audio_streaming_state(state);
+// MessageHelper::SendHMIStatusNotification(*(*it));
+// }
+// }
+// }
+// }
+//}
+
+//void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) {
+
+// ApplicationManagerImpl::ApplicationListAccessor accessor;
+// ApplicationManagerImpl::ApplictionSetConstIt it = accessor.begin();
+// ApplicationManagerImpl::ApplictionSetConstIt itEnd = accessor.end();
+
+// for (; it != itEnd; ++it) {
+// if ((*it).valid()) {
+// if ((*it)->is_media_application()) {
+// if (kTTSSessionChanging == changing_state) {
+// (*it)->set_tts_speak_state(false);
+// }
+// if ((!(vr_session_started())) &&
+// (!((*it)->tts_speak_state())) &&
+// ((*it)->audio_streaming_state() !=
+// mobile_apis::AudioStreamingState::AUDIBLE) &&
+// (mobile_api::HMILevel::HMI_NONE != (*it)->hmi_level()) &&
+// (mobile_api::HMILevel::HMI_BACKGROUND != (*it)->hmi_level())) {
+// (*it)->set_audio_streaming_state(
+// mobile_apis::AudioStreamingState::AUDIBLE);
+// MessageHelper::SendHMIStatusNotification(*(*it));
+// }
+// }
+// }
+// }
+//}
mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
const std::vector<uint8_t>& binary_data, const std::string& file_path,
@@ -2846,39 +2836,7 @@ void ApplicationManagerImpl::ChangeAppsHMILevel(uint32_t app_id,
}
HmiStatePtr new_state( new HmiState(*(app->RegularHmiState())));
new_state->set_hmi_level(level);
- state_ctrl_.SetRegularState(app, new_state);
-}
-
-void ApplicationManagerImpl::MakeAppNotAudible(uint32_t app_id) {
- using namespace mobile_apis;
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_DEBUG(logger_, "There is no app with id: " << app_id);
- return;
- }
- ChangeAppsHMILevel(app_id, HMILevel::HMI_BACKGROUND);
- app->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE);
-}
-
-bool ApplicationManagerImpl::MakeAppFullScreen(uint32_t app_id) {
- using namespace mobile_apis;
- ApplicationSharedPtr app = application(app_id);
- if (!app) {
- LOG4CXX_DEBUG(logger_, "There is no app with id: " << app_id);
- return false;
- }
-
- ChangeAppsHMILevel(app_id, HMILevel::HMI_FULL);
- if (app->is_media_application() || app->is_navi()) {
- app->set_audio_streaming_state(AudioStreamingState::AUDIBLE);
- }
- app->set_system_context(SystemContext::SYSCTXT_MAIN);
-
- if(!app->has_been_activated()) {
- app->set_activated(true);
- }
-
- return true;
+ //state_ctrl_.SetRegularState(app, new_state);
}
@@ -2980,12 +2938,10 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
} else if (((*it)->hmi_level() == mobile_api::HMILevel::HMI_FULL) ||
((*it)->hmi_level() == mobile_api::HMILevel::HMI_LIMITED)) {
- MessageHelper::SendActivateAppToHMI((*it)->app_id(),
- hmi_apis::Common_HMILevel::BACKGROUND,
- false);
MessageHelper::SendUIChangeRegistrationRequestToHMI(*it);
- ChangeAppsHMILevel((*it)->app_id(), mobile_api::HMILevel::HMI_BACKGROUND);
- MessageHelper::SendHMIStatusNotification(*(*it));
+ ApplicationManagerImpl::instance()->SetState<true>((*it)->app_id(),
+ mobile_apis::HMILevel::HMI_BACKGROUND
+ );
}
}
}
diff --git a/src/components/application_manager/src/commands/hmi/activate_app_request.cc b/src/components/application_manager/src/commands/hmi/activate_app_request.cc
index 4b07a5dcfa..c8258bd74a 100644
--- a/src/components/application_manager/src/commands/hmi/activate_app_request.cc
+++ b/src/components/application_manager/src/commands/hmi/activate_app_request.cc
@@ -62,54 +62,9 @@ namespace application_manager {
}
#endif
SendRequest();
- subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp,
- correlation_id());
LOG4CXX_TRACE(logger_, "exit");
}
-
- void ActivateAppRequest::on_event(const event_engine::Event& event) {
- LOG4CXX_AUTO_TRACE(logger_);
- const smart_objects::SmartObject& response = event.smart_object();
- const hmi_apis::Common_Result::eType code =
- static_cast<hmi_apis::Common_Result::eType>(
- response[strings::params][hmi_response::code].asInt());
- if (hmi_apis::Common_Result::SUCCESS != code) {
- LOG4CXX_ERROR(logger_, "Error ActivateApp result code " << code);
- return;
- }
- int32_t correlation_id = RequestToHMI::correlation_id();
- // Mobile id is converted to HMI id for HMI requests
- const uint32_t hmi_app_id = ApplicationManagerImpl::instance()->
- application_id(correlation_id);
-
- mobile_apis::HMILevel::eType requested_hmi_level = mobile_apis::HMILevel::HMI_FULL;
- if ((*message_)[strings::msg_params].keyExists(
- strings::activate_app_hmi_level)) {
- requested_hmi_level = static_cast<mobile_apis::HMILevel::eType>(
- (*message_)[strings::msg_params][strings::activate_app_hmi_level].asInt());
- LOG4CXX_INFO(logger_, "requested_hmi_level = " << requested_hmi_level);
- }
-
- if (0 == hmi_app_id) {
- LOG4CXX_ERROR(logger_, "Error hmi_app_id = "<< hmi_app_id);
- return;
- }
-
- ApplicationSharedPtr application = ApplicationManagerImpl::instance()->
- application_by_hmi_app(hmi_app_id);
- if (!application.valid()) {
- LOG4CXX_ERROR(logger_, "Application can't be activated.");
- return;
- }
-
- if (mobile_apis::HMILevel::HMI_FULL == requested_hmi_level) {
- if (ApplicationManagerImpl::instance()->ActivateApplication(application)) {
- LOG4CXX_DEBUG(logger_, "Put Application in FULL succes");
- MessageHelper::SendHMIStatusNotification(*(application.get()));
- }
- }
- }
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc
index 7e60eaadaf..0ff76a45f5 100644
--- a/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_app_activated_notification.cc
@@ -50,7 +50,9 @@ OnAppActivatedNotification::~OnAppActivatedNotification() {
void OnAppActivatedNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
uint32_t app_id = ((*message_)[strings::msg_params][strings::app_id]).asUInt();
- MessageHelper::SendActivateAppToHMI(app_id);
+ ApplicationManagerImpl::instance()->SetState<true>(app_id,
+ mobile_apis::HMILevel::HMI_FULL
+ );
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
index 1d55044f7a..5f369d44aa 100644
--- a/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_app_deactivated_notification.cc
@@ -80,51 +80,29 @@ void OnAppDeactivatedNotification::Run() {
if (HMI_NONE == app->hmi_level()) {
return;
}
+ HmiStatePtr regular = app->RegularHmiState();
+ DCHECK_OR_RETURN_VOID(regular);
+ HmiStatePtr new_regular(new HmiState(*regular));
- eType new_hmi_level = app->hmi_level();
switch ((*message_)[strings::msg_params][hmi_request::reason].asInt()) {
case hmi_apis::Common_DeactivateReason::AUDIO: {
- if (app->is_media_application()) {
- if (profile::Profile::instance()->is_mixing_audio_supported() &&
- (ApplicationManagerImpl::instance()->vr_session_started() ||
- app->tts_speak_state())) {
- app->set_audio_streaming_state(mobile_api::AudioStreamingState::ATTENUATED);
- } else {
- app->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE);
- }
- }
- // HMI must send this notification for each active app
- if (app.valid()) {
- if (Compare<eType, EQ, ONE>(app->hmi_level(), HMI_FULL, HMI_LIMITED)) {
- new_hmi_level = HMI_BACKGROUND;
- }
- }
+ new_regular->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE);
+ new_regular->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
break;
}
case hmi_apis::Common_DeactivateReason::NAVIGATIONMAP:
case hmi_apis::Common_DeactivateReason::PHONEMENU:
case hmi_apis::Common_DeactivateReason::SYNCSETTINGS:
case hmi_apis::Common_DeactivateReason::GENERAL: {
- if ((!app->IsAudioApplication()) ||
- ApplicationManagerImpl::instance()->
- DoesAudioAppWithSameHMITypeExistInFullOrLimited(app)) {
- new_hmi_level = HMI_BACKGROUND;
+ if (app->IsAudioApplication()) {
+ new_regular->set_hmi_level(mobile_api::HMILevel::HMI_LIMITED);
} else {
- new_hmi_level = HMI_LIMITED;
+ new_regular->set_hmi_level(mobile_api::HMILevel::HMI_BACKGROUND);
}
- break;
- }
- default: {
- LOG4CXX_ERROR_EXT(logger_, "Unknown reason of app deactivation");
- return;
}
}
+ ApplicationManagerImpl::instance()->SetState<false>(app, new_regular);
- if (new_hmi_level != app->hmi_level()) {
- ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(),
- new_hmi_level);
- MessageHelper::SendHMIStatusNotification(*app);
- }
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
index 9cb40bd645..d64ba3adf9 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc
@@ -70,13 +70,11 @@ void OnExitApplicationNotification::Run() {
break;
}
}
-
- ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app_impl->app_id(),
- mobile_apis::HMILevel::HMI_NONE);
-
- app_impl->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE);
- app_impl->set_system_context(mobile_api::SystemContext::SYSCTXT_MAIN);
- MessageHelper::SendHMIStatusNotification(*app_impl);
+ using namespace mobile_apis;
+ ApplicationManagerImpl::instance()->SetState<false>(app_impl->app_id(),
+ HMILevel::HMI_NONE,
+ AudioStreamingState::NOT_AUDIBLE,
+ SystemContext::SYSCTXT_MAIN);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc
index 8cbafda68e..dc69246d5c 100644
--- a/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_tts_started_notification.cc
@@ -50,7 +50,6 @@ void OnTTSStartedNotification::Run() {
event_engine::Event event(hmi_apis::FunctionID::TTS_Started);
event.set_smart_object(*message_);
event.raise();
- ApplicationManagerImpl::instance()->Mute(kTTSSessionChanging);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc b/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc
index c812c84af5..8d429ed179 100644
--- a/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_tts_stopped_notification.cc
@@ -52,8 +52,6 @@ void OnTTSStoppedNotification::Run() {
event_engine::Event event(hmi_apis::FunctionID::TTS_Stopped);
event.set_smart_object(*message_);
event.raise();
- ApplicationManagerImpl::instance()->Unmute(kTTSSessionChanging);
-
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc
index bcd02196a8..f8f9b4dfad 100644
--- a/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_vr_command_notification.cc
@@ -62,7 +62,10 @@ void OnVRCommandNotification::Run() {
// Check if this is one of standart VR commands (i.e. "Help")
if (cmd_id > max_cmd_id + 1) {
LOG4CXX_INFO(logger_, "Switched App");
- MessageHelper::SendActivateAppToHMI(cmd_id - max_cmd_id);
+ const uint32_t app_id = cmd_id - max_cmd_id;
+ ApplicationManagerImpl::instance()->SetState<true>(app_id,
+ mobile_apis::HMILevel::HMI_FULL
+ );
return;
}
diff --git a/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc
index 6e56dd29c0..8ab63ca61e 100644
--- a/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_vr_started_notification.cc
@@ -49,7 +49,7 @@ void OnVRStartedNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationManagerImpl::instance()->set_vr_session_started(true);
- ApplicationManagerImpl::instance()->Mute(kVRSessionChanging);
+ //ApplicationManagerImpl::instance()->Mute(kVRSessionChanging);
}
} // namespace commands
diff --git a/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc b/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc
index 442968ea1e..02c2c165a1 100644
--- a/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_vr_stopped_notification.cc
@@ -49,7 +49,7 @@ void OnVRStoppedNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
ApplicationManagerImpl::instance()->set_vr_session_started(false);
- ApplicationManagerImpl::instance()->Unmute(kVRSessionChanging);
+ //ApplicationManagerImpl::instance()->Unmute(kVRSessionChanging);
}
} // namespace commands
diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc
index 2e97b5a2f3..4cd5e771f9 100644
--- a/src/components/application_manager/src/hmi_state.cc
+++ b/src/components/application_manager/src/hmi_state.cc
@@ -29,7 +29,6 @@ HmiState::HmiState(const HmiState& copy_from):
}
-
HmiState::HmiState(mobile_apis::HMILevel::eType hmi_level,
mobile_apis::AudioStreamingState::eType audio_streaming_state,
mobile_apis::SystemContext::eType system_context):
@@ -43,7 +42,6 @@ void HmiState::setParent(HmiStatePtr parent) {
parent_ = parent;
}
-
VRHmiState::VRHmiState(HmiStatePtr previous):
HmiState(previous) {
}
diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc
index 829c894b2e..36954a50dc 100644
--- a/src/components/application_manager/src/message_helper.cc
+++ b/src/components/application_manager/src/message_helper.cc
@@ -1303,25 +1303,26 @@ void MessageHelper::SendOnAppUnregNotificationToHMI(
ApplicationManagerImpl::instance()->ManageHMICommand(notification);
}
-void MessageHelper::SendActivateAppToHMI(uint32_t const app_id,
+uint32_t MessageHelper::SendActivateAppToHMI(uint32_t const app_id,
hmi_apis::Common_HMILevel::eType level,
bool send_policy_priority) {
+ u_int32_t correlation_id = 0;
application_manager::ApplicationConstSharedPtr app =
application_manager::ApplicationManagerImpl::instance()
->application(app_id);
if (!app) {
LOG4CXX_WARN(logger_, "Invalid app_id: " << app_id);
- return;
+ return correlation_id;
}
+ correlation_id =
+ ApplicationManagerImpl::instance()->GetNextHMICorrelationID();
utils::SharedPtr<smart_objects::SmartObject> message = new smart_objects::SmartObject(
smart_objects::SmartType_Map);
-
(*message)[strings::params][strings::function_id] =
hmi_apis::FunctionID::BasicCommunication_ActivateApp;
(*message)[strings::params][strings::message_type] = MessageType::kRequest;
- (*message)[strings::params][strings::correlation_id] =
- ApplicationManagerImpl::instance()->GetNextHMICorrelationID();
+ (*message)[strings::params][strings::correlation_id] = correlation_id;
(*message)[strings::msg_params][strings::app_id] = app_id;
if (send_policy_priority) {
@@ -1352,6 +1353,7 @@ void MessageHelper::SendActivateAppToHMI(uint32_t const app_id,
}
ApplicationManagerImpl::instance()->ManageHMICommand(message);
+ return correlation_id;
}
void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id) {
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index fe9d14df16..5316aaec7c 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -103,14 +103,9 @@ struct DeactivateApplication {
void operator()(const ApplicationSharedPtr& app) {
if (device_id_ == app->device()) {
- if (mobile_api::HMILevel::HMI_NONE != app->hmi_level()) {
- ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(),
- mobile_apis::HMILevel::HMI_NONE);
- app->set_audio_streaming_state(mobile_api::AudioStreamingState::NOT_AUDIBLE);
- MessageHelper::SendActivateAppToHMI(
- app->app_id(), hmi_apis::Common_HMILevel::NONE);
- MessageHelper::SendHMIStatusNotification(*app.get());
- }
+ ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
+ mobile_apis::HMILevel::HMI_NONE,
+ mobile_apis::AudioStreamingState::NOT_AUDIBLE);
}
}
@@ -130,32 +125,22 @@ struct SDLAlowedNotification {
}
if (device_id_ == app->device()) {
std::string hmi_level;
- hmi_apis::Common_HMILevel::eType default_hmi;
mobile_apis::HMILevel::eType default_mobile_hmi;
policy_manager_->GetDefaultHmi(app->mobile_app_id(), &hmi_level);
if ("BACKGROUND" == hmi_level) {
- default_hmi = hmi_apis::Common_HMILevel::BACKGROUND;
default_mobile_hmi = mobile_apis::HMILevel::HMI_BACKGROUND;
} else if ("FULL" == hmi_level) {
- default_hmi = hmi_apis::Common_HMILevel::FULL;
default_mobile_hmi = mobile_apis::HMILevel::HMI_FULL;
} else if ("LIMITED" == hmi_level) {
- default_hmi = hmi_apis::Common_HMILevel::LIMITED;
default_mobile_hmi = mobile_apis::HMILevel::HMI_LIMITED;
} else if ("NONE" == hmi_level) {
- default_hmi = hmi_apis::Common_HMILevel::NONE;
default_mobile_hmi = mobile_apis::HMILevel::HMI_NONE;
} else {
return ;
}
- if (app->hmi_level() == default_mobile_hmi) {
- LOG4CXX_DEBUG(logger_, "Application already in default hmi state.");
- } else {
- ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(),
- default_mobile_hmi);
- MessageHelper::SendHMIStatusNotification(*app);
- }
- MessageHelper::SendActivateAppToHMI(app->app_id(), default_hmi);
+ ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
+ default_mobile_hmi
+ );
}
}
private:
@@ -645,27 +630,23 @@ void PolicyHandler::OnPendingPermissionChange(
const uint32_t app_id = app->app_id();
- using mobile_apis::HMILevel::eType;
+ namespace ma = mobile_apis;
if (permissions.appRevoked) {
application_manager::MessageHelper::SendOnAppPermissionsChangedNotification(
app_id, permissions);
-
- ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(),
- eType::HMI_NONE);
- app->set_audio_streaming_state(mobile_apis::AudioStreamingState::NOT_AUDIBLE);
- application_manager::MessageHelper::SendActivateAppToHMI(
- app_id, hmi_apis::Common_HMILevel::NONE);
- application_manager::MessageHelper::SendHMIStatusNotification(*app);
+ ApplicationManagerImpl::instance()->SetState<false>(app->app_id(),
+ ma::HMILevel::HMI_NONE,
+ ma::AudioStreamingState::NOT_AUDIBLE);
policy_manager_->RemovePendingPermissionChanges(policy_app_id);
return;
}
- eType app_hmi_level = app->hmi_level();
+ ma::HMILevel::eType app_hmi_level = app->hmi_level();
switch (app_hmi_level) {
- case eType::HMI_FULL:
- case eType::HMI_LIMITED: {
+ case ma::HMILevel::eType::HMI_FULL:
+ case ma::HMILevel::eType::HMI_LIMITED: {
if (permissions.appPermissionsConsentNeeded) {
MessageHelper::
SendOnAppPermissionsChangedNotification(app->app_id(), permissions);
@@ -674,7 +655,7 @@ void PolicyHandler::OnPendingPermissionChange(
}
break;
}
- case eType::HMI_BACKGROUND: {
+ case ma::HMILevel::eType::HMI_BACKGROUND: {
if (permissions.isAppPermissionsRevoked) {
MessageHelper::
SendOnAppPermissionsChangedNotification(app->app_id(), permissions);
@@ -947,17 +928,9 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id,
LOG4CXX_INFO(logger_, "Changing hmi level of application "
<< policy_app_id
<< " to default hmi level " << default_hmi);
- // If default is FULL, send request to HMI. Notification to mobile will be
- // sent on response receiving.
- if (mobile_apis::HMILevel::HMI_FULL == hmi_level) {
- MessageHelper::SendActivateAppToHMI(app->app_id());
- } else {
- // Set application hmi level
- ApplicationManagerImpl::instance()->ChangeAppsHMILevel(app->app_id(),
- hmi_level);
- // If hmi Level is full, it will be seted after ActivateApp response
- MessageHelper::SendHMIStatusNotification(*app.get());
- }
+ ApplicationManagerImpl::instance()->SetState<true>(app->app_id(),
+ mobile_apis::HMILevel::HMI_FULL
+ );
break;
}
default:
diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp
index fab14f8819..ff4415a164 100644
--- a/src/components/application_manager/src/resume_ctrl.cpp
+++ b/src/components/application_manager/src/resume_ctrl.cpp
@@ -233,9 +233,15 @@ bool ResumeCtrl::SetAppHMIState(ApplicationSharedPtr application,
HMILevel::HMI_LIMITED == restored_hmi_level ? AudioStreamingState::AUDIBLE:
AudioStreamingState::NOT_AUDIBLE;
- ApplicationManagerImpl::instance()->SetState(application->app_id(),
- restored_hmi_level,
- restored_audio_state);
+ if (restored_hmi_level == HMILevel::HMI_FULL) {
+ ApplicationManagerImpl::instance()->SetState<true>(application->app_id(),
+ restored_hmi_level,
+ restored_audio_state);
+ } else {
+ ApplicationManagerImpl::instance()->SetState<false>(application->app_id(),
+ restored_hmi_level,
+ restored_audio_state);
+ }
LOG4CXX_INFO(logger_, "Set up application "
<< application->mobile_app_id()
<< " to HMILevel " << hmi_level);
diff --git a/src/components/application_manager/src/state_controller.cc b/src/components/application_manager/src/state_controller.cc
index c4fe6f9a97..b567aa9cd0 100644
--- a/src/components/application_manager/src/state_controller.cc
+++ b/src/components/application_manager/src/state_controller.cc
@@ -59,27 +59,17 @@ StateController::StateController():EventObserver() {
}
void StateController::SetRegularState(ApplicationSharedPtr app,
- const mobile_apis::HMILevel::eType hmi_level,
const mobile_apis::AudioStreamingState::eType audio_state) {
- HmiStatePtr hmi_state(new HmiState(hmi_level, audio_state, system_context_));
- SetRegularState(app, hmi_state);
+ DCHECK_OR_RETURN_VOID(app);
+ HmiStatePtr prev_regular = app->RegularHmiState();
+ DCHECK_OR_RETURN_VOID(prev_regular);
+ HmiStatePtr hmi_state(new HmiState(prev_regular->hmi_level(),
+ audio_state,
+ prev_regular->system_context()));
+ SetRegularState<false>(app, hmi_state);
}
-void StateController::SetRegularState(ApplicationSharedPtr app,
- HmiStatePtr state) {
- DCHECK_OR_RETURN_VOID(app);
- DCHECK_OR_RETURN_VOID(state);
- DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR);
- HmiStatePtr old_state(new HmiState(*(app->RegularHmiState())));
- if (state->hmi_level() == mobile_api::HMILevel::HMI_FULL
- && old_state->hmi_level() != mobile_api::HMILevel::HMI_FULL) {
- MessageHelper::SendActivateAppToHMI(app->app_id());
- waiting_for_activate[app->app_id()] = state;
- } else {
- ApplyRegularState(app, state);
- }
-}
void StateController::HmiLevelConflictResolver::operator ()
(ApplicationSharedPtr to_resolve) {
@@ -105,26 +95,28 @@ void StateController::HmiLevelConflictResolver::operator ()
}
void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
+ HmiStatePtr state) {
+ HmiStatePtr old_state(new HmiState(*(app->CurrentHmiState())));
+ app->SetRegularState(state);
+ HmiStatePtr new_state = app->RegularHmiState();
+ OnStateChanged(app, old_state, new_state);
+}
+
+void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
const mobile_apis::HMILevel::eType hmi_level,
const mobile_apis::AudioStreamingState::eType audio_state) {
using namespace mobile_apis;
using namespace helpers;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(app);
+ HmiStatePtr prev_state = app->RegularHmiState();
+ DCHECK_OR_RETURN_VOID(prev_state);
HmiStatePtr new_state(new HmiState(hmi_level,
audio_state,
- system_context_));
+ prev_state->system_context()));
SetupRegularHmiState(app, new_state);
}
-void StateController::SetupRegularHmiState(ApplicationSharedPtr app,
- HmiStatePtr state) {
- HmiStatePtr old_state(new HmiState(*(app->CurrentHmiState())));
- app->SetRegularState(state);
- HmiStatePtr new_state = app->RegularHmiState();
- OnStateChanged(app, old_state, new_state);
-}
-
void StateController::ApplyRegularState(ApplicationSharedPtr app,
HmiStatePtr state) {
DCHECK_OR_RETURN_VOID(app);
@@ -142,11 +134,6 @@ bool StateController::IsSameAppType(ApplicationConstSharedPtr app1,
app1->is_voice_communication_supported() == app2->is_voice_communication_supported();
}
-void StateController::SetSystemContext(const mobile_apis::SystemContext::eType system_context) {
- system_context_ = system_context;
- //TODO (APPLINK-8555) Need to setup system context for app applications
-}
-
void StateController::on_event(const event_engine::Event& event) {
using namespace smart_objects;
using namespace event_engine;
@@ -156,6 +143,10 @@ void StateController::on_event(const event_engine::Event& event) {
const SmartObject& message = event.smart_object();
const FunctionID::eType id = static_cast<FunctionID::eType> (event.id());
switch (id) {
+ case FunctionID::BasicCommunication_ActivateApp: {
+ OnActivateAppResponse(message);
+ break;
+ }
case FunctionID::BasicCommunication_OnEmergencyEvent: {
bool is_active =
message[strings::msg_params][hmi_notification::is_active].asBool();