From 3d93e4d84d339a0bcb8f4d85724391c5a72baf04 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 14 Mar 2021 18:24:15 +0100 Subject: [PATCH 1/3] mock provider instead of constructor parameter --- .../dash/driver/comm/pair/KeyExchange.kt | 29 +++++++++---------- .../dash/driver/comm/pair/LTKExchanger.kt | 4 ++- .../driver/pod/util/RandomByteGenerator.kt | 9 ++++++ .../driver/pod/util/X25519KeyGenerator.kt | 11 +++++++ .../dash/driver/comm/pair/KeyExchangeTest.kt | 28 +++++++++++++++--- 5 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt create mode 100644 omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt 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 90130a29f0..682098e295 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,39 +1,36 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair -import com.google.crypto.tink.subtle.X25519 import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.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.androidaps.utils.extensions.toHex import org.spongycastle.crypto.engines.AESEngine import org.spongycastle.crypto.macs.CMac import org.spongycastle.crypto.params.KeyParameter -import java.security.SecureRandom +import org.spongycastle.util.encoders.Hex class KeyExchange( private val aapsLogger: AAPSLogger, - var pdmPrivate: ByteArray = X25519.generatePrivateKey(), - val pdmNonce: ByteArray = ByteArray(NONCE_SIZE) -) { - val pdmPublic = X25519.publicFromPrivate(pdmPrivate) + private val x25519: X25519KeyGenerator, + private val randomByteGenerator: RandomByteGenerator +){ + + val pdmNonce: ByteArray = randomByteGenerator.nextBytes(NONCE_SIZE) + val pdmPrivate: ByteArray = x25519.generatePrivateKey() + val pdmPublic = x25519.publicFromPrivate(pdmPrivate) var podPublic = ByteArray(PUBLIC_KEY_SIZE) - var podNonce = ByteArray(NONCE_SIZE) + private set + var podNonce : ByteArray = ByteArray(NONCE_SIZE) val podConf = ByteArray(CMAC_SIZE) val pdmConf = ByteArray(CMAC_SIZE) var ltk = ByteArray(CMAC_SIZE) - init { - if (pdmNonce.all { it == 0.toByte() }) { - // pdmNonce is in the constructor for tests - val random = SecureRandom() - random.nextBytes(pdmNonce) - } - } - fun updatePodPublicData(payload: ByteArray) { if (payload.size != PUBLIC_KEY_SIZE + NONCE_SIZE) { throw MessageIOException("Invalid payload size") @@ -54,7 +51,7 @@ class KeyExchange( } private fun generateKeys() { - val curveLTK = X25519.computeSharedSecret(pdmPrivate, podPublic) + val curveLTK = x25519.computeSharedSecret(pdmPrivate, podPublic) val firstKey = podPublic.copyOfRange(podPublic.size - 4, podPublic.size) + pdmPublic.copyOfRange(pdmPublic.size - 4, pdmPublic.size) + 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 a7f8349aec..f30f7e5c6a 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 @@ -8,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.StringLengthPrefixEncoding 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.androidaps.utils.extensions.hexStringToByteArray import info.nightscout.androidaps.utils.extensions.toHex @@ -19,7 +21,7 @@ internal class LTKExchanger( val podAddress: Id ) { - private val keyExchange = KeyExchange(aapsLogger) + private val keyExchange = KeyExchange(aapsLogger, X25519KeyGenerator(), RandomByteGenerator()) private var seq: Byte = 1 fun negotiateLTK(): PairResult { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt new file mode 100644 index 0000000000..f20fdcca21 --- /dev/null +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt @@ -0,0 +1,9 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util + +import java.security.SecureRandom + +open class RandomByteGenerator { + private val secureRandom = SecureRandom() + + open fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes) +} \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt new file mode 100644 index 0000000000..dbd15ba799 --- /dev/null +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt @@ -0,0 +1,11 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util + +import com.google.crypto.tink.subtle.X25519 + +open class X25519KeyGenerator { + + open fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey() + fun publicFromPrivate(privateKey: ByteArray): ByteArray = X25519.publicFromPrivate(privateKey) + fun computeSharedSecret(privateKey: ByteArray, publicKey: ByteArray): ByteArray = + X25519.computeSharedSecret(privateKey, publicKey) +} \ No newline at end of file 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 51d4bca126..0dc0135541 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,18 +1,38 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair import info.nightscout.androidaps.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.androidaps.utils.extensions.toHex -import org.junit.Assert.* +import org.junit.Assert.assertEquals import org.junit.Test +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito +import org.mockito.Mockito.mock +import org.mockito.Mockito.spy import org.spongycastle.util.encoders.Hex class KeyExchangeTest { + + val keyGenerator = X25519KeyGenerator() + val keyGeneratorSpy = spy(keyGenerator) + + var randomByteGenerator: RandomByteGenerator = mock(RandomByteGenerator::class.java) + @Test fun testLTK() { val aapsLogger = AAPSLoggerTest() + + Mockito.doReturn(Hex.decode("27ec94b71a201c5e92698d668806ae5ba00594c307cf5566e60c1fc53a6f6bb6")) + .`when`(keyGeneratorSpy).generatePrivateKey() + + val pdmNonce = Hex.decode("edfdacb242c7f4e1d2bc4d93ca3c5706") + + Mockito.`when`(randomByteGenerator.nextBytes(anyInt())).thenReturn(pdmNonce) + val ke = KeyExchange( aapsLogger, - pdmPrivate = Hex.decode("27ec94b71a201c5e92698d668806ae5ba00594c307cf5566e60c1fc53a6f6bb6"), - pdmNonce = Hex.decode("edfdacb242c7f4e1d2bc4d93ca3c5706") + keyGeneratorSpy, + randomByteGenerator ) val podPublicKey = Hex.decode("2fe57da347cd62431528daac5fbb290730fff684afc4cfc2ed90995f58cb3b74") val podNonce = Hex.decode("00000000000000000000000000000000") @@ -22,4 +42,4 @@ class KeyExchangeTest { ke.validatePodConf(Hex.decode("af4f10db5f96e5d9cd6cfc1f54f4a92f")) assertEquals(ke.ltk.toHex(), "341e16d13f1cbf73b19d1c2964fee02b") } -} +} \ No newline at end of file From bf3fe19a4ed2203fb90c7e81fd6288955d42f663 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 14 Mar 2021 19:42:02 +0100 Subject: [PATCH 2/3] only open for tests/debug --- build.gradle | 1 + omnipod-dash/build.gradle | 5 +++++ .../omnipod/dash/driver/pod/util/RandomByteGenerator.kt | 6 ++++-- .../pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt | 6 ++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 3b9caa5038..913ee7cc76 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,7 @@ buildscript { // in the individual module build.gradle files classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" classpath 'com.hiya:jacoco-android:0.2' } } diff --git a/omnipod-dash/build.gradle b/omnipod-dash/build.gradle index 9d48cfa1c1..e48b09f3c7 100644 --- a/omnipod-dash/build.gradle +++ b/omnipod-dash/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' +apply plugin: 'kotlin-allopen' apply plugin: 'com.hiya.jacoco-android' apply plugin: "io.gitlab.arturbosch.detekt" // TODO move to `subprojects` section in global build.gradle apply plugin: "org.jlleitschuh.gradle.ktlint" // TODO move to `subprojects` section in global build.gradle @@ -16,6 +17,10 @@ android { } } +allOpen { + annotation 'info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenClass' +} + detekt { // TODO move to `subprojects` section in global build.gradle toolVersion = "1.15.0-RC2" config = files("./detekt-config.yml") // TODO move to global space and use "../detekt-config.yml" diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt index f20fdcca21..4bfb6c1fd4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util +import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting import java.security.SecureRandom -open class RandomByteGenerator { +@OpenForTesting +class RandomByteGenerator { private val secureRandom = SecureRandom() - open fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes) + fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes) } \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt index dbd15ba799..dac3553ab8 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util import com.google.crypto.tink.subtle.X25519 +import info.nightscout.androidaps.plugins.pump.omnipod.dash.annotations.OpenForTesting -open class X25519KeyGenerator { +@OpenForTesting +class X25519KeyGenerator { - open fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey() + fun generatePrivateKey(): ByteArray = X25519.generatePrivateKey() fun publicFromPrivate(privateKey: ByteArray): ByteArray = X25519.publicFromPrivate(privateKey) fun computeSharedSecret(privateKey: ByteArray, publicKey: ByteArray): ByteArray = X25519.computeSharedSecret(privateKey, publicKey) From 7db5c28632cc730c1d48a2edc4e6d60a942c1c7c Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 14 Mar 2021 19:52:08 +0100 Subject: [PATCH 3/3] delint --- .../dash/driver/OmnipodDashManagerImpl.kt | 7 ++--- .../dash/driver/comm/pair/KeyExchange.kt | 7 ++--- .../driver/pod/util/RandomByteGenerator.kt | 2 +- .../driver/pod/util/X25519KeyGenerator.kt | 2 +- .../dash/ui/OmnipodDashOverviewFragment.kt | 29 ++++++++++--------- .../action/DashDeactivatePodViewModel.kt | 2 +- .../dash/driver/comm/pair/KeyExchangeTest.kt | 4 +-- 7 files changed, 27 insertions(+), 26 deletions(-) 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 08b79f9d79..629fff1723 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 @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio 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.rx.AapsSchedulers -import info.nightscout.androidaps.utils.rx.retryWithBackoff import io.reactivex.Observable import io.reactivex.functions.Action import io.reactivex.functions.Consumer @@ -38,9 +37,9 @@ class OmnipodDashManagerImpl @Inject constructor( private val observePodReadyForActivationPart2: Observable get() = Observable.defer { - if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) && podStateManager.activationProgress.isBefore( - ActivationProgress.COMPLETED - )) { + if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) && + podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED) + ) { Observable.empty() } else { Observable.error(IllegalStateException("Pod is in an incorrect state")) 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 682098e295..0328be4a5d 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 @@ -10,13 +10,12 @@ import info.nightscout.androidaps.utils.extensions.toHex import org.spongycastle.crypto.engines.AESEngine import org.spongycastle.crypto.macs.CMac import org.spongycastle.crypto.params.KeyParameter -import org.spongycastle.util.encoders.Hex class KeyExchange( private val aapsLogger: AAPSLogger, private val x25519: X25519KeyGenerator, - private val randomByteGenerator: RandomByteGenerator -){ + randomByteGenerator: RandomByteGenerator +) { val pdmNonce: ByteArray = randomByteGenerator.nextBytes(NONCE_SIZE) val pdmPrivate: ByteArray = x25519.generatePrivateKey() @@ -24,7 +23,7 @@ class KeyExchange( var podPublic = ByteArray(PUBLIC_KEY_SIZE) private set - var podNonce : ByteArray = ByteArray(NONCE_SIZE) + var podNonce: ByteArray = ByteArray(NONCE_SIZE) val podConf = ByteArray(CMAC_SIZE) val pdmConf = ByteArray(CMAC_SIZE) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt index 4bfb6c1fd4..ca6beb17dd 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/RandomByteGenerator.kt @@ -8,4 +8,4 @@ class RandomByteGenerator { private val secureRandom = SecureRandom() fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes) -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt index dac3553ab8..160f620df6 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/util/X25519KeyGenerator.kt @@ -10,4 +10,4 @@ class X25519KeyGenerator { fun publicFromPrivate(privateKey: ByteArray): ByteArray = X25519.publicFromPrivate(privateKey) fun computeSharedSecret(privateKey: ByteArray, publicKey: ByteArray): ByteArray = X25519.computeSharedSecret(privateKey, publicKey) -} \ No newline at end of file +} 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 749f0d0de5..3edf8f364a 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 @@ -464,16 +464,15 @@ class OmnipodDashOverviewFragment : DaggerFragment() { private fun updateRefreshStatusButton() { buttonBinding.buttonRefreshStatus.isEnabled = - podStateManager.isUniqueIdSet && podStateManager.activationProgress.isAtLeast( - ActivationProgress.PHASE_1_COMPLETED - ) && - isQueueEmpty() + podStateManager.isUniqueIdSet && + podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) && + isQueueEmpty() } private fun updateResumeDeliveryButton() { - if (podStateManager.isPodRunning && (podStateManager.isSuspended || commandQueue.isCustomCommandInQueue( - CommandResumeDelivery::class.java - ))) { + if (podStateManager.isPodRunning && + (podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandResumeDelivery::class.java)) + ) { buttonBinding.buttonResumeDelivery.visibility = View.VISIBLE buttonBinding.buttonResumeDelivery.isEnabled = isQueueEmpty() } else { @@ -482,9 +481,12 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } private fun updateSilenceAlertsButton() { - if (isAutomaticallySilenceAlertsEnabled() && podStateManager.isPodRunning && (podStateManager.activeAlerts!!.size > 0 || commandQueue.isCustomCommandInQueue( - CommandAcknowledgeAlerts::class.java - ))) { + if (isAutomaticallySilenceAlertsEnabled() && podStateManager.isPodRunning && + ( + podStateManager.activeAlerts!!.size > 0 || + commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java) + ) + ) { buttonBinding.buttonSilenceAlerts.visibility = View.VISIBLE buttonBinding.buttonSilenceAlerts.isEnabled = isQueueEmpty() } else { @@ -494,9 +496,10 @@ class OmnipodDashOverviewFragment : DaggerFragment() { private fun updateSuspendDeliveryButton() { // If the Pod is currently suspended, we show the Resume delivery button instead. - if (isSuspendDeliveryButtonEnabled() && podStateManager.isPodRunning && (!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue( - CommandSuspendDelivery::class.java - ))) { + if (isSuspendDeliveryButtonEnabled() && + podStateManager.isPodRunning && + (!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java)) + ) { buttonBinding.buttonSuspendDelivery.visibility = View.VISIBLE buttonBinding.buttonSuspendDelivery.isEnabled = podStateManager.isPodRunning && !podStateManager.isSuspended && isQueueEmpty() 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 8a6ec92571..96bfb90e57 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 @@ -17,7 +17,7 @@ class DashDeactivatePodViewModel @Inject constructor( ) : DeactivatePodViewModel(injector, logger) { override fun doExecuteAction(): Single = Single.just( - PumpEnactResult(injector).success(true).comment("TODO") + PumpEnactResult(injector).success(true).comment("TODO") ) // TODO override fun discardPod() { 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 0dc0135541..50e04f6e2a 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 @@ -27,7 +27,7 @@ class KeyExchangeTest { val pdmNonce = Hex.decode("edfdacb242c7f4e1d2bc4d93ca3c5706") - Mockito.`when`(randomByteGenerator.nextBytes(anyInt())).thenReturn(pdmNonce) + Mockito.`when`(randomByteGenerator.nextBytes(anyInt())).thenReturn(pdmNonce) val ke = KeyExchange( aapsLogger, @@ -42,4 +42,4 @@ class KeyExchangeTest { ke.validatePodConf(Hex.decode("af4f10db5f96e5d9cd6cfc1f54f4a92f")) assertEquals(ke.ltk.toHex(), "341e16d13f1cbf73b19d1c2964fee02b") } -} \ No newline at end of file +}