diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2018-10-02 13:24:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 13:24:11 -0400 |
commit | c25d70ca8aeb01eee1e736ee181b647d505494c4 (patch) | |
tree | b299e9f917cfb6eb65bb6bc6cbeade9ad85437d0 | |
parent | 85eac92a4b5c8bd9365385fea089583cad531576 (diff) | |
parent | b0f6c448a88daae21925d6f27fd9ec0708a5ca71 (diff) | |
download | sdl_core-c25d70ca8aeb01eee1e736ee181b647d505494c4.tar.gz |
Merge pull request #2644 from smartdevicelink/fix/apply_default_policies_on_ptu
Apply changes to default group on PTU to existing PT
-rw-r--r-- | src/components/policy/policy_external/src/cache_manager.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index e4a4151fa4..c2c2e91257 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -207,6 +207,21 @@ struct ExternalConsentConsentGroupAppender } }; +struct DefaultPolicyUpdater { + DefaultPolicyUpdater(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_; +}; + } // namespace namespace policy { @@ -681,6 +696,13 @@ void CacheManager::ProcessUpdate( initial_policy_iter->second; *(pt_->policy_table.app_policies_section.apps[app_id].RequestType) = merged_pt_request_types; + + if (app_id == kDefaultId) { + std::for_each(pt_->policy_table.app_policies_section.apps.begin(), + pt_->policy_table.app_policies_section.apps.end(), + DefaultPolicyUpdater( + pt_->policy_table.app_policies_section.apps[app_id])); + } } bool CacheManager::ApplyUpdate(const policy_table::Table& update_pt) { |