From 2c94ff01c51efd56dd879e37f1fceee2fd406ad3 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Mon, 9 May 2022 23:34:08 +0200 Subject: [PATCH] stop using DefaultRandom: it does not have enough entropy --- .../plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt | 7 +++---- .../pump/omnipod/dash/history/database/HistoryRecordDao.kt | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 88ba8c2146..04e4abd792 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -66,7 +66,6 @@ import javax.inject.Inject import javax.inject.Singleton import kotlin.concurrent.thread import kotlin.math.ceil -import kotlin.random.Random @Singleton class OmnipodDashPumpPlugin @Inject constructor( @@ -142,7 +141,7 @@ class OmnipodDashPumpPlugin @Inject constructor( duration = T.mins(PodConstants.MAX_POD_LIFETIME.toMinutes()).msecs(), isAbsolute = true, type = PumpSync.TemporaryBasalType.PUMP_SUSPEND, - pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique + pumpId = System.currentTimeMillis(), // we don't use this, just make sure it's unique pumpType = PumpType.OMNIPOD_DASH, pumpSerial = Constants.PUMP_SERIAL_FOR_FAKE_TBR // switching the serialNumber here would need a // call to connectNewPump. If we do that, then we will have a TBR started by the "n/a" pump and @@ -323,7 +322,7 @@ class OmnipodDashPumpPlugin @Inject constructor( duration = T.mins(PodConstants.MAX_POD_LIFETIME.toMinutes()).msecs(), isAbsolute = true, type = PumpSync.TemporaryBasalType.PUMP_SUSPEND, - pumpId = Random.Default.nextLong(), // we don't use this, just make sure it's unique + pumpId = System.currentTimeMillis(), // we don't use this, just make sure it's unique pumpType = PumpType.OMNIPOD_DASH, pumpSerial = serialNumber() ) @@ -356,7 +355,7 @@ class OmnipodDashPumpPlugin @Inject constructor( } pumpSync.insertAnnouncement( error = it.toString(), - pumpId = Random.Default.nextLong(), + pumpId = System.currentTimeMillis(), pumpType = PumpType.OMNIPOD_DASH, pumpSerial = serialNumber() ) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt index da2525e8f4..13ba7b1953 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordDao.kt @@ -15,7 +15,7 @@ abstract class HistoryRecordDao { @Query("SELECT * from historyrecords") abstract fun all(): Single> - + @Query("SELECT * from historyrecords ORDER BY id LIMIT 1") abstract fun first(): HistoryRecordEntity?