summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_external')
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h14
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h14
-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.xml3
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_queries.h3
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_representation.h4
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc27
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc9
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc39
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_queries.cc7
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc17
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc38
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc68
14 files changed, 253 insertions, 11 deletions
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 3344b149e4..9cc1d25bfb 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -229,6 +229,20 @@ class CacheManager : public CacheManagerInterface {
const std::string& hybrid_app_preference);
/**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param service_name Service name published by app service provider
+ * @param service_type Service type published by app service provider
+ * @param handled_rpcs Vector of allowed function ids an app service provider
+ * can handle
+ */
+ virtual void GetAppServiceParameters(
+ const std::string& policy_app_id,
+ std::string& service_name,
+ std::string& service_type,
+ std::vector<uint64_t>& handled_rpcs) const;
+
+ /**
* @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 6a172e6f4b..b48b6a1041 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
@@ -238,6 +238,20 @@ class CacheManagerInterface {
const std::string& hybrid_app_preference) = 0;
/**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param service_name Service name published by app service provider
+ * @param service_type Service type published by app service provider
+ * @param handled_rpcs Vector of allowed function ids an app service provider
+ * can handle
+ */
+ virtual void GetAppServiceParameters(
+ const std::string& policy_app_id,
+ std::string& service_name,
+ std::string& service_type,
+ std::vector<uint64_t>& handled_rpcs) const = 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 399c95170d..fa64614e1f 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
@@ -640,6 +640,20 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& hybrid_app_preference) OVERRIDE;
/**
+ * @brief Get app service parameters from the policy table
+ * @param policy_app_id Unique application id
+ * @param service_name Service name published by app service provider
+ * @param service_type Service type published by app service provider
+ * @param handled_rpcs Vector of allowed function ids an app service provider
+ * can handle
+ */
+ void GetAppServiceParameters(
+ const std::string& policy_app_id,
+ std::string& service_name,
+ std::string& service_type,
+ std::vector<uint64_t>& handled_rpcs) const OVERRIDE;
+
+ /**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
* It will send OnAppPermissionSend notification and will try to start PTU. *
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 f37531eb63..ed845b1191 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
@@ -104,6 +104,8 @@ typedef Array<Enum<RequestType>, 0, 255> RequestsTypeArray;
typedef Strings RequestSubTypes;
+typedef Array<Integer<uint64_t, 0u, UINT_MAX>, 0, 255> HandledRpcs;
+
typedef Map<Strings, 0, 255> RemoteRpcs;
typedef Map<RemoteRpcs, 0, 255> AccessModules;
typedef Array<Enum<ModuleType>, 0, 255> ModuleTypes;
@@ -185,6 +187,11 @@ struct ApplicationParams : PolicyBase {
Optional<String<0, 65535> > auth_token;
Optional<String<0, 255> > cloud_transport_type;
+ // App Service Params
+ Optional<String<0, 255> > service_name;
+ Optional<String<0, 255> > service_type;
+ Optional<HandledRpcs> handled_rpcs;
+
public:
ApplicationParams();
ApplicationParams(const Strings& groups,
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 5ed852cf45..3b3bc2d7a6 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
@@ -108,6 +108,9 @@
<param name="cloud_transport_type" type="String" minlength="0" maxlength="255"
mandatory="false" />
<param name="hybrid_app_preference" type="HybridAppPreference" mandatory="false" />
+ <param name="service_name" type="String" mandatory="false" />
+ <param name="service_type" type="AppServiceType" mandatory="false" />
+ <param name="handled_rpcs" array="true" mandatory="false">
</struct>
<typedef name="HmiLevels" type="HmiLevel" array="true"
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h
index dd9e0204e7..c66d878e5a 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h
@@ -66,6 +66,7 @@ extern const std::string kSelectNicknames;
extern const std::string kSelectAppTypes;
extern const std::string kSelectRequestTypes;
extern const std::string kSelectRequestSubTypes;
+extern const std::string kSelectHandledRpcs;
extern const std::string kSelectSecondsBetweenRetries;
extern const std::string kSelectIgnitionCycles;
extern const std::string kSelectKilometers;
@@ -80,6 +81,7 @@ extern const std::string kInsertNickname;
extern const std::string kInsertAppType;
extern const std::string kInsertRequestType;
extern const std::string kInsertRequestSubType;
+extern const std::string kInsertHandledRpcs;
extern const std::string kInsertMessageType;
extern const std::string kInsertLanguage;
extern const std::string kInsertMessageString;
@@ -101,6 +103,7 @@ extern const std::string kDeleteAppGroup;
extern const std::string kDeleteApplication;
extern const std::string kDeleteRequestType;
extern const std::string kDeleteRequestSubType;
+extern const std::string kDeleteHandledRpcs;
extern const std::string kDeleteDevice;
extern const std::string kIncrementIgnitionCycles;
extern const std::string kResetIgnitionCycles;
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h
index 13816eb6c5..ebc307cc8b 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h
@@ -134,6 +134,8 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool GatherRequestSubType(
const std::string& app_id,
policy_table::RequestSubTypes* request_subtypes) const;
+ bool GatherHandledRpcs(const std::string& app_id,
+ policy_table::HandledRpcs* handled_rpcs) const;
bool GatherNickName(const std::string& app_id,
policy_table::Strings* nicknames) const;
@@ -172,6 +174,8 @@ class SQLPTRepresentation : public virtual PTRepresentation {
bool SaveRequestSubType(
const std::string& app_id,
const policy_table::RequestSubTypes& request_subtypes);
+ bool SaveHandledRpcs(const std::string& app_id,
+ const policy_table::HandledRpcs& handled_rpcs);
public:
virtual std::string GetLockScreenIconUrl() const;
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 8cec6ef91c..b94230548f 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1501,6 +1501,33 @@ void CacheManager::SetHybridAppPreference(
}
}
+void CacheManager::GetAppServiceParameters(
+ const std::string& policy_app_id,
+ std::string& service_name,
+ std::string& service_type,
+ std::vector<uint64_t>& handled_rpcs) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ 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;
+ service_name = app_policy.service_name.is_initialized()
+ ? *app_policy.service_name
+ : std::string();
+ service_type = app_policy.service_type.is_initialized()
+ ? *app_policy.service_type
+ : std::string();
+ if (!app_policy.handled_rpcs.is_initialized()) {
+ return;
+ }
+ for (const auto& rpc : *(app_policy.handled_rpcs)) {
+ handled_rpcs.push_back(rpc);
+ }
+ }
+}
+
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 0844edd8eb..56eac75127 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -772,6 +772,15 @@ void PolicyManagerImpl::SetHybridAppPreference(
cache_->SetHybridAppPreference(policy_app_id, hybrid_app_preference);
}
+void PolicyManagerImpl::GetAppServiceParameters(
+ const std::string& policy_app_id,
+ std::string& service_name,
+ std::string& service_type,
+ std::vector<uint64_t>& handled_rpcs) const {
+ cache_->GetAppServiceParameters(
+ policy_app_id, service_name, service_type, handled_rpcs);
+}
+
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/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc
index 977448dacd..8e822cb8d2 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -247,8 +247,10 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, 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")) {
-}
+ , cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type"))
+ , service_name(impl::ValueMember(value__, "service_name"))
+ , service_type(impl::ValueMember(value__, "service_type"))
+ , handled_rpcs(impl::ValueMember(value__, "handled_rpcs")) {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -267,6 +269,9 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("enabled", enabled, &result__);
impl::WriteJsonField("auth_token", auth_token, &result__);
impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__);
+ impl::WriteJsonField("service_name", service_name, &result__);
+ impl::WriteJsonField("service_type", service_type, &result__);
+ impl::WriteJsonField("handled_rpcs", handled_rpcs, &result__);
return result__;
}
@@ -309,6 +314,15 @@ bool ApplicationParams::is_valid() const {
if (!hybrid_app_preference.is_valid()) {
return false;
}
+ if (!service_name.is_valid()) {
+ return false;
+ }
+ if (!service_type.is_valid()) {
+ return false;
+ }
+ if (!handled_rpcs.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -359,6 +373,15 @@ bool ApplicationParams::struct_empty() const {
if (hybrid_app_preference.is_initialized()) {
return false;
}
+ if (service_name.is_initialized()) {
+ return false;
+ }
+ if (service_type.is_initialized()) {
+ return false;
+ }
+ if (handled_rpcs.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -426,6 +449,15 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
moduleType.ReportErrors(
&report__->ReportSubobject("hybrid_app_preference"));
}
+ if (!service_name.is_valid()) {
+ service_name.ReportErrors(&report__->ReportSubobject("service_name"));
+ }
+ if (!service_type.is_valid()) {
+ service_type.ReportErrors(&report__->ReportSubobject("service_type"));
+ }
+ if (!handled_rpcs.is_valid()) {
+ handled_rpcs.ReportErrors(&report__->ReportSubobject("handled_rpcs"));
+ }
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -441,6 +473,9 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
enabled.SetPolicyTableType(pt_type);
cloud_transport_type.SetPolicyTableType(pt_type);
hybrid_app_preference.SetPolicyTableType(pt_type);
+ service_name.SetPolicyTableType(pt_type);
+ service_type.SetPolicyTableType(pt_type);
+ handled_rpcs.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 32320b6d6c..25827c719b 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
@@ -207,8 +207,8 @@ const std::string kInsertApplication =
" `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, "
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
" `endpoint`, `enabled`, `auth_token`, "
- " `cloud_transport_type`) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ " `cloud_transport_type`, `service_name`, `service_type`) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -237,7 +237,8 @@ const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, "
" `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
" `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` "
- " `cloud_transport_type` FROM `application`";
+ " `cloud_transport_type`, `service_name`, `service_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 43961815d6..8f82ca0546 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
@@ -771,6 +771,12 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
app.second.cloud_transport_type.is_initialized()
? app_query.Bind(13, *app.second.cloud_transport_type)
: app_query.Bind(13);
+ app.second.service_name.is_initialized()
+ ? app_query.Bind(14, *app.second.service_name)
+ : app_query.Bind(14);
+ app.second.service_type.is_initialized()
+ ? app_query.Bind(15, *app.second.service_type)
+ : app_query.Bind(15);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -805,6 +811,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
return false;
}
+ if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) {
+ return false;
+ }
+
return true;
}
@@ -909,6 +919,10 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(11);
*params.cloud_transport_type = query.GetString(12);
+ // AppService Parameters
+ *params.service_name = query.GetString(13);
+ *params.service_type = query.GetString(14);
+
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
@@ -941,6 +955,9 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
return false;
}
+ if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) {
+ return false;
+ }
GatherPreconsentedGroup(gather_app_id, &*params.preconsented_groups);
(*policies).apps[app_id] = params;
}
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 162d6957e7..1cf38e64c9 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -156,6 +156,8 @@ const std::string kCreateSchema =
" `enabled` BOOLEAN, "
" `auth_token` VARCHAR(65535), "
" `cloud_transport_type` VARCHAR(255), "
+ " `service_name` VARCHAR(255), "
+ " `service_type` VARCHAR(255), "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
@@ -301,6 +303,14 @@ const std::string kCreateSchema =
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
+ "CREATE TABLE IF NOT EXISTS `handled_rpcs`( "
+ " `handled_rpcs` INTEGER, "
+ " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, "
+ " PRIMARY KEY(`handled_rpcs`,`application_id`), "
+ " CONSTRAINT `fk_handled_rpcs_app_id` "
+ " FOREIGN KEY(`application_id`) "
+ " REFERENCES `application`(`id`) "
+ "); "
"CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
" ON `app_type`(`application_id` COLLATE NOCASE); "
"CREATE TABLE IF NOT EXISTS `consent_group`( "
@@ -509,6 +519,7 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `app_type`; "
"DROP TABLE IF EXISTS `request_type`; "
"DROP TABLE IF EXISTS `request_subtype`; "
+ "DROP TABLE IF EXISTS `handled_rpcs`; "
"DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; "
"DROP TABLE IF EXISTS `nickname`; "
"DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; "
@@ -649,8 +660,8 @@ const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
"`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
"`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
- "`cloud_transport_type`) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?)";
+ "`cloud_transport_type`, `service_name`, `service_type`) VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kInsertAppGroup =
"INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
@@ -671,6 +682,11 @@ const std::string kInsertRequestSubType =
"`request_subtype`) "
"VALUES (?, ?)";
+const std::string kInsertHandledRpcs =
+ "INSERT INTO `handled_rpcs` (`application_id`, "
+ "`handled_rpcs`) "
+ "VALUES (?, ?)";
+
const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?";
const std::string kInsertMessageType =
@@ -774,7 +790,8 @@ const std::string kSelectUserMsgsVersion =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `memory_kb`, "
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` FROM "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
+ "`service_name`, `service_type` FROM "
" `application`";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -802,6 +819,11 @@ const std::string kSelectRequestSubTypes =
"`application_id` "
"= ?";
+const std::string kSelectHandledRpcs =
+ "SELECT DISTINCT `handled_rpcs` FROM `handled_rpcs` WHERE "
+ "`application_id` "
+ "= ?";
+
const std::string kSelectSecondsBetweenRetries =
"SELECT `value` FROM `seconds_between_retry` ORDER BY `index`";
@@ -849,6 +871,8 @@ const std::string kDeleteRequestType = "DELETE FROM `request_type`";
const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`";
+const std::string kDeleteHandledRpcs = "DELETE FROM `handled_rpcs`";
+
const std::string kSelectApplicationRevoked =
"SELECT `is_revoked` FROM `application` WHERE `id` = ?";
@@ -875,14 +899,16 @@ const std::string kInsertApplicationFull =
" `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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " `auth_token`, `cloud_transport_type`, `service_name`, "
+ "`service_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`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type` "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
+ "`service_name`, `service_type` "
"FROM `application` "
"WHERE `id` = ?";
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 b794d4c3a6..dbddd1bbd6 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -778,6 +778,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(8);
*params.cloud_transport_type = query.GetString(9);
+ // AppService Parameters
+ *params.service_name = query.GetString(10);
+ *params.service_type = query.GetString(11);
+
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
@@ -810,6 +814,9 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
if (!GatherRequestSubType(gather_app_id, &*params.RequestSubType)) {
return false;
}
+ if (!GatherHandledRpcs(gather_app_id, &*params.handled_rpcs)) {
+ return false;
+ }
(*policies).apps[app_id] = params;
}
@@ -1070,6 +1077,12 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
app.second.cloud_transport_type.is_initialized()
? app_query.Bind(10, *app.second.cloud_transport_type)
: app_query.Bind(10);
+ app.second.service_name.is_initialized()
+ ? app_query.Bind(11, *app.second.service_name)
+ : app_query.Bind(11);
+ app.second.service_type.is_initialized()
+ ? app_query.Bind(12, *app.second.service_type)
+ : app_query.Bind(12);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -1106,6 +1119,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
if (!SaveRequestType(app.first, *app.second.RequestType)) {
return false;
}
+ if (!SaveHandledRpcs(app.first, *app.second.handled_rpcs)) {
+ return false;
+ }
return true;
}
@@ -1270,6 +1286,32 @@ bool SQLPTRepresentation::SaveRequestSubType(
return true;
}
+bool SQLPTRepresentation::SaveHandledRpcs(
+ const std::string& app_id, const policy_table::HandledRpcs& handled_rpcs) {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kInsertHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect insert statement for handled rpcs.");
+ return false;
+ }
+
+ policy_table::HandledRpcs::const_iterator it;
+ if (!handled_rpcs.empty()) {
+ LOG4CXX_TRACE(logger_, "Handled Rpcs are not empty.");
+ for (it = handled_rpcs.begin(); it != handled_rpcs.end(); ++it) {
+ query.Bind(0, app_id);
+
+ // TODO: Bind does not like uint64_t. Only takes ints? Not sure why this
+ // is broken since seconds between retries is able to handle
+ query.Bind(1, static_cast<int>(*it));
+ if (!query.Exec() || !query.Reset()) {
+ LOG4CXX_WARN(logger_, "Incorrect insert into handled rpcs.");
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
bool SQLPTRepresentation::SaveModuleMeta(const policy_table::ModuleMeta& meta) {
// Section Module Meta is empty for SDL specific
return true;
@@ -1696,6 +1738,22 @@ bool SQLPTRepresentation::GatherRequestSubType(
return true;
}
+bool SQLPTRepresentation::GatherHandledRpcs(
+ const std::string& app_id, policy_table::HandledRpcs* handled_rpcs) const {
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kSelectHandledRpcs)) {
+ LOG4CXX_WARN(logger_, "Incorrect select from handled rpcs.");
+ return false;
+ }
+
+ query.Bind(0, app_id);
+ while (query.Next()) {
+ const uint64_t rpc_id = query.GetInteger(0);
+ handled_rpcs->push_back(rpc_id);
+ }
+ return true;
+}
+
bool SQLPTRepresentation::GatherNickName(
const std::string& app_id, policy_table::Strings* nicknames) const {
utils::dbms::SQLQuery query(db());
@@ -2041,6 +2099,12 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) {
return false;
}
+ policy_table::HandledRpcs handled_rpcs;
+ if (!GatherHandledRpcs(kDefaultId, &handled_rpcs) ||
+ !SaveHandledRpcs(app_id, handled_rpcs)) {
+ return false;
+ }
+
policy_table::Strings default_groups;
bool ret = (GatherAppGroup(kDefaultId, &default_groups) &&
SaveAppGroup(app_id, default_groups));
@@ -2172,6 +2236,10 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(14, source_app.GetString(13));
source_app.IsNull(14) ? query.Bind(15)
: query.Bind(15, source_app.GetString(14));
+ source_app.IsNull(15) ? query.Bind(16)
+ : query.Bind(16, source_app.GetString(15));
+ source_app.IsNull(16) ? query.Bind(17)
+ : query.Bind(17, source_app.GetString(16));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");