diff options
Diffstat (limited to 'src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc')
-rw-r--r-- | src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc | 70 |
1 files changed, 51 insertions, 19 deletions
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 d64ba3adf9..a7b6b9a2cd 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 @@ -31,8 +31,9 @@ */ #include "application_manager/commands/hmi/on_exit_application_notification.h" -#include "application_manager/application_manager_impl.h" + #include "application_manager/application_impl.h" +#include "application_manager/state_controller.h" #include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" @@ -42,39 +43,70 @@ namespace application_manager { namespace commands { OnExitApplicationNotification::OnExitApplicationNotification( - const MessageSharedPtr& message) : NotificationFromHMI(message) { -} + const MessageSharedPtr& message, ApplicationManager& application_manager) + : NotificationFromHMI(message, application_manager) {} -OnExitApplicationNotification::~OnExitApplicationNotification() { -} +OnExitApplicationNotification::~OnExitApplicationNotification() {} void OnExitApplicationNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationManagerImpl* app_mgr = ApplicationManagerImpl::instance(); - ApplicationSharedPtr app_impl = app_mgr->application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); + using namespace mobile_apis; + using namespace hmi_apis; + + uint32_t app_id = (*message_)[strings::msg_params][strings::app_id].asUInt(); + ApplicationSharedPtr app_impl = application_manager_.application(app_id); + if (!(app_impl.valid())) { LOG4CXX_ERROR(logger_, "Application does not exist"); return; } - hmi_apis::Common_ApplicationToNONEReason::eType reason; - reason = static_cast<hmi_apis::Common_ApplicationToNONEReason::eType> - ((*message_)[strings::msg_params][strings::reason].asInt()); + + Common_ApplicationExitReason::eType reason; + reason = static_cast<Common_ApplicationExitReason::eType>( + (*message_)[strings::msg_params][strings::reason].asInt()); + switch (reason) { - case hmi_apis::Common_ApplicationToNONEReason::USER_EXIT : { + case Common_ApplicationExitReason::DRIVER_DISTRACTION_VIOLATION: { + application_manager_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, + AppInterfaceUnregisteredReason::DRIVER_DISTRACTION_VIOLATION), + commands::Command::ORIGIN_SDL); break; } - default : { - LOG4CXX_WARN(logger_, "Unhandled reason"); + case Common_ApplicationExitReason::USER_EXIT: { break; } + case Common_ApplicationExitReason::UNAUTHORIZED_TRANSPORT_REGISTRATION: { + application_manager_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, AppInterfaceUnregisteredReason::APP_UNAUTHORIZED), + commands::Command::ORIGIN_SDL); + // HMI rejects registration for navi application + application_manager_.UnregisterApplication(app_id, Result::SUCCESS); + return; + } + case Common_ApplicationExitReason::UNSUPPORTED_HMI_RESOURCE: { + application_manager_.ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, AppInterfaceUnregisteredReason::UNSUPPORTED_HMI_RESOURCE), + commands::Command::ORIGIN_SDL); + application_manager_.UnregisterApplication(app_id, Result::SUCCESS); + return; + } + default: { + LOG4CXX_WARN(logger_, "Unhandled reason"); + return; + } + } + ApplicationSharedPtr app = application_manager_.application(app_id); + if (app) { + application_manager_.state_controller().SetRegularState( + app, HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, false); + } else { + LOG4CXX_ERROR(logger_, "Unable to find appication " << app_id); } - using namespace mobile_apis; - ApplicationManagerImpl::instance()->SetState<false>(app_impl->app_id(), - HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_MAIN); } } // namespace commands |