summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Chernysheva <ychernysheva@luxoft.com>2021-01-11 13:38:24 +0200
committerLitvinenkoIra <ilytvynenko@luxoft.com>2021-02-02 11:24:11 +0200
commitd4c70f9f8a1bc11b513879d255b75b9bc8652a13 (patch)
tree62ee77913d7093c90ea357934e114f474a6b15c6
parenta888182904e82455f7d3239dfe74f42778cde348 (diff)
downloadsdl_core-d4c70f9f8a1bc11b513879d255b75b9bc8652a13.tar.gz
Support new database hardware version parameter
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h1
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml1
-rw-r--r--src/components/policy/policy_external/include/policy/pt_ext_representation.h8
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h1
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h4
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc18
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_queries.cc15
-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.cc1
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/pt_representation.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_queries.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_representation.h3
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc2
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc13
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc11
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc25
-rw-r--r--src/components/utils/test/policy.sql1
19 files changed, 126 insertions, 23 deletions
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 6b2f05d336..25439f835b 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
@@ -490,6 +490,7 @@ struct ModuleMeta : CompositeType {
Optional<String<0, 500> > ccpu_version;
Optional<String<0, 250> > language;
Optional<String<0, 250> > wers_country_code;
+ Optional<String<0, 500> > hardware_version;
Optional<Integer<uint32_t, 0, ODO_MAX> > pt_exchanged_at_odometer_x;
Optional<Integer<uint16_t, 0, 65535> > pt_exchanged_x_days_after_epoch;
Optional<Integer<uint16_t, 0, 65535> > ignition_cycles_since_last_exchange;
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 64eab51870..08da927fa9 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
@@ -221,6 +221,7 @@
<param name="ccpu_version" type="String" maxlength="250" mandatory="false"/>
<param name="language" type="String" maxlength="250" mandatory="false"/>
<param name="wers_country_code" type="String" maxlength="250" mandatory="false"/>
+ <param name="hardware_version" type="String" maxlength="500" mandatory="false"/>
<param name="pt_exchanged_at_odometer_x" type="Integer" minvalue="0" maxvalue="65535" mandatory="false"/>
<param name="pt_exchanged_x_days_after_epoch" type="Integer" minvalue="0" maxvalue="65535" mandatory="false"/>
<param name="ignition_cycles_since_last_exchange" type="Integer" minvalue="0" maxvalue="65535" mandatory="false"/>
diff --git a/src/components/policy/policy_external/include/policy/pt_ext_representation.h b/src/components/policy/policy_external/include/policy/pt_ext_representation.h
index f03947268a..867033bc20 100644
--- a/src/components/policy/policy_external/include/policy/pt_ext_representation.h
+++ b/src/components/policy/policy_external/include/policy/pt_ext_representation.h
@@ -198,7 +198,7 @@ class PTExtRepresentation : public virtual PTRepresentation {
const std::string& language) = 0;
/**
- * @brief Records information about head unit system to PT
+ * @brief Records mandatory information about head unit system to PT
* @return bool Success of operation
*/
virtual bool SetMetaInfo(const std::string& ccpu_version,
@@ -206,6 +206,12 @@ class PTExtRepresentation : public virtual PTRepresentation {
const std::string& language) = 0;
/**
+ * @brief Records information about hardware version to PT
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h
index b8f85ec7b1..abb18d51e4 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h
@@ -65,6 +65,7 @@ extern const std::string kInsertExternalConsentStatusGroups;
extern const std::string kCountUnconsentedGroups;
extern const std::string kSelectModuleMeta;
extern const std::string kUpdateMetaParams;
+extern const std::string kUpdateMetaHardwareVersion;
extern const std::string kUpdateModuleMetaVinParam;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectMetaParams;
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
index 889ede9d20..de2d0c1536 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
@@ -94,7 +94,9 @@ class SQLPTExtRepresentation : public SQLPTRepresentation,
bool SetMetaInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
- const std::string& language);
+ const std::string& language) OVERRIDE;
+
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
bool IsMetaInfoPresent();
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 cb7f2bdd9d..47c4202de0 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -1424,6 +1424,7 @@ ModuleMeta::ModuleMeta(const Json::Value* value__)
, ccpu_version(impl::ValueMember(value__, "ccpu_version"))
, language(impl::ValueMember(value__, "language"))
, wers_country_code(impl::ValueMember(value__, "wers_country_code"))
+ , hardware_version(impl::ValueMember(value__, "hardware_version"))
, pt_exchanged_at_odometer_x(
impl::ValueMember(value__, "pt_exchanged_at_odometer_x"))
, pt_exchanged_x_days_after_epoch(
@@ -1437,6 +1438,7 @@ Json::Value ModuleMeta::ToJsonValue() const {
impl::WriteJsonField("ccpu_version", ccpu_version, &result__);
impl::WriteJsonField("language", language, &result__);
impl::WriteJsonField("wers_country_code", wers_country_code, &result__);
+ impl::WriteJsonField("hardware_version", hardware_version, &result__);
impl::WriteJsonField(
"pt_exchanged_at_odometer_x", pt_exchanged_at_odometer_x, &result__);
impl::WriteJsonField("pt_exchanged_x_days_after_epoch",
@@ -1462,6 +1464,11 @@ bool ModuleMeta::is_valid() const {
if (!wers_country_code.is_valid()) {
return false;
}
+
+ if (!hardware_version.is_valid()) {
+ return false;
+ }
+
if (!pt_exchanged_at_odometer_x.is_valid()) {
return false;
}
@@ -1492,6 +1499,11 @@ bool ModuleMeta::struct_empty() const {
if (wers_country_code.is_initialized()) {
return false;
}
+
+ if (hardware_version.is_initialized()) {
+ return false;
+ }
+
if (pt_exchanged_at_odometer_x.is_initialized()) {
return false;
}
@@ -1506,6 +1518,7 @@ bool ModuleMeta::struct_empty() const {
if (vin.is_initialized()) {
return false;
}
+
return true;
}
@@ -1523,6 +1536,10 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
wers_country_code.ReportErrors(
&report__->ReportSubobject("wers_country_code"));
}
+ if (!hardware_version.is_valid()) {
+ hardware_version.ReportErrors(
+ &report__->ReportSubobject("hardware_version"));
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
pt_exchanged_at_odometer_x.ReportErrors(
&report__->ReportSubobject("pt_exchanged_at_odometer_x"));
@@ -1551,6 +1568,7 @@ void ModuleMeta::SetPolicyTableType(PolicyTableType pt_type) {
ccpu_version.SetPolicyTableType(pt_type);
language.SetPolicyTableType(pt_type);
wers_country_code.SetPolicyTableType(pt_type);
+ hardware_version.SetPolicyTableType(pt_type);
pt_exchanged_at_odometer_x.SetPolicyTableType(pt_type);
pt_exchanged_x_days_after_epoch.SetPolicyTableType(pt_type);
ignition_cycles_since_last_exchange.SetPolicyTableType(pt_type);
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 ea323908c0..26d2124d07 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
@@ -170,18 +170,27 @@ const std::string kCountUnconsentedGroups =
" WHERE (`a`.`functional_group_id` = `f`.`id`"
" AND`f`.`user_consent_prompt` IS NULL))";
-const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`";
+const std::string kSelectModuleMeta =
+ "SELECT `ccpu_version`, `language`, "
+ "`wers_country_code`, `hardware_version`, `pt_exchanged_at_odometer_x`, "
+ "`pt_exchanged_x_days_after_epoch`, "
+ "`ignition_cycles_since_last_exchange`, `vin` "
+ "FROM `module_meta`";
const std::string kUpdateMetaParams =
"UPDATE `module_meta` SET "
- "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ? ";
+ "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ?";
+
+const std::string kUpdateMetaHardwareVersion =
+ "UPDATE `module_meta` SET `hardware_version` = ? ";
const std::string kUpdateModuleMetaVinParam =
"UPDATE `module_meta` SET `vin` = ? ";
const std::string kSaveModuleMeta =
"UPDATE `module_meta` SET `ccpu_version` = ?, `language` = ?,"
- "`wers_country_code` = ?, `pt_exchanged_at_odometer_x` = ?,"
+ "`wers_country_code` = ?, `hardware_version` = ?, "
+ "`pt_exchanged_at_odometer_x` = ?,"
"`pt_exchanged_x_days_after_epoch` = ?,"
"`ignition_cycles_since_last_exchange` = ?, `vin` = ?";
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 7147e0949d..fc35551808 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
@@ -600,6 +600,22 @@ bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+void SQLPTExtRepresentation::SetHardwareVersion(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt_ext::kUpdateMetaHardwareVersion)) {
+ SDL_LOG_WARN("Incorrect statement for insert to module meta.");
+ return;
+ }
+
+ query.Bind(0, hardware_version);
+
+ if (!query.Exec()) {
+ SDL_LOG_WARN("Incorrect insert to module meta.");
+ }
+}
+
bool SQLPTExtRepresentation::IsMetaInfoPresent() {
SDL_LOG_AUTO_TRACE();
utils::dbms::SQLQuery query(db());
@@ -1320,10 +1336,11 @@ void SQLPTExtRepresentation::GatherModuleMeta(
*meta->ccpu_version = query.GetString(0);
*meta->language = query.GetString(1);
*meta->wers_country_code = query.GetString(2);
- *meta->pt_exchanged_at_odometer_x = query.GetInteger(3);
- *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(4);
- *meta->ignition_cycles_since_last_exchange = query.GetInteger(5);
- *meta->vin = query.GetString(6);
+ *meta->hardware_version = query.GetString(3);
+ *meta->pt_exchanged_at_odometer_x = query.GetInteger(4);
+ *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(5);
+ *meta->ignition_cycles_since_last_exchange = query.GetInteger(6);
+ *meta->vin = query.GetString(7);
}
}
@@ -1652,10 +1669,11 @@ bool SQLPTExtRepresentation::SaveModuleMeta(
query.Bind(0, *(meta.ccpu_version));
query.Bind(1, *(meta.language));
query.Bind(2, *(meta.wers_country_code));
- query.Bind(3, odometer);
- query.Bind(4, *(meta.pt_exchanged_x_days_after_epoch));
- query.Bind(5, *(meta.ignition_cycles_since_last_exchange));
- query.Bind(6, *(meta.vin));
+ query.Bind(3, *(meta.hardware_version));
+ query.Bind(4, odometer);
+ query.Bind(5, *(meta.pt_exchanged_x_days_after_epoch));
+ query.Bind(6, *(meta.ignition_cycles_since_last_exchange));
+ query.Bind(7, *(meta.vin));
if (!query.Exec()) {
SDL_LOG_WARN("Incorrect update for module_meta.");
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 9e69d2cef8..519e51dde5 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -59,6 +59,7 @@ const std::string kCreateSchema =
" `ccpu_version` VARCHAR(45), "
" `language` VARCHAR(45), "
" `wers_country_code` VARCHAR(45), "
+ " `hardware_version` VARCHAR(45), "
" `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, "
" `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
" `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
index b307270b10..f43fedcfab 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
@@ -105,6 +105,7 @@ class MockPTExtRepresentation : public MockPTRepresentation,
bool(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& vin));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_METHOD0(IsMetaInfoPresent, bool());
MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
MOCK_METHOD0(GetKmFromSuccessfulExchange, int());
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 673f17e32b..7eeb41f064 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
@@ -430,6 +430,7 @@ struct ModuleMeta : CompositeType {
Optional<Integer<uint16_t, 0, 65535> > pt_exchanged_x_days_after_epoch;
Optional<Integer<uint16_t, 0, 65535> > ignition_cycles_since_last_exchange;
Optional<String<0, 500> > ccpu_version;
+ Optional<String<0, 500> > hardware_version;
public:
ModuleMeta();
diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h
index 895b4ea6b5..9a57ed21ad 100644
--- a/src/components/policy/policy_regular/include/policy/pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/pt_representation.h
@@ -152,12 +152,18 @@ class PTRepresentation {
virtual EndpointUrls GetUpdateUrls(int service_type) = 0;
/**
- * @brief Records information about head unit system to PT
+ * @brief Records mandatory information about head unit system to PT
* @return bool Success of operation
*/
virtual bool SetMetaInfo(const std::string& ccpu_version) = 0;
/**
+ * @brief Records information about hardware version to PT
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Get allowed number of notifications
* depending on application priority.
* @param priority Priority of application
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 5bf85a4bb5..fd7f879abf 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
@@ -145,6 +145,7 @@ extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectModuleMeta;
extern const std::string kUpdateMetaParams;
+extern const std::string kUpdateMetaHardwareVersion;
extern const std::string kInsertVehicleDataItem;
extern const std::string kSelectVehicleDataItem;
extern const std::string kDeleteVehicleDataItems;
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 512bfd6326..18147c43f0 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
@@ -90,7 +90,8 @@ class SQLPTRepresentation : public virtual PTRepresentation {
StringArray* nicknames = NULL,
StringArray* app_hmi_types = NULL);
bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
- bool SetMetaInfo(const std::string& ccpu_version);
+ bool SetMetaInfo(const std::string& ccpu_version) OVERRIDE;
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
#ifdef BUILD_TESTS
uint32_t open_counter() {
return open_counter_;
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index d93af5b422..7aabe26581 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -1337,7 +1337,7 @@ void CacheManager::PersistData() {
}
backup_->SetMetaInfo(*(*copy_pt.policy_table.module_meta).ccpu_version);
- ex_backup_->SetHardwareVersion(
+ backup_->SetHardwareVersion(
*(*copy_pt.policy_table.module_meta).hardware_version);
// In case of extended policy the meta info should be backuped as well.
diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc
index d3473bb2a7..d2a70baafe 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -1297,7 +1297,8 @@ ModuleMeta::ModuleMeta(const Json::Value* value__)
impl::ValueMember(value__, "pt_exchanged_x_days_after_epoch"))
, ignition_cycles_since_last_exchange(
impl::ValueMember(value__, "ignition_cycles_since_last_exchange"))
- , ccpu_version(impl::ValueMember(value__, "ccpu_version")) {}
+ , ccpu_version(impl::ValueMember(value__, "ccpu_version"))
+ , hardware_version(impl::ValueMember(value__, "hardware_version")) {}
Json::Value ModuleMeta::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -1319,6 +1320,9 @@ bool ModuleMeta::is_valid() const {
if (!ccpu_version.is_valid()) {
return false;
}
+ if (!hardware_version.is_valid()) {
+ return false;
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
return false;
}
@@ -1339,6 +1343,9 @@ bool ModuleMeta::struct_empty() const {
if (ccpu_version.is_initialized()) {
return false;
}
+ if (hardware_version.is_initialized()) {
+ return false;
+ }
if (pt_exchanged_at_odometer_x.is_initialized()) {
return false;
}
@@ -1359,6 +1366,10 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
if (!ccpu_version.is_valid()) {
ccpu_version.ReportErrors(&report__->ReportSubobject("ccpu_version"));
}
+ if (!hardware_version.is_valid()) {
+ hardware_version.ReportErrors(
+ &report__->ReportSubobject("hardware_version"));
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
pt_exchanged_at_odometer_x.ReportErrors(
&report__->ReportSubobject("pt_exchanged_at_odometer_x"));
diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc
index cf9167406f..ea0b7fe997 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -60,7 +60,8 @@ const std::string kCreateSchema =
" `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
" `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
" `flag_update_required` BOOL NOT NULL, "
- " `ccpu_version` VARCHAR(45) "
+ " `ccpu_version` VARCHAR(45), "
+ " `hardware_version` VARCHAR(45) "
"); "
"CREATE TABLE IF NOT EXISTS `module_config`( "
" `preloaded_pt` BOOL NOT NULL, "
@@ -1076,10 +1077,16 @@ const std::string kSaveModuleMeta =
"`pt_exchanged_x_days_after_epoch` = ?, "
"`ignition_cycles_since_last_exchange` = ? ";
-const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`";
+const std::string kSelectModuleMeta =
+ "SELECT `ccpu_version`, `hardware_version`, `pt_exchanged_at_odometer_x`, "
+ "`pt_exchanged_x_days_after_epoch`, `ignition_cycles_since_last_exchange` "
+ "FROM `module_meta`";
const std::string kUpdateMetaParams =
"UPDATE `module_meta` SET "
"`ccpu_version` = ? ";
+
+const std::string kUpdateMetaHardwareVersion =
+ "UPDATE `module_meta` SET `hardware_version` = ? ";
} // namespace sql_pt
} // namespace policy
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 7193a06bdb..57781ae16f 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -472,10 +472,11 @@ void SQLPTRepresentation::GatherModuleMeta(
SDL_LOG_INFO("Gather Module Meta Info");
utils::dbms::SQLQuery query(db());
if (query.Prepare(sql_pt::kSelectModuleMeta) && query.Next()) {
- *meta->pt_exchanged_at_odometer_x = query.GetInteger(0);
- *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(1);
- *meta->ignition_cycles_since_last_exchange = query.GetInteger(2);
- *meta->ccpu_version = query.GetString(4);
+ *meta->ccpu_version = query.GetString(0);
+ *meta->hardware_version = query.GetString(1);
+ *meta->pt_exchanged_at_odometer_x = query.GetInteger(2);
+ *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(3);
+ *meta->ignition_cycles_since_last_exchange = query.GetInteger(4);
}
}
@@ -716,6 +717,22 @@ bool SQLPTRepresentation::SetMetaInfo(const std::string& ccpu_version) {
return true;
}
+void SQLPTRepresentation::SetHardwareVersion(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kUpdateMetaHardwareVersion)) {
+ SDL_LOG_WARN("Incorrect statement for insert to module meta.");
+ return;
+ }
+
+ query.Bind(0, hardware_version);
+
+ if (!query.Exec()) {
+ SDL_LOG_WARN("Incorrect insert to module meta.");
+ }
+}
+
bool SQLPTRepresentation::GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const {
SDL_LOG_INFO("Gather applications policies");
diff --git a/src/components/utils/test/policy.sql b/src/components/utils/test/policy.sql
index d588d695a6..ed627b5fdc 100644
--- a/src/components/utils/test/policy.sql
+++ b/src/components/utils/test/policy.sql
@@ -22,6 +22,7 @@ BEGIN TRANSACTION;
`ccpu_version` VARCHAR(45),
`language` VARCHAR(45),
`wers_country_code` VARCHAR(45),
+ `hardware_version` VARCHAR(45),
`pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0,
`pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0,
`ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0,