diff options
author | sniukalov <sniukalov@luxoft.com> | 2019-06-26 09:57:00 +0300 |
---|---|---|
committer | sniukalov <sniukalov@luxoft.com> | 2019-08-14 14:59:40 +0300 |
commit | 0560092ff7bb048a50f78b7c46070fcf56643902 (patch) | |
tree | d62806ae380d78f09d67ac06facb91d5e72c9356 /src/components/application_manager/src/policies/policy_handler.cc | |
parent | b59e3e4b37cc9c68f60a25da1fa094c17d217b83 (diff) | |
download | sdl_core-0560092ff7bb048a50f78b7c46070fcf56643902.tar.gz |
Adjustment of proprietary policy component for multiple devices.
Diffstat (limited to 'src/components/application_manager/src/policies/policy_handler.cc')
-rw-r--r-- | src/components/application_manager/src/policies/policy_handler.cc | 94 |
1 files changed, 92 insertions, 2 deletions
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index cac09bd5f3..e71d49f4f0 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -472,7 +472,8 @@ void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id, policy_manager_->ReactOnUserDevConsentForApp(policy_app_id, is_allowed); - policy_manager_->SendNotificationOnPermissionsUpdated(policy_app_id); + policy_manager_->SendNotificationOnPermissionsUpdated(device_id, + policy_app_id); } } } @@ -1383,6 +1384,62 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, } } +void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, + const Permissions& permissions, + const HMILevel& default_hmi) { + LOG4CXX_AUTO_TRACE(logger_); + OnPermissionsUpdated(device_id, policy_app_id, permissions); + + ApplicationSharedPtr app = + application_manager_.application(device_id, policy_app_id); + if (app.use_count() == 0) { + LOG4CXX_WARN( + logger_, + "Connection_key not found for application_id:" << policy_app_id); + return; + } + + // The application currently not running (i.e. in NONE) should change HMI + // level to default + mobile_apis::HMILevel::eType current_hmi_level = app->hmi_level(); + mobile_apis::HMILevel::eType hmi_level = + MessageHelper::StringToHMILevel(default_hmi); + + if (mobile_apis::HMILevel::INVALID_ENUM == hmi_level) { + LOG4CXX_WARN( + logger_, + "Couldn't convert default hmi level " << default_hmi << " to enum."); + return; + } + if (current_hmi_level == hmi_level) { + LOG4CXX_DEBUG(logger_, "Application already in default hmi state."); + return; + } + switch (current_hmi_level) { + case mobile_apis::HMILevel::HMI_NONE: { + LOG4CXX_INFO(logger_, + "Changing hmi level of application " + << policy_app_id << " to default hmi level " + << default_hmi); + + const bool is_full_hmi_level = + mobile_apis::HMILevel::HMI_FULL == hmi_level; + + application_manager_.state_controller().SetRegularState( + app, hmi_level, is_full_hmi_level); + + break; + } + default: + LOG4CXX_WARN(logger_, + "Application " << policy_app_id + << " is running." + "HMI level won't be changed."); + break; + } +} + void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, const Permissions& permissions) { LOG4CXX_AUTO_TRACE(logger_); @@ -1404,6 +1461,28 @@ void PolicyHandler::OnPermissionsUpdated(const std::string& policy_app_id, << app->app_id()); } +void PolicyHandler::OnPermissionsUpdated(const std::string& device_id, + const std::string& policy_app_id, + const Permissions& permissions) { + LOG4CXX_AUTO_TRACE(logger_); + ApplicationSharedPtr app = + application_manager_.application(device_id, policy_app_id); + if (app.use_count() == 0) { + LOG4CXX_WARN( + logger_, + "Connection_key not found for application_id:" << policy_app_id); + return; + } + + MessageHelper::SendOnPermissionsChangeNotification( + app->app_id(), permissions, application_manager_); + + LOG4CXX_DEBUG(logger_, + "Notification sent for application_id:" + << policy_app_id << " and connection_key " + << app->app_id()); +} + bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string, std::string& snap_path) { const std::string& policy_snapshot_file_name = @@ -2080,7 +2159,18 @@ void PolicyHandler::OnAppsSearchCompleted(const bool trigger_ptu) { void PolicyHandler::OnAppRegisteredOnMobile(const std::string& application_id) { POLICY_LIB_CHECK_VOID(); - policy_manager_->OnAppRegisteredOnMobile(application_id); + const auto app = + application_manager_.application_by_policy_id(application_id); + if (app.use_count()) { + policy_manager_->OnAppRegisteredOnMobile(app->mac_address(), + application_id); + } +} + +void PolicyHandler::OnAppRegisteredOnMobile(const std::string& device_id, + const std::string& application_id) { + POLICY_LIB_CHECK_VOID(); + policy_manager_->OnAppRegisteredOnMobile(device_id, application_id); } RequestType::State PolicyHandler::GetAppRequestTypeState( |