summaryrefslogtreecommitdiff
path: root/src/components/policy
diff options
context:
space:
mode:
authorConlain Kelly <conlain.k@gmail.com>2018-06-18 11:43:53 -0400
committerConlain Kelly <conlain.k@gmail.com>2018-06-18 11:43:53 -0400
commitccf9073578e5c43f99ca9c8db09a15382129e0bd (patch)
tree1827a599b8ee1f326013ecc017a110d33fbc43a3 /src/components/policy
parent0dec6ef21fdfd752e33b0364c9e50d27c736371e (diff)
downloadsdl_core-ccf9073578e5c43f99ca9c8db09a15382129e0bd.tar.gz
remove struct timeval and use boost time_duration instead
also cleans up date_time namespacing but maintains helper functions
Diffstat (limited to 'src/components/policy')
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc10
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc2
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc4
-rw-r--r--src/components/policy/policy_external/src/usage_statistics/counter.cc2
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc2
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc2
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc2
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc8
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc4
-rw-r--r--src/components/policy/policy_regular/src/usage_statistics/counter.cc2
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc34
11 files changed, 35 insertions, 37 deletions
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 00bb1e4a1c..6e9465eea4 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1119,8 +1119,8 @@ bool CacheManager::SetUserPermissionsForApp(
it_group->second != is_allowed) {
*out_app_permissions_changed = true;
- const TimevalStruct tm = date_time::DateTime::getCurrentTime();
- int64_t current_time_msec = date_time::DateTime::getmSecs(tm);
+ const date_time::TimeDuration tm = date_time::getCurrentTime();
+ int64_t current_time_msec = date_time::getmSecs(tm);
ucr.consent_last_updated = current_time_msec;
LOG4CXX_DEBUG(logger_, "Updating consents time " << current_time_msec);
}
@@ -1333,7 +1333,7 @@ int CacheManager::TimeoutResponse() {
CACHE_MANAGER_CHECK(0);
sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.module_config.timeout_after_x_seconds *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ date_time::MILLISECONDS_IN_SECOND;
}
bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
@@ -2651,8 +2651,8 @@ void CacheManager::SetExternalConsentForApp(
(*(*pt_->policy_table.device_data)[permissions.device_id]
.user_consent_records)[permissions.policy_app_id];
- const TimevalStruct tm = date_time::DateTime::getCurrentTime();
- int64_t current_time_msec = date_time::DateTime::getmSecs(tm);
+ const date_time::TimeDuration tm = date_time::getCurrentTime();
+ int64_t current_time_msec = date_time::getmSecs(tm);
app_consent_records.ext_consent_last_updated = current_time_msec;
LOG4CXX_DEBUG(logger_, "Updating consents time " << current_time_msec);
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 56de26af64..07afb2fe22 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1507,7 +1507,7 @@ void PolicyManagerImpl::CalculateGroupsConsentFromExternalConsent(
bool PolicyManagerImpl::ExceededDays() {
LOG4CXX_AUTO_TRACE(logger_);
- TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ date_time::TimeDuration current_time = date_time::getCurrentTime();
const int kSecondsInDay = 60 * 60 * 24;
const int days = current_time.tv_sec / kSecondsInDay;
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 b05716dc3f..368dfa80f2 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -235,10 +235,10 @@ int SQLPTRepresentation::TimeoutResponse() {
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) {
LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence");
- const int defaultTimeout = 30 * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ const int defaultTimeout = 30 * date_time::MILLISECONDS_IN_SECOND;
return defaultTimeout;
}
- return query.GetInteger(0) * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ return query.GetInteger(0) * date_time::MILLISECONDS_IN_SECOND;
}
bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
diff --git a/src/components/policy/policy_external/src/usage_statistics/counter.cc b/src/components/policy/policy_external/src/usage_statistics/counter.cc
index 661ea29704..e2c4d59b0e 100644
--- a/src/components/policy/policy_external/src/usage_statistics/counter.cc
+++ b/src/components/policy/policy_external/src/usage_statistics/counter.cc
@@ -107,7 +107,7 @@ AppStopwatchImpl::~AppStopwatchImpl() {}
void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) {
stopwatch_type_ = stopwatch_type;
- timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND,
+ timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND,
timer::kPeriodic);
}
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
index 947bb5d3ad..c1ff1c8487 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc
@@ -924,7 +924,7 @@ TEST_F(
}
uint32_t GetCurrentDaysCount() {
- TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ date_time::TimeDuration current_time = date_time::getCurrentTime();
const uint32_t kSecondsInDay = 60 * 60 * 24;
return current_time.tv_sec / kSecondsInDay;
}
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc
index 2f2162494f..0532710deb 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc
@@ -69,7 +69,7 @@ TEST_F(
// To set UP_TO_DATE before registration
GetPTU(kValidSdlPtUpdateJson);
- const TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ const date_time::TimeDuration current_time = date_time::getCurrentTime();
const int kSecondsInDay = 60 * 60 * 24;
const int days_after_epoch = current_time.tv_sec / kSecondsInDay;
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 1d51b81af4..99621269e2 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -646,7 +646,7 @@ int CacheManager::TimeoutResponse() {
CACHE_MANAGER_CHECK(0);
sync_primitives::AutoLock auto_lock(cache_lock_);
return pt_->policy_table.module_config.timeout_after_x_seconds *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ date_time::MILLISECONDS_IN_SECOND;
}
bool CacheManager::SecondsBetweenRetries(std::vector<int>& seconds) {
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index a48a9a1ba0..5bdfdaf3bb 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -65,7 +65,7 @@ void DeleteManager(policy::PolicyManager* pm) {
namespace {
const uint32_t kDefaultRetryTimeoutInMSec =
- 60u * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ 60u * date_time::MILLISECONDS_IN_SECOND;
} // namespace
namespace policy {
@@ -832,9 +832,9 @@ const PolicySettings& PolicyManagerImpl::get_settings() const {
bool PolicyManagerImpl::ExceededDays() {
LOG4CXX_AUTO_TRACE(logger_);
- TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ date_time::TimeDuration current_time = date_time::getCurrentTime();
const int kSecondsInDay = 60 * 60 * 24;
- const int days = current_time.tv_sec / kSecondsInDay;
+ const int days = date_time::getSecs(current_time) / kSecondsInDay;
return 0 == cache_->DaysBeforeExchange(days);
}
@@ -885,7 +885,7 @@ uint32_t PolicyManagerImpl::NextRetryTimeout() {
for (uint32_t i = 0u; i < retry_sequence_index_; ++i) {
next += retry_sequence_seconds_[i] *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ date_time::MILLISECONDS_IN_SECOND;
next += retry_sequence_timeout_;
}
++retry_sequence_index_;
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 a57230aeb1..043a5e54d4 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -187,10 +187,10 @@ int SQLPTRepresentation::TimeoutResponse() {
utils::dbms::SQLQuery query(db());
if (!query.Prepare(sql_pt::kSelectTimeoutResponse) || !query.Exec()) {
LOG4CXX_INFO(logger_, "Can not select timeout response for retry sequence");
- const int defaultTimeout = 30 * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ const int defaultTimeout = 30 * date_time::MILLISECONDS_IN_SECOND;
return defaultTimeout;
}
- return query.GetInteger(0) * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ return query.GetInteger(0) * date_time::MILLISECONDS_IN_SECOND;
}
bool SQLPTRepresentation::SecondsBetweenRetries(std::vector<int>* seconds) {
diff --git a/src/components/policy/policy_regular/src/usage_statistics/counter.cc b/src/components/policy/policy_regular/src/usage_statistics/counter.cc
index 60e34a929d..83e12194e0 100644
--- a/src/components/policy/policy_regular/src/usage_statistics/counter.cc
+++ b/src/components/policy/policy_regular/src/usage_statistics/counter.cc
@@ -103,7 +103,7 @@ AppStopwatchImpl::AppStopwatchImpl(
void AppStopwatchImpl::Start(AppStopwatchId stopwatch_type) {
stopwatch_type_ = stopwatch_type;
- timer_.Start(time_out_ * date_time::DateTime::MILLISECONDS_IN_SECOND,
+ timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND,
timer::kPeriodic);
}
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index 5fd0a48f7c..c105b304fe 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -840,9 +840,9 @@ TEST_F(PolicyManagerImplTest2,
PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
- TimevalStruct current_time = date_time::DateTime::getCurrentTime();
+ date_time::TimeDuration current_time = date_time::getCurrentTime();
const int kSecondsInDay = 60 * 60 * 24;
- int days = current_time.tv_sec / kSecondsInDay;
+ int days = date_time::getSecs(current_time) / kSecondsInDay;
EXPECT_EQ("UP_TO_DATE", manager->GetPolicyTableStatus());
GetPTU("valid_sdl_pt_update.json");
@@ -900,24 +900,23 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) {
uint32_t timeout_after_x_seconds =
root["policy_table"]["module_config"]["timeout_after_x_seconds"]
.asInt() *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ date_time::MILLISECONDS_IN_SECOND;
const uint32_t first_retry = timeout_after_x_seconds;
EXPECT_EQ(first_retry, manager->NextRetryTimeout());
- uint32_t next_retry = first_retry +
- seconds_between_retries[0].asInt() *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ uint32_t next_retry = first_retry + seconds_between_retries[0].asInt() *
+ date_time::MILLISECONDS_IN_SECOND;
EXPECT_EQ(next_retry, manager->NextRetryTimeout());
- next_retry = first_retry + next_retry +
- seconds_between_retries[1].asInt() *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ next_retry =
+ first_retry + next_retry +
+ seconds_between_retries[1].asInt() * date_time::MILLISECONDS_IN_SECOND;
EXPECT_EQ(next_retry, manager->NextRetryTimeout());
- next_retry = first_retry + next_retry +
- seconds_between_retries[2].asInt() *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ next_retry =
+ first_retry + next_retry +
+ seconds_between_retries[2].asInt() * date_time::MILLISECONDS_IN_SECOND;
EXPECT_EQ(next_retry, manager->NextRetryTimeout());
- next_retry = first_retry + next_retry +
- seconds_between_retries[3].asInt() *
- date_time::DateTime::MILLISECONDS_IN_SECOND;
+ next_retry =
+ first_retry + next_retry +
+ seconds_between_retries[3].asInt() * date_time::MILLISECONDS_IN_SECOND;
EXPECT_EQ(next_retry, manager->NextRetryTimeout());
}
}
@@ -948,9 +947,8 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) {
Json::Value val2(Json::arrayValue);
val2[0] = hmi_level[index];
val[new_data.new_field_value_]["hmi_levels"] = val2;
- root["policy_table"]["functional_groupings"][new_data
- .new_field_name_]["rpcs"] =
- val;
+ root["policy_table"]["functional_groupings"][new_data.new_field_name_]
+ ["rpcs"] = val;
root["policy_table"]["functional_groupings"][new_data.new_field_name_]
["user_consent_prompt"] = new_data.new_field_name_;
}