Dexcom: check for sensorStartTime validity

This commit is contained in:
Milos Kozak 2022-03-16 11:53:47 +01:00
parent 14641e85e6
commit 58b49a05ea

View file

@ -149,11 +149,15 @@ class DexcomPlugin @Inject constructor(
sourceSensor = sourceSensor sourceSensor = sourceSensor
) )
} }
val sensorStartTime = if (sp.getBoolean(R.string.key_dexcom_lognssensorchange, false) && bundle.containsKey("sensorInsertionTime")) { var sensorStartTime = if (sp.getBoolean(R.string.key_dexcom_lognssensorchange, false) && bundle.containsKey("sensorInsertionTime")) {
bundle.getLong("sensorInsertionTime", 0) * 1000 bundle.getLong("sensorInsertionTime", 0) * 1000
} else { } else {
null null
} }
// check start time validity
sensorStartTime?.let {
if (abs(it - now) > T.months(1).msecs() || it > now) sensorStartTime = null
}
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)) repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it) aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it)