summaryrefslogtreecommitdiff
path: root/src/components/policy/include/policy
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2016-05-11 10:05:02 +0300
committerKozoriz <kozorizandriy@gmail.com>2016-05-17 16:34:03 +0300
commit9dba2aecd2a4c7b4054067deb413311c44c80cac (patch)
tree98a107e7f42a1b8979b8f0116a3368d2672f5744 /src/components/policy/include/policy
parentc238ca69b22082e6a35a0a515fb75ee35966a5d9 (diff)
downloadsdl_core-9dba2aecd2a4c7b4054067deb413311c44c80cac.tar.gz
Correct project structure in Policy component
FIles moved to correct directory CMakeLists files corrected Headers corrected
Diffstat (limited to 'src/components/policy/include/policy')
-rw-r--r--src/components/policy/include/policy/cache_manager.h768
-rw-r--r--src/components/policy/include/policy/cache_manager_interface.h631
-rw-r--r--src/components/policy/include/policy/policy_helper.h248
-rw-r--r--src/components/policy/include/policy/policy_listener.h103
-rw-r--r--src/components/policy/include/policy/policy_manager.h481
-rw-r--r--src/components/policy/include/policy/policy_manager_impl.h352
-rw-r--r--src/components/policy/include/policy/policy_table.h62
-rw-r--r--src/components/policy/include/policy/policy_table/enums.h113
-rw-r--r--src/components/policy/include/policy/policy_table/functions.h7
-rw-r--r--src/components/policy/include/policy/policy_table/types.h435
-rw-r--r--src/components/policy/include/policy/pt_ext_representation.h333
-rw-r--r--src/components/policy/include/policy/pt_representation.h324
-rw-r--r--src/components/policy/include/policy/sql_pt_ext_queries.h97
-rw-r--r--src/components/policy/include/policy/sql_pt_ext_representation.h205
-rw-r--r--src/components/policy/include/policy/sql_pt_queries.h121
-rw-r--r--src/components/policy/include/policy/sql_pt_representation.h203
-rw-r--r--src/components/policy/include/policy/sql_wrapper.h44
-rw-r--r--src/components/policy/include/policy/update_status_manager.h198
-rw-r--r--src/components/policy/include/policy/update_status_manager_interface.h107
-rw-r--r--src/components/policy/include/policy/usage_statistics/app_stopwatch.h50
-rw-r--r--src/components/policy/include/policy/usage_statistics/counter.h107
-rw-r--r--src/components/policy/include/policy/user_consent_manager.h44
22 files changed, 5033 insertions, 0 deletions
diff --git a/src/components/policy/include/policy/cache_manager.h b/src/components/policy/include/policy/cache_manager.h
new file mode 100644
index 0000000000..3a46d395f3
--- /dev/null
+++ b/src/components/policy/include/policy/cache_manager.h
@@ -0,0 +1,768 @@
+/*
+ * Copyright (c) 2014, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_CACHE_MANAGER_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_CACHE_MANAGER_H_
+
+#include <map>
+
+#include "utils/shared_ptr.h"
+#include "policy/pt_representation.h"
+#include "policy/pt_ext_representation.h"
+#include "policy/usage_statistics/statistics_manager.h"
+#include "policy/cache_manager_interface.h"
+#include "utils/threads/thread.h"
+#include "utils/threads/thread_delegate.h"
+
+#include "utils/lock.h"
+#include "utils/conditional_variable.h"
+#include "policy/policy_types.h"
+
+namespace policy {
+class PolicySettings;
+
+class CacheManager : public CacheManagerInterface {
+ public:
+ CacheManager();
+ ~CacheManager();
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @return CheckPermissionResult containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ virtual void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ CheckPermissionResult& result);
+
+ /**
+ * @brief Returns true if Policy Table was not updated yet
+ * from preloaded pt file.
+ */
+ virtual bool IsPTPreloaded();
+
+ /**
+ * Gets number of ignition cycles before next update policy table
+ * @return number of ignition cycles
+ */
+ virtual int IgnitionCyclesBeforeExchange();
+
+ /**
+ * Gets value in kilometers before next update policy table
+ * @param current value in kilometers from the odometers
+ * @return value in kilometers
+ */
+ virtual int KilometersBeforeExchange(int current);
+
+ /**
+ * @brief Sets counter value that passed for recieved successful PT UPdate
+ */
+ virtual bool SetCountersPassedForSuccessfulUpdate(Counters counter,
+ int value);
+
+ /**
+ * Gets value in days before next update policy table
+ * @param current value in days after epoch
+ * @return value in days
+ */
+ virtual int DaysBeforeExchange(int current);
+
+ /**
+ * @brief Increment number of ignition cycles since last exchange by 1
+ */
+ virtual void IncrementIgnitionCycles();
+
+ /**
+ * @brief Reset number of ignition cycles since last exchange to 0
+ */
+ virtual void ResetIgnitionCycles();
+
+ /**
+ * @brief Returns timeout to wait for a response of PT update
+ * @return value in seconds
+ */
+ virtual int TimeoutResponse();
+
+ /**
+ * @brief Returns number of seconds between each try of sending PTS
+ * @param seconds Return value: array of 5 elements
+ * @return bool Success of operation
+ */
+ virtual bool SecondsBetweenRetries(std::vector<int>& seconds);
+
+ /**
+ * @brief Get information about vehicle
+ */
+ virtual const VehicleInfo GetVehicleInfo() const;
+
+ /**
+ * @brief Allows to update 'vin' field in module_meta table.
+ *
+ * @param new 'vin' value.
+ *
+ * @return true in case when data has been successfully updated,
+ * false otherwise.
+ */
+ bool SetVINValue(const std::string& value);
+
+ /**
+ * @brief Get message text for displaying/pronouncing for user
+ * dependent on language and context.
+ * @param msg_codes Context of message (Driver distraction, Grant permission
+ * etc)
+ * @param language Language of the message
+ * @return Array of appropriate messages parameters
+ */
+ std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
+ const std::vector<std::string>& msg_codes, const std::string& language);
+
+ /**
+ * @brief Get list of URLs related to particular service
+ * @param service_type If URLs for specific service are preset,
+ * return them otherwise default URLs.
+ */
+ virtual void GetServiceUrls(const std::string& service_type,
+ EndpointUrls& end_points);
+
+ /**
+ * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ *
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ virtual std::string GetLockScreenIconUrl() const;
+
+ /**
+ * @brief Get allowed number of notifications
+ * depending on application priority.
+ * @param priority Priority of application
+ */
+ virtual rpc::policy_table_interface_base::NumberOfNotificationsType
+ GetNotificationsNumber(const std::string& priority);
+
+ /**
+ * @brief Get priority for given application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string& priority) const OVERRIDE;
+
+ /**
+ * @brief Initialized Policy Table (load)
+ * @return bool Success of operation
+ */
+ bool Init(const std::string& file_name, const PolicySettings* settings);
+
+ /**
+ * @brief Get snapshot of Policy Table
+ * including app_policies, functional_groups,
+ * device_info, statistics, excluding user messages
+ * @return Generated structure for obtaining Json string.
+ */
+ virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot();
+
+ /**
+ * Applies policy table to the current table
+ * @param update_pt policy table
+ * @return true if successfully
+ */
+ bool ApplyUpdate(const policy_table::Table& update_pt);
+
+ /**
+ * @brief Gets list of appHMIType associated with mobile appID
+ * @param container of appHMIType
+ */
+ virtual void GetHMIAppTypeAfterUpdate(
+ std::map<std::string, StringArray>& app_hmi_types);
+
+ /**
+ * Gets flag updateRequired
+ * @return true if update is required
+ */
+ bool UpdateRequired() const;
+
+ /**
+ * @brief Saves flag updateRequired
+ * @param status update status if true then update required.
+ */
+ void SaveUpdateRequired(bool status);
+
+ /**
+ * @brief GetInitialAppData Retrieves data from app_policies
+ * about app on its registration
+ * @param app_id id of registered app.
+ * All outputs are filled in only if not null
+ * @param nicknames Synonyms for application
+ * @param app_hmi_types app_types Section on HMI where app can
+ * appear (Navigation, Phone etc)
+ * @return true in case initial application data was obtained successfuly.
+ */
+ bool GetInitialAppData(const std::string& app_id,
+ StringArray& nicknames,
+ StringArray& app_hmi_types);
+
+ /**
+ * Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ bool IsApplicationRevoked(const std::string& app_id) const;
+
+ /**
+ * @brief Get functional groupings from DB
+ * @param groups Known functional groupings
+ * @return true, if succeeded, otherwise - false
+ */
+ bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
+
+ /**
+ * Checks if the application is represented in policy table
+ * @param app_id application id
+ * @return true if application is represented in policy table
+ */
+ bool IsApplicationRepresented(const std::string& app_id) const;
+
+ /**
+ * Checks if the application has default policy
+ * @param app_id application id
+ * @return true if application has default policy
+ */
+ bool IsDefaultPolicy(const std::string& app_id);
+
+ /**
+ * @brief SetIsDefault Sets is_default flag for application
+ * @param app_id app specific application
+ * @return true in case opperation was done successfully.
+ */
+ bool SetIsDefault(const std::string& app_id);
+
+ /**
+ * Checks if the application has pre_data policy
+ * @param app_id application id
+ * @return true if application has pre_data policy
+ */
+ bool IsPredataPolicy(const std::string& app_id);
+
+ /**
+ * Sets default policy for application
+ * @param app_id application id
+ * @return true if success
+ */
+ bool SetDefaultPolicy(const std::string& app_id);
+
+ /**
+ * @brief Is application allowed to send notifications while in
+ * Backgound or limited mode.
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ bool CanAppKeepContext(const std::string& app_id) const OVERRIDE;
+
+ /**
+ * @brief Is application allowed to move foreground at will?
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ bool CanAppStealFocus(const std::string& app_id) const;
+
+ /**
+ * @brief Gets default_hmi for given application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value was
+ * not set
+ * @return true, if succedeed, otherwise - false
+ */
+ bool GetDefaultHMI(const std::string& app_id, std::string& default_hmi) const;
+
+ /**
+ * @brief Reset user consent for device data and applications permissions
+ * @return
+ */
+ bool ResetUserConsent();
+
+ /**
+ * @brief Get user permissions for device data usage
+ * @param device_id Generated or obtained id of device
+ * @param consented_groups Groups consented by user
+ * @param disallowed_groups Groups not consented by user
+ * @return true, if query was successfull, otherwise - false
+ */
+ bool GetUserPermissionsForDevice(const std::string& device_id,
+ StringArray& consented_groups,
+ StringArray& disallowed_groups) const;
+
+ /**
+ * @brief Gets list of groups permissions from policy table
+ * @param device_id Unique device id, which hosts specific application
+ * @param policy_app_id Unique application id
+ * @param group_types Group list sorted by permission status
+ * @return true, if query was successfull, otherwise - false
+ */
+ bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types);
+
+ /**
+ * @brief Get device groups and preconsented groups from policies section
+ * @param groups List of groups to be consented for device usage
+ * @param preconsented_groups List of preconsented groups for device usage
+ * @return true, if query was successful, otherwise - false
+ */
+ bool GetDeviceGroupsFromPolicies(
+ rpc::policy_table_interface_base::Strings& groups,
+ rpc::policy_table_interface_base::Strings& preconsented_groups) const;
+
+ /**
+ * @brief Add's information about mobile device in Policy Table.
+ * @param device_id Generated or obtained id of device
+ * @param connection_type device connection type
+ * @return bool Success of operation
+ */
+ bool AddDevice(const std::string& device_id,
+ const std::string& connection_type);
+
+ /**
+ * @brief Record information about mobile device in Policy Table.
+ * @param device_id Generated or obtained id of device
+ * @return bool Success of operation
+ */
+ bool SetDeviceData(const std::string& device_id,
+ const std::string& hardware = "",
+ const std::string& firmware = "",
+ const std::string& os = "",
+ const std::string& os_version = "",
+ const std::string& carrier = "",
+ const uint32_t number_of_ports = 0,
+ const std::string& connection_type = "");
+
+ /**
+ * @brief Sets user consent for particular mobile device,
+ * i.e. to use device for exchanging of Policy Table.
+ * @return bool Success of operation
+ */
+ bool SetUserPermissionsForDevice(
+ const std::string& device_id,
+ const StringArray& consented_groups = StringArray(),
+ const StringArray& disallowed_groups = StringArray());
+
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ */
+ bool ReactOnUserDevConsentForApp(const std::string& app_id,
+ bool is_device_allowed);
+
+ /**
+ * @brief Set user consent on functional groups
+ * @param permissions User consent on functional group
+ * @return true, if operation succedeed, otherwise - false
+ */
+ bool SetUserPermissionsForApp(const PermissionConsent& permissions);
+
+ /**
+ * @brief Records information about head unit system to PT
+ * @return bool Success of operation
+ */
+ bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language);
+
+ /**
+ * @brief Checks, if specific head unit is present in PT
+ * @return boot Suceess, if present, otherwise - false
+ */
+ bool IsMetaInfoPresent() const;
+
+ /**
+ * @brief Set current system language
+ * @param language System language
+ * @return true, if succedeed, otherwise - false
+ */
+ bool SetSystemLanguage(const std::string& language);
+
+ /**
+ * Increments global counter
+ * @param type type of counter
+ */
+ void Increment(usage_statistics::GlobalCounterId type);
+
+ /**
+ * Increments counter of application
+ * @param app_id id application
+ * @param type type of counter
+ */
+ void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type);
+
+ /**
+ * Sets value of application information
+ * @param app_id id application
+ * @param type type of information
+ * @param value value of information
+ */
+ void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value);
+
+ /**
+ * Adds value to stopwatch of application
+ * @param app_id id application
+ * @param type type of stopwatch
+ * @param seconds value for adding in seconds
+ */
+ void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int seconds);
+
+ /**
+ * @brief CountUnconsentedGroups allows to obtain the count of unconsented
+ * groups for specific application.
+ * @param policy_app_id application id.
+ * @param device_id device id.
+ * @return the count of unconsented groups
+ */
+ int CountUnconsentedGroups(const std::string& policy_app_id,
+ const std::string& device_id);
+
+ /**
+ * @brief Gets functional group names and user_consent_prompts, if any
+ * @param Array to be filled with group ids, names and functional prompts
+ * @return true, if succeeded, otherwise - false
+ */
+ bool GetFunctionalGroupNames(FunctionalGroupNames& names);
+
+ /**
+ * @brief GetAllAppGroups allows to obtain all groups for certain application.
+ * @param app_id specific application id.
+ * @param all_group_ids parameter to fill.
+ */
+ void GetAllAppGroups(const std::string& app_id,
+ FunctionalGroupIDs& all_group_ids);
+ /**
+ * @brief GetPreConsentedGroups allows to obtain all pre-consented groups for
+ * specific application.
+ * @param app_id specific application id.
+ * @param preconsented_groups parameter to fill.
+ */
+ void GetPreConsentedGroups(const std::string& app_id,
+ FunctionalGroupIDs& preconsented_groups);
+ /**
+ * @brief GetConsentedGroups allows to obtain list of allowed and disallowed
+ * groups for specific application on certain device.
+ * @param device_id certain device
+ * @param app_id application id.
+ * @param allowed_groups list of allowed groups
+ * @param disallowed_groups list of disallowed groups
+ */
+ void GetConsentedGroups(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& allowed_groups,
+ FunctionalGroupIDs& disallowed_groups);
+
+ /**
+ * @brief GetUnconsentedGroups allows to obtain list of allowed and disallowed
+ * groups for specific application on certain device.
+ * @param device_id certain device
+ * @param policy_app_id application id.
+ * @param unconsented_groups list of unconsented groups.
+ */
+ void GetUnconsentedGroups(const std::string& device_id,
+ const std::string& policy_app_id,
+ FunctionalGroupIDs& unconsented_groups);
+
+ void RemoveAppConsentForGroup(const std::string& app_id,
+ const std::string& group_name);
+
+ /**
+ * @brief Set app policy to pre_DataConsented policy
+ * @param app_id Policy ID of application to be changed
+ * @return true, if succeeded, otherwise - false
+ */
+ bool SetPredataPolicy(const std::string& app_id);
+
+ /**
+ * @brief Removes unpaired devices
+ * @return true if success
+ */
+ bool CleanupUnpairedDevices();
+
+ /**
+ * Sets flag of unpaired device
+ * @param device_id Unique device id
+ * @param unpaired True, if should be marked as unpaired, otherwise - false
+ * @return true if success
+ */
+ bool SetUnpairedDevice(const std::string& device_id, bool unpaired = true);
+
+ /**
+ * Resets Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ bool ResetPT(const std::string& file_name);
+
+ /**
+ * @brief LoadFromBackup allows to load policy into the cache from backup.
+ * @return true in case operation was successful.
+ */
+ bool LoadFromBackup();
+
+ /**
+ * @brief LoadFromFile allows to load policy cache from preloaded table.
+ * @param file_name preloaded
+ * @return
+ */
+ bool LoadFromFile(const std::string& file_name, policy_table::Table& table);
+
+ /**
+ * @brief Backup allows to save cache onto hard drive.
+ */
+ void Backup();
+
+ /**
+ * Returns heart beat timeout
+ * @param app_id application id
+ * @return if timeout was set then value in milliseconds greater zero
+ * otherwise heart beat for specific application isn't set
+ */
+ uint32_t HeartBeatTimeout(const std::string& app_id) const;
+
+ /**
+ * @brief Allows to generate hash from the specified string.
+ * The djb2 algorithm uses for hash generation.
+ * @param str_to_hash - the string from which hash should be generated.
+ * @return integer hash for the specified string.
+ */
+ static int32_t GenerateHash(const std::string& str_to_hash);
+
+ /**
+ * @brief Gets request types for application
+ * @param policy_app_id Unique application id
+ * @param request_types Request types of application
+ */
+ void GetAppRequestTypes(const std::string& policy_app_id,
+ std::vector<std::string>& request_types) const;
+
+ /**
+ * @brief GetCertificate allows to obtain certificate in order to
+ * make secure connection
+ *
+ * @return The certificate in PKCS#7.
+ */
+ virtual std::string GetCertificate() const OVERRIDE;
+
+ /**
+ * @brief MergePreloadPT allows to load policy table from certain JSON file,
+ * and then decide if merge is needed. The merge is needed in case when
+ *preload
+ * JSON date is different than current database.
+ *
+ * @param file_name the preloaded policy table JSON file.
+ */
+ void MergePreloadPT(const std::string& file_name);
+
+ /**
+ * @brief MergeMC allows to merge ModuleConfig section by definite rules.
+ *
+ * The rules are:
+ * 1. Add new fields (known to PoliciesManager) & sub-sections if such are
+ * present in the updated Preloaded PT
+ * 2. "vehicle_make", “model”, “year” – leave the fields & values as they were
+ * in the database
+ * 3. For all other fields – overwrite the values with the new ones from
+ *preloaded PT.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database.
+ */
+ void MergeMC(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
+ /**
+ * @brief MergeFG allows to merge FunctionalGroupings sections by definite
+ *rules.
+ *
+ * The rules are:
+ * 1. If functional_group_name exists in both database (LocalPT) and updated
+ * PreloadedPT -> PoliciesManager must overwrite it (that is, replace such
+ * functional_group_name in the database by the one from Pre-PT).
+ * 2. If functional_group_name exists in updated PreloadedPT and does not
+ * exist in database (LocalPT), PoliciesManager must add such group to the
+ *database.
+ * 3. If functional_group_name does not exist in updated PreloadedPT and
+ * exists in the database (LocalPT), PoliciesManager must leave such group in
+ * the database without changes.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database.
+ */
+ void MergeFG(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
+ /**
+ * @brief MergeAP Allows to merge ApplicationPolicies section by definite
+ *relues.
+ * The rules are:
+ * 1. Leave “<appID>” sub-sections as they were in the database (fields &
+ *their values).
+ * 2. Over-write "default", "device", "pre_DataConsent" subsections.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database.
+ */
+ void MergeAP(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
+ /**
+ * @brief MergeCFM allows to merge ConsumerFriendlyMessages section by
+ *definite rules.
+ *
+ * The rules are:
+ * 1. If friendly_message_name exists in both database (LocalPT) and updated
+ * Preloaded PT -> PoliciesManager must overwrite it.
+ * 2. If friendly_message_name exists in updated Preloaded PT and does not
+ * exist in database (LocalPT), PoliciesManager must add such
+ * friendly_message_name to the database (LocalPT).
+ * 3. If friendly_message_name does not exist in updated Preloaded PT and
+ * exists in the database (LocalPT), PoliciesManager must leave such
+ * friendly_message_name in the database without changes.
+ *
+ * @param new_pt the policy table loaded from updated preload JSON file.
+ *
+ * @param pt the exists database
+ */
+ void MergeCFM(const policy_table::PolicyTable& new_pt,
+ policy_table::PolicyTable& pt);
+
+ const PolicySettings& get_settings() const;
+
+#ifdef BUILD_TESTS
+ utils::SharedPtr<policy_table::Table> GetPT() const {
+ return pt_;
+ }
+#endif
+
+ private:
+ std::string currentDateTime();
+ struct AppHMITypeToString {
+ std::string operator()(rpc::Enum<policy_table::AppHMIType> value) {
+ return std::string(policy_table::EnumToJsonString(value));
+ }
+ };
+
+ void GetGroupNameByHashID(const int32_t group_id, std::string& group_name);
+ void FillDeviceSpecificData();
+ bool AppExists(const std::string& app_id) const;
+ long ConvertSecondsToMinute(int seconds);
+
+ /**
+ * @brief Checks snapshot initialization and initializes to default values, if
+ * necessary
+ */
+ void CheckSnapshotInitialization();
+
+ void PersistData();
+
+ void ResetCalculatedPermissions();
+
+ void AddCalculatedPermissions(const std::string& device_id,
+ const std::string& policy_app_id,
+ const policy::Permissions& permissions);
+
+ bool IsPermissionsCalculated(const std::string& device_id,
+ const std::string& policy_app_id,
+ policy::Permissions& permission);
+
+ private:
+ /**
+ * @brief Checks, if input string is known service represented by number, than
+ * converts input string to service number
+ * @param input Input string
+ * @param output Output service
+ * @return true, if successfully converted, otherwise - false
+ */
+ bool IsNumberService(const std::string& input, std::string& output) const;
+
+ private:
+ utils::SharedPtr<policy_table::Table> pt_;
+ utils::SharedPtr<policy_table::Table> snapshot_;
+ utils::SharedPtr<PTRepresentation> backup_;
+ bool update_required;
+ typedef std::set<std::string> UnpairedDevices;
+ UnpairedDevices is_unpaired_;
+
+ sync_primitives::Lock cache_lock_;
+ sync_primitives::Lock unpaired_lock_;
+
+ typedef std::map<std::string, Permissions> AppCalculatedPermissions;
+ typedef std::map<std::string, AppCalculatedPermissions> CalculatedPermissions;
+ CalculatedPermissions calculated_permissions_;
+ sync_primitives::Lock calculated_permissions_lock_;
+
+ class BackgroundBackuper : public threads::ThreadDelegate {
+ friend class CacheManager;
+
+ public:
+ BackgroundBackuper(CacheManager* cache_manager);
+ ~BackgroundBackuper();
+ virtual void threadMain();
+ virtual void exitThreadMain();
+ void DoBackup();
+
+ private:
+ void InternalBackup();
+ CacheManager* cache_manager_;
+ sync_primitives::ConditionalVariable backup_notifier_;
+ volatile bool stop_flag_;
+ volatile bool new_data_available_;
+
+ sync_primitives::Lock need_backup_lock_;
+ DISALLOW_COPY_AND_ASSIGN(BackgroundBackuper);
+ };
+ threads::Thread* backup_thread_;
+ sync_primitives::Lock backuper_locker_;
+ BackgroundBackuper* backuper_;
+ const PolicySettings* settings_;
+};
+} // namespace policy
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_CACHE_MANAGER_H_
diff --git a/src/components/policy/include/policy/cache_manager_interface.h b/src/components/policy/include/policy/cache_manager_interface.h
new file mode 100644
index 0000000000..2b8a9fa101
--- /dev/null
+++ b/src/components/policy/include/policy/cache_manager_interface.h
@@ -0,0 +1,631 @@
+/*
+ * Copyright (c) 2014, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_CACHE_MANAGER_INTERFACE_H_
+#define SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_CACHE_MANAGER_INTERFACE_H_
+
+#include <string>
+#include <vector>
+
+#include "utils/shared_ptr.h"
+#include "policy/usage_statistics/counter.h"
+#include "policy/policy_types.h"
+#include "policy/policy_settings.h"
+
+namespace policy_table = rpc::policy_table_interface_base;
+
+namespace policy {
+
+class CacheManagerInterface {
+ public:
+ virtual ~CacheManagerInterface() {}
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @return CheckPermissionResult containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ virtual void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ CheckPermissionResult& result) = 0;
+
+ /**
+ * @brief Returns true if Policy Table was not updated yet
+ * from preloaded pt file.
+ */
+ virtual bool IsPTPreloaded() = 0;
+
+ /**
+ * Gets number of ignition cycles before next update policy table
+ * @return number of ignition cycles
+ */
+ virtual int IgnitionCyclesBeforeExchange() = 0;
+
+ /**
+ * Gets value in kilometers before next update policy table
+ * @param current value in kilometers from the odometers
+ * @return value in kilometers
+ */
+ virtual int KilometersBeforeExchange(int current) = 0;
+
+ /**
+ * @brief Sets counter value that passed for recieved successful PT UPdate
+ */
+ virtual bool SetCountersPassedForSuccessfulUpdate(Counters counter,
+ int value) = 0;
+
+ /**
+ * Gets value in days before next update policy table
+ * @param current value in days after epoch
+ * @return value in days
+ */
+ virtual int DaysBeforeExchange(int current) = 0;
+
+ /**
+ * @brief Increment number of ignition cycles since last exchange by 1
+ */
+ virtual void IncrementIgnitionCycles() = 0;
+
+ /**
+ * @brief Reset number of ignition cycles since last exchange to 0
+ */
+ virtual void ResetIgnitionCycles() = 0;
+
+ /**
+ * @brief Returns timeout to wait for a response of PT update
+ * @return value in seconds
+ */
+ virtual int TimeoutResponse() = 0;
+
+ /**
+ * @brief Returns number of seconds between each try of sending PTS
+ * @param seconds Return value: array of 5 elements
+ * @return bool Success of operation
+ */
+ virtual bool SecondsBetweenRetries(std::vector<int>& seconds) = 0;
+
+ /**
+ * @brief Get information about vehicle
+ */
+ virtual const VehicleInfo GetVehicleInfo() const = 0;
+
+ /**
+ * @brief Allows to update 'vin' field in module_meta table.
+ *
+ * @param new 'vin' value.
+ *
+ * @return true in case when data has been successfully updated,
+ * false otherwise.
+ */
+ virtual bool SetVINValue(const std::string& value) = 0;
+
+ /**
+ * @brief Get message text for displaying/pronouncing for user
+ * dependent on language and context.
+ * @param msg_codes Context of message (Driver distraction, Grant permission
+ * etc)
+ * @param language Language of the message
+ * @return Array of appropriate messages parameters
+ */
+ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
+ const std::vector<std::string>& msg_codes,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Get list of URLs related to particular service
+ * @param service_type If URLs for specific service are preset,
+ * return them otherwise default URLs.
+ */
+ virtual void GetServiceUrls(const std::string& service_type,
+ EndpointUrls& end_points) = 0;
+
+ /**
+ * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ *
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ virtual std::string GetLockScreenIconUrl() const = 0;
+
+ /**
+ * @brief Get allowed number of notifications
+ * depending on application priority.
+ * @param priority Priority of application
+ */
+ virtual policy_table::NumberOfNotificationsType GetNotificationsNumber(
+ const std::string& priority) = 0;
+
+ /**
+ * @brief Get priority for given application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string& priority) const = 0;
+
+ /**
+ * @brief Initialized Policy Table (load)
+ * @return bool Success of operation
+ */
+ virtual bool Init(const std::string& file_name,
+ const PolicySettings* settings) = 0;
+
+ /**
+ * @brief Get snapshot of Policy Table
+ * including app_policies, functional_groups,
+ * device_info, statistics, excluding user messages
+ * @return Generated structure for obtaining Json string.
+ */
+ virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() = 0;
+
+ /**
+ * Applies policy table to the current table
+ * @param update_pt policy table
+ * @return true if successfully
+ */
+ virtual bool ApplyUpdate(const policy_table::Table& update_pt) = 0;
+
+ /**
+ * @brief Gets list of appHMIType associated with mobile appID
+ * @param container of appHMIType
+ */
+ virtual void GetHMIAppTypeAfterUpdate(
+ std::map<std::string, StringArray>& app_hmi_types) = 0;
+
+ /**
+ * Gets flag updateRequired
+ * @return true if update is required
+ */
+ virtual bool UpdateRequired() const = 0;
+
+ /**
+ * @brief Saves flag updateRequired
+ * @param status update status if true then update required.
+ */
+ virtual void SaveUpdateRequired(bool status) = 0;
+
+ /**
+ * @brief GetInitialAppData Retrieves data from app_policies
+ * about app on its registration
+ * @param app_id id of registered app.
+ * All outputs are filled in only if not null
+ * @param nicknames Synonyms for application
+ * @param app_hmi_types app_types Section on HMI where app can
+ * appear (Navigation, Phone etc)
+ * @return true in case initial application data was obtained successfuly.
+ */
+ virtual bool GetInitialAppData(const std::string& app_id,
+ StringArray& nicknames,
+ StringArray& app_hmi_types) = 0;
+
+ /**
+ * Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Get functional groupings from DB
+ * @param groups Known functional groupings
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool GetFunctionalGroupings(
+ policy_table::FunctionalGroupings& groups) = 0;
+
+ /**
+ * Checks if the application is represented in policy table
+ * @param app_id application id
+ * @return true if application is represented in policy table
+ */
+ virtual bool IsApplicationRepresented(const std::string& app_id) const = 0;
+
+ /**
+ * Checks if the application has default policy
+ * @param app_id application id
+ * @return true if application has default policy
+ */
+ virtual bool IsDefaultPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief SetIsDefault Sets is_default flag for application
+ * @param app_id app specific application
+ * @return true in case opperation was done successfully.
+ */
+ virtual bool SetIsDefault(const std::string& app_id) = 0;
+
+ /**
+ * Checks if the application has pre_data policy
+ * @param app_id application id
+ * @return true if application has pre_data policy
+ */
+ virtual bool IsPredataPolicy(const std::string& app_id) = 0;
+
+ /**
+ * Sets default policy for application
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual bool SetDefaultPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief Is application allowed to send notifications while in
+ * Backgound or limited mode.
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ virtual bool CanAppKeepContext(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Is application allowed to move foreground at will?
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ virtual bool CanAppStealFocus(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Get default_hmi for given application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value was
+ * not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetDefaultHMI(const std::string& app_id,
+ std::string& default_hmi) const = 0;
+
+ /**
+ * @brief Reset user consent for device data and applications permissions
+ * @return
+ */
+ virtual bool ResetUserConsent() = 0;
+
+ /**
+ * @brief Get user permissions for device data usage
+ * @param device_id Generated or obtained id of device
+ * @param consented_groups Groups consented by user
+ * @param disallowed_groups Groups not consented by user
+ * @return true, if query was successfull, otherwise - false
+ */
+ virtual bool GetUserPermissionsForDevice(
+ const std::string& device_id,
+ StringArray& consented_groups,
+ StringArray& disallowed_groups) const = 0;
+
+ /**
+ * @brief Gets list of groups permissions from policy table
+ * @param device_id Unique device id, which hosts specific application
+ * @param policy_app_id Unique application id
+ * @param group_types Group list sorted by permission status
+ * @return true, if query was successfull, otherwise - false
+ */
+ virtual bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) = 0;
+
+ /**
+ * @brief Get device groups and preconsented groups from policies section
+ * @param groups List of groups to be consented for device usage
+ * @param preconsented_groups List of preconsented groups for device usage
+ * @return true, if query was successful, otherwise - false
+ */
+ virtual bool GetDeviceGroupsFromPolicies(
+ rpc::policy_table_interface_base::Strings& groups,
+ rpc::policy_table_interface_base::Strings& preconsented_groups) const = 0;
+
+ /**
+ * @brief Add's information about mobile device in Policy Table.
+ * @param device_id Generated or obtained id of device
+ * @param connection_type device connection type
+ * @return bool Success of operation
+ */
+ virtual bool AddDevice(const std::string& device_id,
+ const std::string& connection_type) = 0;
+
+ /**
+ * @brief Record information about mobile device in Policy Table.
+ * @param device_id Generated or obtained id of device
+ * @return bool Success of operation
+ */
+ virtual bool SetDeviceData(const std::string& device_id,
+ const std::string& hardware,
+ const std::string& firmware,
+ const std::string& os,
+ const std::string& os_version,
+ const std::string& carrier,
+ const uint32_t number_of_ports,
+ const std::string& connection_type) = 0;
+
+ /**
+ * @brief Sets user consent for particular mobile device,
+ * i.e. to use device for exchanging of Policy Table.
+ * @return bool Success of operation
+ */
+ virtual bool SetUserPermissionsForDevice(
+ const std::string& device_id,
+ const StringArray& consented_groups,
+ const StringArray& disallowed_groups) = 0;
+
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ */
+ virtual bool ReactOnUserDevConsentForApp(const std::string& app_id,
+ bool is_device_allowed) = 0;
+
+ /**
+ * @brief Set user consent on functional groups
+ * @param permissions User consent on functional group
+ * @return true, if operation succedeed, otherwise - false
+ */
+ virtual bool SetUserPermissionsForApp(
+ const PermissionConsent& permissions) = 0;
+
+ /**
+ * @brief Records information about head unit system to PT
+ * @return bool Success of operation
+ */
+ virtual bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Checks, if specific head unit is present in PT
+ * @return boot Suceess, if present, otherwise - false
+ */
+ virtual bool IsMetaInfoPresent() const = 0;
+
+ /**
+ * @brief Set current system language
+ * @param language System language
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool SetSystemLanguage(const std::string& language) = 0;
+
+ /**
+ * Increments global counter
+ * @param type type of counter
+ */
+ virtual void Increment(usage_statistics::GlobalCounterId type) = 0;
+
+ /**
+ * Increments counter of application
+ * @param app_id id application
+ * @param type type of counter
+ */
+ virtual void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type) = 0;
+
+ /**
+ * Sets value of application information
+ * @param app_id id application
+ * @param type type of information
+ * @param value value of information
+ */
+ virtual void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value) = 0;
+
+ /**
+ * Adds value to stopwatch of application
+ * @param app_id id application
+ * @param type type of stopwatch
+ * @param seconds value for adding in seconds
+ */
+ virtual void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int seconds) = 0;
+
+ /**
+ * @brief CountUnconsentedGroups allows to obtain the count of unconsented
+ * groups for specific application.
+ * @param policy_app_id application id.
+ * @param device_id device id.
+ * @param the count of unconsented groups
+ */
+ virtual int CountUnconsentedGroups(const std::string& policy_app_id,
+ const std::string& device_id) = 0;
+
+ /**
+ * @brief Gets functional group names and user_consent_prompts, if any
+ * @param Array to be filled with group ids, names and functional prompts
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool GetFunctionalGroupNames(FunctionalGroupNames& names) = 0;
+
+ /**
+ * @brief GetAllAppGroups allows to obtain all groups for certain application.
+ * @param app_id specific application id.
+ * @param all_group_ids parameter to fill.
+ */
+ virtual void GetAllAppGroups(const std::string& app_id,
+ FunctionalGroupIDs& all_group_ids) = 0;
+ /**
+ * @brief GetPreConsentedGroups allows to obtain all pre-consented groups for
+ * specific application.
+ * @param app_id specific application id.
+ * @param preconsented_groups parameter to fill.
+ */
+ virtual void GetPreConsentedGroups(
+ const std::string& app_id, FunctionalGroupIDs& preconsented_groups) = 0;
+ /**
+ * @brief GetConsentedGroups allows to obtain list of allowed and disallowed
+ * groups for specific application on certain device.
+ * @param device_id certain device
+ * @param app_id application id.
+ * @param allowed_groups list of allowed groups
+ * @param disallowed_groups list of disallowed groups
+ */
+ virtual void GetConsentedGroups(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& allowed_groups,
+ FunctionalGroupIDs& disallowed_groups) = 0;
+
+ /**
+ * @brief GetUnconsentedGroups allows to obtain list of allowed and disallowed
+ * groups for specific application on certain device.
+ * @param device_id certain device
+ * @param policy_app_id application id.
+ * @param unconsented_groups list of unconsented groups.
+ */
+ virtual void GetUnconsentedGroups(const std::string& device_id,
+ const std::string& policy_app_id,
+ FunctionalGroupIDs& unconsented_groups) = 0;
+
+ virtual void RemoveAppConsentForGroup(const std::string& app_id,
+ const std::string& group_name) = 0;
+
+ /**
+ * @brief Set app policy to pre_DataConsented policy
+ * @param app_id Policy ID of application to be changed
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool SetPredataPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief Removes unpaired devices
+ * @return true if success
+ */
+ virtual bool CleanupUnpairedDevices() = 0;
+
+ /**
+ * Sets flag of unpaired device
+ * @param device_id Unique device id
+ * @param unpaired True, if should be marked as unpaired, otherwise - false
+ * @return true if success
+ */
+ virtual bool SetUnpairedDevice(const std::string& device_id,
+ bool unpaired = true) = 0;
+
+ /**
+ * Resets Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ virtual bool ResetPT(const std::string& file_name) = 0;
+
+ /**
+ * @brief LoadFromBackup allows to load policy into the cache from backup.
+ * @return true in case operation was successful.
+ */
+ virtual bool LoadFromBackup() = 0;
+
+ /**
+ * @brief LoadFromFile allows to load policy cache from preloaded table.
+ * @param file_name preloaded
+ * @param table object which will be filled during file parsing.
+ * @return true in case file was successfuly loaded, false otherwise.
+ */
+ virtual bool LoadFromFile(const std::string& file_name,
+ policy_table::Table& table) = 0;
+
+ /**
+ * @brief Backup allows to save cache onto hard drive.
+ */
+ virtual void Backup() = 0;
+
+ /**
+ * Returns heart beat timeout
+ * @param app_id application id
+ * @return if timeout was set then value in milliseconds greater zero
+ * otherwise heart beat for specific application isn't set
+ */
+ virtual uint32_t HeartBeatTimeout(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Resets all calculated permissions in cache
+ */
+ virtual void ResetCalculatedPermissions() = 0;
+
+ /**
+ * @brief Adds calculated permissions for specific app on particular device
+ * into cache
+ * @param device_id Device id
+ * @param policy_app_id Application id
+ * @param permissions Calculated permissions
+ */
+ virtual void AddCalculatedPermissions(
+ const std::string& device_id,
+ const std::string& policy_app_id,
+ const policy::Permissions& permissions) = 0;
+
+ /**
+ * @brief Checks if permissions calculated for specific app on particular
+ * device
+ * @param device_id Device id
+ * @param policy_app_id Application id
+ * @param permission Permissions to be filled, in case of presence in cache
+ * @return true if present, otherwise false
+ */
+ virtual bool IsPermissionsCalculated(const std::string& device_id,
+ const std::string& policy_app_id,
+ policy::Permissions& permission) = 0;
+
+ /**
+ * @brief Gets request types for application
+ * @param policy_app_id Unique application id
+ * @param request_types Request types of application
+ */
+ virtual void GetAppRequestTypes(
+ const std::string& policy_app_id,
+ std::vector<std::string>& request_types) const = 0;
+
+ /**
+ * @brief GetCertificate allows to obtain certificate in order to
+ * make secure connection
+ *
+ * @return The certificate in PKCS#7.
+ */
+ virtual std::string GetCertificate() const = 0;
+
+#ifdef BUILD_TESTS
+ /**
+ * @brief GetPT allows to obtain SharedPtr to PT.
+ * Used ONLY in Unit tests
+ * @return SharedPTR to PT
+ *
+ */
+ virtual utils::SharedPtr<policy_table::Table> GetPT() const = 0;
+#endif
+};
+
+typedef utils::SharedPtr<CacheManagerInterface> CacheManagerInterfaceSPtr;
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_CACHE_MANAGER_INTERFACE_H_
diff --git a/src/components/policy/include/policy/policy_helper.h b/src/components/policy/include/policy/policy_helper.h
new file mode 100644
index 0000000000..746c5efeba
--- /dev/null
+++ b/src/components/policy/include/policy/policy_helper.h
@@ -0,0 +1,248 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_HELPER_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_HELPER_H_
+
+#include "policy/policy_table/functions.h"
+#include "utils/shared_ptr.h"
+#include "policy/policy_types.h"
+
+namespace policy {
+class PolicyManagerImpl;
+
+const std::string kAllowedKey = "allowed";
+const std::string kUserDisallowedKey = "userDisallowed";
+const std::string kUndefinedKey = "undefined";
+
+namespace policy_table = rpc::policy_table_interface_base;
+
+typedef policy_table::Strings::const_iterator StringsConstItr;
+typedef policy_table::ApplicationPolicies::const_iterator AppPoliciesConstItr;
+typedef policy_table::HmiLevels::const_iterator HMILevelsConstItr;
+typedef policy_table::Parameters::const_iterator ParametersConstItr;
+typedef policy_table::FunctionalGroupings::const_iterator FuncGroupConstItr;
+
+typedef policy_table::ApplicationPolicies::value_type AppPoliciesValueType;
+typedef policy_table::Rpc::value_type RpcValueType;
+typedef policy_table::Strings::value_type StringsValueType;
+
+/*
+ * @brief Helper struct to compare functional group names
+ */
+struct CompareGroupName {
+ explicit CompareGroupName(const StringsValueType& group_name);
+ bool operator()(const StringsValueType& group_name_to_compare) const;
+
+ private:
+ 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
+ * In case of policies changed for some application, current data will be
+ * updated and notification will be sent to application
+ */
+struct CheckAppPolicy {
+ CheckAppPolicy(PolicyManagerImpl* pm,
+ const utils::SharedPtr<policy_table::Table> update,
+ const utils::SharedPtr<policy_table::Table> snapshot);
+ bool operator()(const AppPoliciesValueType& app_policy);
+
+ private:
+ enum PermissionsCheckResult {
+ RESULT_NO_CHANGES,
+ RESULT_APP_REVOKED,
+ RESULT_NICKNAME_MISMATCH,
+ RESULT_PERMISSIONS_REVOKED,
+ RESULT_CONSENT_NEEDED,
+ RESULT_CONSENT_NOT_REQIURED,
+ RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
+ RESULT_REQUEST_TYPE_CHANGED
+ };
+
+ void SetPendingPermissions(const AppPoliciesValueType& app_policy,
+ PermissionsCheckResult result) const;
+ PermissionsCheckResult CheckPermissionsChanges(
+ const AppPoliciesValueType& app_policy) const;
+ bool HasRevokedGroups(const AppPoliciesValueType& app_policy,
+ policy_table::Strings* revoked_groups = NULL) const;
+ bool HasNewGroups(const AppPoliciesValueType& app_policy,
+ policy_table::Strings* new_groups = NULL) const;
+ bool HasConsentNeededGroups(const AppPoliciesValueType& app_policy) const;
+ std::vector<FunctionalGroupPermission> GetRevokedGroups(
+ const AppPoliciesValueType& app_policy) const;
+ void RemoveRevokedConsents(
+ const AppPoliciesValueType& app_policy,
+ 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;
+ bool IsAppRevoked(const AppPoliciesValueType& app_policy) const;
+ bool NicknamesMatch(const AppPoliciesValueType& app_policy) const;
+ /**
+ * @brief Allows to check if appropriate group requires any consent.
+ * @param group_name the group for which consent will be checked.
+ * @return true if consent is required, false otherwise.
+ */
+ bool IsConsentRequired(const std::string& app_id,
+ const std::string& group_name) const;
+ bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const;
+
+ private:
+ PolicyManagerImpl* pm_;
+ const utils::SharedPtr<policy_table::Table> update_;
+ const utils::SharedPtr<policy_table::Table> snapshot_;
+};
+
+/*
+ * @brief Fill permissions data with merged rpc permissions for hmi levels and
+ * parameters
+ */
+struct FillNotificationData {
+ FillNotificationData(Permissions& data,
+ GroupConsent group_state,
+ GroupConsent undefined_group_consent);
+ bool operator()(const RpcValueType& rpc);
+ void UpdateHMILevels(const policy_table::HmiLevels& in_hmi,
+ std::set<HMILevel>& out_hmi);
+ void UpdateParameters(const policy_table::Parameters& in_parameters,
+ std::set<Parameter>& out_parameter);
+
+ private:
+ void ExcludeSame();
+ void ExcludeSameHMILevels(std::set<HMILevel>& source,
+ const std::set<HMILevel>& target);
+ void ExcludeSameParameters(std::set<Parameter>& source,
+ const std::set<Parameter>& target);
+ void InitRpcKeys(const std::string& rpc_name);
+ std::string current_key_;
+ Permissions& data_;
+};
+
+/*
+ * @brief Checks for functional group presence and pass it to helper struct,
+ * which fills permissions data according to group consent
+ */
+struct ProcessFunctionalGroup {
+ ProcessFunctionalGroup(
+ const policy_table::FunctionalGroupings& fg,
+ const std::vector<FunctionalGroupPermission>& group_permissions,
+ Permissions& data,
+ GroupConsent undefined_group_consent = GroupConsent::kGroupDisallowed);
+ bool operator()(const StringsValueType& group_name);
+
+ private:
+ GroupConsent GetGroupState(const std::string& group_name);
+ const policy_table::FunctionalGroupings& fg_;
+ const std::vector<FunctionalGroupPermission>& group_permissions_;
+ Permissions& data_;
+ GroupConsent undefined_group_consent_;
+};
+
+struct FunctionalGroupInserter {
+ FunctionalGroupInserter(const policy_table::Strings& preconsented_groups,
+ PermissionsList& list);
+ void operator()(const StringsValueType& group_name);
+
+ private:
+ PermissionsList& list_;
+ const policy_table::Strings& preconsented_;
+};
+
+/**
+ * @brief Fills FunctionalGroupPermissions with provided params
+ * @param ids Functional group ids from DB
+ * @param names Group names and user_consent_prompt
+ * @param state User consent for group
+ * @param permissions Struct to be filled with provided params
+ */
+void FillFunctionalGroupPermissions(
+ FunctionalGroupIDs& ids,
+ FunctionalGroupNames& names,
+ GroupConsent state,
+ std::vector<FunctionalGroupPermission>& permissions);
+
+/**
+ * @brief Checks, if application is predefined, e.g. "default", i.e. which is
+ * must be present in policy table
+ * @param app Application struct
+ * @return true, if app is predefined, otherwise - false
+ */
+bool IsPredefinedApp(const AppPoliciesValueType& app);
+
+/**
+ * @brief Excludes same values
+ * @param from Source, which should be checked
+ * @param what Target, which should be excluded from source
+ * @return Values without excluded
+ */
+FunctionalGroupIDs ExcludeSame(const FunctionalGroupIDs& from,
+ const FunctionalGroupIDs& what);
+
+/**
+ * @brief Merges all values without same values
+ * @param first First source of values
+ * @param second Second source of values
+ * @return Merged values w/o same values
+ */
+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
+ * @param app_policies Application policies to unwrap
+ * @return true, if succeded, otherwise - false
+ */
+bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies);
+}
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_HELPER_H_
diff --git a/src/components/policy/include/policy/policy_listener.h b/src/components/policy/include/policy/policy_listener.h
new file mode 100644
index 0000000000..9592e6a712
--- /dev/null
+++ b/src/components/policy/include/policy/policy_listener.h
@@ -0,0 +1,103 @@
+/*
+ Copyright (c) 2016, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_LISTENER_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_LISTENER_H_
+
+#include <queue>
+
+#include "policy/policy_types.h"
+#include "utils/custom_string.h"
+
+namespace policy {
+
+namespace custom_str = utils::custom_string;
+
+class PolicyListener {
+ public:
+ virtual ~PolicyListener() {}
+ virtual void OnPermissionsUpdated(const std::string& policy_app_id,
+ const Permissions& permissions,
+ const policy::HMILevel& default_hmi) = 0;
+ virtual void OnPermissionsUpdated(const std::string& policy_app_id,
+ const Permissions& permissions) = 0;
+ virtual void OnPendingPermissionChange(const std::string& policy_app_id) = 0;
+ virtual void OnUpdateStatusChanged(const std::string&) = 0;
+ virtual std::string OnCurrentDeviceIdUpdateRequired(
+ const std::string& policy_app_id) = 0;
+ virtual void OnSystemInfoUpdateRequired() = 0;
+ virtual custom_str::CustomString GetAppName(
+ const std::string& policy_app_id) = 0;
+ virtual void OnUpdateHMIAppType(
+ std::map<std::string, StringArray> app_hmi_types) = 0;
+
+ /**
+ * @brief CanUpdate allows to find active application
+ * and check whether related device consented.
+ *
+ * @return true if there are at least one application has been registered
+ * with consented device.
+ */
+ virtual bool CanUpdate() = 0;
+
+ /**
+ * @brief OnSnapshotCreated the notification which will be sent
+ * when snapshot for PTU has been created.
+ *
+ * @param pt_string the snapshot
+ */
+ virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0;
+
+ /**
+ * @brief Make appropriate changes for related applications permissions and
+ * notify them, if it possible
+ * @param device_id Unique device id, which consent had been changed
+ * @param device_consent Device consent, which is done by user
+ */
+ virtual void OnDeviceConsentChanged(const std::string& device_id,
+ bool is_allowed) = 0;
+
+ /**
+ * @brief GetAvailableApps allows to obtain list of registered applications.
+ */
+ virtual void GetAvailableApps(std::queue<std::string>&) = 0;
+
+ /**
+ * @brief OnCertificateUpdated the callback which signals if certificate field
+ * has been updated during PTU
+ *
+ * @param certificate_data the value of the updated field.
+ */
+ virtual void OnCertificateUpdated(const std::string& certificate_data) = 0;
+};
+} // namespace policy
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_LISTENER_H_
diff --git a/src/components/policy/include/policy/policy_manager.h b/src/components/policy/include/policy/policy_manager.h
new file mode 100644
index 0000000000..70ec5d23a2
--- /dev/null
+++ b/src/components/policy/include/policy/policy_manager.h
@@ -0,0 +1,481 @@
+/*
+ Copyright (c) 2016, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_H_
+
+#include <vector>
+#include <cstdint>
+
+#include "policy/policy_types.h"
+#include "policy/policy_listener.h"
+#include "policy/usage_statistics/statistics_manager.h"
+
+namespace policy {
+class PolicySettings;
+
+class PolicyManager : public usage_statistics::StatisticsManager {
+ public:
+ virtual ~PolicyManager() {}
+
+ virtual void set_listener(PolicyListener* listener) = 0;
+
+ /**
+ * Inits Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ virtual bool InitPT(const std::string& file_name,
+ const PolicySettings* settings) = 0;
+
+ /**
+ * @brief Updates Policy Table from binary message received from
+ * mobile device. Saves to Policy Table diff between Policy Table
+ * sent in snapshot and received Policy Table.
+ * @param file name of file with update policy table
+ * @param pt_content PTU as binary string
+ * @return bool Success of operation
+ */
+ virtual bool LoadPT(const std::string& file,
+ const BinaryMessage& pt_content) = 0;
+
+ /**
+ * Resets Policy Table
+ * @param file_name Path to preloaded PT file
+ * @return true if successfully
+ */
+ virtual bool ResetPT(const std::string& file_name) = 0;
+
+ /**
+ * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ *
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ virtual std::string GetLockScreenIconUrl() const = 0;
+
+ /**
+ * @brief Gets all URLs for sending PTS to from PT itself.
+ * @param service_type Service specifies user of URL
+ * @return vector of urls
+ */
+ virtual void GetServiceUrls(const std::string& service_type,
+ EndpointUrls& end_points) = 0;
+
+ /**
+ * @brief PTU is needed, for this PTS has to be formed and sent.
+ */
+ virtual bool RequestPTUpdate() = 0;
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @param CheckPermissionResult containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ virtual void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ const RPCParams& rpc_params,
+ CheckPermissionResult& result) = 0;
+
+ /**
+ * @brief Clear all record of user consents. Used during Factory Reset.
+ * @return bool Success of operation
+ */
+ virtual bool ResetUserConsent() = 0;
+
+ /**
+ * @brief Returns current status of policy table for HMI
+ * @return Current status of policy table
+ */
+ virtual std::string GetPolicyTableStatus() const = 0;
+
+ /**
+ * Checks is PT exceeded kilometers
+ * @param kilometers current kilometers at odometer
+ * @return true if exceeded
+ */
+ virtual void KmsChanged(int kilometers) = 0;
+
+ /**
+ * Increments counter of ignition cycles
+ */
+ virtual void IncrementIgnitionCycles() = 0;
+
+ /**
+ * @brief ExchangeByUserRequest
+ */
+ virtual std::string ForcePTExchange() = 0;
+
+ /**
+ * Resets retry sequence
+ */
+ virtual void ResetRetrySequence() = 0;
+
+ /**
+ * Gets timeout to wait before next retry updating PT
+ * If timeout is equal to zero then the retry sequence is not need.
+ * @return timeout in seconds
+ */
+ virtual uint32_t NextRetryTimeout() = 0;
+
+ /**
+ * Gets timeout to wait until receive response
+ * @return timeout in seconds
+ */
+ virtual int TimeoutExchange() = 0;
+
+ /**
+ * @brief List of timeouts in seconds between retries
+ * when attempt to update PT fails
+ * @return List of delays between attempts.
+ */
+ virtual const std::vector<int> RetrySequenceDelaysSeconds() = 0;
+
+ /**
+ * Handler of exceeding timeout of exchanging policy table
+ */
+ virtual void OnExceededTimeout() = 0;
+
+ /**
+ * @brief Handler of PTS sending out
+ */
+ virtual void OnUpdateStarted() = 0;
+
+ /**
+ * @brief Check user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @return status of device consent
+ */
+ virtual DeviceConsent GetUserConsentForDevice(
+ const std::string& device_id) const = 0;
+
+ /**
+ * @brief Get user consent for application
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ virtual void GetUserConsentForApp(
+ const std::string& device_id,
+ const std::string& policy_app_id,
+ std::vector<FunctionalGroupPermission>& permissions) = 0;
+
+ /**
+ * @brief Set user consent for mobile device data connection
+ * @param device_id Unique device identifier
+ * @param is_allowed User consent for usage device data connection
+ */
+ virtual void SetUserConsentForDevice(const std::string& device_id,
+ bool is_allowed) = 0;
+
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ */
+ virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
+ bool is_device_allowed) = 0;
+ /**
+ * Sets counter value that passed for receiving PT UPdate.
+ */
+ virtual void PTUpdatedAt(Counters counter, int value) = 0;
+
+ /**
+ * @brief Retrieves data from app_policies about app on its registration:
+ * @param app_id - id of registered app
+ * @param app_types Section on HMI where app can appear (Navigation, Phone
+ * etc)
+ * @param nicknames Synonyms for application
+ */
+ virtual bool GetInitialAppData(const std::string& application_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_hmi_types = NULL) = 0;
+
+ /**
+ * @brief Add's device to policy table
+ * @param device_id Device mac address
+ * @param connection_type Device connection type
+ */
+ virtual void AddDevice(const std::string& device_id,
+ const std::string& connection_type) = 0;
+
+ /**
+ * @brief Stores device parameters received during application registration
+ * to policy table
+ * @param device_id Device mac address
+ * @param device_info Received device parameters
+ */
+ virtual void SetDeviceInfo(const std::string& device_id,
+ const DeviceInfo& device_info) = 0;
+
+ /**
+ * @brief Set user consent for application functional groups
+ * @param permissions User-defined application group pemissions.
+ * The permissions is not const reference because it may contains
+ * valid data as well as invalid. So we will remove all invalid data
+ * from this structure.
+ */
+ virtual void SetUserConsentForApp(const PermissionConsent& permissions) = 0;
+
+ /**
+ * @brief Get default HMI level for application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value
+ * was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetDefaultHmi(const std::string& policy_app_id,
+ std::string* default_hmi) const = 0;
+
+ /**
+ * @brief Get priority for application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) const = 0;
+
+ /**
+ * @brief Get user friendly messages for given RPC messages and language
+ * @param message_codes RPC message codes
+ * @param language Language
+ * @return Array of structs with appropriate message parameters
+ */
+ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
+ const std::vector<std::string>& message_code,
+ const std::string& language) = 0;
+
+ /**
+ * Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Get resulting RPCs permissions for application which started on
+ * specific device
+ * @param device_id Device id
+ * @param policy_app_id Unique application id
+ * @param permissions Array of functional groups permissions
+ */
+ virtual void GetPermissionsForApp(
+ const std::string& device_id,
+ const std::string& policy_app_id,
+ std::vector<FunctionalGroupPermission>& permissions) = 0;
+
+ /**
+ * @brief Gets specific application permissions changes since last policy
+ * table update
+ * @param policy_app_id Unique application id
+ * @return Permissions changes
+ */
+ virtual AppPermissions GetAppPermissionsChanges(
+ const std::string& policy_app_id) = 0;
+
+ virtual void RemovePendingPermissionChanges(const std::string& app_id) = 0;
+
+ /**
+ * @brief Return device id, which hosts specific application
+ * @param Application id, which is required to update device id
+ */
+ virtual std::string& GetCurrentDeviceId(
+ const std::string& policy_app_id) const = 0;
+
+ /**
+ * @brief Set current system language
+ * @param language Language
+ */
+ virtual void SetSystemLanguage(const std::string& language) = 0;
+
+ /**
+ * @brief Set data from GetSystemInfo response to policy table
+ * @param ccpu_version CCPU version
+ * @param wers_country_code WERS country code
+ * @param language System language
+ */
+ virtual void SetSystemInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Send OnPermissionsUpdated for choosen application
+ * @param application_id
+ */
+ virtual void SendNotificationOnPermissionsUpdated(
+ const std::string& application_id) = 0;
+
+ /**
+ * Marks device as upaired
+ * @param device_id id device
+ */
+ virtual void MarkUnpairedDevice(const std::string& device_id) = 0;
+
+ /**
+ * @brief Adds, application to the db or update existed one
+ * run PTU if policy update is necessary for application.
+ * @param Application id assigned by Ford to the application
+ */
+ virtual void AddApplication(const std::string& application_id) = 0;
+
+ /**
+ * @brief Removes unpaired device records and related records from DB
+ * @param device_ids List of device_id, which should be removed
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool CleanupUnpairedDevices() = 0;
+
+ /**
+ * @brief Check if app can keep context.
+ */
+ virtual bool CanAppKeepContext(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Check if app can steal focus.
+ */
+ virtual bool CanAppStealFocus(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Runs necessary operations, which is depends on external system
+ * state, e.g. getting system-specific parameters which are need to be
+ * filled into policy table
+ */
+ virtual void OnSystemReady() = 0;
+
+ /**
+ * @brief GetNotificationNumber
+ * @param priority
+ * @return
+ */
+ virtual uint32_t GetNotificationsNumber(
+ const std::string& priority) const = 0;
+
+ /**
+ * @brief Allows to update Vehicle Identification Number in policy table.
+ * @param new value for the parameter.
+ */
+ virtual void SetVINValue(const std::string& value) = 0;
+
+ /**
+ * @brief Checks, if application has policy assigned w/o data consent
+ * @param policy_app_id Unique application id
+ * @return true, if policy assigned w/o data consent, otherwise -false
+ */
+ virtual bool IsPredataPolicy(const std::string& policy_app_id) = 0;
+
+ /**
+ * Returns heart beat timeout
+ * @param app_id application id
+ * @return if timeout was set then value in milliseconds greater zero
+ * otherwise heart beat for specific application isn't set
+ */
+ virtual uint32_t HeartBeatTimeout(const std::string& app_id) const = 0;
+
+ /**
+ * @brief SaveUpdateStatusRequired alows to save update status.
+ */
+ virtual void SaveUpdateStatusRequired(bool is_update_needed) = 0;
+
+ /**
+ * @brief Handler on applications search started
+ */
+ virtual void OnAppsSearchStarted() = 0;
+
+ /**
+ * @brief Handler on applications search completed
+ */
+ virtual void OnAppsSearchCompleted() = 0;
+ /**
+ * @brief Gets request types for application
+ * @param policy_app_id Unique application id
+ * @return request_types Request types of application
+ */
+ virtual const std::vector<std::string> GetAppRequestTypes(
+ const std::string policy_app_id) const = 0;
+
+ /**
+ * @brief Get information about vehicle
+ */
+ virtual const VehicleInfo GetVehicleInfo() const = 0;
+
+ /**
+ * @brief OnAppRegisteredOnMobile alows to handle event when application were
+ * succesfully registered on mobile device.
+ * It will send OnAppPermissionSend notification and will try to start PTU.
+ *
+ * @param application_id registered application.
+ */
+ virtual void OnAppRegisteredOnMobile(const std::string& application_id) = 0;
+
+ /**
+ * @brief RetrieveCertificate Allows to obtain certificate in order
+ * to start secure connection.
+ *
+ * @return The certificate in PKCS#7 format.
+ */
+ virtual std::string RetrieveCertificate() const = 0;
+
+ virtual const PolicySettings& get_settings() const = 0;
+
+ protected:
+ /**
+ * Checks is PT exceeded IgnitionCycles
+ * @return true if exceeded
+ */
+ virtual bool ExceededIgnitionCycles() = 0;
+
+ /**
+ * Checks is PT exceeded days
+ * @return true if exceeded
+ */
+ virtual bool ExceededDays() = 0;
+
+ /**
+ * @brief StartPTExchange allows to start PTU. The function will check
+ * if one is required and starts the update flow in only case when previous
+ * condition is true.
+ */
+ virtual void StartPTExchange() = 0;
+};
+
+} // namespace policy
+
+extern "C" policy::PolicyManager* CreateManager();
+extern "C" void DeleteManager(policy::PolicyManager*);
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_H_
diff --git a/src/components/policy/include/policy/policy_manager_impl.h b/src/components/policy/include/policy/policy_manager_impl.h
new file mode 100644
index 0000000000..66a96bf7a7
--- /dev/null
+++ b/src/components/policy/include/policy/policy_manager_impl.h
@@ -0,0 +1,352 @@
+/*
+ Copyright (c) 2016, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
+
+#include <string>
+#include <list>
+#include <cstdint>
+
+#include "utils/shared_ptr.h"
+#include "utils/lock.h"
+#include "policy/policy_manager.h"
+#include "policy/policy_table.h"
+#include "policy/cache_manager_interface.h"
+#include "policy/update_status_manager.h"
+#include "policy/policy_table/functions.h"
+#include "policy/usage_statistics/statistics_manager.h"
+#include "policy/policy_helper.h"
+#include "utils/timer.h"
+
+namespace policy_table = rpc::policy_table_interface_base;
+
+namespace policy {
+struct CheckAppPolicy;
+
+class PolicyManagerImpl : public PolicyManager {
+ public:
+ PolicyManagerImpl();
+ virtual void set_listener(PolicyListener* listener);
+ PolicyListener* listener() const {
+ return listener_;
+ }
+ virtual bool InitPT(const std::string& file_name,
+ const PolicySettings* settings);
+ virtual bool LoadPT(const std::string& file, const BinaryMessage& pt_content);
+ virtual bool ResetPT(const std::string& file_name);
+
+ virtual void GetServiceUrls(const std::string& service_type,
+ EndpointUrls& end_points);
+
+ virtual std::string GetLockScreenIconUrl() const;
+ virtual bool RequestPTUpdate();
+ virtual void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ const RPCParams& rpc_params,
+ CheckPermissionResult& result);
+ virtual bool ResetUserConsent();
+ virtual void KmsChanged(int kilometers);
+ virtual void IncrementIgnitionCycles();
+ virtual std::string ForcePTExchange();
+ virtual std::string GetPolicyTableStatus() const;
+ virtual void ResetRetrySequence();
+ virtual uint32_t NextRetryTimeout();
+ virtual int TimeoutExchange();
+ virtual const std::vector<int> RetrySequenceDelaysSeconds();
+ virtual void OnExceededTimeout();
+ virtual void OnUpdateStarted();
+ virtual void PTUpdatedAt(Counters counter, int value);
+
+ /**
+ * Refresh data about retry sequence from policy table
+ */
+ virtual void RefreshRetrySequence();
+ virtual DeviceConsent GetUserConsentForDevice(
+ const std::string& device_id) const OVERRIDE;
+ virtual void GetUserConsentForApp(
+ const std::string& device_id,
+ const std::string& policy_app_id,
+ std::vector<FunctionalGroupPermission>& permissions);
+ virtual void SetUserConsentForDevice(const std::string& device_id,
+ bool is_allowed);
+ virtual bool ReactOnUserDevConsentForApp(const std::string app_id,
+ bool is_device_allowed);
+ virtual bool GetInitialAppData(const std::string& application_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_hmi_types = NULL);
+
+ virtual void AddDevice(const std::string& device_id,
+ const std::string& connection_type);
+
+ virtual void SetDeviceInfo(const std::string& device_id,
+ const DeviceInfo& device_info);
+
+ virtual void SetUserConsentForApp(const PermissionConsent& permissions);
+
+ virtual bool GetDefaultHmi(const std::string& policy_app_id,
+ std::string* default_hmi) const;
+
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) const;
+
+ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMessages(
+ const std::vector<std::string>& message_code,
+ const std::string& language);
+
+ virtual bool IsApplicationRevoked(const std::string& app_id) const;
+
+ virtual void GetPermissionsForApp(
+ const std::string& device_id,
+ const std::string& policy_app_id,
+ std::vector<FunctionalGroupPermission>& permissions);
+
+ virtual std::string& GetCurrentDeviceId(
+ const std::string& policy_app_id) const;
+
+ virtual void SetSystemLanguage(const std::string& language);
+
+ virtual void SetSystemInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language);
+ virtual void OnSystemReady();
+
+ virtual uint32_t GetNotificationsNumber(
+ const std::string& priority) const OVERRIDE;
+
+ virtual void SetVINValue(const std::string& value);
+
+ // Interface StatisticsManager (begin)
+ virtual void Increment(usage_statistics::GlobalCounterId type);
+ virtual void Increment(const std::string& app_id,
+ usage_statistics::AppCounterId type);
+ virtual void Set(const std::string& app_id,
+ usage_statistics::AppInfoId type,
+ const std::string& value);
+ virtual void Add(const std::string& app_id,
+ usage_statistics::AppStopwatchId type,
+ int32_t timespan_seconds);
+ // Interface StatisticsManager (end)
+
+ AppPermissions GetAppPermissionsChanges(const std::string& policy_app_id);
+ void RemovePendingPermissionChanges(const std::string& app_id);
+
+ void SendNotificationOnPermissionsUpdated(const std::string& application_id);
+
+ bool CleanupUnpairedDevices();
+
+ bool CanAppKeepContext(const std::string& app_id) const;
+ bool CanAppStealFocus(const std::string& app_id) const;
+ void MarkUnpairedDevice(const std::string& device_id);
+
+ void AddApplication(const std::string& application_id);
+
+ virtual void RemoveAppConsentForGroup(const std::string& app_id,
+ const std::string& group_name);
+
+ virtual uint32_t HeartBeatTimeout(const std::string& app_id) const;
+
+ virtual void SaveUpdateStatusRequired(bool is_update_needed);
+
+ virtual bool IsPredataPolicy(const std::string& policy_app_id);
+ void set_cache_manager(CacheManagerInterface* cache_manager);
+
+ virtual void OnAppsSearchStarted();
+
+ virtual void OnAppsSearchCompleted();
+
+#ifdef BUILD_TESTS
+ inline CacheManagerInterfaceSPtr GetCache() {
+ return cache_;
+ }
+#endif // BUILD_TESTS
+ virtual const std::vector<std::string> GetAppRequestTypes(
+ const std::string policy_app_id) const;
+
+ virtual const VehicleInfo GetVehicleInfo() const;
+
+ virtual void OnAppRegisteredOnMobile(
+ const std::string& application_id) OVERRIDE;
+
+ virtual std::string RetrieveCertificate() const OVERRIDE;
+
+ protected:
+#ifdef USE_HMI_PTU_DECRYPTION
+ virtual utils::SharedPtr<policy_table::Table> Parse(
+ const BinaryMessage& pt_content);
+#else
+ virtual utils::SharedPtr<policy_table::Table> ParseArray(
+ const BinaryMessage& pt_content);
+#endif
+
+ const PolicySettings& get_settings() const OVERRIDE;
+
+ private:
+ void CheckTriggers();
+ /*
+ * @brief Checks policy table update along with current data for any changes
+ * in assigned functional group list of application
+ *
+ * @param Policy table update struct
+ */
+ void CheckPermissionsChanges(
+ const utils::SharedPtr<policy_table::Table> update,
+ const utils::SharedPtr<policy_table::Table> snapshot);
+
+ /**
+ * @brief Fill structure to be sent with OnPermissionsChanged notification
+ *
+ * @param Policy table struct, which contains rpc functional groups data
+ * @param List of rpc functional group names, which should be checked
+ * @param group_permission User permissions for functional groups
+ * @param Notification struct to be filled and sent
+ */
+ void PrepareNotificationData(
+ const policy_table::FunctionalGroupings& groups,
+ const policy_table::Strings& group_names,
+ const std::vector<FunctionalGroupPermission>& group_permission,
+ Permissions& notification_data);
+
+ /**
+ * @brief Validate PermissionConsent structure according to currently
+ * assigned groups
+ * @param permissions PermissionConsent structure that should be validated.
+ * @return PermissonConsent struct, which contains no foreign groups
+ */
+ PermissionConsent EnsureCorrectPermissionConsent(
+ const PermissionConsent& permissions_to_check);
+
+ /**
+ * @brief Allows to process case when added application is not present in
+ * policy db.
+ * @param policy application id.
+ * @param cuuren consent for application's device.
+ */
+ void AddNewApplication(const std::string& application_id,
+ DeviceConsent device_consent);
+
+ /**
+ * @brief Allows to process case when added application is already
+ * in policy db.
+ * @param policy application id.
+ * @param cuuren consent for application's device.
+ */
+ void PromoteExistedApplication(const std::string& application_id,
+ DeviceConsent device_consent);
+
+ /**
+ * @brief Check if certain application already in policy db.
+ * @param policy application id.
+ * @return true if application presents false otherwise.
+ */
+ bool IsNewApplication(const std::string& application_id) const;
+
+ /**
+ * Checks existing and permissions of AppStorageFolder
+ * @return true if AppStorageFolder exists and has permissions read/write
+ */
+ bool CheckAppStorageFolder() const;
+
+ /**
+ * @brief Checks whether need ask the permission of users
+ * @return true if user consent is needed
+ */
+ virtual bool IsConsentNeeded(const std::string& app_id);
+
+ /**
+ * @brief Changes isConsentNeeded for app pending permissions, in case
+ * user set permissions before app activation.
+ * @param Unique app id
+ * @param Current permissions for app
+ */
+ void CheckPendingPermissionsChanges(
+ const std::string& policy_app_id,
+ const std::vector<FunctionalGroupPermission>& current_permissions);
+
+ virtual void StartPTExchange();
+ virtual bool ExceededDays();
+ virtual bool ExceededIgnitionCycles();
+ bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table,
+ policy_table::PolicyTableType type) const;
+
+ void RetrySequence();
+
+ private:
+ PolicyListener* listener_;
+
+ UpdateStatusManager update_status_manager_;
+ CacheManagerInterfaceSPtr cache_;
+ sync_primitives::Lock apps_registration_lock_;
+ sync_primitives::Lock app_permissions_diff_lock_;
+ std::map<std::string, AppPermissions> app_permissions_diff_;
+
+ /**
+ * Timeout to wait response with UpdatePT
+ */
+ uint32_t retry_sequence_timeout_;
+
+ /**
+ * Seconds between retries to update PT
+ */
+ std::vector<int> retry_sequence_seconds_;
+
+ /**
+ * Current index trying of retry sequence
+ */
+ uint32_t retry_sequence_index_;
+
+ /**
+ * Lock for guarding retry sequence
+ */
+ sync_primitives::Lock retry_sequence_lock_;
+
+ /**
+ * Timer to retry UpdatePT
+ */
+ timer::Timer timer_retry_sequence_;
+
+ /**
+ * @brief Device id, which is used during PTU handling for specific
+ * application
+ */
+ mutable std::string last_device_id_;
+
+ bool ignition_check;
+
+ const PolicySettings* settings_;
+ friend struct CheckAppPolicy;
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_MANAGER_IMPL_H_
diff --git a/src/components/policy/include/policy/policy_table.h b/src/components/policy/include/policy/policy_table.h
new file mode 100644
index 0000000000..fdd4c9c2fc
--- /dev/null
+++ b/src/components/policy/include/policy/policy_table.h
@@ -0,0 +1,62 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TABLE_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TABLE_H_
+
+#include "utils/shared_ptr.h"
+#include "policy/pt_representation.h"
+#include "policy/pt_ext_representation.h"
+
+namespace policy {
+
+class PolicyTable {
+ public:
+ PolicyTable();
+ explicit PolicyTable(utils::SharedPtr<PTRepresentation> pt_data);
+ virtual ~PolicyTable();
+
+ /**
+ * @brief Returns current implementation of
+ * actual class storing policy table.
+ * @return PTRepresentation* Policy Table Content Handler
+ */
+ utils::SharedPtr<PTRepresentation> pt_data() const {
+ return pt_data_;
+ }
+
+ private:
+ utils::SharedPtr<PTRepresentation> pt_data_;
+};
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TABLE_H_
diff --git a/src/components/policy/include/policy/policy_table/enums.h b/src/components/policy/include/policy/policy_table/enums.h
new file mode 100644
index 0000000000..523c2e9d04
--- /dev/null
+++ b/src/components/policy/include/policy/policy_table/enums.h
@@ -0,0 +1,113 @@
+// This file is generated, do not edit
+#ifndef POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_ENUMS_H_
+#define POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_ENUMS_H_
+#include <string>
+
+namespace rpc {
+namespace policy_table_interface_base {
+
+enum Priority {
+ P_EMERGENCY,
+ P_NAVIGATION,
+ P_VOICECOM,
+ P_COMMUNICATION,
+ P_NORMAL,
+ P_NONE,
+};
+
+bool IsValidEnum(Priority val);
+const char* EnumToJsonString(Priority val);
+bool EnumFromJsonString(const std::string& literal, Priority* result);
+
+enum HmiLevel {
+ HL_BACKGROUND,
+ HL_FULL,
+ HL_LIMITED,
+ HL_NONE,
+};
+bool IsValidEnum(HmiLevel val);
+const char* EnumToJsonString(HmiLevel val);
+bool EnumFromJsonString(const std::string& literal, HmiLevel* result);
+
+enum Parameter {
+ P_GPS,
+ P_SPEED,
+ P_ENGINETORQUE,
+ P_EXTERNALTEMPERATURE,
+ P_FUELLEVEL,
+ P_FUELLEVEL_STATE,
+ P_HEADLAMPSTATUS,
+ P_INSTANTFUELCONSUMPTION,
+ P_ODOMETER,
+ P_TIREPRESSURE,
+ P_WIPERSTATUS,
+ P_VIN,
+ P_ACCPEDALPOSITION,
+ P_BELTSTATUS,
+ P_DRIVERBRAKING,
+ P_PRNDL,
+ P_RPM,
+ P_STEERINGWHEELANGLE,
+ P_MYKEY,
+ P_AIRBAGSTATUS,
+ P_BODYINFORMATION,
+ P_CLUSTERMODESTATUS,
+ P_DEVICESTATUS,
+ P_EMERGENCYEVENT,
+ P_ECALLINFO,
+};
+bool IsValidEnum(Parameter val);
+const char* EnumToJsonString(Parameter val);
+bool EnumFromJsonString(const std::string& literal, Parameter* result);
+
+enum AppHMIType {
+ AHT_DEFAULT,
+ AHT_COMMUNICATION,
+ AHT_MEDIA,
+ AHT_MESSAGING,
+ AHT_NAVIGATION,
+ AHT_INFORMATION,
+ AHT_SOCIAL,
+ AHT_BACKGROUND_PROCESS,
+ AHT_TESTING,
+ AHT_SYSTEM,
+};
+bool IsValidEnum(AppHMIType val);
+const char* EnumToJsonString(AppHMIType val);
+bool EnumFromJsonString(const std::string& literal, AppHMIType* result);
+
+enum RequestType {
+ RT_HTTP,
+ RT_FILE_RESUME,
+ RT_AUTH_REQUEST,
+ RT_AUTH_CHALLENGE,
+ RT_AUTH_ACK,
+ RT_PROPRIETARY,
+ RT_QUERY_APPS,
+ RT_LAUNCH_APP,
+ RT_LOCK_SCREEN_ICON_URL,
+ RT_TRAFFIC_MESSAGE_CHANNEL,
+ RT_DRIVER_PROFILE,
+ RT_VOICE_SEARCH,
+ RT_NAVIGATION,
+ RT_PHONE,
+ RT_CLIMATE,
+ RT_SETTINGS,
+ RT_VEHICLE_DIAGNOSTICS,
+ RT_EMERGENCY,
+ RT_MEDIA,
+ RT_FOTA
+};
+
+bool IsValidEnum(RequestType val);
+const char* EnumToJsonString(RequestType val);
+bool EnumFromJsonString(const std::string& literal, RequestType* result);
+
+extern const std::string kDefaultApp;
+extern const std::string kPreDataConsentApp;
+extern const std::string kDeviceApp;
+
+} // namespace policy_table_interface_base
+} // namespace rpc
+
+#endif // POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_ENUMS_H_
diff --git a/src/components/policy/include/policy/policy_table/functions.h b/src/components/policy/include/policy/policy_table/functions.h
new file mode 100644
index 0000000000..ee4b16b649
--- /dev/null
+++ b/src/components/policy/include/policy/policy_table/functions.h
@@ -0,0 +1,7 @@
+// This file is generated, do not edit
+#ifndef POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_FUNCTIONS_H_
+#define POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_FUNCTIONS_H_
+#include "./enums.h"
+#include "./types.h"
+
+#endif // POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_FUNCTIONS_H_
diff --git a/src/components/policy/include/policy/policy_table/types.h b/src/components/policy/include/policy/policy_table/types.h
new file mode 100644
index 0000000000..ce8af22044
--- /dev/null
+++ b/src/components/policy/include/policy/policy_table/types.h
@@ -0,0 +1,435 @@
+// This file is generated, do not edit
+#ifndef POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_TYPES_H_
+#define POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_TYPES_H_
+#include <climits>
+
+#include "./enums.h"
+#include "rpc_base/rpc_message.h"
+namespace Json {
+class Value;
+} // namespace Json
+namespace rpc {
+namespace policy_table_interface_base {
+struct AppLevel;
+struct ApplicationParams;
+struct DeviceParams;
+struct MessageLanguages;
+struct MessageString;
+struct RpcParameters;
+struct Rpcs;
+} // namespace policy_table_interface_base
+} // namespace rpc
+
+namespace rpc {
+namespace policy_table_interface_base {
+
+typedef Array<String<1, 255>, 0, 255> Strings;
+
+typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes;
+
+typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels;
+
+typedef Array<Enum<Parameter>, 0, 24> Parameters;
+
+typedef Map<RpcParameters, 0, 50> Rpc;
+
+typedef Array<String<10, 255>, 1, 255> URL;
+
+typedef Map<URL, 1, 255> URLList;
+
+typedef Map<URLList, 1, 255> ServiceEndpoints;
+
+typedef uint8_t NumberOfNotificationsType;
+typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 6>
+ NumberOfNotificationsPerMinute;
+
+typedef Array<Integer<uint16_t, 1, 1000>, 0, 10> SecondsBetweenRetries;
+
+typedef Map<MessageString, 0, 500> Languages;
+
+typedef Map<MessageLanguages, 0, 255> Messages;
+
+typedef Map<AppLevel, 0, 255> AppLevels;
+
+typedef Map<Stringifyable<Nullable<ApplicationParams> >, 1, 1000>
+ ApplicationPolicies;
+
+typedef Map<Rpcs, 1, 255> FunctionalGroupings;
+
+typedef Map<DeviceParams, 0, 255> DeviceData;
+
+typedef Array<Enum<RequestType>, 0, 255> RequestTypes;
+
+struct PolicyBase : CompositeType {
+ public:
+ Enum<Priority> priority;
+
+ public:
+ PolicyBase();
+ PolicyBase(Priority priority);
+ virtual ~PolicyBase();
+ explicit PolicyBase(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct DevicePolicy : PolicyBase {
+ public:
+ DevicePolicy();
+ DevicePolicy(Priority priority);
+ ~DevicePolicy();
+ explicit DevicePolicy(const Json::Value* value__);
+};
+
+struct ApplicationParams : PolicyBase {
+ public:
+ Strings groups;
+ Optional<Strings> nicknames;
+ Optional<AppHMITypes> AppHMIType;
+ Optional<RequestTypes> RequestType;
+ Optional<Integer<uint16_t, 0, 65225> > memory_kb;
+ Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms;
+ Optional<String<0, 255> > certificate;
+
+ public:
+ ApplicationParams();
+ ApplicationParams(const Strings& groups, Priority priority);
+ ~ApplicationParams();
+ explicit ApplicationParams(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct ApplicationPoliciesSection : CompositeType {
+ public:
+ mutable ApplicationPolicies apps;
+ DevicePolicy device;
+
+ public:
+ ApplicationPoliciesSection();
+ ApplicationPoliciesSection(const ApplicationPolicies& apps,
+ const DevicePolicy& device);
+ ~ApplicationPoliciesSection();
+ explicit ApplicationPoliciesSection(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct RpcParameters : CompositeType {
+ public:
+ HmiLevels hmi_levels;
+ Optional<Parameters> parameters;
+
+ public:
+ RpcParameters();
+ explicit RpcParameters(const HmiLevels& hmi_levels);
+ ~RpcParameters();
+ explicit RpcParameters(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct Rpcs : CompositeType {
+ public:
+ Optional<String<1, 255> > user_consent_prompt;
+ Nullable<Rpc> rpcs;
+
+ public:
+ Rpcs();
+ explicit Rpcs(const Rpc& rpcs);
+ ~Rpcs();
+ explicit Rpcs(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct ModuleConfig : CompositeType {
+ public:
+ Optional<Map<String<0, 100>, 0, 255> > device_certificates;
+ Optional<Boolean> preloaded_pt;
+ Integer<uint8_t, 0, 255> exchange_after_x_ignition_cycles;
+ Integer<int64_t, 0, 4294967296ll> exchange_after_x_kilometers;
+ Integer<uint8_t, 0, 255> exchange_after_x_days;
+ Integer<uint16_t, 0, 65535> timeout_after_x_seconds;
+ SecondsBetweenRetries seconds_between_retries;
+ ServiceEndpoints endpoints;
+ NumberOfNotificationsPerMinute notifications_per_minute_by_priority;
+ Optional<String<1, 100> > vehicle_make;
+ Optional<String<1, 100> > vehicle_model;
+ Optional<String<4, 4> > vehicle_year;
+ Optional<String<0, 10> > preloaded_date;
+ Optional<String<0, 65535> > certificate;
+
+ public:
+ ModuleConfig();
+ ModuleConfig(uint8_t exchange_after_x_ignition_cycles,
+ int64_t exchange_after_x_kilometers,
+ uint8_t exchange_after_x_days,
+ uint16_t timeout_after_x_seconds,
+ const SecondsBetweenRetries& seconds_between_retries,
+ const ServiceEndpoints& endpoints,
+ const NumberOfNotificationsPerMinute&
+ notifications_per_minute_by_priority);
+ ~ModuleConfig();
+ explicit ModuleConfig(const Json::Value* value__);
+ void SafeCopyFrom(const ModuleConfig& from);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct MessageString : CompositeType {
+ public:
+ Optional<String<1, 65535> > line1;
+ Optional<String<1, 65535> > line2;
+ Optional<String<1, 65535> > tts;
+ Optional<String<1, 65535> > label;
+ Optional<String<1, 65535> > textBody;
+
+ public:
+ MessageString();
+ ~MessageString();
+ explicit MessageString(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct MessageLanguages : CompositeType {
+ public:
+ Languages languages;
+
+ public:
+ MessageLanguages();
+ explicit MessageLanguages(const Languages& languages);
+ ~MessageLanguages();
+ explicit MessageLanguages(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct ConsumerFriendlyMessages : CompositeType {
+ public:
+ String<1, 100> version;
+ Optional<Messages> messages;
+
+ public:
+ ConsumerFriendlyMessages();
+ explicit ConsumerFriendlyMessages(const std::string& version);
+ ~ConsumerFriendlyMessages();
+ explicit ConsumerFriendlyMessages(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct ModuleMeta : CompositeType {
+ public:
+ public:
+ ModuleMeta();
+ ~ModuleMeta();
+ explicit ModuleMeta(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
+struct AppLevel : CompositeType {
+ public:
+ Integer<uint16_t, 0, 65535> minutes_in_hmi_full;
+ String<1, 10> app_registration_language_gui;
+ String<0, 10> app_registration_language_vui;
+ Integer<uint16_t, 0, 65535> minutes_in_hmi_limited;
+ Integer<uint16_t, 0, 65535> minutes_in_hmi_background;
+ Integer<uint16_t, 0, 65535> minutes_in_hmi_none;
+ Integer<uint16_t, 0, 65535> count_of_user_selections;
+ Integer<uint16_t, 0, 65535> count_of_rejections_sync_out_of_memory;
+ Integer<uint16_t, 0, 65535> count_of_rejections_nickname_mismatch;
+ Integer<uint16_t, 0, 65535> count_of_rejections_duplicate_name;
+ Integer<uint16_t, 0, 65535> count_of_rejected_rpc_calls;
+ Integer<uint16_t, 0, 65535> count_of_rpcs_sent_in_hmi_none;
+ Integer<uint16_t, 0, 65535> count_of_removals_for_bad_behavior;
+ Integer<uint16_t, 0, 65535> count_of_tls_errors;
+ Integer<uint16_t, 0, 65535> count_of_run_attempts_while_revoked;
+
+ public:
+ AppLevel();
+ AppLevel(uint16_t minutes_in_hmi_full,
+ const std::string& app_registration_language_gui,
+ const std::string& app_registration_language_vui,
+ uint16_t minutes_in_hmi_limited,
+ uint16_t minutes_in_hmi_background,
+ uint16_t minutes_in_hmi_none,
+ uint16_t count_of_user_selections,
+ uint16_t count_of_rejections_sync_out_of_memory,
+ uint16_t count_of_rejections_nickname_mismatch,
+ uint16_t count_of_rejections_duplicate_name,
+ uint16_t count_of_rejected_rpc_calls,
+ uint16_t count_of_rpcs_sent_in_hmi_none,
+ uint16_t count_of_removals_for_bad_behavior,
+ uint16_t count_of_tls_errors,
+ uint16_t count_of_run_attempts_while_revoked);
+ ~AppLevel();
+ explicit AppLevel(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
+struct UsageAndErrorCounts : CompositeType {
+ public:
+ Optional<AppLevels> app_level;
+
+ public:
+ UsageAndErrorCounts();
+ ~UsageAndErrorCounts();
+ explicit UsageAndErrorCounts(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct DeviceParams : CompositeType {
+ public:
+ public:
+ DeviceParams();
+ ~DeviceParams();
+ explicit DeviceParams(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+
+ private:
+ bool Validate() const;
+};
+
+struct PolicyTable : CompositeType {
+ public:
+ ApplicationPoliciesSection app_policies_section;
+ FunctionalGroupings functional_groupings;
+ Optional<ConsumerFriendlyMessages> consumer_friendly_messages;
+ ModuleConfig module_config;
+ Optional<ModuleMeta> module_meta;
+ Optional<UsageAndErrorCounts> usage_and_error_counts;
+ Optional<DeviceData> device_data;
+
+ public:
+ PolicyTable();
+ PolicyTable(const ApplicationPoliciesSection& app_policies_section,
+ const FunctionalGroupings& functional_groupings,
+ const ConsumerFriendlyMessages& consumer_friendly_messages,
+ const ModuleConfig& module_config);
+ ~PolicyTable();
+ explicit PolicyTable(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+
+struct Table : CompositeType {
+ public:
+ PolicyTable policy_table;
+
+ public:
+ Table();
+ explicit Table(const PolicyTable& policy_table);
+ ~Table();
+ explicit Table(const Json::Value* value__);
+ Json::Value ToJsonValue() const;
+ bool is_valid() const;
+ bool is_initialized() const;
+ bool struct_empty() const;
+ void ReportErrors(rpc::ValidationReport* report__) const;
+ virtual void SetPolicyTableType(PolicyTableType pt_type);
+
+ private:
+ bool Validate() const;
+};
+} // namespace policy_table_interface_base
+} // namespace rpc
+
+#endif // POLICY_TABLE_INTERFACE_BASE_POLICY_TABLE_INTERFACE_BASE_TYPES_H_
diff --git a/src/components/policy/include/policy/pt_ext_representation.h b/src/components/policy/include/policy/pt_ext_representation.h
new file mode 100644
index 0000000000..2c5db4f002
--- /dev/null
+++ b/src/components/policy/include/policy/pt_ext_representation.h
@@ -0,0 +1,333 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
+
+#include "policy/pt_representation.h"
+
+namespace policy {
+
+enum StatisticsType {
+ S_NONE = 0,
+ S_IAP_BUFFER_FULL,
+ S_SYNC_OUT_OF_MEMORY,
+ S_SYNC_REBOOTS,
+ S_MINS_HMI_FULL,
+ S_MINS_HMI_LIMITED,
+ S_MINS_HMI_BACKGROUND,
+ S_MINS_HMI_NONE,
+ S_RFCOM_LIMIT_REACHED,
+ S_USER_SELECTIONS,
+ S_REJECTIONS_SYNC_OUT_OF_MEMORY,
+ S_REJECTIONS_NICKNAME_MISMATCH,
+ S_REJECTIONS_DUPLICATE_NAME,
+ S_REJECTED_RPC_CALLS,
+ S_RPCS_IN_HMI_NONE,
+ S_REMOVALS_MISBEHAVED,
+ S_RUN_ATTEMPTS_WHILE_REVOKED
+};
+
+enum LanguageType { L_NONE = 0, L_GUI, L_VUI };
+
+class PTExtRepresentation : public virtual PTRepresentation {
+ public:
+ virtual ~PTExtRepresentation() {}
+
+ /**
+ * @brief Is application allowed to send notifications while in
+ * Backgound or limited mode.
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ virtual bool CanAppKeepContext(const std::string& app_id) = 0;
+
+ /**
+ * @brief Is application allowed to move foreground at will?
+ * @param app_id Application id
+ * @return bool Allowed/disallowed.
+ */
+ virtual bool CanAppStealFocus(const std::string& app_id) = 0;
+
+ /**
+ * @brief Get default_hmi for given application
+ * @param policy_app_id Unique application id
+ * @param default_hmi Default HMI level for application or empty, if value was
+ * not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetDefaultHMI(const std::string& policy_app_id,
+ std::string* default_hmi) = 0;
+
+ /**
+ * @brief Reset user consent for device data and applications permissions
+ * @return
+ */
+ virtual bool ResetUserConsent() = 0;
+
+ /**
+ * @brief Reset user consent for device data
+ * @return
+ */
+ virtual bool ResetDeviceConsents() = 0;
+
+ /**
+ * @brief Reset user consent for applications permissions
+ * @return
+ */
+ virtual bool ResetAppConsents() = 0;
+
+ /**
+ * @brief Get user permissions for device data usage
+ * @param device_id Generated or obtained id of device
+ * @param consented_groups Groups consented by user
+ * @param disallowed_groups Groups not consented by user
+ * @return true, if query was successfull, otherwise - false
+ */
+ virtual bool GetUserPermissionsForDevice(
+ const std::string& device_id,
+ StringArray* consented_groups = NULL,
+ StringArray* disallowed_groups = NULL) = 0;
+
+ /**
+ * @brief Gets list of groups permissions from policy table
+ * @param device_id Unique device id, which hosts specific application
+ * @param policy_app_id Unique application id
+ * @param group_types Group list sorted by permission status
+ * @return true, if query was successfull, otherwise - false
+ */
+ virtual bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& policy_app_id,
+ FunctionalIdType* group_types) = 0;
+
+ /**
+ * @brief Get device groups and preconsented groups from policies section
+ * @param groups List of groups to be consented for device usage
+ * @param preconsented_groups List of preconsented groups for device usage
+ * @return true, if query was successful, otherwise - false
+ */
+ virtual bool GetDeviceGroupsFromPolicies(
+ policy_table::Strings* groups = NULL,
+ policy_table::Strings* preconsented_groups = NULL) = 0;
+
+ /**
+ * @brief Record information about mobile device in Policy Table.
+ * @param device_id Generated or obtained id of device
+ * @return bool Success of operation
+ */
+ virtual bool SetDeviceData(const std::string& device_id,
+ const std::string& hardware = "",
+ const std::string& firmware = "",
+ const std::string& os = "",
+ const std::string& os_version = "",
+ const std::string& carrier = "",
+ const uint32_t number_of_ports = 0,
+ const std::string& connection_type = "") = 0;
+
+ /**
+ * @brief Sets user consent for particular mobile device,
+ * i.e. to use device for exchanging of Policy Table.
+ * @return bool Success of operation
+ */
+ virtual bool SetUserPermissionsForDevice(
+ const std::string& device_id,
+ const StringArray& consented_groups = StringArray(),
+ const StringArray& disallowed_gropus = StringArray()) = 0;
+
+ /**
+ * @brief Update Application Policies as reaction
+ * on User allowing/disallowing device this app is running on.
+ */
+ virtual bool ReactOnUserDevConsentForApp(const std::string& app_id,
+ bool is_device_allowed) = 0;
+
+ /**
+ * @brief Set user consent on functional groups
+ * @param permissions User consent on functional group
+ * @return true, if operation succedeed, otherwise - false
+ */
+ virtual bool SetUserPermissionsForApp(
+ const PermissionConsent& permissions) = 0;
+
+ /**
+ * @brief Counter for statistics information: adds 1 to existing number.
+ * @param type Type of statistics (errors, mins in mode etc)
+ * @return bool Success of operation
+ */
+ virtual bool IncreaseStatisticsData(StatisticsType type) = 0;
+
+ /**
+ * @brief Records information about what language
+ * application tried to register with.
+ * @param app_id Id of application
+ * @param type - language for UI/VR
+ * @param language Language
+ * @return bool Success of operation
+ */
+ virtual bool SetAppRegistrationLanguage(const std::string& app_id,
+ LanguageType type,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Records information about head unit system to PT
+ * @return bool Success of operation
+ */
+ virtual bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Checks, if specific head unit is present in PT
+ * @return boot Suceess, if present, otherwise - false
+ */
+ virtual bool IsMetaInfoPresent() = 0;
+
+ /**
+ * @brief Kms pass since last successfull PT update
+ */
+ virtual int GetKmFromSuccessfulExchange() = 0;
+
+ /**
+ * @brief Days pass since last successfull PT update
+ */
+ virtual int GetDayFromScsExchange() = 0;
+
+ /**
+ * @brief Ignition cycles pass since last successfull PT update
+ */
+ virtual int GetIgnitionsFromScsExchange() = 0;
+
+ /**
+ * @brief Set current system language
+ * @param language System language
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool SetSystemLanguage(const std::string& language) = 0;
+
+ /**
+ * Increments global counter
+ * @param type type of counter
+ */
+ virtual void Increment(const std::string& type) const = 0;
+
+ /**
+ * Increments counter of application
+ * @param app_id id application
+ * @param type type of counter
+ */
+ virtual void Increment(const std::string& app_id,
+ const std::string& type) const = 0;
+
+ /**
+ * Sets value of application information
+ * @param app_id id application
+ * @param type type of information
+ * @param value value of information
+ */
+ virtual void Set(const std::string& app_id,
+ const std::string& type,
+ const std::string& value) const = 0;
+
+ /**
+ * Adds value to stopwatch of application
+ * @param app_id id application
+ * @param type type of stopwatch
+ * @param seconds value for adding in seconds
+ */
+ virtual void Add(const std::string& app_id,
+ const std::string& type,
+ int seconds) const = 0;
+
+ virtual bool CountUnconsentedGroups(const std::string& policy_app_id,
+ const std::string& device_id,
+ int* result) const = 0;
+
+ /**
+ * @brief Gets functional group names and user_consent_prompts, if any
+ * @param Array to be filled with group ids, names and functional prompts
+ * @return true, if succeeded, otherwise - false
+ */
+ // TODO(AOleynik): Possibly, we can get rid of this method. Check this.
+ virtual bool GetFunctionalGroupNames(policy::FunctionalGroupNames& names) = 0;
+
+ /**
+ * @brief Set app policy to pre_DataConsented policy
+ * @param app_id Policy ID of application to be changed
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool SetPredataPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief Updates application policy to either pre_DataConsented or not
+ * @param app_id Policy Id of application to be checked
+ * @param is_pre_data True of False to setting app policy to be
+ * pre_DataConsented
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool SetIsPredata(const std::string& app_id, bool is_pre_data) = 0;
+
+ /**
+ * @brief Removes unpaired devices
+ * @return true if success
+ */
+ virtual bool CleanupUnpairedDevices(const DeviceIds& device_ids) const = 0;
+
+ /**
+ * Sets flag of unpaired device
+ * @param device_id Unique device id
+ * @param unpaired True, if unpaired, otherwise - false
+ * @return true if success
+ */
+ virtual bool SetUnpairedDevice(const std::string& device_id,
+ bool unpaired) const = 0;
+
+ /**
+ * Gets list of unpaired devices
+ * @param device_ids output list
+ * @return true if success
+ */
+ virtual bool UnpairedDevicesList(DeviceIds* device_ids) const = 0;
+
+ /**
+ * @brief Remove application consent for particular group
+ * @param policy_app_id Unique application id
+ * @param functional_group_name Functional group name, which consents should
+ * be removed
+ * @return true, in case of success, otherwise - false
+ */
+ virtual bool RemoveAppConsentForGroup(
+ const std::string& policy_app_id,
+ const std::string& functional_group_name) const = 0;
+};
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_
diff --git a/src/components/policy/include/policy/pt_representation.h b/src/components/policy/include/policy/pt_representation.h
new file mode 100644
index 0000000000..122f5326d8
--- /dev/null
+++ b/src/components/policy/include/policy/pt_representation.h
@@ -0,0 +1,324 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_REPRESENTATION_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_REPRESENTATION_H_
+
+#include <vector>
+#include <string>
+#include "policy/policy_types.h"
+#include "policy/policy_table/types.h"
+#include "policy/policy_settings.h"
+
+namespace policy_table = rpc::policy_table_interface_base;
+
+namespace policy {
+
+enum InitResult { NONE = 0, EXISTS, SUCCESS, FAIL };
+
+class PTRepresentation {
+ public:
+ virtual ~PTRepresentation() {}
+
+ /**
+ * @brief Check if specified RPC for specified application
+ * has permission to be executed in specified HMI Level
+ * and also its permitted params.
+ * @param app_id Id of application provided during registration
+ * @param hmi_level Current HMI Level of application
+ * @param rpc Name of RPC
+ * @params CheckPermissionResult containing flag if HMI Level is allowed
+ * and list of allowed params.
+ */
+ virtual void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ CheckPermissionResult& result) = 0;
+
+ /**
+ * @brief Returns true if Policy Table was not updated yet
+ * from preloaded pt file.
+ */
+ virtual bool IsPTPreloaded() = 0;
+
+ virtual bool RefreshDB() = 0;
+ /**
+ * Gets number of ignition cycles before next update policy table
+ * @return number of ignition cycles
+ */
+ virtual int IgnitionCyclesBeforeExchange() = 0;
+
+ /**
+ * Gets value in kilometers before next update policy table
+ * @param current value in kilometers from the odometers
+ * @return value in kilometers
+ */
+ virtual int KilometersBeforeExchange(int current) = 0;
+
+ /**
+ * @brief Sets kilometers and days after epoch, that passed for recieved
+ * successful PT UPdate
+ */
+ virtual bool SetCountersPassedForSuccessfulUpdate(int kilometers,
+ int days_after_epoch) = 0;
+
+ /**
+ * Gets value in days before next update policy table
+ * @param current value in days after epoch
+ * @return value in days
+ */
+ virtual int DaysBeforeExchange(int current) = 0;
+
+ /**
+ * @brief Increment number of ignition cycles since last exchange by 1
+ */
+ virtual void IncrementIgnitionCycles() = 0;
+
+ /**
+ * @brief Reset number of ignition cycles since last exchange to 0
+ */
+ virtual void ResetIgnitionCycles() = 0;
+
+ /**
+ * @brief Returns timeout to wait for a response of PT update
+ * @return value in seconds
+ */
+ virtual int TimeoutResponse() = 0;
+
+ /**
+ * @brief Returns number of seconds between each try of sending PTS
+ * @param seconds Return value: array of 5 elements
+ * @return bool Success of operation
+ */
+ virtual bool SecondsBetweenRetries(std::vector<int>* seconds) = 0;
+
+ /**
+ * @brief Get information about vehicle
+ */
+ virtual const VehicleInfo GetVehicleInfo() const = 0;
+
+ /**
+ * @brief Allows to update 'vin' field in module_meta table.
+ *
+ * @param new 'vin' value.
+ *
+ * @return true in case when data has been successfully updated,
+ * false otherwise.
+ */
+ virtual bool SetVINValue(const std::string& value) = 0;
+
+ /**
+ * @brief Get message text for displaying/pronouncing for user
+ * dependent on language and context.
+ * @param msg_codes Context of message (Driver distraction, Grant permission
+ * etc)
+ * @param language Language of the message
+ * @return Array of appropriate messages parameters
+ */
+ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
+ const std::vector<std::string>& msg_codes,
+ const std::string& language) = 0;
+
+ /**
+ * @brief Get list of URL to send PTS to
+ * @param service_type If URLs for specific service are preset,
+ * return them otherwise default URLs.
+ */
+ virtual EndpointUrls GetUpdateUrls(int service_type) = 0;
+
+ /**
+ * @brief GetLockScreenIcon allows to obtain lock screen icon url;
+ *
+ * @return url which point to the resourse where lock screen icon could be
+ *obtained.
+ */
+ virtual std::string GetLockScreenIconUrl() const = 0;
+
+ /**
+ * @brief Get allowed number of notifications
+ * depending on application priority.
+ * @param priority Priority of application
+ */
+ virtual int GetNotificationsNumber(const std::string& priority) = 0;
+
+ /**
+ * @brief Get priority for given application
+ * @param policy_app_id Unique application id
+ * @param priority Priority for application or empty, if value was not set
+ * @return true, if succedeed, otherwise - false
+ */
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string* priority) = 0;
+
+ /**
+ * @brief Initialized Policy Table (load)
+ * @return bool Success of operation
+ */
+ virtual InitResult Init(const PolicySettings* settings) = 0;
+
+ /**
+ * @brief Close policy table
+ * @return bool Success of operation
+ */
+ virtual bool Close() = 0;
+
+ /**
+ * @brief Removes policy table content.
+ * @return bool Success of operation
+ */
+ virtual bool Clear() = 0;
+
+ /**
+ * Drops policy table (schema and content)
+ * @return true if successfully
+ */
+ virtual bool Drop() = 0;
+
+ /**
+ * @brief Get snapshot of Policy Table
+ * including app_policies, functional_groups,
+ * device_info, statistics, excluding user messages
+ * @return Generated structure for obtaining Json string.
+ */
+ virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const = 0;
+
+ virtual bool Save(const policy_table::Table& table) = 0;
+
+ /**
+ * Gets flag updateRequired
+ * @return true if update is required
+ */
+ virtual bool UpdateRequired() const = 0;
+
+ /**
+ * Saves flag updateRequired
+ */
+ virtual void SaveUpdateRequired(bool value) = 0;
+
+ /*
+ Retrieves data from app_policies about app on its registration:
+ app_id - id of registered app; all outputs are filled in only if not null
+ output: nicknames Synonyms for application
+ output: app_types Section on HMI where app can appear (Navigation, Phone etc)
+ */
+ virtual bool GetInitialAppData(const std::string& app_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_types = NULL) = 0;
+
+ /**
+ * Checks if the application is revoked
+ * @param app_id application id
+ * @return true if application is revoked
+ */
+ virtual bool IsApplicationRevoked(const std::string& app_id) const = 0;
+
+ /**
+ * @brief Get functional groupings from DB
+ * @param groups Known functional groupings
+ * @return true, if succeeded, otherwise - false
+ */
+ virtual bool GetFunctionalGroupings(
+ policy_table::FunctionalGroupings& groups) = 0;
+
+ /**
+ * Checks if the application is represented in policy table
+ * @param app_id application id
+ * @return true if application is represented in policy table
+ */
+ virtual bool IsApplicationRepresented(const std::string& app_id) const = 0;
+
+ /**
+ * Checks if the application has default policy
+ * @param app_id application id
+ * @return true if application has default policy
+ */
+ virtual bool IsDefaultPolicy(const std::string& app_id) const = 0;
+
+ /**
+ * Checks if the application has pre_data policy
+ * @param app_id application id
+ * @return true if application has pre_data policy
+ */
+ virtual bool IsPredataPolicy(const std::string& app_id) const = 0;
+
+ /**
+ * Sets default policy for application
+ * @param app_id application id
+ * @return true if success
+ */
+ virtual bool SetDefaultPolicy(const std::string& app_id) = 0;
+
+ /**
+ * @brief SaveApplicationCustomData allows to save specific data to database.
+ * This data is only for internal use.
+ * @param app_id the application id for which the data will be saved.
+ * @param is_revoked parameter to save.
+ * @param is_default parameter to save.
+ * @param is_predata parameter to save.
+ */
+ virtual bool SaveApplicationCustomData(const std::string& app_id,
+ bool is_revoked,
+ bool is_default,
+ bool is_predata) = 0;
+
+ virtual void WriteDb() = 0;
+
+ /**
+ * @brief RemoveDB allows to remove the database.
+ * It will either remove or do nothing in case file not exists or any other
+ * troubles are happens during this operation.
+ */
+ virtual void RemoveDB() const = 0;
+
+ /**
+ * @brief Checks if DB version is actual to current schema
+ * @return true if actual, otherwise - false
+ */
+ virtual bool IsDBVersionActual() const = 0;
+
+ /**
+ * @brief Updates DB version according to current schema
+ * @return true if success, otherwise - false
+ */
+ virtual bool UpdateDBVersion() const = 0;
+
+ protected:
+ const PolicySettings& get_settings() const {
+ DCHECK(settings_);
+ return *settings_;
+ }
+ const PolicySettings* settings_;
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_PT_REPRESENTATION_H_
diff --git a/src/components/policy/include/policy/sql_pt_ext_queries.h b/src/components/policy/include/policy/sql_pt_ext_queries.h
new file mode 100644
index 0000000000..2b65df45f3
--- /dev/null
+++ b/src/components/policy/include/policy/sql_pt_ext_queries.h
@@ -0,0 +1,97 @@
+/*
+ Copyright (c) 2013, " Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, " with or without
+ modification, " are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, " this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice, "
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, " INCLUDING, " BUT NOT LIMITED TO, " THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, " INDIRECT, " INCIDENTAL, " SPECIAL, " EXEMPLARY, " OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, " BUT NOT LIMITED TO, " PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, " DATA, " OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, " WHETHER IN
+ CONTRACT, " STRICT LIABILITY, " OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_
+
+#include <string>
+
+namespace policy {
+namespace sql_pt_ext {
+
+extern const std::string kSelectKeepContext;
+extern const std::string kSelectStealFocus;
+extern const std::string kResetDeviceConsents;
+extern const std::string kResetAppConsents;
+extern const std::string kCountDeviceConsentGroup;
+extern const std::string kCountDevice;
+extern const std::string kSelectDeviceConsentedGroup;
+extern const std::string kUpdateDeviceConsentedGroup;
+extern const std::string kUpdateDevice;
+extern const std::string kInsertDeviceConsentedGroup;
+extern const std::string kInsertDevice;
+extern const std::string kSelectDeviceData;
+extern const std::string kSelectConsentGroup;
+extern const std::string kInsertPreconsentedGroups;
+extern const std::string kSelectPreconsentedGroups;
+extern const std::string kDeletePreconsentedGroups;
+extern const std::string kSelectUsageAndErrorCount;
+extern const std::string kSelectAppLevels;
+extern const std::string kUpdateGlobalCounters;
+extern const std::string kInsertDeviceData;
+extern const std::string kDeleteDeviceData;
+extern const std::string kInsertConsentGroups;
+extern const std::string kCountUnconsentedGroups;
+extern const std::string kSelectModuleMeta;
+extern const std::string kUpdateMetaParams;
+extern const std::string kUpdateModuleMetaVinParam;
+extern const std::string kSaveModuleMeta;
+extern const std::string kSelectMetaParams;
+extern const std::string kCountAppLevel;
+extern const std::string kUpdateGroupPermissions;
+extern const std::string kSelectDefaultHmi;
+extern const std::string kInsertApplication;
+extern const std::string kSelectFriendlyMsg;
+extern const std::string kCollectFriendlyMsg;
+extern const std::string kSelectAppGroupsId;
+extern const std::string kSelectConsentedGroupsId;
+extern const std::string kCountAppConsents;
+extern const std::string kSelectPreconsentedGroupsId;
+extern const std::string kSelectFunctionalGroupNames;
+extern const std::string kSelectAppPolicies;
+extern const std::string kUpdateMetaLanguage;
+extern const std::string kDeleteDeviceConsent;
+extern const std::string kDeleteAppGroupConsent;
+extern const std::string kSelectGroupId;
+extern const std::string kSelectApplicationIsPreData;
+extern const std::string kUpdateIsPredata;
+extern const std::string kHasAppPreloadedGroups;
+extern const std::string kUpdateUnpairedDevice;
+extern const std::string kSelectUnpairedDevices;
+extern const std::string kHasMsgLanguageCode;
+extern const std::string kDeletePreconsentedGroupsByApplicationId;
+extern const std::string kDeleteAppConsent;
+
+} // namespace sql_pt_ext
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_
diff --git a/src/components/policy/include/policy/sql_pt_ext_representation.h b/src/components/policy/include/policy/sql_pt_ext_representation.h
new file mode 100644
index 0000000000..1d33750b12
--- /dev/null
+++ b/src/components/policy/include/policy/sql_pt_ext_representation.h
@@ -0,0 +1,205 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_
+
+#include <string>
+#include "policy/sql_pt_representation.h"
+#include "policy/pt_ext_representation.h"
+
+namespace policy {
+
+class SQLPTExtRepresentation : public SQLPTRepresentation,
+ public PTExtRepresentation {
+ public:
+ bool CanAppKeepContext(const std::string& app_id);
+ bool CanAppStealFocus(const std::string& app_id);
+ bool GetDefaultHMI(const std::string& policy_app_id,
+ std::string* default_hmi);
+ bool ResetUserConsent();
+ bool ResetDeviceConsents();
+ bool ResetAppConsents();
+ bool GetUserPermissionsForDevice(const std::string& device_id,
+ StringArray* consented_groups = NULL,
+ StringArray* disallowed_groups = NULL);
+
+ bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& policy_app_id,
+ FunctionalIdType* group_types);
+
+ bool GetDeviceGroupsFromPolicies(
+ policy_table::Strings* groups = NULL,
+ policy_table::Strings* preconsented_groups = NULL);
+ bool SetDeviceData(const std::string& device_id,
+ const std::string& hardware = "",
+ const std::string& firmware = "",
+ const std::string& os = "",
+ const std::string& os_version = "",
+ const std::string& carrier = "",
+ const uint32_t number_of_ports = 0,
+ const std::string& connection_type = "");
+ bool SetUserPermissionsForDevice(
+ const std::string& device_id,
+ const StringArray& consented_groups = StringArray(),
+ const StringArray& disallowed_groups = StringArray());
+
+ bool ReactOnUserDevConsentForApp(const std::string& app_id,
+ bool is_device_allowed);
+
+ bool SetUserPermissionsForApp(const PermissionConsent& permissions);
+
+ std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
+ const std::vector<std::string>& msg_codes, const std::string& language);
+
+ bool IncreaseStatisticsData(StatisticsType type) {
+ return true;
+ }
+ bool SetAppRegistrationLanguage(const std::string& app_id,
+ LanguageType type,
+ const std::string& language) {
+ return true;
+ }
+
+ bool SetMetaInfo(const std::string& ccpu_version,
+ const std::string& wers_country_code,
+ const std::string& language);
+
+ bool IsMetaInfoPresent();
+
+ bool SetSystemLanguage(const std::string& language);
+
+ int GetKmFromSuccessfulExchange() {
+ return true;
+ }
+ int GetDayFromScsExchange() {
+ return true;
+ }
+ int GetIgnitionsFromScsExchange() {
+ return true;
+ }
+
+ bool GetFunctionalGroupNames(FunctionalGroupNames& names);
+ bool CleanupUnpairedDevices(const DeviceIds& device_ids) const;
+
+ void Increment(const std::string& type) const;
+ void Increment(const std::string& app_id, const std::string& type) const;
+ void Set(const std::string& app_id,
+ const std::string& type,
+ const std::string& value) const;
+ void Add(const std::string& app_id,
+ const std::string& type,
+ int seconds) const;
+ bool SetDefaultPolicy(const std::string& app_id);
+ bool SetPredataPolicy(const std::string& app_id);
+ bool SetIsPredata(const std::string& app_id, bool is_pre_data);
+ bool IsPredataPolicy(const std::string& app_id) const;
+ bool SetUnpairedDevice(const std::string& device_id, bool unpaired) const;
+ bool UnpairedDevicesList(DeviceIds* device_ids) const;
+ bool RemoveAppConsentForGroup(const std::string& policy_app_id,
+ const std::string& functional_group_name) const;
+
+ virtual bool SetVINValue(const std::string& value);
+
+ private:
+ void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
+ void GatherPreconsentedGroup(const std::string& app_id,
+ policy_table::Strings* groups) const;
+ bool GatherUsageAndErrorCounts(
+ policy_table::UsageAndErrorCounts* counts) const;
+ bool GatherAppLevels(policy_table::AppLevels* apps) const;
+ void GatherDeviceData(policy_table::DeviceData* data) const;
+ void GatherConsentGroup(const std::string& device_id,
+ policy_table::UserConsentRecords* records) const;
+ bool GatherApplicationPoliciesSection(
+ policy_table::ApplicationPoliciesSection* policies) const;
+ bool SaveDeviceData(const policy_table::DeviceData& devices);
+ bool GatherConsumerFriendlyMessages(
+ policy_table::ConsumerFriendlyMessages* messages) const;
+ bool SaveConsentGroup(const std::string& device_id,
+ const policy_table::UserConsentRecords& records);
+ bool SaveApplicationPoliciesSection(
+ const policy_table::ApplicationPoliciesSection& policies);
+ bool SaveSpecificAppPolicy(
+ const policy_table::ApplicationPolicies::value_type& app);
+ bool SaveDevicePolicy(const policy_table::DevicePolicy& device);
+ bool SavePreconsentedGroup(const std::string& app_id,
+ const policy_table::Strings& groups);
+ bool SaveMessageString(const std::string& type,
+ const std::string& lang,
+ const policy_table::MessageString& strings);
+
+ virtual bool SaveUsageAndErrorCounts(
+ const policy_table::UsageAndErrorCounts& counts);
+
+ virtual bool SaveModuleMeta(const policy_table::ModuleMeta& meta);
+
+ bool SaveAppCounters(const policy_table::AppLevels& app_levels);
+
+ bool SaveGlobalCounters(const policy_table::UsageAndErrorCounts& counts);
+
+ bool IsExistAppLevel(const std::string& app_id) const;
+
+ bool GetAllAppGroups(const std::string& policy_app_id,
+ FunctionalGroupIDs& all_groups);
+
+ bool GetConsentedGroups(const std::string& policy_app_id,
+ const std::string& device_id,
+ FunctionalGroupIDs& allowed_groups,
+ FunctionalGroupIDs& disallowed_groups);
+
+ bool GetPreconsentedGroups(const std::string& policy_app_id,
+ FunctionalGroupIDs& preconsented_groups);
+
+ void FillFunctionalGroupPermissions(
+ FunctionalGroupIDs& ids,
+ FunctionalGroupNames& names,
+ GroupConsent state,
+ std::vector<FunctionalGroupPermission>& permissions);
+ bool CountUnconsentedGroups(const std::string& policy_app_id,
+ const std::string& device_id,
+ int* result) const;
+
+ /**
+ * @brief Checks, if there is message present with requested language in PT
+ * @param message Message name
+ * @param language Required message language
+ * @return True, if message with requested language is present, otherwise -
+ * false
+ */
+ bool IsMsgLanguagePresent(const std::string& message,
+ const std::string& language);
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_
diff --git a/src/components/policy/include/policy/sql_pt_queries.h b/src/components/policy/include/policy/sql_pt_queries.h
new file mode 100644
index 0000000000..a2fbdef3f5
--- /dev/null
+++ b/src/components/policy/include/policy/sql_pt_queries.h
@@ -0,0 +1,121 @@
+/*
+ Copyright (c) 2013, " Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, " with or without
+ modification, " are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, " this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice, "
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, " INCLUDING, " BUT NOT LIMITED TO, " THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, " INDIRECT, " INCIDENTAL, " SPECIAL, " EXEMPLARY, " OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, " BUT NOT LIMITED TO, " PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, " DATA, " OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, " WHETHER IN
+ CONTRACT, " STRICT LIABILITY, " OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, " EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_QUERIES_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_QUERIES_H_
+
+#include <string>
+
+namespace policy {
+namespace sql_pt {
+
+extern const std::string kSelectPriority;
+extern const std::string kCreateSchema;
+extern const std::string kDropSchema;
+extern const std::string kDeleteData;
+extern const std::string kCheckPgNumber;
+extern const std::string kCheckDBIntegrity;
+extern const std::string kSelectRpc;
+extern const std::string kSelectPreloaded;
+extern const std::string kIsFirstRun;
+extern const std::string kSetNotFirstRun;
+extern const std::string kSelectEndpoint;
+extern const std::string kSelectLockScreenIcon;
+extern const std::string kSelectModuleConfig;
+extern const std::string kSelectEndpoints;
+extern const std::string kSelectNotificationsPerMin;
+extern const std::string kSelectNotificationsPerPriority;
+extern const std::string kSelectAppLevels;
+extern const std::string kSelectDeviceData;
+extern const std::string kSelectFunctionalGroups;
+extern const std::string kSelectAllRpcs;
+extern const std::string kSelectUserMsgsVersion;
+extern const std::string kSelectAppPolicies;
+extern const std::string kSelectAppGroups;
+extern const std::string kSelectNicknames;
+extern const std::string kSelectAppTypes;
+extern const std::string kSelectRequestTypes;
+extern const std::string kSelectSecondsBetweenRetries;
+extern const std::string kSelectIgnitionCycles;
+extern const std::string kSelectKilometers;
+extern const std::string kSelectDays;
+extern const std::string kSelectTimeoutResponse;
+extern const std::string kInsertFunctionalGroup;
+extern const std::string kInsertRpc;
+extern const std::string kInsertRpcWithParameter;
+extern const std::string kInsertApplication;
+extern const std::string kInsertAppGroup;
+extern const std::string kInsertNickname;
+extern const std::string kInsertAppType;
+extern const std::string kInsertRequestType;
+extern const std::string kInsertMessageType;
+extern const std::string kInsertLanguage;
+extern const std::string kInsertMessageString;
+extern const std::string kUpdateVersion;
+extern const std::string kUpdateModuleConfig;
+extern const std::string kInsertEndpoint;
+extern const std::string kInsertSecondsBetweenRetry;
+extern const std::string kInsertNotificationsByPriority;
+extern const std::string kInsertDeviceData;
+extern const std::string kInsertAppLevel;
+extern const std::string kDeleteSecondsBetweenRetries;
+extern const std::string kDeleteEndpoint;
+extern const std::string kDeleteAppLevel;
+extern const std::string kDeleteMessageString;
+extern const std::string kDeleteFunctionalGroup;
+extern const std::string kDeleteRpc;
+extern const std::string kDeleteAppGroup;
+extern const std::string kDeleteApplication;
+extern const std::string kDeleteRequestType;
+extern const std::string kDeleteDevice;
+extern const std::string kIncrementIgnitionCycles;
+extern const std::string kResetIgnitionCycles;
+extern const std::string kUpdateFlagUpdateRequired;
+extern const std::string kSelectFlagUpdateRequired;
+extern const std::string kUpdateCountersSuccessfulUpdate;
+extern const std::string kSelectApplicationRevoked;
+extern const std::string kUpdateApplicationCustomData;
+extern const std::string kSelectApplicationRepresented;
+extern const std::string kSelectApplicationIsDefault;
+extern const std::string kUpdateIsDefault;
+extern const std::string kInsertInitData;
+extern const std::string kDeleteAppGroupByApplicationId;
+extern const std::string kInsertApplicationFull;
+extern const std::string kDeletePreconsentedGroupsByApplicationId;
+extern const std::string kSelectApplicationFull;
+extern const std::string kUpdatePreloaded;
+extern const std::string kSelectDBVersion;
+extern const std::string kUpdateDBVersion;
+} // namespace sql_pt
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_QUERIES_H_
diff --git a/src/components/policy/include/policy/sql_pt_representation.h b/src/components/policy/include/policy/sql_pt_representation.h
new file mode 100644
index 0000000000..89ee3788f0
--- /dev/null
+++ b/src/components/policy/include/policy/sql_pt_representation.h
@@ -0,0 +1,203 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_REPRESENTATION_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_REPRESENTATION_H_
+
+#include <string>
+#include <vector>
+#include "policy/pt_representation.h"
+#include "rpc_base/rpc_base.h"
+#include "policy/policy_table/types.h"
+
+namespace policy_table = rpc::policy_table_interface_base;
+
+namespace utils {
+namespace dbms {
+class SQLDatabase;
+} // namespace dbms
+} // namespace utils
+
+namespace policy {
+
+class SQLPTRepresentation : public virtual PTRepresentation {
+ public:
+ SQLPTRepresentation();
+ ~SQLPTRepresentation();
+ virtual void CheckPermissions(const PTString& app_id,
+ const PTString& hmi_level,
+ const PTString& rpc,
+ CheckPermissionResult& result);
+
+ virtual bool IsPTPreloaded();
+ virtual int IgnitionCyclesBeforeExchange();
+ virtual int KilometersBeforeExchange(int current);
+ virtual bool SetCountersPassedForSuccessfulUpdate(int kilometers,
+ int days_after_epoch);
+ virtual int DaysBeforeExchange(int current);
+ virtual void IncrementIgnitionCycles();
+ virtual void ResetIgnitionCycles();
+ virtual int TimeoutResponse();
+ virtual bool SecondsBetweenRetries(std::vector<int>* seconds);
+ virtual bool RefreshDB();
+ virtual const VehicleInfo GetVehicleInfo() const;
+
+ virtual std::vector<UserFriendlyMessage> GetUserFriendlyMsg(
+ const std::vector<std::string>& msg_codes, const std::string& language);
+
+ virtual EndpointUrls GetUpdateUrls(int service_type);
+ virtual std::string GetLockScreenIconUrl() const;
+ virtual int GetNotificationsNumber(const std::string& priority);
+ virtual bool GetPriority(const std::string& policy_app_id,
+ std::string* priority);
+ InitResult Init(const PolicySettings* settings);
+ bool Close();
+ bool Clear();
+ bool Drop();
+ virtual void WriteDb();
+ virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const;
+ virtual bool Save(const policy_table::Table& table);
+ bool GetInitialAppData(const std::string& app_id,
+ StringArray* nicknames = NULL,
+ StringArray* app_hmi_types = NULL);
+ bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
+
+#ifdef BUILD_TESTS
+ uint32_t open_counter() {
+ return open_counter_;
+ }
+#endif // BUILD_TESTS
+ protected:
+ virtual void GatherModuleMeta(policy_table::ModuleMeta* meta) const;
+ virtual void GatherModuleConfig(policy_table::ModuleConfig* config) const;
+ virtual bool GatherUsageAndErrorCounts(
+ policy_table::UsageAndErrorCounts* counts) const;
+ virtual void GatherDeviceData(policy_table::DeviceData* data) const;
+ virtual bool GatherFunctionalGroupings(
+ policy_table::FunctionalGroupings* groups) const;
+ virtual bool GatherConsumerFriendlyMessages(
+ policy_table::ConsumerFriendlyMessages* messages) const;
+ virtual bool GatherApplicationPoliciesSection(
+ policy_table::ApplicationPoliciesSection* policies) const;
+
+ bool GatherAppGroup(const std::string& app_id,
+ policy_table::Strings* app_groups) const;
+ bool GatherAppType(const std::string& app_id,
+ policy_table::AppHMITypes* app_types) const;
+ bool GatherRequestType(const std::string& app_id,
+ policy_table::RequestTypes* request_types) const;
+ bool GatherNickName(const std::string& app_id,
+ policy_table::Strings* nicknames) const;
+
+ virtual bool SaveApplicationCustomData(const std::string& app_id,
+ bool is_revoked,
+ bool is_default,
+ bool is_predata);
+
+ virtual bool SaveModuleMeta(const policy_table::ModuleMeta& meta);
+ virtual bool SaveModuleConfig(const policy_table::ModuleConfig& config);
+ virtual bool SaveUsageAndErrorCounts(
+ const policy_table::UsageAndErrorCounts& counts);
+ virtual bool SaveDeviceData(const policy_table::DeviceData& devices);
+ virtual bool SaveFunctionalGroupings(
+ const policy_table::FunctionalGroupings& groups);
+ virtual bool SaveConsumerFriendlyMessages(
+ const policy_table::ConsumerFriendlyMessages& messages);
+ virtual bool SaveApplicationPoliciesSection(
+ const policy_table::ApplicationPoliciesSection& policies);
+ virtual bool SaveSpecificAppPolicy(
+ const policy_table::ApplicationPolicies::value_type& app);
+ virtual bool SaveDevicePolicy(const policy_table::DevicePolicy& device);
+
+ virtual bool SaveMessageString(const std::string& type,
+ const std::string& lang,
+ const policy_table::MessageString& strings);
+
+ bool SaveAppGroup(const std::string& app_id,
+ const policy_table::Strings& app_groups);
+ bool SaveNickname(const std::string& app_id,
+ const policy_table::Strings& nicknames);
+ bool SaveAppType(const std::string& app_id,
+ const policy_table::AppHMITypes& types);
+ bool SaveRequestType(const std::string& app_id,
+ const policy_table::RequestTypes& types);
+
+ public:
+ bool UpdateRequired() const;
+ void SaveUpdateRequired(bool value);
+
+ bool IsApplicationRepresented(const std::string& app_id) const;
+ bool CopyApplication(const std::string& source,
+ const std::string& destination);
+
+ bool IsApplicationRevoked(const std::string& app_id) const;
+ virtual bool IsDefaultPolicy(const std::string& app_id) const;
+ virtual bool IsPredataPolicy(const std::string& app_id) const;
+ virtual bool SetDefaultPolicy(const std::string& app_id);
+ virtual void SetPreloaded(bool value);
+
+ virtual bool SetVINValue(const std::string& value);
+
+ virtual utils::dbms::SQLDatabase* db() const;
+ virtual bool SetIsDefault(const std::string& app_id, bool is_default) const;
+
+ void RemoveDB() const OVERRIDE;
+ virtual bool IsDBVersionActual() const OVERRIDE;
+ virtual bool UpdateDBVersion() const OVERRIDE;
+
+ private:
+ static const std::string kDatabaseName;
+ utils::dbms::SQLDatabase* db_;
+
+#ifdef BUILD_TESTS
+ uint32_t open_counter_;
+#endif // BUILD_TESTS
+
+ /**
+ * @brief Calculates DB version from current schema
+ * @return version
+ */
+ const int32_t GetDBVersion() const;
+ bool SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs);
+ bool SaveServiceEndpoints(const policy_table::ServiceEndpoints& endpoints);
+ bool SaveSecondsBetweenRetries(
+ const policy_table::SecondsBetweenRetries& seconds);
+ bool SaveNumberOfNotificationsPerMinute(
+ const policy_table::NumberOfNotificationsPerMinute& notifications);
+ bool SaveMessageType(const std::string& type);
+ bool SaveLanguage(const std::string& code);
+
+ bool is_in_memory;
+};
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_PT_REPRESENTATION_H_
diff --git a/src/components/policy/include/policy/sql_wrapper.h b/src/components/policy/include/policy/sql_wrapper.h
new file mode 100644
index 0000000000..d6639f6635
--- /dev/null
+++ b/src/components/policy/include/policy/sql_wrapper.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_WRAPPER_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_WRAPPER_H_
+
+#if __QNX__
+#include "qdb_wrapper/sql_database.h"
+#include "qdb_wrapper/sql_query.h"
+#else // __QNX__
+#include "sqlite_wrapper/sql_database.h"
+#include "sqlite_wrapper/sql_query.h"
+#endif // __QNX__
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_SQL_WRAPPER_H_
diff --git a/src/components/policy/include/policy/update_status_manager.h b/src/components/policy/include/policy/update_status_manager.h
new file mode 100644
index 0000000000..b4f52a8b03
--- /dev/null
+++ b/src/components/policy/include/policy/update_status_manager.h
@@ -0,0 +1,198 @@
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H
+
+#include "policy/policy_types.h"
+#include "utils/lock.h"
+#include "utils/threads/thread.h"
+#include "utils/threads/thread_delegate.h"
+#include "utils/conditional_variable.h"
+#include "utils/lock.h"
+#include "utils/logger.h"
+#include "utils/macro.h"
+
+namespace policy {
+
+class PolicyListener;
+
+class UpdateStatusManager {
+ public:
+ /**
+ * @brief Constructor
+ */
+ UpdateStatusManager();
+
+ ~UpdateStatusManager();
+
+ /**
+ * @brief Sets listener pointer
+ * @param listener Pointer to policy listener implementation
+ */
+ void set_listener(PolicyListener* listener);
+
+ /**
+ * @brief Update status hanlder for PTS sending out
+ * @param update_timeout Timeout for waiting of incoming PTU
+ */
+ void OnUpdateSentOut(uint32_t update_timeout);
+
+ /**
+ * @brief Update status handler for PTU waiting timeout
+ */
+ void OnUpdateTimeoutOccurs();
+
+ /**
+ * @brief Update status handler for valid PTU receiving
+ */
+ void OnValidUpdateReceived();
+
+ /**
+ * @brief Update status handler for wrong PTU receiving
+ */
+ void OnWrongUpdateReceived();
+
+ /**
+ * @brief Update status handler for reset PT to default state
+ * @param is_update_required Update necessity flag
+ */
+ void OnResetDefaultPT(bool is_update_required);
+
+ /**
+ * @brief Update status handler for restarting retry sequence
+ */
+ void OnResetRetrySequence();
+
+ /**
+ * @brief Update status handler on new application registering
+ */
+ void OnNewApplicationAdded();
+
+ /**
+ * @brief Update status handler for policy initialization
+ * @param is_update_required Update necessity flag
+ */
+ void OnPolicyInit(bool is_update_required);
+
+ /**
+ * @brief IsUpdateRequired allows to distiguish if update is required
+ *
+ * @return true if update required.
+ */
+ bool IsUpdateRequired() const;
+
+ /**
+ * @brief IsUpdatePending allows to distinguish if update is in pending mode.
+ *
+ * @return true if update is in pending mode.
+ */
+ bool IsUpdatePending() const;
+
+ /**
+ * @brief ScheduleUpdate allows to schedule next update.
+ * It will change state to Update_Needed, that's is.
+ */
+ void ScheduleUpdate();
+
+ /**
+ * @brief ResetUpdateSchedule allows to reset all scheduled updates.
+ */
+ void ResetUpdateSchedule();
+
+ /**
+ * @brief StringifiedUpdateStatus allows to obtain update status as a string.
+ *
+ * @return stringified update status.
+ */
+ std::string StringifiedUpdateStatus() const;
+
+ /**
+ * @brief Status handler on applications search started
+ */
+ void OnAppsSearchStarted();
+
+ /**
+ * @brief Status handler on applications search completed
+ */
+ void OnAppsSearchCompleted();
+
+ /**
+ * @brief Returns status is application search in progress
+ * @return true, if in progress, otherwise - false
+ */
+ bool IsAppsSearchInProgress();
+
+#ifdef BUILD_TESTS
+ PolicyTableStatus GetLastUpdateStatus() const {
+ return GetUpdateStatus();
+ }
+#endif // BUILD_TESTS
+
+ private:
+ /*
+ * @brief Sets flag for update progress
+ *
+ * @param value
+ */
+ void set_exchange_in_progress(bool value);
+
+ /*
+ * @brief Sets flag for pending update
+ *
+ * @param value
+ */
+ void set_exchange_pending(bool value);
+
+ /*
+ * @brief Sets flag for update necessity
+ *
+ * @param value
+ */
+ void set_update_required(bool value);
+
+ /**
+ * @brief Check update status and notify HMI on changes
+ */
+ void CheckUpdateStatus();
+
+ private:
+ /**
+ * @brief Returns current policy update status
+ * @return
+ */
+ PolicyTableStatus GetUpdateStatus() const;
+
+ PolicyListener* listener_;
+ bool exchange_in_progress_;
+ bool update_required_;
+ bool update_scheduled_;
+ bool exchange_pending_;
+ bool apps_search_in_progress_;
+ sync_primitives::Lock exchange_in_progress_lock_;
+ sync_primitives::Lock update_required_lock_;
+ sync_primitives::Lock exchange_pending_lock_;
+ sync_primitives::Lock apps_search_in_progress_lock_;
+ /**
+ * @brief Last status of policy table update
+ */
+ PolicyTableStatus last_update_status_;
+
+ class UpdateThreadDelegate : public threads::ThreadDelegate {
+ public:
+ UpdateThreadDelegate(UpdateStatusManager* update_status_manager);
+ ~UpdateThreadDelegate();
+ virtual void threadMain();
+ virtual void exitThreadMain();
+ void updateTimeOut(const uint32_t timeout_ms);
+
+ volatile uint32_t timeout_;
+ volatile bool stop_flag_;
+ sync_primitives::Lock state_lock_;
+ sync_primitives::ConditionalVariable termination_condition_;
+ UpdateStatusManager* update_status_manager_;
+ };
+
+ UpdateThreadDelegate* update_status_thread_delegate_;
+ threads::Thread* thread_;
+};
+}
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_H
diff --git a/src/components/policy/include/policy/update_status_manager_interface.h b/src/components/policy/include/policy/update_status_manager_interface.h
new file mode 100644
index 0000000000..4c74910791
--- /dev/null
+++ b/src/components/policy/include/policy/update_status_manager_interface.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2014, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_INTERFACE_H_
+#define SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_INTERFACE_H_
+
+#include "utils/shared_ptr.h"
+#include "policy/policy_types.h"
+
+namespace policy {
+
+class PolicyListener;
+
+class UpdateStatusManagerInterface {
+ public:
+ virtual ~UpdateStatusManagerInterface() {}
+ /**
+ * @brief Sets listener pointer
+ * @param listener Pointer to policy listener implementation
+ */
+ virtual void set_listener(PolicyListener* listener) = 0;
+
+ /**
+ * @brief Update status hanlder for PTS sending out
+ * @param update_timeout Timeout for waiting of incoming PTU
+ */
+ virtual void OnUpdateSentOut(uint32_t update_timeout) = 0;
+
+ /**
+ * @brief Update status handler for PTU waiting timeout
+ */
+ virtual void OnUpdateTimeoutOccurs() = 0;
+
+ /**
+ * @brief Update status handler for valid PTU receiving
+ */
+ virtual void OnValidUpdateReceived() = 0;
+
+ /**
+ * @brief Update status handler for wrong PTU receiving
+ */
+ virtual void OnWrongUpdateReceived() = 0;
+
+ /**
+ * @brief Update status handler for reset PT to default state
+ * @param is_update_required Update necessity flag
+ */
+ virtual void OnResetDefaultPT(bool is_update_required) = 0;
+
+ /**
+ * @brief Update status handler for restarting retry sequence
+ */
+ virtual void OnResetRetrySequence() = 0;
+
+ /**
+ * @brief Update status handler on new application registering
+ */
+ virtual void OnNewApplicationAdded() = 0;
+
+ /**
+ * @brief Update status handler for policy initialization
+ * @param is_update_required Update necessity flag
+ */
+ virtual void OnPolicyInit(bool is_update_required) = 0;
+
+ /**
+ * @brief Returns current policy update status
+ * @return
+ */
+ virtual PolicyTableStatus GetUpdateStatus() = 0;
+};
+
+typedef utils::SharedPtr<UpdateStatusManagerInterface>
+ UpdateStatusManagerInterfaceSPtr;
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_INTERFACE_H_
diff --git a/src/components/policy/include/policy/usage_statistics/app_stopwatch.h b/src/components/policy/include/policy/usage_statistics/app_stopwatch.h
new file mode 100644
index 0000000000..0f9ce35459
--- /dev/null
+++ b/src/components/policy/include/policy/usage_statistics/app_stopwatch.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
+
+#include "policy/usage_statistics/statistics_manager.h"
+
+namespace usage_statistics {
+
+class AppStopwatch {
+ public:
+ virtual ~AppStopwatch() {}
+ virtual void Start(AppStopwatchId stopwatch_type) = 0;
+ virtual void Switch(AppStopwatchId stopwatch_type) = 0;
+ virtual void WriteTime() = 0;
+};
+
+} // namespace usage_statistics
+
+#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
diff --git a/src/components/policy/include/policy/usage_statistics/counter.h b/src/components/policy/include/policy/usage_statistics/counter.h
new file mode 100644
index 0000000000..6f50013bcd
--- /dev/null
+++ b/src/components/policy/include/policy/usage_statistics/counter.h
@@ -0,0 +1,107 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_USAGE_STATISTICS_COUNTER_H
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_USAGE_STATISTICS_COUNTER_H
+
+#include <ctime>
+#include "policy/usage_statistics/statistics_manager.h"
+#include "policy/usage_statistics/app_stopwatch.h"
+#include "utils/shared_ptr.h"
+#include "utils/timer.h"
+#include "utils/macro.h"
+
+namespace usage_statistics {
+
+using timer::Timer;
+
+class GlobalCounter {
+ public:
+ GlobalCounter(utils::SharedPtr<StatisticsManager> statistics_manager,
+ GlobalCounterId counter_type);
+ void operator++() const;
+
+ private:
+ GlobalCounterId counter_type_;
+ utils::SharedPtr<StatisticsManager> statistics_manager_;
+};
+
+class AppCounter {
+ public:
+ AppCounter(utils::SharedPtr<StatisticsManager> statistics_manager,
+ const std::string& app_id,
+ AppCounterId counter_type);
+ void operator++() const;
+
+ private:
+ std::string app_id_;
+ AppCounterId counter_type_;
+ utils::SharedPtr<StatisticsManager> statistics_manager_;
+};
+
+class AppInfo {
+ public:
+ AppInfo(utils::SharedPtr<StatisticsManager> statistics_manager,
+ const std::string& app_id,
+ AppInfoId info_type);
+ void Update(const std::string& new_info) const;
+
+ private:
+ std::string app_id_;
+ AppInfoId info_type_;
+ utils::SharedPtr<StatisticsManager> statistics_manager_;
+};
+
+class AppStopwatchImpl : public AppStopwatch {
+ public:
+ AppStopwatchImpl(utils::SharedPtr<StatisticsManager> statistics_manager,
+ const std::string& app_id);
+ AppStopwatchImpl(utils::SharedPtr<StatisticsManager> statistics_manager,
+ const std::string& app_id,
+ std::uint32_t timeout);
+ void Start(AppStopwatchId stopwatch_type) OVERRIDE;
+ void Switch(AppStopwatchId stopwatch_type) OVERRIDE;
+ void WriteTime() OVERRIDE;
+
+ private:
+ // Fields
+ std::string app_id_;
+ AppStopwatchId stopwatch_type_;
+ utils::SharedPtr<StatisticsManager> statistics_manager_;
+ timer::Timer timer_;
+ const std::uint32_t time_out_;
+ DISALLOW_COPY_AND_ASSIGN(AppStopwatchImpl);
+};
+
+} // namespace usage_statistics
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_USAGE_STATISTICS_COUNTER_H
diff --git a/src/components/policy/include/policy/user_consent_manager.h b/src/components/policy/include/policy/user_consent_manager.h
new file mode 100644
index 0000000000..55c6239a6c
--- /dev/null
+++ b/src/components/policy/include/policy/user_consent_manager.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2013, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_USER_CONSENT_MANAGER_H_
+#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_USER_CONSENT_MANAGER_H_
+
+namespace policy {
+class UserConsentManager {
+ public:
+ UserConsentManager() {}
+ ~UserConsentManager() {}
+};
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_USER_CONSENT_MANAGER_H_