delint
This commit is contained in:
parent
bf3fe19a4e
commit
7db5c28632
|
@ -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"))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -8,4 +8,4 @@ class RandomByteGenerator {
|
|||
private val secureRandom = SecureRandom()
|
||||
|
||||
fun nextBytes(length: Int): ByteArray = ByteArray(length).also(secureRandom::nextBytes)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue