diff options
author | igapchuck <igapchuck@luxoft.com> | 2019-06-27 14:23:15 +0300 |
---|---|---|
committer | igapchuck <igapchuck@luxoft.com> | 2019-07-24 10:26:36 +0300 |
commit | 2187d3b081785547d0a80555ea4828adf19ee2c6 (patch) | |
tree | 60e44ba37618abe5de81c3e901083309b3ead3f5 /src/components/policy | |
parent | c1cced8d10c5fa8b509a7502a5873360fa66aca5 (diff) | |
download | sdl_core-2187d3b081785547d0a80555ea4828adf19ee2c6.tar.gz |
Add lock_screen_dismissal_warning to Policy Interface
Diffstat (limited to 'src/components/policy')
10 files changed, 99 insertions, 6 deletions
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 144061e58b..19a475371d 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -161,6 +161,9 @@ class CacheManager : public CacheManagerInterface { const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE; + const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; + /** * @brief Get a list of enabled cloud applications * @param enabled_apps List filled with the policy app id of each enabled @@ -286,7 +289,7 @@ class CacheManager : public CacheManagerInterface { std::vector<UserFriendlyMessage> GetUserFriendlyMsg( const std::vector<std::string>& msg_codes, const std::string& language, - const std::string& active_hmi_language); + const std::string& active_hmi_language) const; /** * @brief GetLockScreenIcon allows to obtain lock screen icon url; diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index 10e3ddde8e..0cbbb6df1f 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -280,6 +280,15 @@ class CacheManagerInterface { const = 0; /** + * @brief Returns lock screen warning message. In case when specified language + * is absent in policy table will be returned message on default language + * ("en-us"). Otherwise returns uninitialized boost::optional<std::string> + * @return std::string Lock screen warning message + */ + virtual const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language) const = 0; + + /** * @brief Allows to update 'vin' field in module_meta table. * * @param new 'vin' value. @@ -300,7 +309,7 @@ class CacheManagerInterface { virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg( const std::vector<std::string>& msg_codes, const std::string& language, - const std::string& active_hmi_language) = 0; + const std::string& active_hmi_language) const = 0; /** * @brief Get list of URL to send PTS to diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 6888e38740..9dd2b3c6ec 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -150,6 +150,9 @@ class PolicyManagerImpl : public PolicyManager { const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE; + const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; + /** * @brief Increments counter of ignition cycles */ diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 6e0c868ed8..4170e7aaa6 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -1573,10 +1573,32 @@ const boost::optional<bool> CacheManager::LockScreenDismissalEnabledState() return empty; } +const boost::optional<std::string> +CacheManager::LockScreenDismissalWarningMessage( + const std::string& language) const { + LOG4CXX_AUTO_TRACE(logger_); + boost::optional<std::string> empty; + CACHE_MANAGER_CHECK(empty); + + const std::string lock_screen_dismissal_warning_message = + "LockScreenDismissalWarning"; + sync_primitives::AutoLock auto_lock(cache_lock_); + + std::vector<std::string> msg_codes{lock_screen_dismissal_warning_message}; + + const auto messages = GetUserFriendlyMsg(msg_codes, language, "en-us"); + + if (messages.empty() || messages[0].text_body.empty()) { + return empty; + } + + return boost::optional<std::string>(messages[0].text_body); +} + std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg( const std::vector<std::string>& msg_codes, const std::string& language, - const std::string& active_hmi_language) { + const std::string& active_hmi_language) const { LOG4CXX_AUTO_TRACE(logger_); std::vector<UserFriendlyMessage> result; CACHE_MANAGER_CHECK(result); diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 4cefa11dd8..42b67734ae 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1757,6 +1757,13 @@ const boost::optional<bool> PolicyManagerImpl::LockScreenDismissalEnabledState() return cache_->LockScreenDismissalEnabledState(); } +const boost::optional<std::string> +PolicyManagerImpl::LockScreenDismissalWarningMessage( + const std::string& language) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->LockScreenDismissalWarningMessage(language); +} + void PolicyManagerImpl::IncrementIgnitionCycles() { cache_->IncrementIgnitionCycles(); } diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 392956c784..1c28b596c0 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -148,6 +148,8 @@ class CacheManager : public CacheManagerInterface { const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE; + const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; /** * @brief Get a list of enabled cloud applications * @param enabled_apps List filled with the policy app id of each enabled @@ -269,7 +271,8 @@ class CacheManager : public CacheManagerInterface { * @return Array of appropriate messages parameters */ std::vector<UserFriendlyMessage> GetUserFriendlyMsg( - const std::vector<std::string>& msg_codes, const std::string& language); + const std::vector<std::string>& msg_codes, + const std::string& language) const; /** * @brief Get list of URLs related to particular service diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index a59cb4522d..e8f2644bc5 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -266,6 +266,14 @@ class CacheManagerInterface { const = 0; /** + * @brief Returns lock screen warning message. In case when specified language + * is absent in policy table will be returned message on default language + * ("en-us"). Otherwise returns uninitialized boost::optional<std::string> + * @return std::string Lock screen warning message + */ + virtual const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language_code) const = 0; + /** * @brief Allows to update 'vin' field in module_meta table. * * @param new 'vin' value. @@ -285,7 +293,7 @@ class CacheManagerInterface { */ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg( const std::vector<std::string>& msg_codes, - const std::string& language) = 0; + const std::string& language) const = 0; /** * @brief Get list of URLs related to particular service diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 407b3510d6..13d19e1a41 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -164,6 +164,9 @@ class PolicyManagerImpl : public PolicyManager { const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE; + const boost::optional<std::string> LockScreenDismissalWarningMessage( + const std::string& language) const OVERRIDE; + /** * @brief Increments counter of ignition cycles */ diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index ebc1e2315e..d121886765 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -872,8 +872,31 @@ const boost::optional<bool> CacheManager::LockScreenDismissalEnabledState() return empty; } +const boost::optional<std::string> +CacheManager::LockScreenDismissalWarningMessage( + const std::string& language) const { + LOG4CXX_AUTO_TRACE(logger_); + boost::optional<std::string> empty; + CACHE_MANAGER_CHECK(empty); + + const std::string lock_screen_dismissal_warning_message = + "LockScreenDismissalWarning"; + sync_primitives::AutoLock auto_lock(cache_lock_); + + std::vector<std::string> msg_codes{lock_screen_dismissal_warning_message}; + + const auto messages = GetUserFriendlyMsg(msg_codes, language); + + if (messages.empty() || messages[0].text_body.empty()) { + return empty; + } + + return boost::optional<std::string>(messages[0].text_body); +} + std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg( - const std::vector<std::string>& msg_codes, const std::string& language) { + const std::vector<std::string>& msg_codes, + const std::string& language) const { LOG4CXX_AUTO_TRACE(logger_); std::vector<UserFriendlyMessage> result; CACHE_MANAGER_CHECK(result); @@ -919,6 +942,12 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg( UserFriendlyMessage msg; msg.message_code = *it; + msg.tts = *message_string.tts; + msg.label = *message_string.label; + msg.line1 = *message_string.line1; + msg.line2 = *message_string.line2; + msg.text_body = *message_string.textBody; + result.push_back(msg); } return result; diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index c6db002980..00a3d33379 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1085,6 +1085,12 @@ const boost::optional<bool> PolicyManagerImpl::LockScreenDismissalEnabledState() return cache_->LockScreenDismissalEnabledState(); } +const boost::optional<std::string> +PolicyManagerImpl::LockScreenDismissalWarningMessage( + const std::string& language) const { + return cache_->LockScreenDismissalWarningMessage(language); +} + void PolicyManagerImpl::IncrementIgnitionCycles() { cache_->IncrementIgnitionCycles(); } |