diff options
Diffstat (limited to 'src/components/application_manager/src/application_manager_impl.cc')
-rw-r--r-- | src/components/application_manager/src/application_manager_impl.cc | 73 |
1 files changed, 69 insertions, 4 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4e13da694b..a2703aca75 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -143,7 +143,8 @@ ApplicationManagerImpl::ApplicationManagerImpl( : settings_(am_settings) , applications_list_lock_(true) , audio_pass_thru_active_(false) - , is_distracting_driver_(false) + , driver_distraction_state_( + hmi_apis::Common_DriverDistractionState::INVALID_ENUM) , is_vr_session_strated_(false) , hmi_cooperating_(false) , is_all_apps_allowed_(true) @@ -621,6 +622,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const std::string& bundle_id = app_info[strings::bundle_id].asString(); application->set_bundle_id(bundle_id); } + PutDriverDistractionMessageToPostponed(application); + // Stops timer of saving data to resumption in order to // doesn't erase data from resumption storage. // Timer will be started after hmi level resumption. @@ -791,8 +794,14 @@ bool ApplicationManagerImpl::EndAudioPassThrough() { } } -void ApplicationManagerImpl::set_driver_distraction(const bool is_distracting) { - is_distracting_driver_ = is_distracting; +hmi_apis::Common_DriverDistractionState::eType +ApplicationManagerImpl::driver_distraction_state() const { + return driver_distraction_state_; +} + +void ApplicationManagerImpl::set_driver_distraction_state( + const hmi_apis::Common_DriverDistractionState::eType state) { + driver_distraction_state_ = state; } DEPRECATED void ApplicationManagerImpl::set_vr_session_started( @@ -1850,7 +1859,6 @@ bool ApplicationManagerImpl::ManageMobileCommand( const commands::MessageSharedPtr message, commands::Command::CommandOrigin origin) { LOG4CXX_AUTO_TRACE(logger_); - if (!message) { LOG4CXX_WARN(logger_, "Null-pointer message received."); return false; @@ -3608,6 +3616,41 @@ void ApplicationManagerImpl::OnHMILevelChanged( mobile_apis::HMILevel::eType from, mobile_apis::HMILevel::eType to) { LOG4CXX_AUTO_TRACE(logger_); + ProcessPostponedMessages(app_id); + ProcessApp(app_id, from, to); +} + +void ApplicationManagerImpl::ProcessPostponedMessages(const uint32_t app_id) { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application(app_id); + if (!app) { + LOG4CXX_WARN(logger_, "The app with id: " << app_id << " does not exist"); + return; + } + MobileMessageQueue messages; + app->SwapMobileMessageQueue(messages); + auto push_allowed_messages = + [this, &app](smart_objects::SmartObjectSPtr message) { + const std::string function_id = MessageHelper::StringifiedFunctionID( + static_cast<mobile_apis::FunctionID::eType>( + (*message)[strings::params][strings::function_id].asUInt())); + const RPCParams params; + const mobile_apis::Result::eType check_result = + CheckPolicyPermissions(app, function_id, params); + if (mobile_api::Result::SUCCESS == check_result) { + ManageMobileCommand(message, + commands::Command::CommandOrigin::ORIGIN_SDL); + } else { + app->PushMobileMessage(message); + } + }; + std::for_each(messages.begin(), messages.end(), push_allowed_messages); +} + +void ApplicationManagerImpl::ProcessApp(const uint32_t app_id, + const mobile_apis::HMILevel::eType from, + const mobile_apis::HMILevel::eType to) { using namespace mobile_apis::HMILevel; using namespace helpers; @@ -4145,6 +4188,28 @@ void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) { #endif // SDL_REMOTE_CONTROL } +void ApplicationManagerImpl::PutDriverDistractionMessageToPostponed( + ApplicationSharedPtr application) const { + LOG4CXX_AUTO_TRACE(logger_); + if (hmi_apis::Common_DriverDistractionState::INVALID_ENUM == + driver_distraction_state()) { + LOG4CXX_WARN(logger_, "DriverDistractionState is INVALID_ENUM"); + return; + } + smart_objects::SmartObjectSPtr on_driver_distraction = + utils::MakeShared<smart_objects::SmartObject>(); + + (*on_driver_distraction)[strings::params][strings::message_type] = + static_cast<int32_t>(application_manager::MessageType::kNotification); + (*on_driver_distraction)[strings::params][strings::function_id] = + mobile_api::FunctionID::OnDriverDistractionID; + (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = + driver_distraction_state(); + (*on_driver_distraction)[strings::params][strings::connection_key] = + application->app_id(); + application->PushMobileMessage(on_driver_distraction); +} + protocol_handler::MajorProtocolVersion ApplicationManagerImpl::SupportedSDLVersion() const { LOG4CXX_AUTO_TRACE(logger_); |