summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorigapchuck <igapchuck@luxoft.com>2019-06-27 14:23:15 +0300
committerigapchuck <igapchuck@luxoft.com>2019-07-24 10:26:36 +0300
commit2187d3b081785547d0a80555ea4828adf19ee2c6 (patch)
tree60e44ba37618abe5de81c3e901083309b3ead3f5
parentc1cced8d10c5fa8b509a7502a5873360fa66aca5 (diff)
downloadsdl_core-2187d3b081785547d0a80555ea4828adf19ee2c6.tar.gz
Add lock_screen_dismissal_warning to Policy Interface
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h2
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc7
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h2
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h9
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h8
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h12
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h2
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h10
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h2
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h5
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h11
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h3
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc24
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc7
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h5
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h10
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h3
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc31
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc6
20 files changed, 146 insertions, 15 deletions
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index cda3b5c1ed..d0280f91f2 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -205,6 +205,8 @@ class PolicyHandler : public PolicyHandlerInterface,
void OnExceededTimeout() OVERRIDE;
void OnSystemReady() OVERRIDE;
const boost::optional<bool> LockScreenDismissalEnabledState() const OVERRIDE;
+ virtual const boost::optional<std::string> LockScreenDismissalWarningMessage(
+ const std::string& language) const OVERRIDE;
void PTUpdatedAt(Counters counter, int value) OVERRIDE;
void add_listener(PolicyHandlerObserver* listener) OVERRIDE;
void remove_listener(PolicyHandlerObserver* listener) OVERRIDE;
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 033df7071f..cac09bd5f3 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1589,6 +1589,13 @@ const boost::optional<bool> PolicyHandler::LockScreenDismissalEnabledState()
return policy_manager_->LockScreenDismissalEnabledState();
}
+const boost::optional<std::string>
+PolicyHandler::LockScreenDismissalWarningMessage(
+ const std::string& language) const {
+ POLICY_LIB_CHECK(boost::optional<std::string>());
+ return policy_manager_->LockScreenDismissalWarningMessage(language);
+}
+
void PolicyHandler::PTUpdatedAt(Counters counter, int value) {
POLICY_LIB_CHECK_VOID();
policy_manager_->PTUpdatedAt(counter, value);
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index a743b92185..835ddedd28 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -126,6 +126,8 @@ class PolicyHandlerInterface {
virtual void OnSystemReady() = 0;
virtual const boost::optional<bool> LockScreenDismissalEnabledState()
const = 0;
+ virtual const boost::optional<std::string> LockScreenDismissalWarningMessage(
+ const std::string& language) const = 0;
virtual void PTUpdatedAt(Counters counter, int value) = 0;
virtual void add_listener(PolicyHandlerObserver* listener) = 0;
virtual void remove_listener(PolicyHandlerObserver* listener) = 0;
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index 6a80e6615e..aecc4b607a 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -175,6 +175,15 @@ class PolicyManager : public usage_statistics::StatisticsManager {
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 Increments counter of ignition cycles
*/
virtual void IncrementIgnitionCycles() = 0;
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index eee7986948..713f71dcdb 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -176,6 +176,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
const = 0;
/**
+ * @brief Returns lock screen warning message
+ * @param language_code Specific language for which need message
+ * @return std::string Lock screen warning message
+ */
+ virtual const boost::optional<std::string> LockScreenDismissalWarningMessage(
+ const std::string& language) const = 0;
+
+ /**
* @brief Increments counter of ignition cycles
*/
virtual void IncrementIgnitionCycles() = 0;
diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
index 7ba29a625d..342debca0a 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
@@ -111,6 +111,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
MOCK_METHOD0(OnSystemReady, void());
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState,
const boost::optional<bool>());
+ MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage,
+ const boost::optional<std::string>(const std::string&));
MOCK_METHOD2(PTUpdatedAt, void(policy::Counters counter, int value));
MOCK_METHOD1(add_listener, void(policy::PolicyHandlerObserver* listener));
MOCK_METHOD1(remove_listener, void(policy::PolicyHandlerObserver* listener));
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index ab5c34f91d..0a6bef45dd 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -112,6 +112,8 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
bool(const std::string& policy_app_id));
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState,
const boost::optional<bool>());
+ MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage,
+ const boost::optional<std::string>(const std::string&));
MOCK_CONST_METHOD1(GetDeviceConsent,
DeviceConsent(const std::string& device_id));
MOCK_METHOD2(SetDeviceConsent,
@@ -122,11 +124,11 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
MOCK_CONST_METHOD1(GetCachedDeviceConsent,
DeviceConsent(const std::string& device_id));
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
- MOCK_METHOD3(GetUserFriendlyMsg,
- std::vector<UserFriendlyMessage>(
- const std::vector<std::string>& msg_codes,
- const std::string& language,
- const std::string& active_hmi_language));
+ MOCK_CONST_METHOD3(GetUserFriendlyMsg,
+ std::vector<UserFriendlyMessage>(
+ const std::vector<std::string>& msg_codes,
+ const std::string& language,
+ const std::string& active_hmi_language));
MOCK_METHOD2(GetUpdateUrls,
void(const std::string& service_type,
EndpointUrls& out_end_points));
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index be346c49ff..309e357235 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -79,6 +79,8 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD1(KmsChanged, void(int kilometers));
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState,
const boost::optional<bool>());
+ MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage,
+ const boost::optional<std::string>(const std::string&));
MOCK_METHOD0(IncrementIgnitionCycles, void());
MOCK_METHOD0(ForcePTExchange, std::string());
MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index 13cc45cfe2..c296701e34 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -93,11 +93,13 @@ class MockCacheManagerInterface : public CacheManagerInterface {
const std::string& hybrid_app_preference));
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState,
const boost::optional<bool>());
+ MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage,
+ const boost::optional<std::string>(const std::string&));
MOCK_METHOD1(SetVINValue, bool(const std::string& value));
- MOCK_METHOD2(GetUserFriendlyMsg,
- std::vector<UserFriendlyMessage>(
- const std::vector<std::string>& msg_codes,
- const std::string& language));
+ MOCK_CONST_METHOD2(GetUserFriendlyMsg,
+ std::vector<UserFriendlyMessage>(
+ const std::vector<std::string>& msg_codes,
+ const std::string& language));
MOCK_CONST_METHOD2(
GetAppServiceParameters,
void(const std::string& policy_app_id,
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index c440c26208..a670e99bef 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -80,6 +80,8 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD1(KmsChanged, void(int kilometers));
MOCK_CONST_METHOD0(LockScreenDismissalEnabledState,
const boost::optional<bool>());
+ MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage,
+ const boost::optional<std::string>(const std::string&));
MOCK_METHOD0(IncrementIgnitionCycles, void());
MOCK_METHOD0(ForcePTExchange, std::string());
MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
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();
}