This commit is contained in:
AdrianLxM 2021-03-14 19:52:08 +01:00
parent bf3fe19a4e
commit 7db5c28632
7 changed files with 27 additions and 26 deletions

View file

@ -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<PodEvent>
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"))

View file

@ -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)

View file

@ -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()

View file

@ -17,7 +17,7 @@ class DashDeactivatePodViewModel @Inject constructor(
) : DeactivatePodViewModel(injector, logger) {
override fun doExecuteAction(): Single<PumpEnactResult> = Single.just(
PumpEnactResult(injector).success(true).comment("TODO")
PumpEnactResult(injector).success(true).comment("TODO")
) // TODO
override fun discardPod() {

View file

@ -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,