diff options
Diffstat (limited to 'src/components/policy')
12 files changed, 43 insertions, 168 deletions
diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index 69ba8806d4..87a9228c12 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -68,13 +68,6 @@ struct CompareGroupName { const StringsValueType& group_name_; }; -/* - * @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 @@ -393,15 +386,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_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 67d8bdb2d1..570246adb7 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -166,7 +166,8 @@ struct LinkCollector typedef std::vector<policy_table::UserConsentRecords::key_type> ApplicationsIds; - LinkCollector(std::map<std::string, std::string>& links) : links_(links) {} + explicit LinkCollector(std::map<std::string, std::string>& links) + : links_(links) {} void operator()(const policy_table::DeviceData::value_type& value) { using namespace policy_table; @@ -208,10 +209,12 @@ struct ExternalConsentConsentGroupAppender }; struct DefaultPolicyUpdater { - DefaultPolicyUpdater(const policy_table::ApplicationParams& default_params) + explicit DefaultPolicyUpdater( + 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); @@ -1704,6 +1707,8 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg( SDL_LOG_ERROR("No fallback language found for message code: " << *it); continue; } + // FIXME (VSemenyuk): message_string will always be overwritten by + // active_hmi_language_message_string message_string = fallback_message_string; } message_string = active_hmi_language_message_string; @@ -1827,10 +1832,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; @@ -2182,9 +2183,9 @@ int CacheManager::CountUnconsentedGroups(const std::string& policy_app_id, pt_->policy_table.app_policies_section; policy_table::Strings::iterator app_groups; - policy_table::Strings::iterator app_groups_end = app_groups; + policy_table::Strings::iterator app_groups_end; policy_table::Strings::iterator app_pre_groups; - policy_table::Strings::iterator app_pre_groups_end = app_pre_groups; + policy_table::Strings::iterator app_pre_groups_end; if (kDeviceId == policy_app_id) { app_groups = app_policies_section.device.groups.begin(); @@ -2294,11 +2295,10 @@ std::string CacheManager::GetCCPUVersionFromPT() const { bool CacheManager::IsMetaInfoPresent() const { CACHE_MANAGER_CHECK(false); - bool result = true; sync_primitives::AutoLock lock(cache_lock_); - result = NULL != pt_->policy_table.module_meta->ccpu_version && - NULL != pt_->policy_table.module_meta->wers_country_code && - NULL != pt_->policy_table.module_meta->language; + bool result = NULL != pt_->policy_table.module_meta->ccpu_version && + NULL != pt_->policy_table.module_meta->wers_country_code && + NULL != pt_->policy_table.module_meta->language; return result; } diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 4607c3ca5f..e6605aed3a 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -102,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, @@ -607,7 +588,6 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, return false; } - bool is_preconsented = false; policy_table::Strings::value_type str(group_name); policy_table::Strings::iterator pre_begin = update_->policy_table.app_policies_section.apps[app_id] @@ -618,7 +598,7 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, policy_table::Strings::iterator it2 = std::find(pre_begin, pre_end, str); - is_preconsented = pre_end != it2; + bool is_preconsented = pre_end != it2; return it->second.user_consent_prompt.is_initialized() && !is_preconsented; } @@ -768,7 +748,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); @@ -953,8 +933,7 @@ void FillNotificationData::UpdateParameters( // If 'parameters' section is omitted if (!in_parameters.is_initialized()) { - if (!does_require_user_consent_ || - (does_require_user_consent_ && kAllowedKey == current_key_)) { + if (!does_require_user_consent_ || kAllowedKey == current_key_) { out_parameter.any_parameter_allowed = true; } } @@ -1251,28 +1230,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_default = app_policies.find(kDefaultId); 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 773c689409..fc7fc0f171 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -62,7 +62,7 @@ namespace { struct GroupNamesAppender : public std::unary_function<void, const policy::FunctionalGroupPermission&> { - GroupNamesAppender(policy_table::Strings& names) : names_(names) {} + explicit GroupNamesAppender(policy_table::Strings& names) : names_(names) {} void operator()(const policy::FunctionalGroupPermission& value) { names_.push_back(value.group_name); @@ -1827,13 +1827,12 @@ bool PolicyManagerImpl::IsNeedToUpdateExternalConsentStatus( ItemV difference_v; difference_v.resize(new_status_v.size() + existing_status_v.size()); - ItemV::iterator ci = difference_v.begin(); - ci = std::set_difference(new_status_v.begin(), - new_status_v.end(), - existing_status_v.begin(), - existing_status_v.end(), - difference_v.begin(), - ConsentStatusComparatorFunc); + ItemV::iterator ci = std::set_difference(new_status_v.begin(), + new_status_v.end(), + existing_status_v.begin(), + existing_status_v.end(), + difference_v.begin(), + ConsentStatusComparatorFunc); difference_v.resize(ci - difference_v.begin()); return !difference_v.empty(); @@ -2386,7 +2385,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); } }; @@ -2587,6 +2586,7 @@ __attribute__((visibility("default"))) policy::PolicyManager* CreateManager( return new policy::PolicyManagerImpl(); } +// cppcheck-suppress unusedFunction __attribute__((visibility("default"))) void DeleteManager( policy::PolicyManager* pm) { delete pm; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 1f344f5263..0194ac68a3 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -872,7 +872,6 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {} void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { - exchange_after_x_days = from.exchange_after_x_days; exchange_after_x_kilometers = from.exchange_after_x_kilometers; exchange_after_x_days = from.exchange_after_x_days; exchange_after_x_ignition_cycles = from.exchange_after_x_ignition_cycles; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 36e363d922..fc9ebd96a9 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1750,9 +1750,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; 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; |