From 58a40778d9f51343f99e6a24f17024b8632881f4 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Mon, 9 May 2022 23:25:30 +0200 Subject: [PATCH 1/3] format. switch historyId to Long --- .../omnipod/dash/history/DashHistoryTest.kt | 2 +- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 6 +- .../dash/dagger/OmnipodDashHistoryModule.kt | 2 +- .../dash/driver/OmnipodDashManagerImpl.kt | 4 +- .../driver/comm/OmnipodDashBleManagerImpl.kt | 4 +- .../dash/driver/comm/ServiceDiscoverer.kt | 4 +- .../driver/comm/callbacks/BleCommCallbacks.kt | 4 +- .../dash/driver/comm/endecrypt/EnDecrypt.kt | 2 +- .../pump/omnipod/dash/driver/comm/io/BleIO.kt | 4 +- .../omnipod/dash/driver/comm/io/CmdBleIO.kt | 2 +- .../omnipod/dash/driver/comm/io/DataBleIO.kt | 2 +- .../dash/driver/comm/message/MessageIO.kt | 4 +- .../dash/driver/comm/pair/KeyExchange.kt | 4 +- .../dash/driver/comm/pair/LTKExchanger.kt | 4 +- .../dash/driver/comm/scan/PodScanner.kt | 4 +- .../dash/driver/comm/scan/ScanCollector.kt | 2 +- .../dash/driver/comm/session/Connection.kt | 4 +- .../dash/driver/comm/session/EapMessage.kt | 2 +- .../dash/driver/comm/session/Milenage.kt | 2 +- .../dash/driver/comm/session/Session.kt | 4 +- .../driver/comm/session/SessionEstablisher.kt | 4 +- .../pod/state/OmnipodDashPodStateManager.kt | 8 +- .../state/OmnipodDashPodStateManagerImpl.kt | 8 +- .../pump/omnipod/dash/history/DashHistory.kt | 23 ++-- .../dash/history/data/HistoryRecord.kt | 7 +- .../history/database/DashHistoryDatabase.kt | 2 +- .../dash/history/database/HistoryRecordDao.kt | 17 +-- .../history/database/HistoryRecordEntity.kt | 11 +- .../dash/history/mapper/HistoryMapper.kt | 17 --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 56 ++++---- .../dash/ui/DashPodManagementActivity.kt | 1 - .../dash/ui/OmnipodDashOverviewFragment.kt | 126 ++++++++++-------- .../DashPodActivationWizardActivity.kt | 4 +- .../action/DashInitializePodViewModel.kt | 6 +- .../action/DashInsertCannulaViewModel.kt | 6 +- .../action/DashDeactivatePodViewModel.kt | 2 +- .../plugins/pump/omnipod/dash/util/I8n.kt | 2 +- .../driver/comm/endecrypt/EnDecryptTest.kt | 2 +- .../driver/comm/message/MessagePacketTest.kt | 2 +- .../dash/driver/comm/pair/KeyExchangeTest.kt | 2 +- 40 files changed, 185 insertions(+), 187 deletions(-) diff --git a/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt b/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt index 251b239355..fdb073b3c4 100644 --- a/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt +++ b/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt @@ -5,11 +5,11 @@ import androidx.room.Room import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.github.guepardoapps.kulid.ULID -import info.nightscout.shared.logging.AAPSLoggerTest import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper +import info.nightscout.shared.logging.AAPSLoggerTest import io.reactivex.schedulers.Schedulers import org.junit.After import org.junit.Before 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 d163c9d4c3..88ba8c2146 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 @@ -16,6 +16,7 @@ import info.nightscout.androidaps.extensions.convertedToAbsolute import info.nightscout.androidaps.extensions.plannedRemainingMinutes import info.nightscout.androidaps.extensions.toStringFull import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction @@ -48,7 +49,6 @@ import info.nightscout.androidaps.utils.DecimalFormatter.to2Decimal import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.TimeChangeType -import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag @@ -1324,8 +1324,8 @@ class OmnipodDashPumpPlugin @Inject constructor( private fun executeProgrammingCommand( pre: Completable = Completable.complete(), - historyEntry: Single, - activeCommandEntry: (historyId: String) -> Single = + historyEntry: Single, + activeCommandEntry: (historyId: Long) -> Single = { historyId -> podStateManager.createActiveCommand(historyId) }, command: Completable, post: Completable = Completable.complete(), diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt index af5239f615..574ea7b7d3 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/dagger/OmnipodDashHistoryModule.kt @@ -4,11 +4,11 @@ import android.content.Context import dagger.Module import dagger.Provides import dagger.Reusable -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper +import info.nightscout.shared.logging.AAPSLogger import javax.inject.Singleton @Module diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt index 8e105489e6..38b059d096 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt @@ -1,8 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver import android.os.SystemClock -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.* @@ -17,6 +15,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import io.reactivex.rxjava3.core.Observable import io.reactivex.rxjava3.functions.Action import io.reactivex.rxjava3.functions.Consumer diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt index 48010e80cd..dc5da6d1f8 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt @@ -4,8 +4,6 @@ import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothManager import android.content.Context import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.LTKExchanger @@ -15,6 +13,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEven import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import io.reactivex.rxjava3.core.Observable import java.util.concurrent.CountDownLatch import java.util.concurrent.atomic.AtomicBoolean diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt index 46d2152c65..cd35a45bdb 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt @@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGattCharacteristic -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ConnectException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType @@ -11,6 +9,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.Connection import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.Connection.Companion.STOP_CONNECTING_CHECK_INTERVAL_MS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.ConnectionWaitCondition +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import java.math.BigInteger import java.util.* diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt index d5106d35c3..83ee2346b4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt @@ -6,11 +6,11 @@ import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattDescriptor import android.bluetooth.BluetoothProfile import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.CharacteristicType.Companion.byValue import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.IncomingPackets import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.DisconnectHandler +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import java.util.* import java.util.concurrent.BlockingQueue import java.util.concurrent.CountDownLatch diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecrypt.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecrypt.kt index bedcdc3a18..0bda5dff61 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecrypt.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecrypt.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt import info.nightscout.androidaps.extensions.toHex +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket import org.spongycastle.crypto.engines.AESEngine import org.spongycastle.crypto.modes.CCMBlockCipher import org.spongycastle.crypto.params.AEADParameters diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt index a10114e1d6..0c93a2fc88 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt @@ -6,13 +6,13 @@ import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattDescriptor import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationError import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.WriteConfirmationSuccess import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommandRTS import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.* +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import java.util.concurrent.BlockingQueue import java.util.concurrent.TimeUnit diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt index af57ad7251..a5fda80425 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt @@ -2,11 +2,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGattCharacteristic -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManagerImpl import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommand import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.BleCommandHello +import info.nightscout.shared.logging.AAPSLogger import java.util.concurrent.BlockingQueue sealed class BleConfirmResult diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/DataBleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/DataBleIO.kt index 8a77528d43..6fc46dbdc1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/DataBleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/DataBleIO.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io import android.bluetooth.BluetoothGatt import android.bluetooth.BluetoothGattCharacteristic -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.callbacks.BleCommCallbacks +import info.nightscout.shared.logging.AAPSLogger import java.util.concurrent.BlockingQueue class DataBleIO( diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt index 08ff9ecd79..7df5ede178 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt @@ -1,13 +1,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.BlePacket import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadJoiner import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.packet.PayloadSplitter +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag sealed class MessageSendResult object MessageSendSuccess : MessageSendResult() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchange.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchange.kt index e9e1af8ac6..04c6765b7a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchange.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchange.kt @@ -1,12 +1,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import org.spongycastle.crypto.engines.AESEngine import org.spongycastle.crypto.macs.CMac import org.spongycastle.crypto.params.KeyParameter diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt index 4392c8c966..fa28370161 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt @@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair import info.nightscout.androidaps.extensions.hexStringToByteArray import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.PairingException @@ -13,6 +11,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag internal class LTKExchanger( private val aapsLogger: AAPSLogger, diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt index cbdde59692..1f60603742 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/PodScanner.kt @@ -4,10 +4,10 @@ import android.bluetooth.BluetoothAdapter import android.bluetooth.le.ScanFilter import android.bluetooth.le.ScanSettings import android.os.ParcelUuid -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import java.util.* class PodScanner(private val logger: AAPSLogger, private val bluetoothAdapter: BluetoothAdapter) { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt index c5cd59d92f..7513ed0b66 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/scan/ScanCollector.kt @@ -2,9 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.scan import android.bluetooth.le.ScanCallback import android.bluetooth.le.ScanResult +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException import java.util.* import java.util.concurrent.ConcurrentHashMap diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt index 97603ef9ef..b403cb7af2 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt @@ -7,8 +7,6 @@ import android.bluetooth.BluetoothProfile import android.content.Context import android.os.SystemClock import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.ServiceDiscoverer @@ -22,6 +20,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.DataB import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.IncomingPackets import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageIO import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import java.lang.IllegalArgumentException import java.util.concurrent.CountDownLatch diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessage.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessage.kt index df452bc7c6..133c6a2ddb 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessage.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/EapMessage.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session import info.nightscout.androidaps.extensions.toHex +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import java.nio.ByteBuffer enum class EapCode(val code: Byte) { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt index 4c2cc73f06..d9fa77fd32 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Milenage.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session import info.nightscout.androidaps.extensions.toHex +import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag -import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig import org.spongycastle.util.encoders.Hex import java.security.SecureRandom import javax.crypto.Cipher diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt index d15d0c11ac..5dcbabf3c7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt @@ -1,8 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt.EnDecrypt import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.CouldNotParseResponseException @@ -11,6 +9,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag sealed class CommandSendResult object CommandSendSuccess : CommandSendResult() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt index 18957d4769..620aac32db 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt @@ -1,8 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Ids import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt.Nonce import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.SessionEstablishmentException @@ -10,6 +8,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageSendSuccess import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessageType +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import java.security.SecureRandom import java.util.* diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt index 2d0a97cafa..e09fa9cf56 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt @@ -94,7 +94,7 @@ interface OmnipodDashPodStateManager { fun updateTimeZone() fun createActiveCommand( - historyId: String, + historyId: Long, basalProgram: BasalProgram? = null, tempBasal: TempBasal? = null, requestedBolus: Double? = null @@ -103,7 +103,7 @@ interface OmnipodDashPodStateManager { fun observeNoActiveCommand(): Completable fun getCommandConfirmationFromState(): CommandConfirmationFromState - fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType) + fun createLastBolus(requestedUnits: Double, historyId: Long, bolusType: DetailedBolusInfo.BolusType) fun markLastBolusComplete(): LastBolus? fun onStart() /* @@ -120,7 +120,7 @@ interface OmnipodDashPodStateManager { val sequence: Short, val createdRealtime: Long, var sentRealtime: Long = 0, - val historyId: String, + val historyId: Long, var sendError: Throwable?, var basalProgram: BasalProgram?, val tempBasal: TempBasal?, @@ -135,7 +135,7 @@ interface OmnipodDashPodStateManager { val requestedUnits: Double, var bolusUnitsRemaining: Double, var deliveryComplete: Boolean, - val historyId: String, + val historyId: Long, val bolusType: DetailedBolusInfo.BolusType ) { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index fa8c448adc..3ab29d722e 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state import android.os.SystemClock import com.google.gson.Gson import info.nightscout.androidaps.data.DetailedBolusInfo -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.pump.omnipod.dash.EventOmnipodDashPumpValuesChanged import info.nightscout.androidaps.plugins.pump.omnipod.dash.R @@ -17,6 +15,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse import info.nightscout.androidaps.utils.Round +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Maybe @@ -323,7 +323,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( get() = podState.activeCommand @Synchronized - override fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType) { + override fun createLastBolus(requestedUnits: Double, historyId: Long, bolusType: DetailedBolusInfo.BolusType) { podState.lastBolus = OmnipodDashPodStateManager.LastBolus( startTime = System.currentTimeMillis(), requestedUnits = requestedUnits, @@ -358,7 +358,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( @Synchronized override fun createActiveCommand( - historyId: String, + historyId: Long, basalProgram: BasalProgram?, tempBasal: OmnipodDashPodStateManager.TempBasal?, requestedBolus: Double? diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt index 2f25ea03c9..d8a42eff34 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt @@ -1,8 +1,5 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history -import com.github.guepardoapps.kulid.ULID -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_BOLUS import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_TEMPORARY_BASAL @@ -11,6 +8,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordEntity import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Single import java.lang.System.currentTimeMillis @@ -22,19 +21,19 @@ class DashHistory @Inject constructor( private val logger: AAPSLogger ) { - private fun markSuccess(id: String): Completable = dao.markResolved( + private fun markSuccess(id: Long): Completable = dao.markResolved( id, ResolvedResult.SUCCESS, currentTimeMillis() ) - private fun markFailure(id: String): Completable = dao.markResolved( + private fun markFailure(id: Long): Completable = dao.markResolved( id, ResolvedResult.FAILURE, currentTimeMillis() ) - fun getById(id: String): HistoryRecord { + fun getById(id: Long): HistoryRecord { val entry = dao.byIdBlocking(id) ?: throw java.lang.IllegalArgumentException("history entry [$id] not found") return historyMapper.entityToDomain(entry) @@ -50,9 +49,11 @@ class DashHistory @Inject constructor( basalProfileRecord: BasalValuesRecord? = null, resolveResult: ResolvedResult? = null, resolvedAt: Long? = null - ): Single = Single.defer { - val id = ULID.random() - + ): Single = Single.defer { + var id: Long = 0 + if (dao.first() != null) { + id = currentTimeMillis() + } when { commandType == SET_BOLUS && bolusRecord == null -> Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS")) @@ -72,7 +73,7 @@ class DashHistory @Inject constructor( resolvedResult = resolveResult, resolvedAt = resolvedAt ) - ).toSingle { id } + ) } } @@ -82,7 +83,7 @@ class DashHistory @Inject constructor( fun getRecordsAfter(time: Long): Single> = dao.allSince(time).map { list -> list.map(historyMapper::entityToDomain) } - fun updateFromState(podState: OmnipodDashPodStateManager) = Completable.defer { + fun updateFromState(podState: OmnipodDashPodStateManager): Completable = Completable.defer { val historyId = podState.activeCommand?.historyId if (historyId == null) { logger.error(LTag.PUMP, "HistoryId not found to for updating from state") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/HistoryRecord.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/HistoryRecord.kt index baef277087..40cb5a7d24 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/HistoryRecord.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/data/HistoryRecord.kt @@ -1,11 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data -import com.github.guepardoapps.kulid.ULID import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType -import java.nio.ByteBuffer data class HistoryRecord( - val id: String, // ULID + val id: Long, val createdAt: Long, // creation date of the record val date: Long, // when event actually happened val commandType: OmnipodCommandType, @@ -15,8 +13,7 @@ data class HistoryRecord( val resolvedAt: Long? ) { fun pumpId(): Long { - val entropy = ULID.getEntropy(id) - return ByteBuffer.wrap(entropy).long + return id } fun displayTimestamp(): Long { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt index 993d49d564..5482e8a669 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/DashHistoryDatabase.kt @@ -18,7 +18,7 @@ abstract class DashHistoryDatabase : RoomDatabase() { companion object { - const val VERSION = 2 + const val VERSION = 3 fun build(context: Context) = Room.databaseBuilder( 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 2d079acbd2..da2525e8f4 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,28 +15,25 @@ abstract class HistoryRecordDao { @Query("SELECT * from historyrecords") abstract fun all(): Single> - - @Query("SELECT * from historyrecords") - abstract fun allBlocking(): List + + @Query("SELECT * from historyrecords ORDER BY id LIMIT 1") + abstract fun first(): HistoryRecordEntity? @Query("SELECT * from historyrecords WHERE createdAt >= :since ORDER BY createdAt DESC") abstract fun allSince(since: Long): Single> @Query("SELECT * FROM historyrecords WHERE id = :id LIMIT 1") - abstract fun byIdBlocking(id: String): HistoryRecordEntity? + abstract fun byIdBlocking(id: Long): HistoryRecordEntity? @Insert(onConflict = OnConflictStrategy.REPLACE) - abstract fun saveBlocking(historyRecordEntity: HistoryRecordEntity) - - @Insert(onConflict = OnConflictStrategy.REPLACE) - abstract fun save(historyRecordEntity: HistoryRecordEntity): Completable + abstract fun save(historyRecordEntity: HistoryRecordEntity): Single @Delete abstract fun delete(historyRecordEntity: HistoryRecordEntity): Completable @Query("UPDATE historyrecords SET resolvedResult = :resolvedResult, resolvedAt = :resolvedAt WHERE id = :id ") - abstract fun markResolved(id: String, resolvedResult: ResolvedResult, resolvedAt: Long): Completable + abstract fun markResolved(id: Long, resolvedResult: ResolvedResult, resolvedAt: Long): Completable @Query("UPDATE historyrecords SET initialResult = :initialResult WHERE id = :id ") - abstract fun setInitialResult(id: String, initialResult: InitialResult): Completable + abstract fun setInitialResult(id: Long, initialResult: InitialResult): Completable } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt index c135e24cd5..1993f525cb 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/database/HistoryRecordEntity.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database import androidx.room.Embedded import androidx.room.Entity +import androidx.room.Index import androidx.room.PrimaryKey import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BasalValuesRecord @@ -10,9 +11,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.Initial import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.ResolvedResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.TempBasalRecord -@Entity(tableName = "historyrecords") +@Entity( + tableName = "historyrecords", + indices = [ + Index("createdAt"), + ] +) data class HistoryRecordEntity( - @PrimaryKey val id: String, // ULID + @PrimaryKey(autoGenerate = true) + val id: Long = 0, val createdAt: Long, // creation date of the record val date: Long, // when event actually happened val commandType: OmnipodCommandType, diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt index 765c538ee6..26827110b2 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/mapper/HistoryMapper.kt @@ -1,27 +1,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper -import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BasalValuesRecord -import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.BolusRecord import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.HistoryRecord -import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.TempBasalRecord import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordEntity class HistoryMapper { - fun domainToEntity(historyRecord: HistoryRecord): HistoryRecordEntity = - HistoryRecordEntity( - id = historyRecord.id, - createdAt = historyRecord.createdAt, - date = historyRecord.date, - commandType = historyRecord.commandType, - initialResult = historyRecord.initialResult, - tempBasalRecord = historyRecord.record as? TempBasalRecord, - bolusRecord = historyRecord.record as? BolusRecord, - resolvedResult = historyRecord.resolvedResult, - resolvedAt = historyRecord.resolvedAt, - basalProfileRecord = historyRecord.record as? BasalValuesRecord - ) - fun entityToDomain(entity: HistoryRecordEntity): HistoryRecord = HistoryRecord( id = entity.id, diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index a5e64791f5..fcfd47b5dd 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -53,44 +53,44 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup { return when (type) { - OmnipodCommandType.INITIALIZE_POD -> + OmnipodCommandType.INITIALIZE_POD -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.INSERT_CANNULA -> + OmnipodCommandType.INSERT_CANNULA -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.DEACTIVATE_POD -> + OmnipodCommandType.DEACTIVATE_POD -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.DISCARD_POD -> + OmnipodCommandType.DISCARD_POD -> PumpHistoryEntryGroup.Prime OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_BASAL_PROFILE -> + OmnipodCommandType.SET_BASAL_PROFILE -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_TEMPORARY_BASAL -> + OmnipodCommandType.SET_TEMPORARY_BASAL -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.RESUME_DELIVERY -> + OmnipodCommandType.RESUME_DELIVERY -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SUSPEND_DELIVERY -> + OmnipodCommandType.SUSPEND_DELIVERY -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_BOLUS -> + OmnipodCommandType.SET_BOLUS -> PumpHistoryEntryGroup.Bolus - OmnipodCommandType.CANCEL_BOLUS -> + OmnipodCommandType.CANCEL_BOLUS -> PumpHistoryEntryGroup.Bolus - OmnipodCommandType.ACKNOWLEDGE_ALERTS -> + OmnipodCommandType.ACKNOWLEDGE_ALERTS -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.CONFIGURE_ALERTS -> + OmnipodCommandType.CONFIGURE_ALERTS -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.PLAY_TEST_BEEP -> + OmnipodCommandType.PLAY_TEST_BEEP -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.GET_POD_STATUS -> + OmnipodCommandType.GET_POD_STATUS -> PumpHistoryEntryGroup.Configuration - OmnipodCommandType.SET_TIME -> + OmnipodCommandType.SET_TIME -> PumpHistoryEntryGroup.Configuration - OmnipodCommandType.READ_POD_PULSE_LOG -> + OmnipodCommandType.READ_POD_PULSE_LOG -> PumpHistoryEntryGroup.Unknown } } @@ -209,7 +209,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun setTextViewColor(check_result: Boolean, textview: TextView, record: HistoryRecord) { if (check_result && !record.isSuccess()) { // Record says not success - textview.setTextColor(rh.gac( textview.context, R.attr.omniYellowColor)) + textview.setTextColor(rh.gac(textview.context, R.attr.omniYellowColor)) return } // On success set color @@ -222,13 +222,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.DISCARD_POD, OmnipodCommandType.SUSPEND_DELIVERY, OmnipodCommandType.RESUME_DELIVERY, - OmnipodCommandType.SET_BASAL_PROFILE -> { + OmnipodCommandType.SET_BASAL_PROFILE -> { R.attr.omniCyanColor } // User action OmnipodCommandType.PLAY_TEST_BEEP, OmnipodCommandType.ACKNOWLEDGE_ALERTS, - OmnipodCommandType.CANCEL_BOLUS -> { + OmnipodCommandType.CANCEL_BOLUS -> { R.attr.omniCyanColor } // Insulin treatment @@ -237,11 +237,11 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { R.attr.defaultTextColor } - else -> + else -> // Other - R.attr.omniGrayColor + R.attr.omniGrayColor } - textview.setTextColor(rh.gac( textview.context, textColorAttr)) + textview.setTextColor(rh.gac(textview.context, textColorAttr)) } private fun setType(record: HistoryRecord, typeView: TextView) { @@ -265,7 +265,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - OmnipodCommandType.SET_BOLUS -> { + OmnipodCommandType.SET_BOLUS -> { val bolus = historyEntry.record as BolusRecord bolus.let { rh.gs(R.string.omnipod_common_history_bolus_value, it.amout) @@ -275,12 +275,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.SET_BASAL_PROFILE, OmnipodCommandType.SET_TIME, OmnipodCommandType.INSERT_CANNULA, - OmnipodCommandType.RESUME_DELIVERY -> { + OmnipodCommandType.RESUME_DELIVERY -> { val basal = historyEntry.record as BasalValuesRecord ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH) } - else -> + else -> "" } // Set some color @@ -303,12 +303,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { return when { historyEntry.initialResult == InitialResult.FAILURE_SENDING -> R.string.omnipod_dash_failed_to_send - historyEntry.initialResult == InitialResult.NOT_SENT -> + historyEntry.initialResult == InitialResult.NOT_SENT -> R.string.omnipod_dash_command_not_sent historyEntry.initialResult == InitialResult.SENT && - historyEntry.resolvedResult == ResolvedResult.FAILURE -> + historyEntry.resolvedResult == ResolvedResult.FAILURE -> R.string.omnipod_dash_command_not_received_by_the_pod - else -> + else -> R.string.omnipod_dash_unknown } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt index 791f655273..cb253cae21 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt @@ -8,7 +8,6 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.NoSplashAppCompatActivity import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.interfaces.CommandQueue -import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.PodActivationWizardActivity import info.nightscout.androidaps.plugins.pump.omnipod.dash.R diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index 98fc46781c..3b8f32c426 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -1,7 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui import android.content.Intent -import android.graphics.Color import android.os.Bundle import android.os.Handler import android.os.HandlerThread @@ -16,6 +15,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.PumpSync +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification @@ -41,10 +41,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.protection.ProtectionCheck -import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers -import info.nightscout.shared.sharedPreferences.SP import info.nightscout.androidaps.utils.ui.UIRunnable +import info.nightscout.shared.sharedPreferences.SP import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import org.apache.commons.lang3.StringUtils @@ -117,7 +116,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() { protectionCheck.queryProtection( activity, ProtectionCheck.Protection.PREFERENCES, - UIRunnable { startActivity(Intent(context, DashPodManagementActivity::class.java)) }) + UIRunnable { startActivity(Intent(context, DashPodManagementActivity::class.java)) } + ) } } @@ -267,14 +267,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() { val quality = "${podStateManager.successfulConnectionAttemptsAfterRetries}/$connectionAttempts :: $successPercentageString" bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.text = quality - val connectionStatsColor = rh.gac( context, when { - connectionSuccessPercentage < 70 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 -> - R.attr.warningColor - connectionSuccessPercentage < 90 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 -> - R.attr.omniYellowColor - else -> - R.attr.defaultTextColor - }) + val connectionStatsColor = rh.gac( + context, + when { + connectionSuccessPercentage < 70 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 -> + R.attr.warningColor + connectionSuccessPercentage < 90 && podStateManager.successfulConnectionAttemptsAfterRetries > 50 -> + R.attr.omniYellowColor + else -> + R.attr.defaultTextColor + } + ) bluetoothStatusBinding.omnipodDashBluetoothConnectionQuality.setTextColor(connectionStatsColor) bluetoothStatusBinding.omnipodDashDeliveryStatus.text = podStateManager.deliveryStatus?.let { podStateManager.deliveryStatus.toString() @@ -296,11 +299,11 @@ class OmnipodDashOverviewFragment : DaggerFragment() { podInfoBinding.firmwareVersion.text = PLACEHOLDER podInfoBinding.timeOnPod.text = PLACEHOLDER podInfoBinding.podExpiryDate.text = PLACEHOLDER - podInfoBinding.podExpiryDate.setTextColor(rh.gac(context,R.attr.defaultTextColor)) + podInfoBinding.podExpiryDate.setTextColor(rh.gac(context, R.attr.defaultTextColor)) podInfoBinding.baseBasalRate.text = PLACEHOLDER podInfoBinding.totalDelivered.text = PLACEHOLDER podInfoBinding.reservoir.text = PLACEHOLDER - podInfoBinding.reservoir.setTextColor(rh.gac(context,R.attr.defaultTextColor)) + podInfoBinding.reservoir.setTextColor(rh.gac(context, R.attr.defaultTextColor)) podInfoBinding.podActiveAlerts.text = PLACEHOLDER } else { podInfoBinding.uniqueId.text = podStateManager.uniqueId.toString() @@ -335,15 +338,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() { ).isNegative } ?: false podInfoBinding.timeOnPod.setTextColor( - rh.gac( context, - when { - !podStateManager.sameTimeZone -> - R.attr.omniMagentaColor - timeDeviationTooBig -> - R.attr.omniYellowColor - else -> - R.attr.defaultTextColor - }) + rh.gac( + context, + when { + !podStateManager.sameTimeZone -> + R.attr.omniMagentaColor + timeDeviationTooBig -> + R.attr.omniYellowColor + else -> + R.attr.defaultTextColor + } + ) ) // Update Pod expiry time @@ -353,15 +358,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } ?: PLACEHOLDER podInfoBinding.podExpiryDate.setTextColor( - rh.gac( context, - when { - expiresAt != null && ZonedDateTime.now().isAfter(expiresAt) -> - R.attr.warningColor - expiresAt != null && ZonedDateTime.now().isAfter(expiresAt.minusHours(4)) -> - R.attr.omniYellowColor - else -> - R.attr.defaultTextColor - }) + rh.gac( + context, + when { + expiresAt != null && ZonedDateTime.now().isAfter(expiresAt) -> + R.attr.warningColor + expiresAt != null && ZonedDateTime.now().isAfter(expiresAt.minusHours(4)) -> + R.attr.omniYellowColor + else -> + R.attr.defaultTextColor + } + ) ) podStateManager.alarmType?.let { @@ -401,7 +408,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { if (podStateManager.pulsesRemaining == null) { podInfoBinding.reservoir.text = rh.gs(R.string.omnipod_common_overview_reservoir_value_over50) - podInfoBinding.reservoir.setTextColor(rh.gac(context,R.attr.defaultTextColor)) + podInfoBinding.reservoir.setTextColor(rh.gac(context, R.attr.defaultTextColor)) } else { // TODO // val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits @@ -413,12 +420,14 @@ class OmnipodDashOverviewFragment : DaggerFragment() { (podStateManager.pulsesRemaining!! * PodConstants.POD_PULSE_BOLUS_UNITS) ) podInfoBinding.reservoir.setTextColor( - rh.gac(context, - if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) { - R.attr.warningColor - } else { - R.attr.defaultTextColor - }) + rh.gac( + context, + if (podStateManager.pulsesRemaining!! < lowReservoirThreshold) { + R.attr.warningColor + } else { + R.attr.defaultTextColor + } + ) ) } @@ -429,10 +438,10 @@ class OmnipodDashOverviewFragment : DaggerFragment() { if (errors.size == 0) { podInfoBinding.errors.text = PLACEHOLDER - podInfoBinding.errors.setTextColor(rh.gac(context,R.attr.defaultTextColor)) + podInfoBinding.errors.setTextColor(rh.gac(context, R.attr.defaultTextColor)) } else { podInfoBinding.errors.text = StringUtils.join(errors, System.lineSeparator()) - podInfoBinding.errors.setTextColor(rh.gac(context,R.attr.warningColor)) + podInfoBinding.errors.setTextColor(rh.gac(context, R.attr.warningColor)) } } @@ -468,15 +477,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() { ) ) val lastConnectionColor = - rh.gac(context, - if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().toMillis())) { - R.attr.warningColor - } else { - R.attr.defaultTextColor - }) + rh.gac( + context, + if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().toMillis())) { + R.attr.warningColor + } else { + R.attr.defaultTextColor + } + ) podInfoBinding.lastConnection.setTextColor(lastConnectionColor) } else { - podInfoBinding.lastConnection.setTextColor(rh.gac(context,R.attr.defaultTextColor )) + podInfoBinding.lastConnection.setTextColor(rh.gac(context, R.attr.defaultTextColor)) podInfoBinding.lastConnection.text = PLACEHOLDER } } @@ -512,14 +523,17 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } } - val podStatusColor = rh.gac( context, when { - !podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended -> - R.attr.warningColor - podStateManager.activeCommand != null -> - R.attr.omniYellowColor - else -> - R.attr.defaultTextColor - }) + val podStatusColor = rh.gac( + context, + when { + !podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended -> + R.attr.warningColor + podStateManager.activeCommand != null -> + R.attr.omniYellowColor + else -> + R.attr.defaultTextColor + } + ) podInfoBinding.podStatus.setTextColor(podStatusColor) } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt index 6d4028c7f4..e7b5b99756 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/DashPodActivationWizardActivity.kt @@ -13,5 +13,5 @@ class DashPodActivationWizardActivity : PodActivationWizardActivity() { super.onCreate(savedInstanceState) blePreCheck.prerequisitesCheck(this) - } -} \ No newline at end of file + } +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt index 7b022089ab..18dca74640 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activatio import androidx.annotation.StringRes import dagger.android.HasAndroidInjector import info.nightscout.androidaps.data.PumpEnactResult -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activation.viewmodel.action.InitializePodViewModel import info.nightscout.androidaps.plugins.pump.omnipod.dash.R @@ -15,8 +14,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.InitialResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.ResolvedResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n -import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.kotlin.plusAssign diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt index 30704e755b..a3c478725f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt @@ -6,8 +6,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.PumpSync -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification @@ -25,8 +24,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.Constants import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.kotlin.plusAssign diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt index e7f4e7193c..edda5f7429 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/deactivation/viewmodel/action/DashDeactivatePodViewModel.kt @@ -4,7 +4,6 @@ import androidx.annotation.StringRes import dagger.android.HasAndroidInjector import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.CommandQueue -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification @@ -14,6 +13,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.deactiva import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.AAPSLogger import io.reactivex.rxjava3.core.Single import javax.inject.Inject diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/I8n.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/I8n.kt index 534a6ee45c..7f57283f56 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/I8n.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/I8n.kt @@ -1,11 +1,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.util +import info.nightscout.androidaps.interfaces.ResourceHelper import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.FailedToConnectException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.NotConnectedException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException -import info.nightscout.androidaps.interfaces.ResourceHelper class I8n { companion object { diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt index b96bc6c036..c37c76a903 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLoggerTest import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket +import info.nightscout.shared.logging.AAPSLoggerTest import org.junit.Assert import org.junit.Test import org.spongycastle.util.encoders.Hex diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt index 4a046506c4..d51e841cd8 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacketTest.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import com.google.crypto.tink.subtle.Hex import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLoggerTest import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id +import info.nightscout.shared.logging.AAPSLoggerTest import org.junit.Assert.assertEquals import org.junit.Test diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt index 4862327108..ab671d94e2 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/KeyExchangeTest.kt @@ -1,9 +1,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair import info.nightscout.androidaps.extensions.toHex -import info.nightscout.shared.logging.AAPSLoggerTest import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator +import info.nightscout.shared.logging.AAPSLoggerTest import org.junit.Assert.assertEquals import org.junit.Test import org.mockito.ArgumentMatchers.anyInt From 2c94ff01c51efd56dd879e37f1fceee2fd406ad3 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Mon, 9 May 2022 23:34:08 +0200 Subject: [PATCH 2/3] 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? From 31ccb9a7d40cf5b9de248374302e8274e5005c0d Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Tue, 10 May 2022 18:48:12 +0200 Subject: [PATCH 3/3] fix --- .../androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt index d8a42eff34..2a69c98501 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistory.kt @@ -51,7 +51,7 @@ class DashHistory @Inject constructor( resolvedAt: Long? = null ): Single = Single.defer { var id: Long = 0 - if (dao.first() != null) { + if (dao.first() == null) { id = currentTimeMillis() } when {