delint
This commit is contained in:
parent
bf3fe19a4e
commit
7db5c28632
7 changed files with 27 additions and 26 deletions
|
@ -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.response.*
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
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.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.rx.retryWithBackoff
|
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.functions.Action
|
import io.reactivex.functions.Action
|
||||||
import io.reactivex.functions.Consumer
|
import io.reactivex.functions.Consumer
|
||||||
|
@ -38,9 +37,9 @@ class OmnipodDashManagerImpl @Inject constructor(
|
||||||
|
|
||||||
private val observePodReadyForActivationPart2: Observable<PodEvent>
|
private val observePodReadyForActivationPart2: Observable<PodEvent>
|
||||||
get() = Observable.defer {
|
get() = Observable.defer {
|
||||||
if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) && podStateManager.activationProgress.isBefore(
|
if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) &&
|
||||||
ActivationProgress.COMPLETED
|
podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED)
|
||||||
)) {
|
) {
|
||||||
Observable.empty()
|
Observable.empty()
|
||||||
} else {
|
} else {
|
||||||
Observable.error(IllegalStateException("Pod is in an incorrect state"))
|
Observable.error(IllegalStateException("Pod is in an incorrect state"))
|
||||||
|
|
|
@ -10,13 +10,12 @@ import info.nightscout.androidaps.utils.extensions.toHex
|
||||||
import org.spongycastle.crypto.engines.AESEngine
|
import org.spongycastle.crypto.engines.AESEngine
|
||||||
import org.spongycastle.crypto.macs.CMac
|
import org.spongycastle.crypto.macs.CMac
|
||||||
import org.spongycastle.crypto.params.KeyParameter
|
import org.spongycastle.crypto.params.KeyParameter
|
||||||
import org.spongycastle.util.encoders.Hex
|
|
||||||
|
|
||||||
class KeyExchange(
|
class KeyExchange(
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
private val x25519: X25519KeyGenerator,
|
private val x25519: X25519KeyGenerator,
|
||||||
private val randomByteGenerator: RandomByteGenerator
|
randomByteGenerator: RandomByteGenerator
|
||||||
){
|
) {
|
||||||
|
|
||||||
val pdmNonce: ByteArray = randomByteGenerator.nextBytes(NONCE_SIZE)
|
val pdmNonce: ByteArray = randomByteGenerator.nextBytes(NONCE_SIZE)
|
||||||
val pdmPrivate: ByteArray = x25519.generatePrivateKey()
|
val pdmPrivate: ByteArray = x25519.generatePrivateKey()
|
||||||
|
@ -24,7 +23,7 @@ class KeyExchange(
|
||||||
|
|
||||||
var podPublic = ByteArray(PUBLIC_KEY_SIZE)
|
var podPublic = ByteArray(PUBLIC_KEY_SIZE)
|
||||||
private set
|
private set
|
||||||
var podNonce : ByteArray = ByteArray(NONCE_SIZE)
|
var podNonce: ByteArray = ByteArray(NONCE_SIZE)
|
||||||
|
|
||||||
val podConf = ByteArray(CMAC_SIZE)
|
val podConf = ByteArray(CMAC_SIZE)
|
||||||
val pdmConf = ByteArray(CMAC_SIZE)
|
val pdmConf = ByteArray(CMAC_SIZE)
|
||||||
|
|
|
@ -464,16 +464,15 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
|
|
||||||
private fun updateRefreshStatusButton() {
|
private fun updateRefreshStatusButton() {
|
||||||
buttonBinding.buttonRefreshStatus.isEnabled =
|
buttonBinding.buttonRefreshStatus.isEnabled =
|
||||||
podStateManager.isUniqueIdSet && podStateManager.activationProgress.isAtLeast(
|
podStateManager.isUniqueIdSet &&
|
||||||
ActivationProgress.PHASE_1_COMPLETED
|
podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) &&
|
||||||
) &&
|
isQueueEmpty()
|
||||||
isQueueEmpty()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateResumeDeliveryButton() {
|
private fun updateResumeDeliveryButton() {
|
||||||
if (podStateManager.isPodRunning && (podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(
|
if (podStateManager.isPodRunning &&
|
||||||
CommandResumeDelivery::class.java
|
(podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandResumeDelivery::class.java))
|
||||||
))) {
|
) {
|
||||||
buttonBinding.buttonResumeDelivery.visibility = View.VISIBLE
|
buttonBinding.buttonResumeDelivery.visibility = View.VISIBLE
|
||||||
buttonBinding.buttonResumeDelivery.isEnabled = isQueueEmpty()
|
buttonBinding.buttonResumeDelivery.isEnabled = isQueueEmpty()
|
||||||
} else {
|
} else {
|
||||||
|
@ -482,9 +481,12 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSilenceAlertsButton() {
|
private fun updateSilenceAlertsButton() {
|
||||||
if (isAutomaticallySilenceAlertsEnabled() && podStateManager.isPodRunning && (podStateManager.activeAlerts!!.size > 0 || commandQueue.isCustomCommandInQueue(
|
if (isAutomaticallySilenceAlertsEnabled() && podStateManager.isPodRunning &&
|
||||||
CommandAcknowledgeAlerts::class.java
|
(
|
||||||
))) {
|
podStateManager.activeAlerts!!.size > 0 ||
|
||||||
|
commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java)
|
||||||
|
)
|
||||||
|
) {
|
||||||
buttonBinding.buttonSilenceAlerts.visibility = View.VISIBLE
|
buttonBinding.buttonSilenceAlerts.visibility = View.VISIBLE
|
||||||
buttonBinding.buttonSilenceAlerts.isEnabled = isQueueEmpty()
|
buttonBinding.buttonSilenceAlerts.isEnabled = isQueueEmpty()
|
||||||
} else {
|
} else {
|
||||||
|
@ -494,9 +496,10 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
||||||
|
|
||||||
private fun updateSuspendDeliveryButton() {
|
private fun updateSuspendDeliveryButton() {
|
||||||
// If the Pod is currently suspended, we show the Resume delivery button instead.
|
// If the Pod is currently suspended, we show the Resume delivery button instead.
|
||||||
if (isSuspendDeliveryButtonEnabled() && podStateManager.isPodRunning && (!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(
|
if (isSuspendDeliveryButtonEnabled() &&
|
||||||
CommandSuspendDelivery::class.java
|
podStateManager.isPodRunning &&
|
||||||
))) {
|
(!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java))
|
||||||
|
) {
|
||||||
buttonBinding.buttonSuspendDelivery.visibility = View.VISIBLE
|
buttonBinding.buttonSuspendDelivery.visibility = View.VISIBLE
|
||||||
buttonBinding.buttonSuspendDelivery.isEnabled =
|
buttonBinding.buttonSuspendDelivery.isEnabled =
|
||||||
podStateManager.isPodRunning && !podStateManager.isSuspended && isQueueEmpty()
|
podStateManager.isPodRunning && !podStateManager.isSuspended && isQueueEmpty()
|
||||||
|
|
|
@ -17,7 +17,7 @@ class DashDeactivatePodViewModel @Inject constructor(
|
||||||
) : DeactivatePodViewModel(injector, logger) {
|
) : DeactivatePodViewModel(injector, logger) {
|
||||||
|
|
||||||
override fun doExecuteAction(): Single<PumpEnactResult> = Single.just(
|
override fun doExecuteAction(): Single<PumpEnactResult> = Single.just(
|
||||||
PumpEnactResult(injector).success(true).comment("TODO")
|
PumpEnactResult(injector).success(true).comment("TODO")
|
||||||
) // TODO
|
) // TODO
|
||||||
|
|
||||||
override fun discardPod() {
|
override fun discardPod() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class KeyExchangeTest {
|
||||||
|
|
||||||
val pdmNonce = Hex.decode("edfdacb242c7f4e1d2bc4d93ca3c5706")
|
val pdmNonce = Hex.decode("edfdacb242c7f4e1d2bc4d93ca3c5706")
|
||||||
|
|
||||||
Mockito.`when`(randomByteGenerator.nextBytes(anyInt())).thenReturn(pdmNonce)
|
Mockito.`when`(randomByteGenerator.nextBytes(anyInt())).thenReturn(pdmNonce)
|
||||||
|
|
||||||
val ke = KeyExchange(
|
val ke = KeyExchange(
|
||||||
aapsLogger,
|
aapsLogger,
|
||||||
|
|
Loading…
Reference in a new issue