diff options
Diffstat (limited to 'src/components/policy/policy_regular/include/policy')
18 files changed, 553 insertions, 728 deletions
diff --git a/src/components/policy/policy_regular/include/policy/access_remote_impl.h b/src/components/policy/policy_regular/include/policy/access_remote_impl.h index 933690dc49..dbe317667a 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_regular/include/policy/access_remote_impl.h @@ -35,7 +35,7 @@ #include <map> #include "policy/policy_table/types.h" #include "utils/macro.h" -#include "utils/shared_ptr.h" + #include "policy/access_remote.h" #include "policy/cache_manager.h" @@ -46,7 +46,7 @@ namespace policy { class AccessRemoteImpl : public AccessRemote { public: AccessRemoteImpl(); - explicit AccessRemoteImpl(utils::SharedPtr<CacheManager> cache); + explicit AccessRemoteImpl(std::shared_ptr<CacheManager> cache); /** * @brief CheckModuleType check if module type is allowed for application * @param app_id application id @@ -139,7 +139,7 @@ class AccessRemoteImpl : public AccessRemote { /** * @brief cache_ contains pointer to cache manager instance */ - utils::SharedPtr<CacheManager> cache_; + std::shared_ptr<CacheManager> cache_; /** * @brief hmi_types_ contains list of default HMI types for applications diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 8c0acd44d2..48e00f7049 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -35,9 +35,7 @@ #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" @@ -73,6 +71,22 @@ class CacheManager : public CacheManagerInterface { CheckPermissionResult& result); /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -200,7 +214,7 @@ class CacheManager : public CacheManagerInterface { * device_info, statistics, excluding user messages * @return Generated structure for obtaining Json string. */ - virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot(); + virtual std::shared_ptr<policy_table::Table> GenerateSnapshot(); /** * Applies policy table to the current table @@ -597,8 +611,18 @@ class CacheManager : public CacheManagerInterface { * @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; + void GetAppRequestTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const OVERRIDE; + + /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const OVERRIDE; /** * @brief GetCertificate allows to obtain certificate in order to @@ -697,7 +721,7 @@ class CacheManager : public CacheManagerInterface { const PolicySettings& get_settings() const; - utils::SharedPtr<policy_table::Table> pt() const { + std::shared_ptr<policy_table::Table> pt() const { return pt_; } @@ -749,14 +773,14 @@ class CacheManager : public CacheManagerInterface { policy::Permissions& permission); private: - utils::SharedPtr<policy_table::Table> pt_; - utils::SharedPtr<policy_table::Table> snapshot_; - utils::SharedPtr<PTRepresentation> backup_; + std::shared_ptr<policy_table::Table> pt_; + std::shared_ptr<policy_table::Table> snapshot_; + std::shared_ptr<PTRepresentation> backup_; bool update_required; typedef std::set<std::string> UnpairedDevices; UnpairedDevices is_unpaired_; - mutable sync_primitives::Lock cache_lock_; + mutable sync_primitives::RecursiveLock cache_lock_; sync_primitives::Lock unpaired_lock_; typedef std::map<std::string, Permissions> AppCalculatedPermissions; diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 9f7c7318db..10a6ea7f89 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -36,7 +36,6 @@ #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" @@ -46,6 +45,16 @@ namespace policy_table = rpc::policy_table_interface_base; namespace policy { +namespace RequestType { +// Describes available RequestType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestType + +namespace RequestSubType { +// Describes available RequestSubType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestSubType + class CacheManagerInterface { public: virtual ~CacheManagerInterface() {} @@ -67,6 +76,22 @@ class CacheManagerInterface { CheckPermissionResult& result) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -196,7 +221,7 @@ class CacheManagerInterface { * device_info, statistics, excluding user messages * @return Generated structure for obtaining Json string. */ - virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() = 0; + virtual std::shared_ptr<policy_table::Table> GenerateSnapshot() = 0; /** * Applies policy table to the current table @@ -627,6 +652,15 @@ class CacheManagerInterface { std::vector<std::string>& request_types) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + virtual void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const = 0; + + /** * @brief GetCertificate allows to obtain certificate in order to * make secure connection * @@ -635,12 +669,12 @@ class CacheManagerInterface { virtual std::string GetCertificate() const = 0; /** - * @brief pt allows to obtain SharedPtr to PT. + * @brief pt allows to obtain std::shared_ptr to PT. * Used ONLY in Unit tests - * @return SharedPTR to PT + * @return std::shared_ptr to PT * */ - virtual utils::SharedPtr<policy_table::Table> pt() const = 0; + virtual std::shared_ptr<policy_table::Table> pt() const = 0; /** * @brief OnDeviceSwitching Processes existing policy permissions for devices @@ -652,7 +686,7 @@ class CacheManagerInterface { const std::string& device_id_to) = 0; }; -typedef utils::SharedPtr<CacheManagerInterface> CacheManagerInterfaceSPtr; +typedef std::shared_ptr<CacheManagerInterface> CacheManagerInterfaceSPtr; } // namespace policy diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h index 8a60801dd4..3ca0f93ebd 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -34,7 +34,7 @@ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_HELPER_H_ #include "policy/policy_table/functions.h" -#include "utils/shared_ptr.h" + #include "policy/policy_types.h" namespace policy { @@ -82,8 +82,8 @@ bool operator!=(const policy_table::ApplicationParams& first, */ struct CheckAppPolicy { CheckAppPolicy(PolicyManagerImpl* pm, - const utils::SharedPtr<policy_table::Table> update, - const utils::SharedPtr<policy_table::Table> snapshot); + const std::shared_ptr<policy_table::Table> update, + const std::shared_ptr<policy_table::Table> snapshot); bool operator()(const AppPoliciesValueType& app_policy); private: @@ -95,7 +95,8 @@ struct CheckAppPolicy { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; void SetPendingPermissions(const AppPoliciesValueType& app_policy, @@ -126,11 +127,12 @@ struct CheckAppPolicy { bool IsConsentRequired(const std::string& app_id, const std::string& group_name) const; bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const; + bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; private: PolicyManagerImpl* pm_; - const utils::SharedPtr<policy_table::Table> update_; - const utils::SharedPtr<policy_table::Table> snapshot_; + const std::shared_ptr<policy_table::Table> update_; + const std::shared_ptr<policy_table::Table> snapshot_; }; /* diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 941db1a67f..51d4ee88aa 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -37,7 +37,6 @@ #include <list> #include <cstdint> -#include "utils/shared_ptr.h" #include "utils/lock.h" #include "policy/policy_manager.h" #include "policy/policy_table.h" @@ -47,10 +46,8 @@ #include "policy/usage_statistics/statistics_manager.h" #include "policy/policy_helper.h" #include "utils/timer.h" -#ifdef SDL_REMOTE_CONTROL #include "policy/access_remote.h" #include "policy/access_remote_impl.h" -#endif // SDL_REMOTE_CONTROL namespace policy_table = rpc::policy_table_interface_base; @@ -448,7 +445,6 @@ class PolicyManagerImpl : public PolicyManager { const std::string& application_id, const rpc::policy_table_interface_base::AppHmiTypes& hmi_types) OVERRIDE; -#ifdef SDL_REMOTE_CONTROL /** * @brief Assigns new HMI types for specified application * @param application_id Unique application id @@ -470,7 +466,7 @@ class PolicyManagerImpl : public PolicyManager { * @brief Setter for access_remote instance * @param access_remote pointer to new access_remote instance */ - void set_access_remote(utils::SharedPtr<AccessRemote> access_remote) OVERRIDE; + void set_access_remote(std::shared_ptr<AccessRemote> access_remote) OVERRIDE; /** * @brief Sends notification about application HMI level changed @@ -483,7 +479,6 @@ class PolicyManagerImpl : public PolicyManager { * @param application_id Unique id of application */ void OnPrimaryGroupsChanged(const std::string& application_id); -#endif // SDL_REMOTE_CONTROL /** * @brief Removes consent for application functional group @@ -532,6 +527,22 @@ class PolicyManagerImpl : public PolicyManager { void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -540,6 +551,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string policy_app_id) const OVERRIDE; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Get information about vehicle * @return vehicle information */ @@ -651,7 +670,7 @@ class PolicyManagerImpl : public PolicyManager { * @param pt_content binary content of PT * @return pointer to converted PT */ - virtual utils::SharedPtr<policy_table::Table> Parse( + virtual std::shared_ptr<policy_table::Table> Parse( const BinaryMessage& pt_content); #else /** @@ -659,7 +678,7 @@ class PolicyManagerImpl : public PolicyManager { * @param pt_content binary content of PT * @return pointer to converted PT */ - virtual utils::SharedPtr<policy_table::Table> ParseArray( + virtual std::shared_ptr<policy_table::Table> ParseArray( const BinaryMessage& pt_content); #endif @@ -685,8 +704,8 @@ class PolicyManagerImpl : public PolicyManager { * @return Collection per-application results */ void CheckPermissionsChanges( - const utils::SharedPtr<policy_table::Table> update, - const utils::SharedPtr<policy_table::Table> snapshot); + const std::shared_ptr<policy_table::Table> update, + const std::shared_ptr<policy_table::Table> snapshot); /** * @brief Fill structure to be sent with OnPermissionsChanged notification @@ -783,7 +802,7 @@ class PolicyManagerImpl : public PolicyManager { * @param type policy table type * @return true if policy table valid, otherwise false */ - bool IsPTValid(utils::SharedPtr<policy_table::Table> policy_table, + bool IsPTValid(std::shared_ptr<policy_table::Table> policy_table, policy_table::PolicyTableType type) const; /** @@ -792,7 +811,6 @@ class PolicyManagerImpl : public PolicyManager { void RetrySequence(); private: -#ifdef SDL_REMOTE_CONTROL /** * @brief Get resulting RPCs permissions for application which started on * specific device @@ -829,10 +847,10 @@ class PolicyManagerImpl : public PolicyManager { */ bool GetModuleTypes(const std::string& policy_app_id, std::vector<std::string>* modules) const OVERRIDE; -#endif // SDL_REMOTE_CONTROL - /** - * @brief pointer to policy table listener for callbacks - */ + + /** + * @brief pointer to policy table listener for callbacks + */ PolicyListener* listener_; /** @@ -844,12 +862,11 @@ class PolicyManagerImpl : public PolicyManager { * @brief pointer to CacheManagerInterface instance for getting policy data */ CacheManagerInterfaceSPtr cache_; -#ifdef SDL_REMOTE_CONTROL + /** * @brief pointer to AccessRemote instance for working with RC applications */ - utils::SharedPtr<AccessRemote> access_remote_; -#endif + std::shared_ptr<AccessRemote> access_remote_; /** * @brief lock guard for protecting applications list access diff --git a/src/components/policy/policy_regular/include/policy/policy_table.h b/src/components/policy/policy_regular/include/policy/policy_table.h index afee8a34e4..8ef3cd7fc8 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table.h +++ b/src/components/policy/policy_regular/include/policy/policy_table.h @@ -33,16 +33,14 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_TABLE_H_ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_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); + explicit PolicyTable(std::shared_ptr<PTRepresentation> pt_data); virtual ~PolicyTable(); /** @@ -50,12 +48,12 @@ class PolicyTable { * actual class storing policy table. * @return PTRepresentation* Policy Table Content Handler */ - utils::SharedPtr<PTRepresentation> pt_data() const { + std::shared_ptr<PTRepresentation> pt_data() const { return pt_data_; } private: - utils::SharedPtr<PTRepresentation> pt_data_; + std::shared_ptr<PTRepresentation> pt_data_; }; } // namespace policy diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 4eb35d2aa4..1f10db9f6f 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -44,6 +44,7 @@ enum Priority { P_VOICECOM, P_COMMUNICATION, P_NORMAL, + P_PROJECTION, P_NONE, }; @@ -66,20 +67,24 @@ enum Parameter { P_SPEED, P_ENGINETORQUE, P_EXTERNALTEMPERATURE, + P_TURNSIGNAL, P_FUELLEVEL, P_FUELLEVEL_STATE, P_HEADLAMPSTATUS, P_INSTANTFUELCONSUMPTION, + P_FUELRANGE, P_ODOMETER, P_TIREPRESSURE, P_WIPERSTATUS, P_VIN, P_ACCPEDALPOSITION, P_BELTSTATUS, + P_ELECTRONICPARKBRAKESTATUS, P_DRIVERBRAKING, P_PRNDL, P_RPM, P_STEERINGWHEELANGLE, + P_ENGINEOILLIFE, P_MYKEY, P_AIRBAGSTATUS, P_BODYINFORMATION, @@ -132,7 +137,9 @@ enum RequestType { RT_VEHICLE_DIAGNOSTICS, RT_EMERGENCY, RT_MEDIA, - RT_FOTA + RT_FOTA, + RT_OEM_SPECIFIC, + RT_EMPTY // Added to allow empty Request Types handling }; bool IsValidEnum(RequestType val); @@ -150,11 +157,382 @@ bool EnumFromJsonString(const std::string& literal, Input* result); enum ModuleType { MT_CLIMATE, MT_RADIO, + MT_SEAT, + MT_AUDIO, + MT_LIGHT, + MT_HMI_SETTINGS, + MT_EMPTY }; bool IsValidEnum(ModuleType val); const char* EnumToJsonString(ModuleType val); bool EnumFromJsonString(const std::string& literal, ModuleType* result); +/** + * @brief Enumeration FunctionID. + * + * Enumeration linking function names with function IDs in AppLink protocol. + * Assumes enumeration starts at value 0. + */ +enum FunctionID { + /** + * @brief RESERVED. + */ + RESERVED = 0, + + /** + * @brief RegisterAppInterfaceID. + */ + RegisterAppInterfaceID = 1, + + /** + * @brief UnregisterAppInterfaceID. + */ + UnregisterAppInterfaceID = 2, + + /** + * @brief SetGlobalPropertiesID. + */ + SetGlobalPropertiesID = 3, + + /** + * @brief ResetGlobalPropertiesID. + */ + ResetGlobalPropertiesID = 4, + + /** + * @brief AddCommandID. + */ + AddCommandID = 5, + + /** + * @brief DeleteCommandID. + */ + DeleteCommandID = 6, + + /** + * @brief AddSubMenuID. + */ + AddSubMenuID = 7, + + /** + * @brief DeleteSubMenuID. + */ + DeleteSubMenuID = 8, + + /** + * @brief CreateInteractionChoiceSetID. + */ + CreateInteractionChoiceSetID = 9, + + /** + * @brief PerformInteractionID. + */ + PerformInteractionID = 10, + + /** + * @brief DeleteInteractionChoiceSetID. + */ + DeleteInteractionChoiceSetID = 11, + + /** + * @brief AlertID. + */ + AlertID = 12, + + /** + * @brief ShowID. + */ + ShowID = 13, + + /** + * @brief SpeakID. + */ + SpeakID = 14, + + /** + * @brief SetMediaClockTimerID. + */ + SetMediaClockTimerID = 15, + + /** + * @brief PerformAudioPassThruID. + */ + PerformAudioPassThruID = 16, + + /** + * @brief EndAudioPassThruID. + */ + EndAudioPassThruID = 17, + + /** + * @brief SubscribeButtonID. + */ + SubscribeButtonID = 18, + + /** + * @brief UnsubscribeButtonID. + */ + UnsubscribeButtonID = 19, + + /** + * @brief SubscribeVehicleDataID. + */ + SubscribeVehicleDataID = 20, + + /** + * @brief UnsubscribeVehicleDataID. + */ + UnsubscribeVehicleDataID = 21, + + /** + * @brief GetVehicleDataID. + */ + GetVehicleDataID = 22, + + /** + * @brief ReadDIDID. + */ + ReadDIDID = 23, + + /** + * @brief GetDTCsID. + */ + GetDTCsID = 24, + + /** + * @brief ScrollableMessageID. + */ + ScrollableMessageID = 25, + + /** + * @brief SliderID. + */ + SliderID = 26, + + /** + * @brief ShowConstantTBTID. + */ + ShowConstantTBTID = 27, + + /** + * @brief AlertManeuverID. + */ + AlertManeuverID = 28, + + /** + * @brief UpdateTurnListID. + */ + UpdateTurnListID = 29, + + /** + * @brief ChangeRegistrationID. + */ + ChangeRegistrationID = 30, + + /** + * @brief GenericResponseID. + */ + GenericResponseID = 31, + + /** + * @brief PutFileID. + */ + PutFileID = 32, + + /** + * @brief DeleteFileID. + */ + DeleteFileID = 33, + + /** + * @brief ListFilesID. + */ + ListFilesID = 34, + + /** + * @brief SetAppIconID. + */ + SetAppIconID = 35, + + /** + * @brief SetDisplayLayoutID. + */ + SetDisplayLayoutID = 36, + + /** + * @brief DiagnosticMessageID. + */ + DiagnosticMessageID = 37, + + /** + * @brief SystemRequestID. + */ + SystemRequestID = 38, + + /** + * @brief SendLocationID. + */ + SendLocationID = 39, + + /** + * @brief DialNumberID. + */ + DialNumberID = 40, + + /** + * @brief ButtonPressID. + */ + ButtonPressID = 41, + + /** + * @brief GetInteriorVehicleDataID. + */ + GetInteriorVehicleDataID = 43, + + /** + * @brief SetInteriorVehicleDataID. + */ + SetInteriorVehicleDataID = 44, + + /** + * @brief GetWayPointsID. + */ + GetWayPointsID = 45, + + /** + * @brief SubscribeWayPointsID. + */ + SubscribeWayPointsID = 46, + + /** + * @brief UnsubscribeWayPointsID. + */ + UnsubscribeWayPointsID = 47, + + /** + * @brief GetSystemCapabilityID. + */ + GetSystemCapabilityID = 48, + + /** + * @brief SendHapticDataID. + */ + SendHapticDataID = 49, + + /** + * @brief OnHMIStatusID. + */ + OnHMIStatusID = 32768, + + /** + * @brief OnAppInterfaceUnregisteredID. + */ + OnAppInterfaceUnregisteredID = 32769, + + /** + * @brief OnButtonEventID. + */ + OnButtonEventID = 32770, + + /** + * @brief OnButtonPressID. + */ + OnButtonPressID = 32771, + + /** + * @brief OnVehicleDataID. + */ + OnVehicleDataID = 32772, + + /** + * @brief OnCommandID. + */ + OnCommandID = 32773, + + /** + * @brief OnTBTClientStateID. + */ + OnTBTClientStateID = 32774, + + /** + * @brief OnDriverDistractionID. + */ + OnDriverDistractionID = 32775, + + /** + * @brief OnPermissionsChangeID. + */ + OnPermissionsChangeID = 32776, + + /** + * @brief OnAudioPassThruID. + */ + OnAudioPassThruID = 32777, + + /** + * @brief OnLanguageChangeID. + */ + OnLanguageChangeID = 32778, + + /** + * @brief OnKeyboardInputID. + */ + OnKeyboardInputID = 32779, + + /** + * @brief OnTouchEventID. + */ + OnTouchEventID = 32780, + + /** + * @brief OnSystemRequestID. + */ + OnSystemRequestID = 32781, + + /** + * @brief OnHashChangeID. + */ + OnHashChangeID = 32782, + + /** + * @brief OnInteriorVehicleDataID. + */ + OnInteriorVehicleDataID = 32783, + + /** + * @brief OnWayPointChangeID. + */ + OnWayPointChangeID = 32784, + + /** + * @brief OnRCStatusID. + */ + OnRCStatusID = 32785, + + /** + * @brief EncodedSyncPDataID. + */ + EncodedSyncPDataID = 65536, + + /** + * @brief SyncPDataID. + */ + SyncPDataID = 65537, + + /** + * @brief OnEncodedSyncPDataID. + */ + OnEncodedSyncPDataID = 98304, + + /** + * @brief OnSyncPDataID. + */ + OnSyncPDataID = 98305 +}; +bool IsValidEnum(FunctionID val); +const char* EnumToJsonString(FunctionID val); +bool EnumFromJsonString(const std::string& literal, FunctionID* result); + extern const std::string kDefaultApp; extern const std::string kPreDataConsentApp; extern const std::string kDeviceApp; diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 61585776f2..e201251745 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -65,7 +65,7 @@ typedef Array<Enum<AppHMIType>, 0, 255> AppHMITypes; typedef Array<Enum<HmiLevel>, 0, 4> HmiLevels; -typedef Array<Enum<Parameter>, 0, 24> Parameters; +typedef Array<Enum<Parameter>, 0, 255> Parameters; typedef Map<RpcParameters, 0, UINT_MAX> Rpc; @@ -76,7 +76,7 @@ typedef Map<URL, 1, 255> URLList; typedef Map<URLList, 1, 255> ServiceEndpoints; typedef uint8_t NumberOfNotificationsType; -typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 6> +typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7> NumberOfNotificationsPerMinute; typedef Array<Integer<uint16_t, 1, 1000>, 0, 5> SecondsBetweenRetries; @@ -96,11 +96,11 @@ typedef Map<DeviceParams, 0, 255> DeviceData; typedef Array<Enum<RequestType>, 0, 255> RequestTypes; -#ifdef SDL_REMOTE_CONTROL +typedef Strings RequestSubTypes; + typedef Map<Strings, 0, 255> RemoteRpcs; typedef Map<RemoteRpcs, 0, 255> AccessModules; typedef Array<Enum<ModuleType>, 0, 255> ModuleTypes; -#endif // SDL_REMOTE_CONTROL typedef AppHMIType AppHmiType; typedef std::vector<AppHMIType> AppHmiTypes; @@ -139,12 +139,11 @@ struct ApplicationParams : PolicyBase { Optional<Strings> nicknames; Optional<AppHMITypes> AppHMIType; Optional<RequestTypes> RequestType; + Optional<RequestSubTypes> RequestSubType; Optional<Integer<uint16_t, 0, 65225> > memory_kb; Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms; Optional<String<0, 255> > certificate; -#ifdef SDL_REMOTE_CONTROL mutable Optional<ModuleTypes> moduleType; -#endif // SDL_REMOTE_CONTROL public: ApplicationParams(); @@ -160,9 +159,7 @@ struct ApplicationParams : PolicyBase { private: bool Validate() const; -#ifdef SDL_REMOTE_CONTROL bool ValidateModuleTypes() const; -#endif // SDL_REMOTE_CONTROL }; struct ApplicationPoliciesSection : CompositeType { @@ -233,6 +230,7 @@ struct ModuleConfig : CompositeType { public: Optional<Map<String<0, 100>, 0, 255> > device_certificates; Optional<Boolean> preloaded_pt; + Optional<Boolean> full_app_id_supported; 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; diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h index af1d119e7a..276a0a5dca 100644 --- a/src/components/policy/policy_regular/include/policy/policy_types.h +++ b/src/components/policy/policy_regular/include/policy/policy_types.h @@ -39,7 +39,8 @@ #include <map> #include <set> #include <utility> -#include "utils/shared_ptr.h" +#include <memory> + #include "utils/helpers.h" #include "transport_manager/common.h" @@ -79,7 +80,7 @@ enum PolicyTableStatus { // Code generator uses String class name, so this typedef was renamed to PTSring typedef std::string PTString; typedef std::vector<uint8_t> BinaryMessage; -typedef utils::SharedPtr<BinaryMessage> BinaryMessageSptr; +typedef std::shared_ptr<BinaryMessage> BinaryMessageSptr; typedef std::string HMILevel; typedef std::string Parameter; @@ -267,7 +268,8 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) - , requestTypeChanged(false) {} + , requestTypeChanged(false) + , requestSubTypeChanged(false) {} std::string application_id; bool isAppPermissionsRevoked; @@ -280,6 +282,8 @@ struct AppPermissions { DeviceParams deviceInfo; bool requestTypeChanged; std::vector<std::string> requestType; + bool requestSubTypeChanged; + std::vector<std::string> requestSubType; }; /** @@ -471,7 +475,8 @@ enum PermissionsCheckResult { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; /** diff --git a/src/components/policy/policy_regular/include/policy/pt_ext_representation.h b/src/components/policy/policy_regular/include/policy/pt_ext_representation.h deleted file mode 100644 index f70946d1f5..0000000000 --- a/src/components/policy/policy_regular/include/policy/pt_ext_representation.h +++ /dev/null @@ -1,336 +0,0 @@ -/* - 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_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_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; - virtual bool SaveExternalConsentStatus( - const ExternalConsentStatus& status) const = 0; - virtual ExternalConsentStatus GetExternalConsentStatus() const = 0; -}; -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_PT_EXT_REPRESENTATION_H_ diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h index 08bd6d4923..378a294532 100644 --- a/src/components/policy/policy_regular/include/policy/pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/pt_representation.h @@ -35,9 +35,11 @@ #include <vector> #include <string> +#include <memory> #include "policy/policy_types.h" #include "policy/policy_table/types.h" #include "policy/policy_settings.h" +#include "utils/macro.h" namespace policy { namespace policy_table = rpc::policy_table_interface_base; @@ -208,7 +210,7 @@ class PTRepresentation { * device_info, statistics, excluding user messages * @return Generated structure for obtaining Json string. */ - virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const = 0; + virtual std::shared_ptr<policy_table::Table> GenerateSnapshot() const = 0; virtual bool Save(const policy_table::Table& table) = 0; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h deleted file mode 100644 index 727c0b165d..0000000000 --- a/src/components/policy/policy_regular/include/policy/sql_pt_ext_queries.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - 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_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_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; -extern const std::string kSelectExternalConsentStatus; -} // namespace sql_pt_ext -} // namespace policy - -#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_QUERIES_H_ diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h deleted file mode 100644 index 0958bad5e1..0000000000 --- a/src/components/policy/policy_regular/include/policy/sql_pt_ext_representation.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - 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_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_ -#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_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); - bool SaveExternalConsentStatus(const ExternalConsentStatus& status) const; - ExternalConsentStatus GetExternalConsentStatus() const; - - 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_POLICY_REGULAR_INCLUDE_POLICY_SQL_PT_EXT_REPRESENTATION_H_ diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index 2ded25e456..191873efe0 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -65,6 +65,7 @@ extern const std::string kSelectAppGroups; extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; +extern const std::string kSelectRequestSubTypes; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -78,6 +79,7 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; +extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -97,6 +99,7 @@ extern const std::string kDeleteRpc; extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; +extern const std::string kDeleteRequestSubType; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index 6b5d6111f1..0e9302dfac 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -84,7 +84,7 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool Clear(); bool Drop(); virtual void WriteDb(); - virtual utils::SharedPtr<policy_table::Table> GenerateSnapshot() const; + virtual std::shared_ptr<policy_table::Table> GenerateSnapshot() const; virtual bool Save(const policy_table::Table& table); bool GetInitialAppData(const std::string& app_id, StringArray* nicknames = NULL, @@ -97,7 +97,6 @@ class SQLPTRepresentation : public virtual PTRepresentation { } #endif // BUILD_TESTS protected: -#ifdef SDL_REMOTE_CONTROL enum TypeAccess { kAllowed, kManual }; bool GatherModuleType(const std::string& app_id, policy_table::ModuleTypes* module_types) const; @@ -112,7 +111,6 @@ class SQLPTRepresentation : public virtual PTRepresentation { bool SaveAccessModule(TypeAccess access, const policy_table::AccessModules& modules); bool SaveRemoteRpc(int module_id, const policy_table::RemoteRpcs& rpcs); -#endif // SDL_REMOTE_CONTROL virtual void GatherModuleMeta(policy_table::ModuleMeta* meta) const; virtual void GatherModuleConfig(policy_table::ModuleConfig* config) const; @@ -132,6 +130,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::AppHMITypes* app_types) const; bool GatherRequestType(const std::string& app_id, policy_table::RequestTypes* request_types) const; + bool GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -167,6 +168,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { const policy_table::AppHMITypes& types); bool SaveRequestType(const std::string& app_id, const policy_table::RequestTypes& types); + bool SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes); public: bool UpdateRequired() const; diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h index a68d986d10..c90acd4957 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h @@ -66,14 +66,14 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { * @brief Set next status during event processing * @param status Status shared pointer */ - void SetNextStatus(utils::SharedPtr<Status> status); + void SetNextStatus(std::shared_ptr<Status> status); /** * @brief Set postponed status (will be set after next status) during event * processing * @param status Status shared pointer */ - void SetPostponedStatus(utils::SharedPtr<Status> status); + void SetPostponedStatus(std::shared_ptr<Status> status); /** * @brief Sets listener pointer @@ -118,10 +118,10 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { void OnNewApplicationAdded(const DeviceConsent consent); /** - * @brief Update status handler for policy initialization + * @brief Update status handler on existed application registering * @param is_update_required Update necessity flag */ - void OnPolicyInit(bool is_update_required); + void OnExistedApplicationAdded(const bool is_update_required); /** * @brief In case application from non-consented device has been registered @@ -198,17 +198,17 @@ class UpdateStatusManager : public UpdateStatusManagerInterface { /** * @brief Current update status */ - utils::SharedPtr<Status> current_status_; + std::shared_ptr<Status> current_status_; /** * @brief Next status after current to be set */ - utils::SharedPtr<Status> next_status_; + std::shared_ptr<Status> next_status_; /** * @brief Status to be set after 'next' status */ - utils::SharedPtr<Status> postponed_status_; + std::shared_ptr<Status> postponed_status_; sync_primitives::Lock status_lock_; UpdateEvent last_processed_event_; diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h index e118f9974f..4763ff2eb5 100644 --- a/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/update_status_manager_interface.h @@ -33,7 +33,6 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_INTERFACE_H_ #define SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_UPDATE_STATUS_MANAGER_INTERFACE_H_ -#include "utils/shared_ptr.h" #include "policy/policy_types.h" #include "policy/status.h" @@ -55,14 +54,14 @@ class UpdateStatusManagerInterface { * @brief Set next status during event processing * @param status Status shared pointer */ - virtual void SetNextStatus(utils::SharedPtr<Status> status) = 0; + virtual void SetNextStatus(std::shared_ptr<Status> status) = 0; /** * @brief Set postponed status (will be set after next status) during event * processing * @param status Status shared pointer */ - virtual void SetPostponedStatus(utils::SharedPtr<Status> status) = 0; + virtual void SetPostponedStatus(std::shared_ptr<Status> status) = 0; /** * @brief Sets listener pointer * @param listener Pointer to policy listener implementation @@ -106,13 +105,13 @@ class UpdateStatusManagerInterface { virtual void OnNewApplicationAdded(DeviceConsent device_consent) = 0; /** - * @brief Update status handler for policy initialization + * @brief Update status handler on existed application registering * @param is_update_required Update necessity flag */ - virtual void OnPolicyInit(bool is_update_required) = 0; + virtual void OnExistedApplicationAdded(const bool is_update_required) = 0; }; -typedef utils::SharedPtr<UpdateStatusManagerInterface> +typedef std::shared_ptr<UpdateStatusManagerInterface> UpdateStatusManagerInterfaceSPtr; } // namespace policy diff --git a/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h b/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h index 1e263ec9df..72ae5fd9e0 100644 --- a/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h +++ b/src/components/policy/policy_regular/include/policy/usage_statistics/counter.h @@ -36,7 +36,7 @@ #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" @@ -46,18 +46,18 @@ using timer::Timer; class GlobalCounter { public: - GlobalCounter(utils::SharedPtr<StatisticsManager> statistics_manager, + GlobalCounter(std::shared_ptr<StatisticsManager> statistics_manager, GlobalCounterId counter_type); void operator++() const; private: GlobalCounterId counter_type_; - utils::SharedPtr<StatisticsManager> statistics_manager_; + std::shared_ptr<StatisticsManager> statistics_manager_; }; class AppCounter { public: - AppCounter(utils::SharedPtr<StatisticsManager> statistics_manager, + AppCounter(std::shared_ptr<StatisticsManager> statistics_manager, const std::string& app_id, AppCounterId counter_type); void operator++() const; @@ -65,12 +65,12 @@ class AppCounter { private: std::string app_id_; AppCounterId counter_type_; - utils::SharedPtr<StatisticsManager> statistics_manager_; + std::shared_ptr<StatisticsManager> statistics_manager_; }; class AppInfo { public: - AppInfo(utils::SharedPtr<StatisticsManager> statistics_manager, + AppInfo(std::shared_ptr<StatisticsManager> statistics_manager, const std::string& app_id, AppInfoId info_type); void Update(const std::string& new_info) const; @@ -78,14 +78,14 @@ class AppInfo { private: std::string app_id_; AppInfoId info_type_; - utils::SharedPtr<StatisticsManager> statistics_manager_; + std::shared_ptr<StatisticsManager> statistics_manager_; }; class AppStopwatchImpl : public AppStopwatch { public: - AppStopwatchImpl(utils::SharedPtr<StatisticsManager> statistics_manager, + AppStopwatchImpl(std::shared_ptr<StatisticsManager> statistics_manager, const std::string& app_id); - AppStopwatchImpl(utils::SharedPtr<StatisticsManager> statistics_manager, + AppStopwatchImpl(std::shared_ptr<StatisticsManager> statistics_manager, const std::string& app_id, std::uint32_t timeout); void Start(AppStopwatchId stopwatch_type) OVERRIDE; @@ -96,7 +96,7 @@ class AppStopwatchImpl : public AppStopwatch { // Fields std::string app_id_; AppStopwatchId stopwatch_type_; - utils::SharedPtr<StatisticsManager> statistics_manager_; + std::shared_ptr<StatisticsManager> statistics_manager_; timer::Timer timer_; const std::uint32_t time_out_; DISALLOW_COPY_AND_ASSIGN(AppStopwatchImpl); |