Skip to content
Snippets Groups Projects
Unverified Commit 2acbc0b7 authored by Philipp Woessner's avatar Philipp Woessner Committed by GitHub
Browse files

Hotfix for non whitelisted devices (#16)

* fix that caused a crash for non whitelisted devices during the calculation of the active tracing time in the retention period
parent 4804888a
No related branches found
No related tags found
No related merge requests found
package de.rki.coronawarnapp.risk package de.rki.coronawarnapp.risk
import com.google.android.gms.common.api.ApiException
import de.rki.coronawarnapp.CoronaWarnApplication import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.exception.ExceptionCategory
import de.rki.coronawarnapp.exception.report
import de.rki.coronawarnapp.nearby.InternalExposureNotificationClient import de.rki.coronawarnapp.nearby.InternalExposureNotificationClient
import de.rki.coronawarnapp.storage.LocalData import de.rki.coronawarnapp.storage.LocalData
import de.rki.coronawarnapp.storage.tracing.TracingIntervalRepository import de.rki.coronawarnapp.storage.tracing.TracingIntervalRepository
...@@ -183,9 +186,20 @@ object TimeVariables { ...@@ -183,9 +186,20 @@ object TimeVariables {
.getIntervals() .getIntervals()
.toMutableList() .toMutableList()
if (!InternalExposureNotificationClient.asyncIsEnabled()) { // by default the tracing is deactivated
// if the API is reachable we set the value accordingly
var enIsEnabled = false
try {
enIsEnabled = !InternalExposureNotificationClient.asyncIsEnabled()
} catch (e: ApiException) {
e.report(ExceptionCategory.EXPOSURENOTIFICATION)
}
if (enIsEnabled) {
val current = System.currentTimeMillis() val current = System.currentTimeMillis()
var lastTimeTracingWasNotActivated = LocalData.lastNonActiveTracingTimestamp() ?: current var lastTimeTracingWasNotActivated =
LocalData.lastNonActiveTracingTimestamp() ?: current
if (lastTimeTracingWasNotActivated < (current - getTimeRangeFromRetentionPeriod())) { if (lastTimeTracingWasNotActivated < (current - getTimeRangeFromRetentionPeriod())) {
lastTimeTracingWasNotActivated = current - getTimeRangeFromRetentionPeriod() lastTimeTracingWasNotActivated = current - getTimeRangeFromRetentionPeriod()
...@@ -193,6 +207,7 @@ object TimeVariables { ...@@ -193,6 +207,7 @@ object TimeVariables {
inactiveTracingIntervals.add(Pair(lastTimeTracingWasNotActivated, current)) inactiveTracingIntervals.add(Pair(lastTimeTracingWasNotActivated, current))
} }
val finalTracingMS = tracingActiveMS - inactiveTracingIntervals val finalTracingMS = tracingActiveMS - inactiveTracingIntervals
.map { it.second - it.first } .map { it.second - it.first }
.sum() .sum()
......
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