summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2018-11-02 14:20:45 -0400
committerjacobkeeler <jacob.keeler@livioradio.com>2018-11-09 09:22:26 -0500
commite2c2bf8f584aeaed25c4f9b56237537a00b3575b (patch)
treecca22585f265615d3f5e026821a26520abee74c8
parent0ffb1871b58c730429e25728cd91cd0196d84ee3 (diff)
downloadsdl_core-e2c2bf8f584aeaed25c4f9b56237537a00b3575b.tar.gz
Add cloud app parameters to external policies
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h52
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h17
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h17
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h51
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h52
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h52
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h10
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h7
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml15
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc75
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc34
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc33
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc75
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_queries.cc10
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc34
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc42
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc47
-rw-r--r--src/components/policy/policy_external/test/sql_pt_representation_test.cc4
18 files changed, 612 insertions, 15 deletions
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index 57f6d2f802..2ea8ef08f1 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -521,6 +521,58 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* @return vehicle information
*/
virtual const VehicleInfo GetVehicleInfo() const = 0;
+
+ /**
+ * @brief Get cloud app policy information, all fields that aren't set for a
+ * given app will be filled with empty strings
+ * @param policy_app_id Unique application id
+ * @param endpoint Filled the endpoint used to connect to the cloud
+ * application
+ * @param auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ * @param cloud_transport_type Filled with the transport type used by the
+ * cloud application (ex. "WSS")
+ * @param cloud_transport_type Filled with the hybrid app preference for the
+ * cloud application set by the user
+ * @return true if the cloud app is enabled, false otherwise
+ */
+ virtual const bool GetCloudAppParameters(
+ const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const = 0;
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ virtual void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) = 0;
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ virtual void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) = 0;
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ virtual void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type) = 0;
+
+ /**
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
+ */
+ virtual void SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) = 0;
/**
* @brief Gets meta information
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index a4d50d7cc2..ecbd8c6cd6 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -76,6 +76,23 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
MOCK_METHOD1(SecondsBetweenRetries, bool(std::vector<int>& seconds));
MOCK_CONST_METHOD1(IsDeviceConsentCached, bool(const std::string& device_id));
MOCK_CONST_METHOD0(GetVehicleInfo, const VehicleInfo());
+ MOCK_CONST_METHOD5(GetCloudAppParameters,
+ const bool(const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
+ MOCK_METHOD2(SetCloudAppEnabled,
+ void(const std::string& policy_app_id, const bool enabled));
+ MOCK_METHOD2(SetAppAuthToken,
+ void(const std::string& policy_app_id,
+ const std::string& auth_token));
+ MOCK_METHOD2(SetAppCloudTransportType,
+ void(const std::string& policy_app_id,
+ const std::string& cloud_transport_type));
+ MOCK_METHOD2(SetHybridAppPreference,
+ void(const std::string& policy_app_id,
+ const std::string& hybrid_app_preference));
MOCK_CONST_METHOD1(GetDeviceConsent,
DeviceConsent(const std::string& device_id));
MOCK_METHOD2(SetDeviceConsent,
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index aeabf8fdcb..f58ed10934 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -184,6 +184,23 @@ class MockPolicyManager : public PolicyManager {
GetAppRequestTypes,
const std::vector<std::string>(const std::string policy_app_id));
MOCK_CONST_METHOD0(GetVehicleInfo, const policy::VehicleInfo());
+ MOCK_CONST_METHOD5(GetCloudAppParameters,
+ const bool(const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference));
+ MOCK_METHOD2(SetCloudAppEnabled,
+ void(const std::string& policy_app_id, const bool enabled));
+ MOCK_METHOD2(SetAppAuthToken,
+ void(const std::string& policy_app_id,
+ const std::string& auth_token));
+ MOCK_METHOD2(SetAppCloudTransportType,
+ void(const std::string& policy_app_id,
+ const std::string& cloud_transport_type));
+ MOCK_METHOD2(SetHybridAppPreference,
+ void(const std::string& policy_app_id,
+ const std::string& hybrid_app_preference));
MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo());
MOCK_CONST_METHOD0(RetrieveCertificate, std::string());
MOCK_CONST_METHOD0(HasCertificate, bool());
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index d30e7cea24..d6eeb0457b 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -159,6 +159,57 @@ class CacheManager : public CacheManagerInterface {
virtual const VehicleInfo GetVehicleInfo() const;
/**
+ * @brief Get cloud app policy information, all fields that aren't set for a
+ * given app will be filled with empty strings
+ * @param policy_app_id Unique application id
+ * @param endpoint Filled the endpoint used to connect to the cloud
+ * application
+ * @param auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ * @param cloud_transport_type Filled with the transport type used by the
+ * cloud application (ex. "WSS")
+ * @param cloud_transport_type Filled with the hybrid app preference for the
+ * cloud application set by the user
+ * @return true if the cloud app is enabled, false otherwise
+ */
+ virtual const bool GetCloudAppParameters(
+ const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const;
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ virtual void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled);
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ virtual void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token);
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ virtual void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type);
+
+ /**
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
+ */
+ virtual void SetHybridAppPreference(const std::string& policy_app_id,
+ const std::string& hybrid_app_preference);
+
+ /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index bb9ce14c7f..0c094d2edb 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -166,6 +166,58 @@ class CacheManagerInterface {
virtual const VehicleInfo GetVehicleInfo() const = 0;
/**
+ * @brief Get cloud app policy information, all fields that aren't set for a
+ * given app will be filled with empty strings
+ * @param policy_app_id Unique application id
+ * @param endpoint Filled the endpoint used to connect to the cloud
+ * application
+ * @param auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ * @param cloud_transport_type Filled with the transport type used by the
+ * cloud application (ex. "WSS")
+ * @param cloud_transport_type Filled with the hybrid app preference for the
+ * cloud application set by the user
+ * @return true if the cloud app is enabled, false otherwise
+ */
+ virtual const bool GetCloudAppParameters(
+ const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const = 0;
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ virtual void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) = 0;
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ virtual void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) = 0;
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ virtual void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type) = 0;
+
+ /**
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
+ */
+ virtual void SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) = 0;
+
+ /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index 3837dda1fa..f9648f803c 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -569,6 +569,58 @@ class PolicyManagerImpl : public PolicyManager {
* @return vehicle information
*/
const VehicleInfo GetVehicleInfo() const OVERRIDE;
+
+ /**
+ * @brief Get cloud app policy information, all fields that aren't set for a
+ * given app will be filled with empty strings
+ * @param policy_app_id Unique application id
+ * @param endpoint Filled the endpoint used to connect to the cloud
+ * application
+ * @param auth_token Filled with the token used for authentication when
+ * reconnecting to the cloud app
+ * @param cloud_transport_type Filled with the transport type used by the
+ * cloud application (ex. "WSS")
+ * @param cloud_transport_type Filled with the hybrid app preference for the
+ * cloud application set by the user
+ * @return true if the cloud app is enabled, false otherwise
+ */
+ const bool GetCloudAppParameters(
+ const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const OVERRIDE;
+
+ /**
+ * @brief Enable or disable a cloud application in the HMI
+ * @param enabled Cloud app enabled state
+ */
+ void SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) OVERRIDE;
+
+ /**
+ * @brief Set an app's auth token
+ * @param auth_token Cloud app authentication token
+ */
+ void SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) OVERRIDE;
+
+ /**
+ * @brief Set a cloud app's transport type
+ * @param cloud_transport_type Cloud app transport type
+ */
+ void SetAppCloudTransportType(
+ const std::string& policy_app_id,
+ const std::string& cloud_transport_type) OVERRIDE;
+
+ /**
+ * @brief Set the user preference for how a hybrid (cloud and mobile) app
+ * should be used
+ * @param hybrid_app_preference Hybrid app user preference
+ */
+ void SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) OVERRIDE;
/**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h
index e9d5319f13..b13e6b6f26 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h
@@ -182,6 +182,16 @@ bool IsValidEnum(ModuleType val);
const char* EnumToJsonString(ModuleType val);
bool EnumFromJsonString(const std::string& literal, ModuleType* result);
+enum HybridAppPreference {
+ HAP_MOBILE,
+ HAP_CLOUD,
+ HAP_BOTH
+};
+bool IsValidEnum(HybridAppPreference val);
+const char* EnumToJsonString(HybridAppPreference val);
+bool EnumFromJsonString(const std::string& literal,
+ HybridAppPreference* result);
+
/**
* @brief Enumeration FunctionID.
*
diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h
index 68e29a97ee..f37531eb63 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/types.h
@@ -177,6 +177,13 @@ struct ApplicationParams : PolicyBase {
Optional<Integer<uint16_t, 0, 65225> > memory_kb;
Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms;
mutable Optional<ModuleTypes> moduleType;
+ Optional<String<0, 65535> > certificate;
+ // Cloud application params
+ Optional<Enum<HybridAppPreference> > hybrid_app_preference;
+ Optional<String<0, 255> > endpoint;
+ Optional<Boolean> enabled;
+ Optional<String<0, 65535> > auth_token;
+ Optional<String<0, 255> > cloud_transport_type;
public:
ApplicationParams();
diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
index 0389986695..5ed852cf45 100644
--- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
+++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
@@ -71,6 +71,12 @@
<element name="TESTING" />
<element name="SYSTEM" />
</enum>
+
+ <enum name="HybridAppPreference">
+ <element name="MOBILE" />
+ <element name="CLOUD" />
+ <element name="BOTH" />
+ </enum>
<!-- Common parameters end -->
<!-- app_policies section start -->
@@ -93,8 +99,15 @@
<param name="memory_kb" type="Integer" minvalue="1" maxvalue="65225" mandatory="false"/>
<param name="watchdog_timer_ms" type="Integer" minvalue="1"
maxvalue="65225" mandatory="false"/>
- <param name="certificate" type="String" minlength="0" maxlength="255"
+ <param name="certificate" type="String" minlength="0" maxlength="65535"
+ mandatory="false" />
+ <param name="endpoint" type="String" minlength="0" maxlength="255" mandatory="false" />
+ <param name="enabled" type="Boolean" mandatory="false" />
+ <param name="auth_token" type="String" minlength="0" maxlength="65535"
+ mandatory="false" />
+ <param name="cloud_transport_type" type="String" minlength="0" maxlength="255"
mandatory="false" />
+ <param name="hybrid_app_preference" type="HybridAppPreference" mandatory="false" />
</struct>
<typedef name="HmiLevels" type="HmiLevel" array="true"
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index c2c2e91257..d6d5f6daa5 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1389,6 +1389,81 @@ const policy::VehicleInfo CacheManager::GetVehicleInfo() const {
return vehicle_info;
}
+const bool CacheManager::GetCloudAppParameters(
+ const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const {
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ auto app_policy = (*policy_iter).second;
+ endpoint = app_policy.endpoint.is_initialized() ? *app_policy.endpoint
+ : std::string();
+ auth_token = app_policy.auth_token.is_initialized() ? *app_policy.auth_token
+ : std::string();
+ cloud_transport_type = app_policy.cloud_transport_type.is_initialized()
+ ? *app_policy.cloud_transport_type
+ : std::string();
+ hybrid_app_preference =
+ app_policy.hybrid_app_preference.is_initialized()
+ ? EnumToJsonString(*app_policy.hybrid_app_preference)
+ : std::string();
+ return app_policy.enabled.is_initialized() && *app_policy.enabled;
+ }
+ return false;
+}
+
+void CacheManager::SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.enabled = enabled;
+ }
+}
+
+void CacheManager::SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.auth_token = auth_token;
+ }
+}
+
+void CacheManager::SetAppCloudTransportType(
+ const std::string& policy_app_id, const std::string& cloud_transport_type) {
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ *(*policy_iter).second.cloud_transport_type = cloud_transport_type;
+ }
+}
+
+void CacheManager::SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) {
+ policy_table::HybridAppPreference value;
+ bool valid = EnumFromJsonString(hybrid_app_preference, &value);
+ policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter && valid) {
+ *(*policy_iter).second.hybrid_app_preference = value;
+ }
+}
+
std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes,
const std::string& language,
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index a603f122e2..e7538fa1b0 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -725,6 +725,40 @@ const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const {
return cache_->GetVehicleInfo();
}
+const bool PolicyManagerImpl::GetCloudAppParameters(
+ const std::string& policy_app_id,
+ std::string& endpoint,
+ std::string& auth_token,
+ std::string& cloud_transport_type,
+ std::string& hybrid_app_preference) const {
+ return cache_->GetCloudAppParameters(policy_app_id,
+ endpoint,
+ auth_token,
+ cloud_transport_type,
+ hybrid_app_preference);
+}
+
+void PolicyManagerImpl::SetCloudAppEnabled(const std::string& policy_app_id,
+ const bool enabled) {
+ cache_->SetCloudAppEnabled(policy_app_id, enabled);
+}
+
+void PolicyManagerImpl::SetAppAuthToken(const std::string& policy_app_id,
+ const std::string& auth_token) {
+ cache_->SetAppAuthToken(policy_app_id, auth_token);
+}
+
+void PolicyManagerImpl::SetAppCloudTransportType(
+ const std::string& policy_app_id, const std::string& cloud_transport_type) {
+ cache_->SetAppCloudTransportType(policy_app_id, cloud_transport_type);
+}
+
+void PolicyManagerImpl::SetHybridAppPreference(
+ const std::string& policy_app_id,
+ const std::string& hybrid_app_preference) {
+ cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference);
+}
+
void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
const PTString& hmi_level,
const PTString& rpc,
diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc
index 29227adfc6..48ce4d4f72 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -1,4 +1,5 @@
#include "policy/policy_table/enums.h"
+#include <cstring>
namespace rpc {
namespace policy_table_interface_base {
@@ -847,6 +848,38 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
}
}
+bool IsValidEnum(HybridAppPreference val) {
+ return strlen(EnumToJsonString(val)) > 0;
+}
+
+const char* EnumToJsonString(HybridAppPreference val) {
+ switch (val) {
+ case HAP_MOBILE:
+ return "MOBILE";
+ case HAP_CLOUD:
+ return "CLOUD";
+ case HAP_BOTH:
+ return "BOTH";
+ default:
+ return "";
+ }
+}
+
+bool EnumFromJsonString(const std::string& literal,
+ HybridAppPreference* result) {
+ if ("MOBILE" == literal) {
+ *result = HAP_MOBILE;
+ return true;
+ } else if ("CLOUD" == literal) {
+ *result = HAP_CLOUD;
+ return true;
+ } else if ("BOTH" == literal) {
+ *result = HAP_BOTH;
+ return true;
+ }
+ return false;
+}
+
bool EnumFromJsonString(const std::string& literal, FunctionID* result) {
if ("RegisterAppInterface" == literal) {
*result = RegisterAppInterfaceID;
diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc
index 5922a020e6..4867eef281 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -241,7 +241,13 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, RequestSubType(impl::ValueMember(value__, "RequestSubType"))
, memory_kb(impl::ValueMember(value__, "memory_kb"), 0)
, heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms"))
- , moduleType(impl::ValueMember(value__, "moduleType")) {}
+ , moduleType(impl::ValueMember(value__, "moduleType"))
+ , certificate(impl::ValueMember(value__, "certificate"), "not_specified")
+ , hybrid_app_preference(impl::ValueMember(value__, "hybrid_app_preference"))
+ , endpoint(impl::ValueMember(value__, "endpoint"))
+ , enabled(impl::ValueMember(value__, "enabled"))
+ , auth_token(impl::ValueMember(value__, "auth_token"))
+ , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type")) {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -253,6 +259,13 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField(
"heart_beat_timeout_ms", heart_beat_timeout_ms, &result__);
impl::WriteJsonField("moduleType", moduleType, &result__);
+ impl::WriteJsonField("certificate", certificate, &result__);
+ impl::WriteJsonField(
+ "hybrid_app_preference", hybrid_app_preference, &result__);
+ impl::WriteJsonField("endpoint", endpoint, &result__);
+ impl::WriteJsonField("enabled", enabled, &result__);
+ impl::WriteJsonField("auth_token", auth_token, &result__);
+ impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__);
return result__;
}
@@ -277,6 +290,24 @@ bool ApplicationParams::is_valid() const {
if (!moduleType.is_valid()) {
return false;
}
+ if (!certificate.is_valid()) {
+ return false;
+ }
+ if (!endpoint.is_valid()) {
+ return false;
+ }
+ if (!enabled.is_valid()) {
+ return false;
+ }
+ if (!auth_token.is_valid()) {
+ return false;
+ }
+ if (!cloud_transport_type.is_valid()) {
+ return false;
+ }
+ if (!hybrid_app_preference.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -309,6 +340,24 @@ bool ApplicationParams::struct_empty() const {
if (moduleType.is_initialized()) {
return false;
}
+ if (certificate.is_initialized()) {
+ return false;
+ }
+ if (endpoint.is_initialized()) {
+ return false;
+ }
+ if (enabled.is_initialized()) {
+ return false;
+ }
+ if (auth_token.is_initialized()) {
+ return false;
+ }
+ if (cloud_transport_type.is_initialized()) {
+ return false;
+ }
+ if (hybrid_app_preference.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -357,6 +406,25 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
if (!moduleType.is_valid()) {
moduleType.ReportErrors(&report__->ReportSubobject("moduleType"));
}
+ if (!certificate.is_valid()) {
+ certificate.ReportErrors(&report__->ReportSubobject("certificate"));
+ }
+ if (!endpoint.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("endpoint"));
+ }
+ if (!enabled.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("enabled"));
+ }
+ if (!auth_token.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("auth_token"));
+ }
+ if (!cloud_transport_type.is_valid()) {
+ moduleType.ReportErrors(&report__->ReportSubobject("cloud_transport_type"));
+ }
+ if (!hybrid_app_preference.is_valid()) {
+ moduleType.ReportErrors(
+ &report__->ReportSubobject("hybrid_app_preference"));
+ }
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -367,6 +435,11 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
memory_kb.SetPolicyTableType(pt_type);
heart_beat_timeout_ms.SetPolicyTableType(pt_type);
moduleType.SetPolicyTableType(pt_type);
+ certificate.SetPolicyTableType(pt_type);
+ endpoint.SetPolicyTableType(pt_type);
+ enabled.SetPolicyTableType(pt_type);
+ cloud_transport_type.SetPolicyTableType(pt_type);
+ hybrid_app_preference.SetPolicyTableType(pt_type);
}
// RpcParameters methods
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
index afb1180692..f7e1acb59a 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
@@ -205,7 +205,10 @@ const std::string kUpdateGroupPermissions =
const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application`(`id`, `keep_context`, `steal_focus`, "
" `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, "
- " `heart_beat_timeout_ms`) VALUES( ?, ?, ?, ?, ?, ?, ?, ?) ";
+ " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
+ " `endpoint`, `enabled`, `auth_token`, "
+ " `cloud_transport_type`) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -232,8 +235,9 @@ const std::string kSelectPreconsentedGroupsId =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, "
- "`steal_focus`, "
- " `memory_kb`, `heart_beat_timeout_ms` FROM `application`";
+ " `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
+ " `hybrid_app_preference_value`, `endpoint`, `enabled`, "
+ " `cloud_transport_type` FROM `application`";
const std::string kSelectFunctionalGroupNames =
"SELECT `id`, `user_consent_prompt`, `name`"
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
index a43b22a3b8..6a40e6d135 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
@@ -752,6 +752,24 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
app_query.Bind(5, app.second.is_null());
app_query.Bind(6, *app.second.memory_kb);
app_query.Bind(7, static_cast<int64_t>(*app.second.heart_beat_timeout_ms));
+ app.second.certificate.is_initialized()
+ ? app_query.Bind(8, *app.second.certificate)
+ : app_query.Bind(8);
+ app.second.hybrid_app_preference.is_initialized()
+ ? app_query.Bind(9,
+ std::string(policy_table::EnumToJsonString(
+ *app.second.hybrid_app_preference)))
+ : app_query.Bind(9);
+ app.second.endpoint.is_initialized() ? app_query.Bind(10, *app.second.endpoint)
+ : app_query.Bind(10);
+ app.second.enabled.is_initialized() ? app_query.Bind(11, *app.second.enabled)
+ : app_query.Bind(11);
+ app.second.auth_token.is_initialized()
+ ? app_query.Bind(12, *app.second.auth_token)
+ : app_query.Bind(12);
+ app.second.cloud_transport_type.is_initialized()
+ ? app_query.Bind(13, *app.second.cloud_transport_type)
+ : app_query.Bind(13);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -873,6 +891,22 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
params.steal_focus = query.GetBoolean(4);
*params.memory_kb = query.GetInteger(5);
*params.heart_beat_timeout_ms = query.GetUInteger(6);
+ if (!query.IsNull(7)) {
+ *params.certificate = query.GetString(7);
+ }
+
+ // Read cloud app properties
+ policy_table::HybridAppPreference hap;
+ bool valid = policy_table::EnumFromJsonString(query.GetString(8), &hap);
+ if (valid) {
+ *params.hybrid_app_preference = hap;
+ }
+ *params.endpoint = query.GetString(9);
+ if (!query.IsNull(10)) {
+ *params.enabled = query.GetBoolean(10);
+ }
+ *params.auth_token = query.GetString(11);
+ *params.cloud_transport_type = query.GetString(12);
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc
index 97d75731ea..8c4227963a 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -98,6 +98,9 @@ const std::string kCreateSchema =
"CREATE TABLE IF NOT EXISTS `hmi_level`( "
" `value` VARCHAR(45) PRIMARY KEY NOT NULL "
"); "
+ "CREATE TABLE IF NOT EXISTS `hybrid_app_preference`( "
+ " `value` VARCHAR(45) PRIMARY KEY NOT NULL "
+ "); "
"CREATE TABLE IF NOT EXISTS `notifications_by_priority`( "
" `priority_value` VARCHAR(45) PRIMARY KEY NOT NULL, "
" `value` INTEGER NOT NULL, "
@@ -147,6 +150,12 @@ const std::string kCreateSchema =
" `is_predata` BOOLEAN, "
" `memory_kb` INTEGER NOT NULL, "
" `heart_beat_timeout_ms` INTEGER NOT NULL, "
+ " `certificate` VARCHAR(65535), "
+ " `hybrid_app_preference_value` VARCHAR(255), "
+ " `endpoint` VARCHAR(255), "
+ " `enabled` BOOLEAN, "
+ " `auth_token` VARCHAR(65535), "
+ " `cloud_transport_type` VARCHAR(255), "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
@@ -154,11 +163,17 @@ const std::string kCreateSchema =
" CONSTRAINT `fk_application_priorities1` "
" FOREIGN KEY(`priority_value`) "
" REFERENCES `priority`(`value`) "
+ " CONSTRAINT `fk_application_hybrid_app_preference1` "
+ " FOREIGN KEY(`hybrid_app_preference_value`) "
+ " REFERENCES `hybrid_app_preference`(`value`) "
"); "
"CREATE INDEX IF NOT EXISTS `application.fk_application_hmi_level1_idx` "
" ON `application`(`default_hmi`); "
"CREATE INDEX IF NOT EXISTS `application.fk_application_priorities1_idx` "
" ON `application`(`priority_value`); "
+ "CREATE INDEX IF NOT EXISTS "
+ "`application.fk_application_hybrid_app_preference1` "
+ " ON `application`(`hybrid_app_preference_value`); "
"CREATE TABLE IF NOT EXISTS `app_group`( "
" `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
" `functional_group_id` INTEGER NOT NULL, "
@@ -430,6 +445,9 @@ const std::string kInsertInitData =
"INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('LIMITED'); "
"INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('BACKGROUND'); "
"INSERT OR IGNORE INTO `hmi_level`(`value`) VALUES ('NONE'); "
+ "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('MOBILE'); "
+ "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('CLOUD'); "
+ "INSERT OR IGNORE INTO `hybrid_app_preference`(`value`) VALUES ('BOTH'); "
"INSERT OR IGNORE INTO `version` (`number`) VALUES('0'); "
"INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); "
"";
@@ -532,6 +550,7 @@ const std::string kDropSchema =
"`notifications_by_priority.fk_notifications_by_priority_priority1_idx`; "
"DROP TABLE IF EXISTS `notifications_by_priority`; "
"DROP TABLE IF EXISTS `hmi_level`; "
+ "DROP TABLE IF EXISTS `hybrid_app_preference`; "
"DROP TABLE IF EXISTS `priority`; "
"DROP TABLE IF EXISTS `functional_group`; "
"DROP TABLE IF EXISTS `module_config`; "
@@ -628,8 +647,10 @@ const std::string kInsertRpcWithParameter =
const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
- "`is_revoked`, `memory_kb`,"
- " `heart_beat_timeout_ms`) VALUES (?,?,?,?,?)";
+ "`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
+ "`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
+ "`cloud_transport_type`) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?)";
const std::string kInsertAppGroup =
"INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
@@ -752,7 +773,8 @@ const std::string kSelectUserMsgsVersion =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `memory_kb`, "
- " `heart_beat_timeout_ms` FROM `application`";
+ " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
+ " `endpoint`, `enabled`, `cloud_transport_type` FROM `application`";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -849,15 +871,19 @@ const std::string kDeleteAppGroupByApplicationId =
const std::string kInsertApplicationFull =
"INSERT OR IGNORE INTO `application` (`id`, `keep_context`, `steal_focus`, "
- " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
- "`is_predata`, "
- " `memory_kb`, `heart_beat_timeout_ms`) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
+ " `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, "
+ " `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, "
+ " `auth_token`, `cloud_transport_type`) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
const std::string kSelectApplicationFull =
"SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
" `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
- " `heart_beat_timeout_ms` FROM `application` WHERE `id` = ?";
+ " `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` "
+ "FROM `application` "
+ "WHERE `id` = ?";
const std::string kSelectDBVersion =
"SELECT `db_version_hash` from `_internal_data`";
diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc
index c8b367c8ec..b794d4c3a6 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -761,6 +761,23 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
*params.memory_kb = query.GetInteger(2);
*params.heart_beat_timeout_ms = query.GetUInteger(3);
+ if (!query.IsNull(4)) {
+ *params.certificate = query.GetString(4);
+ }
+
+ // Read cloud app properties
+ policy_table::HybridAppPreference hap;
+ bool valid = policy_table::EnumFromJsonString(query.GetString(5), &hap);
+ if (valid) {
+ *params.hybrid_app_preference = hap;
+ }
+ *params.endpoint = query.GetString(6);
+ if (!query.IsNull(7)) {
+ *params.enabled = query.GetBoolean(7);
+ }
+ *params.auth_token = query.GetString(8);
+ *params.cloud_transport_type = query.GetString(9);
+
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
@@ -1035,6 +1052,24 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
app_query.Bind(2, app.second.is_null());
app_query.Bind(3, *app.second.memory_kb);
app_query.Bind(4, static_cast<int64_t>(*app.second.heart_beat_timeout_ms));
+ app.second.certificate.is_initialized()
+ ? app_query.Bind(5, *app.second.certificate)
+ : app_query.Bind(5);
+ app.second.hybrid_app_preference.is_initialized()
+ ? app_query.Bind(6,
+ std::string(policy_table::EnumToJsonString(
+ *app.second.hybrid_app_preference)))
+ : app_query.Bind(6);
+ app.second.endpoint.is_initialized() ? app_query.Bind(7, *app.second.endpoint)
+ : app_query.Bind(7);
+ app.second.enabled.is_initialized() ? app_query.Bind(8, *app.second.enabled)
+ : app_query.Bind(8);
+ app.second.auth_token.is_initialized()
+ ? app_query.Bind(9, *app.second.auth_token)
+ : app_query.Bind(9);
+ app.second.cloud_transport_type.is_initialized()
+ ? app_query.Bind(10, *app.second.cloud_transport_type)
+ : app_query.Bind(10);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -2125,6 +2160,18 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(7, source_app.GetBoolean(6));
query.Bind(8, source_app.GetInteger(7));
query.Bind(9, source_app.GetInteger(8));
+ source_app.IsNull(9) ? query.Bind(10)
+ : query.Bind(10, source_app.GetString(9));
+ source_app.IsNull(10) ? query.Bind(11)
+ : query.Bind(11, source_app.GetString(10));
+ source_app.IsNull(11) ? query.Bind(12)
+ : query.Bind(12, source_app.GetString(11));
+ source_app.IsNull(12) ? query.Bind(13)
+ : query.Bind(13, source_app.GetBoolean(12));
+ source_app.IsNull(13) ? query.Bind(14)
+ : query.Bind(14, source_app.GetString(13));
+ source_app.IsNull(14) ? query.Bind(15)
+ : query.Bind(15, source_app.GetString(14));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");
diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc
index b0f340b0f2..fddc5e631e 100644
--- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc
@@ -406,8 +406,8 @@ TEST_F(SQLPTRepresentationTest,
query.Prepare(query_select);
query.Next();
- // 33 - is current total tables number created by schema
- const int policy_tables_number = 33;
+ // 34 - is current total tables number created by schema
+ const int policy_tables_number = 34;
ASSERT_EQ(policy_tables_number, query.GetInteger(0));
const std::string query_select_count_of_iap_buffer_full =