summaryrefslogtreecommitdiff
path: root/src/components/policy
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2018-08-28 15:12:52 -0400
committerGitHub <noreply@github.com>2018-08-28 15:12:52 -0400
commit721fcfec20f26ff86dcbd652d12e7cc26e355b7f (patch)
tree4b6475b012a40c40e1e88d91f3598ae19abe1cf0 /src/components/policy
parentae9551d6d4c567caa88a206f6975ad8cb6ecf2c1 (diff)
parent84113996315adc1424199e13b69137fcb269f294 (diff)
downloadsdl_core-721fcfec20f26ff86dcbd652d12e7cc26e355b7f.tar.gz
Merge pull request #2278 from smartdevicelink/feature/boost_datetime_implementation
Feature/boost datetime implementation
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.cc3
-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.cc9
-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.cc3
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc30
11 files changed, 34 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 5387a7700a..e4a4151fa4 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1117,8 +1117,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);
}
@@ -1331,7 +1331,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 5f651645d9..c7d814e56e 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1496,7 +1496,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 b9b0194199..6b07cc647f 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 a7e8368239..d46f6a315a 100644
--- a/src/components/policy/policy_external/src/usage_statistics/counter.cc
+++ b/src/components/policy/policy_external/src/usage_statistics/counter.cc
@@ -107,8 +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::kPeriodic);
+ timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic);
}
void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) {
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 4ef6ed3e10..8d2802c831 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 404991c969..4df4012ad3 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 092fd5b9a4..9accabf59b 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -645,7 +645,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 ebc695142e..f4b6f0ae03 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -62,7 +62,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 {
@@ -827,9 +827,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);
}
@@ -879,8 +879,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;
+ next += retry_sequence_seconds_[i] * 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 00f3349050..8efe2fb59e 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 199b5ae779..ed16fa3e8d 100644
--- a/src/components/policy/policy_regular/src/usage_statistics/counter.cc
+++ b/src/components/policy/policy_regular/src/usage_statistics/counter.cc
@@ -103,8 +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::kPeriodic);
+ timer_.Start(time_out_ * date_time::MILLISECONDS_IN_SECOND, timer::kPeriodic);
}
void AppStopwatchImpl::Switch(AppStopwatchId stopwatch_type) {
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 9b38bc3be8..9f73f60d28 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
@@ -838,9 +838,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");
@@ -898,24 +898,24 @@ 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());
}
}