summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h3
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc20
-rw-r--r--src/components/policy/policy_regular/src/policy_helper.cc22
3 files changed, 39 insertions, 6 deletions
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h
index 996c2917d0..8a60801dd4 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -114,7 +114,8 @@ struct CheckAppPolicy {
const std::vector<FunctionalGroupPermission>& revoked_groups) const;
bool IsKnownAppication(const std::string& application_id) const;
void NotifySystem(const AppPoliciesValueType& app_policy) const;
- void SendPermissionsToApp(const AppPoliciesValueType& app_policy) const;
+ void SendPermissionsToApp(const std::string& app_id,
+ const policy_table::Strings& groups) const;
bool IsAppRevoked(const AppPoliciesValueType& app_policy) const;
bool NicknamesMatch(const AppPoliciesValueType& app_policy) const;
/**
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 98652656c3..12b29e0675 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -83,6 +83,21 @@ struct LanguageFinder {
const std::string& language_;
};
+struct PolicyTableUpdater {
+ PolicyTableUpdater(const policy_table::ApplicationParams& default_params)
+ : default_params_(default_params) {}
+
+ void operator()(policy_table::ApplicationPolicies::value_type& pt_value) {
+ if (policy::kDefaultId == pt_value.second.get_string()) {
+ pt_value.second = default_params_;
+ pt_value.second.set_to_string(policy::kDefaultId);
+ }
+ }
+
+ private:
+ const policy_table::ApplicationParams& default_params_;
+};
+
CacheManager::CacheManager()
: CacheManagerInterface()
, pt_(new policy_table::Table)
@@ -244,6 +259,11 @@ bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) {
"");
} else {
pt_->policy_table.app_policies_section.apps[iter->first] = iter->second;
+ if (kDefaultId == iter->first) {
+ std::for_each(pt_->policy_table.app_policies_section.apps.begin(),
+ pt_->policy_table.app_policies_section.apps.end(),
+ PolicyTableUpdater(iter->second));
+ }
}
}
diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc
index b72a041a83..782a65f91a 100644
--- a/src/components/policy/policy_regular/src/policy_helper.cc
+++ b/src/components/policy/policy_regular/src/policy_helper.cc
@@ -267,9 +267,7 @@ void policy::CheckAppPolicy::NotifySystem(
}
void CheckAppPolicy::SendPermissionsToApp(
- const AppPoliciesValueType& app_policy) const {
- const std::string app_id = app_policy.first;
-
+ const std::string& app_id, const policy_table::Strings& groups) const {
const std::string device_id = pm_->GetCurrentDeviceId(app_id);
if (device_id.empty()) {
LOG4CXX_WARN(logger_,
@@ -281,7 +279,7 @@ void CheckAppPolicy::SendPermissionsToApp(
Permissions notification_data;
pm_->PrepareNotificationData(update_->policy_table.functional_groupings,
- app_policy.second.groups,
+ groups,
group_permissons,
notification_data);
@@ -356,6 +354,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
"Permissions for application:" << app_id
<< " have been changed.");
+ if (IsPredefinedApp(app_policy)) {
+ for (const policy_table::ApplicationPolicies::value_type& app :
+ snapshot_->policy_table.app_policies_section.apps) {
+ if (app_policy.first == app.second.get_string()) {
+ if (RESULT_CONSENT_NOT_REQIURED != result) {
+ SetPendingPermissions(app, result);
+ NotifySystem(app);
+ }
+ SendPermissionsToApp(app.first, app_policy.second.groups);
+ }
+ }
+ return true;
+ }
+
if (!IsPredefinedApp(app_policy) && RESULT_CONSENT_NOT_REQIURED != result) {
SetPendingPermissions(app_policy, result);
NotifySystem(app_policy);
@@ -363,7 +375,7 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) {
// Don't sent notification for predefined apps (e.g. default, device etc.)
if (!IsPredefinedApp(app_policy)) {
- SendPermissionsToApp(app_policy);
+ SendPermissionsToApp(app_policy.first, app_policy.second.groups);
}
return true;
}