summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular/include
diff options
context:
space:
mode:
authorAlexander Kutsan <akutsan@luxoft.com>2017-08-10 14:07:09 +0300
committerAndrey Oleynik <aoleynik@luxoft.com>2017-08-16 22:34:23 +0300
commit59f437dc8608e1ec54c517416a39860d9a7be3b8 (patch)
tree2908c276bd5ea066741c034eb2bd144682ba8649 /src/components/policy/policy_regular/include
parent06729e8b744374a4d9694f669101b6c554ce42e0 (diff)
downloadsdl_core-59f437dc8608e1ec54c517416a39860d9a7be3b8.tar.gz
Implementation of Remote Control plugin
Stype changes after integration Fix policy handler remote unit tests
Diffstat (limited to 'src/components/policy/policy_regular/include')
-rw-r--r--src/components/policy/policy_regular/include/policy/access_remote.h233
-rw-r--r--src/components/policy/policy_regular/include/policy/access_remote_impl.h123
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h18
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h16
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h70
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h18
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_queries.h21
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_representation.h25
-rw-r--r--src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h50
11 files changed, 532 insertions, 57 deletions
diff --git a/src/components/policy/policy_regular/include/policy/access_remote.h b/src/components/policy/policy_regular/include/policy/access_remote.h
new file mode 100644
index 0000000000..b9fd8862e9
--- /dev/null
+++ b/src/components/policy/policy_regular/include/policy/access_remote.h
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2015, 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_ACCESS_REMOTE_H_
+#define SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_ACCESS_REMOTE_H_
+
+#include <vector>
+#include <ostream>
+#include <string>
+#include "policy/policy_table/types.h"
+#include "policy/policy_types.h"
+
+namespace policy_table = ::rpc::policy_table_interface_base;
+
+namespace policy {
+
+enum TypeAccess { kDisallowed, kAllowed, kManual };
+inline std::ostream& operator<<(std::ostream& output, TypeAccess x) {
+ output << "Access: ";
+ switch (x) {
+ case kDisallowed:
+ output << "DISALLOWED";
+ break;
+ case kAllowed:
+ output << "ALLOWED";
+ break;
+ case kManual:
+ output << "MANUAL";
+ break;
+ default:
+ output << "Error: Unknown type";
+ }
+ return output;
+}
+
+struct Subject {
+ PTString dev_id;
+ PTString app_id;
+};
+inline bool operator<(const Subject& x, const Subject& y) {
+ return x.dev_id < y.dev_id || (x.dev_id == y.dev_id && x.app_id < y.app_id);
+}
+inline bool operator==(const Subject& x, const Subject& y) {
+ return x.dev_id == y.dev_id && x.app_id == y.app_id;
+}
+inline std::ostream& operator<<(std::ostream& output, const Subject& who) {
+ output << "Subject(dev:" << who.dev_id << ", app:" << who.app_id << ")";
+ return output;
+}
+
+struct Object {
+ policy_table::ModuleType module;
+};
+inline bool operator<(const Object& x, const Object& y) {
+ return x.module < y.module;
+}
+inline bool operator==(const Object& x, const Object& y) {
+ return x.module == y.module;
+}
+inline std::ostream& operator<<(std::ostream& output, const Object& what) {
+ output << "Object(module:" << EnumToJsonString(what.module) << ")";
+ return output;
+}
+
+typedef std::vector<PTString> RemoteControlParams;
+
+class AccessRemote {
+ public:
+ virtual ~AccessRemote() {}
+
+ /**
+ * Initializes oneself
+ */
+ virtual void Init() = 0;
+
+ /**
+ * Enables remote control
+ */
+ virtual void Enable() = 0;
+
+ /**
+ * Disables remote control
+ */
+ virtual void Disable() = 0;
+
+ /**
+ * Checks if remote control is enabled
+ * @return true if enabled
+ */
+ virtual bool IsEnabled() const = 0;
+
+ /**
+ * Checks whether device is driver's device
+ * @param dev_id unique device id
+ * @return true if device is have driver
+ */
+ virtual bool IsPrimaryDevice(const PTString& dev_id) const = 0;
+
+ /**
+ * Sets device as driver's device
+ * @param dev_id ID device
+ */
+ virtual void SetPrimaryDevice(const PTString& dev_id) = 0;
+
+ /**
+ * Gets current primary device
+ * @return ID device
+ */
+ virtual PTString PrimaryDevice() const = 0;
+
+ /**
+ * Allows access subject to object
+ * @param who subject is dev_id and app_id
+ * @param what object is group_id
+ */
+ virtual void Allow(const Subject& who, const Object& what) = 0;
+
+ /**
+ * Denies access subject to object
+ * @param who subject is dev_id and app_id
+ * @param what object is group_id
+ */
+ virtual void Deny(const Subject& who, const Object& what) = 0;
+
+ /**
+ * Resets access subject to all object
+ * @param who subject is dev_id and app_id
+ */
+ virtual void Reset(const Subject& who) = 0;
+
+ /**
+ * Resets access to object for all subjects
+ * @param what object is group
+ */
+ virtual void Reset(const Object& what) = 0;
+
+ /*
+ * Resets all stored consents
+ */
+ virtual void Reset() = 0;
+
+ /**
+ * Checks access subject to object
+ * @param who subject is dev_id and app_id
+ * @param what object is group_id
+ * @return allowed if access was given, disallowed if access was denied
+ * manual if need to ask driver
+ */
+ virtual TypeAccess Check(const Subject& who, const Object& what) const = 0;
+
+ /**
+ * Checks permissions for module
+ * @param app_id application ID
+ * @param module type
+ * @return true if allowed
+ */
+ virtual bool CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const = 0;
+
+ /**
+ * Sets HMI types if application has default policy permissions
+ * @param who subject
+ * @param hmi_types list of HMI types
+ */
+ virtual void SetDefaultHmiTypes(const Subject& who,
+ const std::vector<int>& hmi_types) = 0;
+
+ /**
+ * Gets groups
+ * @param who subject
+ * @return list of groups
+ */
+ virtual const policy_table::Strings& GetGroups(const Subject& who) = 0;
+
+ /**
+ * Gets permissions for application
+ * @param device_id
+ * @param app_id
+ * @param group_types
+ * @return true if success
+ */
+ virtual bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types) = 0;
+
+ /**
+ * Checks if application has remote functionality
+ * @param who subject
+ * @return true if application uses remote control
+ */
+ virtual bool IsAppRemoteControl(const Subject& who) = 0;
+
+ /**
+ * Gets all allowed module types
+ * @param app_id unique identifier of application
+ * @param list of allowed module types
+ * @return true if application has allowed modules
+ */
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) = 0;
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_ACCESS_REMOTE_H_
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
new file mode 100644
index 0000000000..03427d2501
--- /dev/null
+++ b/src/components/policy/policy_regular/include/policy/access_remote_impl.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2015, 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_ACCESS_REMOTE_IMPL_H_
+#define SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_ACCESS_REMOTE_IMPL_H_
+
+#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"
+
+using policy_table::FunctionalGroupings;
+
+namespace policy {
+
+class AccessRemoteImpl : public AccessRemote {
+ public:
+ typedef std::map<Subject, TypeAccess> AccessControlRow;
+ typedef std::map<Object, AccessControlRow> AccessControlList;
+ typedef std::map<Subject, policy_table::AppHMITypes> HMIList;
+
+ AccessRemoteImpl();
+ explicit AccessRemoteImpl(utils::SharedPtr<CacheManager> cache);
+
+ virtual void Init();
+ virtual void Enable();
+ virtual void Disable();
+ virtual bool IsEnabled() const;
+
+ virtual bool IsPrimaryDevice(const PTString& dev_id) const;
+ virtual void SetPrimaryDevice(const PTString& dev_id);
+ virtual PTString PrimaryDevice() const;
+
+ virtual void Allow(const Subject& who, const Object& what);
+ virtual void Deny(const Subject& who, const Object& what);
+ virtual void Reset(const Subject& who);
+ virtual void Reset(const Object& what);
+ virtual void Reset();
+ virtual TypeAccess Check(const Subject& who, const Object& what) const;
+ virtual bool CheckModuleType(const PTString& app_id,
+ policy_table::ModuleType module) const;
+ virtual void SetDefaultHmiTypes(const Subject& who,
+ const std::vector<int>& hmi_types);
+ virtual const policy_table::Strings& GetGroups(const Subject& who);
+ virtual bool GetPermissionsForApp(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalIdType& group_types);
+ virtual bool IsAppRemoteControl(const Subject& who);
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules);
+
+ private:
+ inline void set_enabled(bool value);
+ inline bool country_consent() const;
+ const policy_table::AppHMITypes& HmiTypes(const Subject& who);
+ void GetGroupsIds(const std::string& device_id,
+ const std::string& app_id,
+ FunctionalGroupIDs& grops_ids);
+ bool IsAllowed(const policy_table::AccessModules& modules,
+ const std::string& module_name,
+ const std::string& rpc_name,
+ RemoteControlParams* input) const;
+ bool CompareParameters(const policy_table::Strings& parameters,
+ RemoteControlParams* input) const;
+ utils::SharedPtr<CacheManager> cache_;
+ PTString primary_device_;
+ bool enabled_;
+ AccessControlList acl_;
+ HMIList hmi_types_;
+
+#ifdef BUILD_TESTS
+ friend struct Erase;
+ friend struct IsTypeAccess;
+
+ FRIEND_TEST(AccessRemoteImplTest, KeyMapTest);
+ FRIEND_TEST(AccessRemoteImplTest, Allow);
+ FRIEND_TEST(AccessRemoteImplTest, Deny);
+ FRIEND_TEST(AccessRemoteImplTest, ChangeAccess);
+ FRIEND_TEST(AccessRemoteImplTest, ResetBySubject);
+ FRIEND_TEST(AccessRemoteImplTest, ResetByObject);
+ FRIEND_TEST(AccessRemoteImplTest, CheckAllowed);
+ FRIEND_TEST(AccessRemoteImplTest, CheckDisallowed);
+ FRIEND_TEST(AccessRemoteImplTest, CheckManual);
+ FRIEND_TEST(AccessRemoteImplTest, CheckModuleType);
+ FRIEND_TEST(AccessRemoteImplTest, EnableDisable);
+ FRIEND_TEST(AccessRemoteImplTest, SetDefaultHmiTypes);
+ FRIEND_TEST(AccessRemoteImplTest, GetGroups);
+#endif // BUILD_TESTS
+};
+
+} // namespace policy
+
+#endif // SRC_COMPONENTS_POLICY_SRC_POLICY_INCLUDE_POLICY_ACCESS_REMOTE_IMPL_H_
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 73c010ce33..c5d4c848f4 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -325,6 +325,13 @@ class CacheManager : public CacheManagerInterface {
bool GetDefaultHMI(const std::string& app_id, std::string& default_hmi) const;
/**
+ * Gets HMI types from specific policy
+ * @param app_id ID application
+ * @return list of HMI types
+ */
+ const policy_table::AppHMITypes* GetHMITypes(const std::string& app_id);
+
+ /**
* @brief Reset user consent for device data and applications permissions
* @return
*/
@@ -690,11 +697,9 @@ class CacheManager : public CacheManagerInterface {
const PolicySettings& get_settings() const;
-#ifdef BUILD_TESTS
- utils::SharedPtr<policy_table::Table> GetPT() const {
+ utils::SharedPtr<policy_table::Table> pt() const {
return pt_;
}
-#endif
private:
std::string currentDateTime();
@@ -767,6 +772,13 @@ class CacheManager : public CacheManagerInterface {
sync_primitives::Lock backuper_locker_;
BackgroundBackuper* backuper_;
const PolicySettings* settings_;
+
+#ifdef BUILD_TESTS
+ friend class AccessRemoteImpl;
+ FRIEND_TEST(AccessRemoteImplTest, CheckModuleType);
+ FRIEND_TEST(AccessRemoteImplTest, EnableDisable);
+ FRIEND_TEST(AccessRemoteImplTest, GetGroups);
+#endif // BUILD_TESTS
};
} // namespace policy
#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_CACHE_MANAGER_H_
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 50896bb8f1..9712b799dc 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
@@ -323,6 +323,14 @@ class CacheManagerInterface {
std::string& default_hmi) const = 0;
/**
+ * Gets HMI types from specific policy
+ * @param app_id ID application
+ * @return list of HMI types
+ */
+ virtual const policy_table::AppHMITypes* GetHMITypes(
+ const std::string& app_id) = 0;
+
+ /**
* @brief Reset user consent for device data and applications permissions
* @return
*/
@@ -626,15 +634,13 @@ class CacheManagerInterface {
*/
virtual std::string GetCertificate() const = 0;
-#ifdef BUILD_TESTS
/**
- * @brief GetPT allows to obtain SharedPtr to PT.
+ * @brief pt 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
+ virtual utils::SharedPtr<policy_table::Table> pt() const = 0;
};
typedef utils::SharedPtr<CacheManagerInterface> CacheManagerInterfaceSPtr;
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 996c2917d0..ce1288fa1b 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -243,6 +243,22 @@ FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first,
* @return true, if succeded, otherwise - false
*/
bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies);
+
+#ifdef SDL_REMOTE_CONTROL
+
+struct ProccessAppGroups {
+ ProccessAppGroups(const policy_table::ApplicationPolicies& apps,
+ PolicyManagerImpl* pm)
+ : new_apps_(apps), pm_(pm), default_(new_apps_.find(kDefaultId)) {}
+ void operator()(const policy_table::ApplicationPolicies::value_type& app);
+
+ private:
+ const policy_table::ApplicationPolicies& new_apps_;
+ PolicyManagerImpl* pm_;
+ policy_table::ApplicationPolicies::const_iterator default_;
+};
+
+#endif // SDL_REMOTE_CONTROL
}
#endif // SRC_COMPONENTS_POLICY_POLICY_REGULAR_INCLUDE_POLICY_POLICY_HELPER_H_
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 3ca9994a8a..868328bcb4 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
@@ -47,6 +47,10 @@
#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;
@@ -176,6 +180,39 @@ class PolicyManagerImpl : public PolicyManager {
StatusNotifier AddApplication(
const std::string& application_id,
const rpc::policy_table_interface_base::AppHmiTypes& hmi_types);
+#ifdef SDL_REMOTE_CONTROL
+ void SetDefaultHmiTypes(const std::string& application_id,
+ const std::vector<int>& hmi_types);
+ /**
+ * Gets HMI types
+ * @param application_id ID application
+ * @param app_types list to save HMI types
+ * @return true if policy has specific policy for this application
+ */
+ virtual bool GetHMITypes(const std::string& application_id,
+ std::vector<int>* app_types) OVERRIDE;
+ virtual void set_access_remote(utils::SharedPtr<AccessRemote> access_remote);
+ TypeAccess CheckDriverConsent(const Subject& who,
+ const Object& what,
+ const std::string& rpc,
+ const RemoteControlParams& params);
+ void CheckPTUUpdatesChange(
+ const utils::SharedPtr<policy_table::Table> pt_update,
+ const utils::SharedPtr<policy_table::Table> snapshot);
+ bool CheckPTURemoteCtrlChange(
+ const utils::SharedPtr<policy_table::Table> pt_update,
+ const utils::SharedPtr<policy_table::Table> snapshot);
+
+ void CheckRemoteGroupsChange(
+ const utils::SharedPtr<policy_table::Table> pt_update,
+ const utils::SharedPtr<policy_table::Table> snapshot);
+
+ void SendHMILevelChanged(const Subject& who);
+ void UpdateDeviceRank(const Subject& who, const std::string& rank);
+
+ void OnPrimaryGroupsChanged(const std::string& application_id);
+ void OnNonPrimaryGroupsChanged(const std::string& application_id);
+#endif // SDL_REMOTE_CONTROL
virtual void RemoveAppConsentForGroup(const std::string& app_id,
const std::string& group_name);
@@ -319,10 +356,43 @@ class PolicyManagerImpl : public PolicyManager {
void RetrySequence();
private:
+#ifdef SDL_REMOTE_CONTROL
+ void GetPermissions(const std::string device_id,
+ const std::string application_id,
+ Permissions* data);
+ virtual TypeAccess CheckAccess(const PTString& device_id,
+ const PTString& app_id,
+ const PTString& module,
+ const PTString& rpc,
+ const RemoteControlParams& params);
+ virtual bool CheckModule(const PTString& app_id, const PTString& module);
+ virtual void SetAccess(const PTString& dev_id,
+ const PTString& app_id,
+ const PTString& module,
+ bool allowed);
+ virtual void ResetAccess(const PTString& dev_id, const PTString& app_id);
+ virtual void ResetAccess(const PTString& module);
+ virtual void SetPrimaryDevice(const PTString& dev_id);
+ virtual void ResetPrimaryDevice();
+ virtual PTString PrimaryDevice() const;
+ virtual void SetRemoteControl(bool enabled);
+ virtual bool GetRemoteControl() const;
+ virtual void OnChangedPrimaryDevice(const std::string& device_id,
+ const std::string& application_id);
+ virtual void OnChangedRemoteControl(const std::string& device_id,
+ const std::string& application_id);
+ virtual void SendAppPermissionsChanged(const std::string& device_id,
+ const std::string& application_id);
+ virtual bool GetModuleTypes(const std::string& policy_app_id,
+ std::vector<std::string>* modules) const;
+#endif // SDL_REMOTE_CONTROL
PolicyListener* listener_;
UpdateStatusManager update_status_manager_;
CacheManagerInterfaceSPtr cache_;
+#ifdef SDL_REMOTE_CONTROL
+ utils::SharedPtr<AccessRemote> access_remote_;
+#endif
sync_primitives::Lock apps_registration_lock_;
sync_primitives::Lock app_permissions_diff_lock_;
std::map<std::string, AppPermissions> app_permissions_diff_;
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 8b9a872a5b..d9d2ad34eb 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
@@ -96,6 +96,12 @@ typedef Map<DeviceParams, 0, 255> DeviceData;
typedef Array<Enum<RequestType>, 0, 255> RequestTypes;
+#ifdef SDL_REMOTE_CONTROL
+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;
@@ -136,6 +142,11 @@ struct ApplicationParams : PolicyBase {
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
+ Optional<Strings> groups_primaryRC;
+ Optional<Strings> groups_nonPrimaryRC;
+ mutable Optional<ModuleTypes> moduleType;
+#endif // SDL_REMOTE_CONTROL
public:
ApplicationParams();
@@ -151,6 +162,9 @@ struct ApplicationParams : PolicyBase {
private:
bool Validate() const;
+#ifdef SDL_REMOTE_CONTROL
+ bool ValidateModuleTypes() const;
+#endif // SDL_REMOTE_CONTROL
};
struct ApplicationPoliciesSection : CompositeType {
@@ -233,6 +247,10 @@ struct ModuleConfig : CompositeType {
Optional<String<4, 4> > vehicle_year;
Optional<String<0, 10> > preloaded_date;
Optional<String<0, 65535> > certificate;
+#ifdef SDL_REMOTE_CONTROL
+ Optional<Boolean> user_consent_passengersRC;
+ Optional<Boolean> country_consent_passengersRC;
+#endif // SDL_REMOTE_CONTROL
public:
ModuleConfig();
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 25aa126a03..09df043197 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -56,6 +56,7 @@ const std::string kDefaultDeviceConnectionType = "UNKNOWN";
*/
const std::string kPreDataConsentId = "pre_DataConsent";
const std::string kDefaultId = "default";
+const std::string kPreConsentPassengersRC = "pre_consent_passengersRC";
const std::string kDeviceId = "device";
/*
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 79a66ba41a..20f5d5aed4 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
@@ -114,6 +114,27 @@ extern const std::string kInsertApplicationFull;
extern const std::string kDeletePreconsentedGroupsByApplicationId;
extern const std::string kSelectApplicationFull;
extern const std::string kUpdatePreloaded;
+extern const std::string kUpdateRemoteControlDenied;
+extern const std::string kSelectRemoteControlDenied;
+extern const std::string kDeleteAppGroupPrimaryByApplicationId;
+extern const std::string kDeleteAppGroupNonPrimaryByApplicationId;
+extern const std::string kCollectFriendlyMsg;
+extern const std::string kSelectAppGroupsPrimary;
+extern const std::string kSelectAppGroupsNonPrimary;
+extern const std::string kSelectModuleTypes;
+extern const std::string kInsertAppGroupPrimary;
+extern const std::string kInsertAppGroupNonPrimary;
+extern const std::string kInsertModuleType;
+extern const std::string kInsertAccessModule;
+extern const std::string kSelectAccessModules;
+extern const std::string kDeleteAccessModules;
+extern const std::string kInsertRemoteRpc;
+extern const std::string kSelectRemoteRpcs;
+extern const std::string kDeleteRemoteRpc;
+extern const std::string kDeleteAppGroupPrimary;
+extern const std::string kDeleteAppGroupNonPrimary;
+extern const std::string kDeleteModuleTypes;
+extern const std::string kDeleteAllDevices;
extern const std::string kSelectDBVersion;
extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
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 bd867389ab..e152c040b1 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
@@ -97,6 +97,31 @@ class SQLPTRepresentation : public virtual PTRepresentation {
}
#endif // BUILD_TESTS
protected:
+#ifdef SDL_REMOTE_CONTROL
+ enum TypeAccess { kAllowed, kManual };
+ bool GatherAppGroupPrimary(const std::string& app_id,
+ policy_table::Strings* app_groups) const;
+ bool GatherAppGroupNonPrimary(const std::string& app_id,
+ policy_table::Strings* app_groups) const;
+ bool GatherModuleType(const std::string& app_id,
+ policy_table::ModuleTypes* module_types) const;
+ bool GatherRemoteControlDenied(const std::string& app_id, bool* denied) const;
+ bool GatherAccessModule(TypeAccess access,
+ policy_table::AccessModules* modules) const;
+ bool GatherRemoteRpc(int module_id, policy_table::RemoteRpcs* rpcs) const;
+ bool SaveAppGroupPrimary(const std::string& app_id,
+ const policy_table::Strings& app_groups);
+ bool SaveAppGroupNonPrimary(const std::string& app_id,
+ const policy_table::Strings& app_groups);
+ bool SaveModuleType(const std::string& app_id,
+ const policy_table::ModuleTypes& types);
+ bool SaveRemoteControlDenied(const std::string& app_id, bool deny);
+
+ 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;
virtual bool GatherUsageAndErrorCounts(
diff --git a/src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h b/src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h
deleted file mode 100644
index 8093c11467..0000000000
--- a/src/components/policy/policy_regular/include/policy/usage_statistics/app_stopwatch.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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_POLICY_REGULAR_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_
-#define SRC_COMPONENTS_POLICY_POLICY_REGULAR_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_POLICY_POLICY_REGULAR_INCLUDE_POLICY_USAGE_STATISTICS_APP_STOPWATCH_H_