summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYana Chernysheva <ychernysheva@luxoft.com>2020-12-30 17:52:29 +0200
committerLitvinenkoIra <ilytvynenko@luxoft.com>2021-02-02 11:24:11 +0200
commita888182904e82455f7d3239dfe74f42778cde348 (patch)
tree194239c7fce27d32d9a0eaee81c1c15aad35af43
parentdc420f008494a0f8c1faf75fbb27e245db463ee4 (diff)
downloadsdl_core-a888182904e82455f7d3239dfe74f42778cde348.tar.gz
Add new methods to CacheManager classes
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h2
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h2
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h10
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc23
-rw-r--r--src/components/policy/policy_external/test/cache_manager_test.cc12
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h10
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc22
-rw-r--r--src/components/policy/policy_regular/test/cache_manager_test.cc12
10 files changed, 108 insertions, 13 deletions
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 d93bdff7f7..a79918cc39 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
@@ -207,7 +207,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
bool(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
MOCK_CONST_METHOD0(IsMetaInfoPresent, bool());
MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index 19de301dc3..716f66f994 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -181,7 +181,9 @@ class MockCacheManagerInterface : public CacheManagerInterface {
bool(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
MOCK_CONST_METHOD0(IsMetaInfoPresent, bool());
MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));
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 12fe8f10cd..8384f56f77 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -597,13 +597,11 @@ class CacheManager : public CacheManagerInterface {
*/
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
- /**
- * @brief Records information about head unit system to PT
- * @return bool Success of operation
- */
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;
/**
* @brief Get information about last ccpu_version from PT
@@ -611,6 +609,8 @@ class CacheManager : public CacheManagerInterface {
*/
std::string GetCCPUVersionFromPT() const;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @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/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index 8ed46e0c72..f33dabd025 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
@@ -645,7 +645,7 @@ class CacheManagerInterface {
virtual void SetPreloadedPtFlag(const bool is_preloaded) = 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,
@@ -653,12 +653,24 @@ class CacheManagerInterface {
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 Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return hardware version from PT
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 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/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 783a622b2e..f93b7b3399 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -2047,7 +2047,8 @@ void CacheManager::PersistData() {
*(*copy_pt.policy_table.module_meta).wers_country_code,
*(*copy_pt.policy_table.module_meta).language);
ex_backup_->SetVINValue(*(*copy_pt.policy_table.module_meta).vin);
-
+ ex_backup_->SetHardwareVersion(
+ *(*copy_pt.policy_table.module_meta).hardware_version);
// Save unpaired flag for devices
policy_table::DeviceData::const_iterator it_device =
copy_pt.policy_table.device_data->begin();
@@ -2300,13 +2301,33 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+void CacheManager::SetHardwareVersion(const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ *pt_->policy_table.module_meta->hardware_version = hardware_version;
+ Backup();
+}
+
std::string CacheManager::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
rpc::Optional<policy_table::ModuleMeta>& module_meta =
pt_->policy_table.module_meta;
return *(module_meta->ccpu_version);
}
+std::string CacheManager::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ return *(module_meta->hardware_version);
+}
+
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
sync_primitives::AutoLock lock(cache_lock_);
diff --git a/src/components/policy/policy_external/test/cache_manager_test.cc b/src/components/policy/policy_external/test/cache_manager_test.cc
index 746d0c7221..9819811803 100644
--- a/src/components/policy/policy_external/test/cache_manager_test.cc
+++ b/src/components/policy/policy_external/test/cache_manager_test.cc
@@ -2169,6 +2169,18 @@ TEST_F(CacheManagerTest, RemoveAppConsentForGroup_GroupIsRemoved) {
EXPECT_FALSE(unconsented_groups_after_removal.empty());
}
+TEST_F(CacheManagerTest, GetHardwareVersion_ValueWasSetBefore_ReturnValue) {
+ std::string hardware_version = "1.1.1.1";
+ cache_manager_->SetHardwareVersion(hardware_version);
+ EXPECT_EQ(hardware_version, cache_manager_->GetHardwareVersionFromPT());
+}
+
+TEST_F(CacheManagerTest,
+ GetHardwareVersion_ValueNotSettedBefore_ReturnEmptyString) {
+ std::string empty_string = "";
+ EXPECT_EQ(empty_string, cache_manager_->GetHardwareVersionFromPT());
+}
+
} // namespace policy_test
} // namespace components
} // namespace test
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 25b4a8bc18..473caef145 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -544,13 +544,11 @@ class CacheManager : public CacheManagerInterface {
*/
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
- /**
- * @brief Records information about head unit system to PT
- * @return bool Success of operation
- */
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;
/**
* @brief Get information about last ccpu_version from PT
@@ -558,6 +556,8 @@ class CacheManager : public CacheManagerInterface {
*/
std::string GetCCPUVersionFromPT() const;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
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 14130c0316..5e536ef315 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
@@ -586,7 +586,7 @@ class CacheManagerInterface {
virtual void SetPreloadedPtFlag(const bool is_preloaded) = 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,
@@ -594,12 +594,24 @@ class CacheManagerInterface {
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 Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return string representation of hardware version from PT, empty if absent
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 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_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index d53ec4d18a..d93af5b422 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -1337,6 +1337,8 @@ void CacheManager::PersistData() {
}
backup_->SetMetaInfo(*(*copy_pt.policy_table.module_meta).ccpu_version);
+ ex_backup_->SetHardwareVersion(
+ *(*copy_pt.policy_table.module_meta).hardware_version);
// In case of extended policy the meta info should be backuped as well.
backup_->WriteDb();
@@ -1490,13 +1492,33 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+void CacheManager::SetHardwareVersion(const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ *pt_->policy_table.module_meta->hardware_version = hardware_version;
+ Backup();
+}
+
std::string CacheManager::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
rpc::Optional<policy_table::ModuleMeta>& module_meta =
pt_->policy_table.module_meta;
return *(module_meta->ccpu_version);
}
+std::string CacheManager::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ return *(module_meta->hardware_version);
+}
+
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
bool result = true;
diff --git a/src/components/policy/policy_regular/test/cache_manager_test.cc b/src/components/policy/policy_regular/test/cache_manager_test.cc
index 31166b8f43..00b632ac17 100644
--- a/src/components/policy/policy_regular/test/cache_manager_test.cc
+++ b/src/components/policy/policy_regular/test/cache_manager_test.cc
@@ -1235,6 +1235,18 @@ TEST_F(CacheManagerTest, IsApplicationRepresented_DeviceApp_ReturnTrue) {
EXPECT_TRUE(cache_manager_->IsApplicationRepresented(kDeviceId));
}
+TEST_F(CacheManagerTest, GetHardwareVersion_ValueWasSetBefore_ReturnValue) {
+ std::string hardware_version = "1.1.1.1";
+ cache_manager_->SetHardwareVersion(hardware_version);
+ EXPECT_EQ(hardware_version, cache_manager_->GetHardwareVersionFromPT());
+}
+
+TEST_F(CacheManagerTest,
+ GetHardwareVersion_ValueNotSettedBefore_ReturnEmptyString) {
+ std::string empty_string = "";
+ EXPECT_EQ(empty_string, cache_manager_->GetHardwareVersionFromPT());
+}
+
} // namespace policy_test
} // namespace components
} // namespace test