diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2019-10-30 10:53:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-30 10:53:49 -0400 |
commit | 891497bc9fb23434242dbe92e1f13dd1273fcb21 (patch) | |
tree | a96314794e50c047b580a0e313e62164ae2998a6 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc | |
parent | ea5960280585d11ee02542b0ab183d4400ed691d (diff) | |
parent | 4d283e625dfa09d166d572fa7bf6e98e91f05050 (diff) | |
download | sdl_core-891497bc9fb23434242dbe92e1f13dd1273fcb21.tar.gz |
Merge pull request #3100 from smartdevicelink/release/6.0.06.0.0
Release 6.0.0
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc')
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc index a5fb9b206e..a743c58672 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_driver_distraction_notification.cc @@ -30,13 +30,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <set> #include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include <set> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" -#include "interfaces/MOBILE_API.h" +#include "application_manager/policies/policy_handler_interface.h" #include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -59,12 +60,39 @@ struct OnDriverDistractionProcessor { void operator()(ApplicationSharedPtr application) { if (application) { - (*on_driver_distraction_so_)[strings::params][strings::connection_key] = - application->app_id(); + // Create modifiable copy of base message + smart_objects::SmartObject message = *on_driver_distraction_so_; + message[strings::params][strings::connection_key] = application->app_id(); const RPCParams params; policy::CheckPermissionResult result; application_manager_.GetPolicyHandler().CheckPermissions( - application, stringified_function_id_, params, result); + application, + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + stringified_function_id_, + params, + result); + auto& msg_params = message[strings::msg_params]; + const bool is_lock_screen_dismissal_exists = msg_params.keyExists( + mobile_notification::lock_screen_dismissal_enabled); + + if (is_lock_screen_dismissal_exists && + msg_params[mobile_notification::lock_screen_dismissal_enabled] + .asBool()) { + const auto language = + MessageHelper::MobileLanguageToString(application->ui_language()); + + const auto warning_message = + application_manager_.GetPolicyHandler() + .LockScreenDismissalWarningMessage(language); + // Only allow lock screen dismissal if a warning message is available + if (warning_message && !warning_message->empty()) { + msg_params[mobile_notification::lock_screen_dismissal_warning] = + *warning_message; + } else { + msg_params[mobile_notification::lock_screen_dismissal_enabled] = + false; + } + } if (result.hmi_level_permitted != policy::kRpcAllowed) { MobileMessageQueue messages; application->SwapMobileMessageQueue(messages); @@ -72,15 +100,19 @@ struct OnDriverDistractionProcessor { std::remove_if( messages.begin(), messages.end(), - [this](smart_objects::SmartObjectSPtr message) { + [](smart_objects::SmartObjectSPtr message) { return (*message)[strings::params][strings::function_id] - .asString() == stringified_function_id_; + .asUInt() == + mobile_api::FunctionID::OnDriverDistractionID; }), messages.end()); - application->PushMobileMessage(on_driver_distraction_so_); + application->SwapMobileMessageQueue(messages); + application->PushMobileMessage( + std::make_shared<smart_objects::SmartObject>(message)); return; } - command_.SendNotificationToMobile(on_driver_distraction_so_); + command_.SendNotificationToMobile( + std::make_shared<smart_objects::SmartObject>(message)); } } @@ -90,7 +122,7 @@ struct OnDriverDistractionProcessor { ApplicationManager& application_manager_; std::string stringified_function_id_; }; -} +} // namespace OnDriverDistractionNotification::OnDriverDistractionNotification( const application_manager::commands::MessageSharedPtr& message, @@ -108,14 +140,12 @@ OnDriverDistractionNotification::~OnDriverDistractionNotification() {} void OnDriverDistractionNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); - const hmi_apis::Common_DriverDistractionState::eType state = + const auto state = static_cast<hmi_apis::Common_DriverDistractionState::eType>( (*message_)[strings::msg_params][hmi_notification::state].asInt()); application_manager_.set_driver_distraction_state(state); - smart_objects::SmartObjectSPtr on_driver_distraction = - std::make_shared<smart_objects::SmartObject>(); - + auto on_driver_distraction = std::make_shared<smart_objects::SmartObject>(); if (!on_driver_distraction) { LOG4CXX_ERROR(logger_, "NULL pointer"); return; @@ -127,6 +157,17 @@ void OnDriverDistractionNotification::Run() { (*on_driver_distraction)[strings::msg_params][mobile_notification::state] = state; + const auto lock_screen_dismissal = + application_manager_.GetPolicyHandler().LockScreenDismissalEnabledState(); + + if (lock_screen_dismissal && + hmi_apis::Common_DriverDistractionState::DD_ON == state) { + (*on_driver_distraction) + [strings::msg_params] + [mobile_notification::lock_screen_dismissal_enabled] = + *lock_screen_dismissal; + } + const ApplicationSet applications = application_manager_.applications().GetData(); @@ -139,4 +180,4 @@ void OnDriverDistractionNotification::Run() { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin |