Skip to content
Snippets Groups Projects
Unverified Commit 8ea76aa9 authored by Alex Paulescu's avatar Alex Paulescu Committed by GitHub
Browse files

Active tracing days count can be negative (EXPOSUREAPP-1844) #828 (#1029)


* Refactored method

* Normalized interval pairs.

* Perfoming additional check for from date

* Removed changes from build.gradle

* Fixed lint errors

Co-authored-by: default avatarJakob Möller <jakob.moeller@sap.com>
parent f1d98958
No related branches found
No related tags found
No related merge requests found
......@@ -188,22 +188,19 @@ object TimeVariables {
// by default the tracing is assumed to be activated
// if the API is reachable we set the value accordingly
var enIsDisabled = false
try {
enIsDisabled = !InternalExposureNotificationClient.asyncIsEnabled()
val enIsDisabled = try {
!InternalExposureNotificationClient.asyncIsEnabled()
} catch (e: ApiException) {
e.report(ExceptionCategory.EXPOSURENOTIFICATION)
false
}
if (enIsDisabled) {
val current = System.currentTimeMillis()
var lastTimeTracingWasNotActivated =
LocalData.lastNonActiveTracingTimestamp() ?: current
if (lastTimeTracingWasNotActivated < (current - getTimeRangeFromRetentionPeriod())) {
lastTimeTracingWasNotActivated = current - getTimeRangeFromRetentionPeriod()
}
val lastTimeTracingWasNotActivated = minOf(
LocalData.lastNonActiveTracingTimestamp() ?: current,
current - tracingActiveMS
)
inactiveTracingIntervals.add(Pair(lastTimeTracingWasNotActivated, current))
}
......
......@@ -61,14 +61,12 @@ class TracingIntervalRepository(private val tracingIntervalDao: TracingIntervalD
}
suspend fun getIntervals(): List<Pair<Long, Long>> {
deleteOutdatedInterval()
return tracingIntervalDao.getAllIntervals().map {
Pair(it.from, it.to)
}.also {
Timber.d("Intervals: $it")
}
}
val retentionTimestamp = System.currentTimeMillis() - TimeVariables.getDefaultRetentionPeriodInMS()
tracingIntervalDao.deleteOutdatedIntervals(retentionTimestamp)
private suspend fun deleteOutdatedInterval() = tracingIntervalDao
.deleteOutdatedIntervals(System.currentTimeMillis() - TimeVariables.getDefaultRetentionPeriodInMS())
return tracingIntervalDao
.getAllIntervals()
.map { Pair(maxOf(it.from, retentionTimestamp), it.to) }
.also { Timber.d("Intervals: $it") }
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment