summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-11-21 13:42:08 -0500
committerGitHub <noreply@github.com>2018-11-21 13:42:08 -0500
commita751881e1f4e04a6af24552be70d691d8076c933 (patch)
tree59bff1fb166fa60b908aeb458365004dbc905af8 /src/components/policy/policy_regular
parent8c761e3fcaf4a7f052df405f129fedee7930258a (diff)
parentcfd35969fae824e1472b4ee064ea1c558afc4fb5 (diff)
downloadsdl_core-a751881e1f4e04a6af24552be70d691d8076c933.tar.gz
Merge pull request #2751 from smartdevicelink/feature/cloud_app_policies_initcloudapp
Initialize new Cloud App in Policies
Diffstat (limited to 'src/components/policy/policy_regular')
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h7
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc21
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc4
5 files changed, 48 insertions, 0 deletions
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 a4ae45d604..8c8f0c55c6 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -179,6 +179,14 @@ class CacheManager : public CacheManagerInterface {
std::string& hybrid_app_preference) const;
/**
+ * Initializes a new cloud application with default policies
+ * Then adds cloud specific policies
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual void InitCloudApp(const std::string& policy_app_id);
+
+ /**
* @brief Enable or disable a cloud application in the HMI
* @param enabled Cloud app enabled state
*/
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 f0ee9c2b25..50b546ecc5 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
@@ -185,6 +185,14 @@ class CacheManagerInterface {
std::string& hybrid_app_preference) const = 0;
/**
+ * Initializes a new cloud application with default policies
+ * Then adds cloud specific policies
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual void InitCloudApp(const std::string& policy_app_id) = 0;
+
+ /**
* @brief Enable or disable a cloud application in the HMI
* @param enabled Cloud app enabled state
*/
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 0a0c260a96..20a37717a7 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
@@ -597,6 +597,13 @@ class PolicyManagerImpl : public PolicyManager {
std::string& hybrid_app_preference) const OVERRIDE;
/**
+ * @ brief Initialize new cloud app in the policy table
+ * @ param policy_app_id Application ID
+ */
+
+ void InitCloudApp(const std::string& policy_app_id) OVERRIDE;
+
+ /**
* @brief Enable or disable a cloud application in the HMI
* @param enabled Cloud app enabled state
*/
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index c4b3d8db53..ca61a338f1 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -728,6 +728,27 @@ void CacheManager::GetCloudAppParameters(
}
}
+void CacheManager::InitCloudApp(const std::string& policy_app_id) {
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator default_iter =
+ policies.find(kDefaultId);
+ policy_table::ApplicationPolicies::const_iterator app_iter =
+ policies.find(policy_app_id);
+
+ if (default_iter != policies.end()) {
+ if (app_iter == policies.end()) {
+ policies[policy_app_id] = policies[kDefaultId];
+ }
+ }
+ // Add cloud app specific policies
+
+ Backup();
+}
+
void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id,
const bool enabled) {
policy_table::ApplicationPolicies& policies =
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 6e635b7f36..9b2392a015 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -566,6 +566,10 @@ void PolicyManagerImpl::GetCloudAppParameters(
hybrid_app_preference);
}
+void PolicyManagerImpl::InitCloudApp(const std::string& policy_app_id) {
+ cache_->InitCloudApp(policy_app_id);
+}
+
void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id,
const bool enabled) {
cache_->SetCloudAppEnabled(policy_app_id, enabled);