diff options
Diffstat (limited to 'src/components/policy/policy_regular')
6 files changed, 17 insertions, 80 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 d5155cf91b..f01d132049 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -68,13 +68,6 @@ struct CompareGroupName { }; /* - * @brief Used for compare of policies parameters mapped with specific - * application ids - */ -bool operator!=(const policy_table::ApplicationParams& first, - const policy_table::ApplicationParams& second); - -/* * @brief Helper struct for checking changes of application policies, which * come with update along with current data snapshot * In case of policies changed for some application, current data will be @@ -257,15 +250,6 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, const FunctionalGroupIDs& second); /** - * @brief Finds same values - * @param first First source of values - * @param second Second source of values - * @return Same values set, if any found - */ -FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, - const FunctionalGroupIDs& second); - -/** * @brief Unwrap application policies from predefined values to specific policy * values, i.e. if application has "default", it will be assigned default * policies 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 307697dd64..dff4802d82 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 @@ -869,7 +869,7 @@ class PolicyManagerImpl : public PolicyManager { void ResetTimeout() OVERRIDE; protected: -#ifdef USE_HMI_PTU_DECRYPTION +#if defined USE_HMI_PTU_DECRYPTION && defined PROPRIETARY_MODE /** * @brief Parse policy table content and convert to PT object * @param pt_content binary content of PT diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 5a75c47725..d031b5f027 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -79,7 +79,7 @@ SDL_CREATE_LOG_VARIABLE("Policy") } struct LanguageFinder { - LanguageFinder(const std::string& language) : language_(language) {} + explicit LanguageFinder(const std::string& language) : language_(language) {} bool operator()(const policy_table::Languages::value_type& lang) const { return !strcasecmp(language_.c_str(), lang.first.c_str()); } @@ -89,10 +89,12 @@ struct LanguageFinder { }; struct PolicyTableUpdater { - PolicyTableUpdater(const policy_table::ApplicationParams& default_params) + explicit PolicyTableUpdater( + const policy_table::ApplicationParams& default_params) : default_params_(default_params) {} - void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + void operator()( + policy_table::ApplicationPolicies::value_type& pt_value) const { if (policy::kDefaultId == pt_value.second.get_string()) { pt_value.second = default_params_; pt_value.second.set_to_string(policy::kDefaultId); @@ -1138,10 +1140,6 @@ bool CacheManager::GetPriority(const std::string& policy_app_id, void CacheManager::CheckSnapshotInitialization() { CACHE_MANAGER_CHECK_VOID(); - if (!snapshot_) { - SDL_LOG_ERROR("Snapshot pointer is not initialized"); - return; - } *(snapshot_->policy_table.module_config.preloaded_pt) = false; @@ -1309,8 +1307,6 @@ void CacheManager::PersistData() { copy_pt.policy_table.app_policies_section.apps.end(); bool is_revoked = false; - bool is_default_policy; - bool is_predata_policy; for (; app_policy_iter != app_policy_iter_end; ++app_policy_iter) { const std::string app_id = (*app_policy_iter).first; @@ -1321,7 +1317,7 @@ void CacheManager::PersistData() { copy_pt.policy_table.app_policies_section.apps[app_id].is_null(); } - is_default_policy = + bool is_default_policy = copy_pt.policy_table.app_policies_section.apps.end() != copy_pt.policy_table.app_policies_section.apps.find(app_id) && policy::kDefaultId == @@ -1329,7 +1325,7 @@ void CacheManager::PersistData() { .get_string(); // TODO(AOleynik): Remove this field from DB - is_predata_policy = + bool is_predata_policy = copy_pt.policy_table.app_policies_section.apps.end() != copy_pt.policy_table.app_policies_section.apps.find(app_id) && policy::kPreDataConsentId == diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index 7d99ff51c0..ec84486ea6 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -54,9 +54,10 @@ bool CompareStrings(const StringsValueType& first, } struct CheckGroupName { - CheckGroupName(const policy::StringsValueType& value) : value_(value) {} + explicit CheckGroupName(const policy::StringsValueType& value) + : value_(value) {} - bool operator()(const FunctionalGroupNames::value_type& value) { + bool operator()(const FunctionalGroupNames::value_type& value) const { return value.second.second == std::string(value_); } @@ -101,25 +102,6 @@ bool CompareGroupName::operator()( return !(strcasecmp(gn_.c_str(), gn_compare.c_str())); } -bool operator!=(const policy_table::ApplicationParams& first, - const policy_table::ApplicationParams& second) { - if (first.groups.size() != second.groups.size()) { - return true; - } - StringsConstItr it_first = first.groups.begin(); - StringsConstItr it_first_end = first.groups.end(); - StringsConstItr it_second = second.groups.begin(); - StringsConstItr it_second_end = second.groups.end(); - for (; it_first != it_first_end; ++it_first) { - CompareGroupName gp(*it_first); - StringsConstItr it = std::find_if(it_second, it_second_end, gp); - if (it_second_end == it) { - return true; - } - } - return false; -} - CheckAppPolicy::CheckAppPolicy( PolicyManagerImpl* pm, const std::shared_ptr<policy_table::Table> update, @@ -559,8 +541,7 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, return false; } - bool is_preconsented = false; - return it->second.user_consent_prompt.is_initialized() && !is_preconsented; + return it->second.user_consent_prompt.is_initialized(); } bool CheckAppPolicy::IsRequestTypeChanged( @@ -707,7 +688,7 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( return result; }; - auto get_app_rpcs = [](const std::string group_name, + auto get_app_rpcs = [](const std::string& group_name, const FunctionalGroupings& groups) -> rpc::Optional<policy_table::Rpcs> { auto it = groups.find(group_name); @@ -1106,28 +1087,6 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, return merged; } -FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, - const FunctionalGroupIDs& second) { - SDL_LOG_INFO("Find same groups"); - FunctionalGroupIDs first_copy(first); - FunctionalGroupIDs second_copy(second); - - std::sort(first_copy.begin(), first_copy.end()); - std::sort(second_copy.begin(), second_copy.end()); - - FunctionalGroupIDs same; - std::set_intersection(first_copy.begin(), - first_copy.end(), - second_copy.begin(), - second_copy.end(), - std::back_inserter(same)); - - same.resize( - std::distance(same.begin(), std::unique(same.begin(), same.end()))); - - return same; -} - bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) { policy_table::ApplicationPolicies::iterator it = app_policies.begin(); policy_table::ApplicationPolicies::iterator it_default = 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 36beeeb07f..6fbc4e798f 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -87,7 +87,7 @@ void PolicyManagerImpl::set_listener(PolicyListener* listener) { update_status_manager_.set_listener(listener); } -#ifdef USE_HMI_PTU_DECRYPTION +#if defined USE_HMI_PTU_DECRYPTION && defined PROPRIETARY_MODE std::shared_ptr<policy_table::Table> PolicyManagerImpl::Parse( const BinaryMessage& pt_content) { @@ -331,7 +331,7 @@ PolicyManager::PtProcessingResult PolicyManagerImpl::LoadPT( "PTU content is: " << std::string(pt_content.begin(), pt_content.end())); -#ifdef USE_HMI_PTU_DECRYPTION +#if defined USE_HMI_PTU_DECRYPTION && defined PROPRIETARY_MODE // Assuemes Policy Table was parsed, formatted, and/or decrypted by // the HMI after system request before calling OnReceivedPolicyUpdate // Parse message into table struct @@ -1708,7 +1708,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes( } struct HMITypeToInt { - int operator()(const policy_table::AppHMITypes::value_type item) { + int operator()(const policy_table::AppHMITypes::value_type item) const { return policy_table::AppHMIType(item); } }; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 49b7f2e7be..bf578aebe5 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -2770,9 +2770,7 @@ SQLPTRepresentation::SelectCompositeVehicleDataItems() const { if (!vdi.is_initialized()) { return policy_table::VehicleDataItems(); } - for (const auto& item : vdi) { - result.push_back(item); - } + std::copy(vdi.begin(), vdi.end(), std::back_inserter(result)); } return result; |