Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

cleanup time constants class #397

Merged
merged 2 commits into from
Jun 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.rki.coronawarnapp.risk

import com.google.android.gms.common.api.ApiException
import de.rki.coronawarnapp.BuildConfig
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.exception.ExceptionCategory
import de.rki.coronawarnapp.exception.reporting.report
Expand Down Expand Up @@ -89,26 +90,22 @@ object TimeVariables {
*/
fun getMaxStaleExposureRiskRange(): Int = MAX_STALE_EXPOSURE_RISK_RANGE

/**
* This is the exact number of days until the end of time is reached.
* This is used by the Google Exposure Notification API daysSinceLastExposure property in the
* ExposureSummary if there was no contact with someone.
*/
private const val END_OF_TIME_DAYS = 2147483647

/**
* Getter function for [END_OF_TIME_DAYS]
*
* @return number of days until end of time
*/
fun getEndOfTimeDays() = END_OF_TIME_DAYS
private const val MILISECONDS_IN_A_SECOND = 1000
private const val SECONDS_IN_A_MINUTES = 60
private const val MINUTES_IN_AN_HOUR = 60
private const val HOURS_IN_AN_DAY = 24

/**
* Delay in milliseconds for manual key retrieval process
* Internal requirements: 24 hours = 1000 * 60 * 60 * 24 milliseconds
* TODO Change this to the real 24 Hours
* Value for testing: 1 min = 1000 * 60 * 1
* Value: 24 hours = 1000 * 60 * 60 * 24 milliseconds
*/
private const val MANUAL_KEY_RETRIEVAL_DELAY = 1000 * 60 * 1
private val MANUAL_KEY_RETRIEVAL_DELAY =
if (BuildConfig.FLAVOR == "deviceForTesters") {
MILISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTES
} else {
MILISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTES * MINUTES_IN_AN_HOUR * HOURS_IN_AN_DAY
}

/**
* Getter function for [MANUAL_KEY_RETRIEVAL_DELAY]
Expand Down Expand Up @@ -160,18 +157,6 @@ object TimeVariables {
* CALCULATED TIME VARIABLES
****************************************************/

/**
* The timeRange for calculating the exposure risk figures
* In milliseconds
*
* @return Pair of Long describing the timerange in milliseconds
*/
fun getCalculationTimeRange(): Pair<Long, Long> =
Pair(
getTimeRangeFromRetentionPeriod(),
System.currentTimeMillis()
)

/**
* The time since the last successful exposure calculation ran in foreground or background.
* In milliseconds
Expand Down