From 14af90e9e315f8781dd374d9b7f6cd48a65223b6 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 4 Apr 2021 13:36:33 +0200 Subject: [PATCH] dash: ktlintFormat --- .../pump/omnipod/dash/driver/comm/io/BleIO.kt | 2 +- .../dash/driver/comm/message/MessagePacket.kt | 3 +-- .../comm/message/StringLengthPrefixEncoding.kt | 2 +- .../omnipod/dash/driver/comm/packet/BlePacket.kt | 5 ++--- .../omnipod/dash/driver/comm/pair/LTKExchanger.kt | 7 ++----- .../dash/driver/comm/session/SessionEstablisher.kt | 14 ++++++++------ 6 files changed, 15 insertions(+), 18 deletions(-) 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 79513c759e..e7033d5a0c 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 @@ -133,4 +133,4 @@ private fun Boolean.assertTrue(operation: String) { if (!this) { throw ConnectException("Could not $operation") } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacket.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacket.kt index 7b14d74094..1401ead5de 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacket.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessagePacket.kt @@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.CouldNotParseMessageException -import retrofit2.http.HEAD import java.nio.ByteBuffer /*** @@ -150,4 +149,4 @@ private fun ByteArray.assertSizeAtLeast(size: Int) { if (this.size < size) { throw CouldNotParseMessageException(this) } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt index 90ff5b9887..013e6cc383 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/StringLengthPrefixEncoding.kt @@ -65,4 +65,4 @@ private fun ByteArray.assertSizeAtLeast(size: Int) { if (this.size < size) { throw MessageIOException("Payload too short: ${this.toHex()}") } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt index b971daed99..116d5f8221 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt @@ -195,9 +195,8 @@ data class LastOptionalPlusOneBlePacket( } } - -private fun ByteArray.assertSizeAtLeast(size: Int, index: Byte?=null) { +private fun ByteArray.assertSizeAtLeast(size: Int, index: Byte? = null) { if (this.size < size) { throw IncorrectPacketException(this, index) } -} \ No newline at end of file +} 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 6777b2b162..c2ad6708c2 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 @@ -36,7 +36,6 @@ internal class LTKExchanger( val sps1 = sps1() throwOnSendError(sps1.messagePacket, "SP1") - val podSps1 = msgIO.receiveMessage() ?: throw PairingException("Could not read SPS1") processSps1FromPod(podSps1) // now we have all the data to generate: confPod, confPdm, ltk and noncePrefix @@ -45,7 +44,6 @@ internal class LTKExchanger( val sps2 = sps2() throwOnSendError(sps2.messagePacket, "SPS2") - val podSps2 = msgIO.receiveMessage() ?: throw PairingException("Could not read SPS2") validatePodSps2(podSps2) @@ -53,7 +51,6 @@ internal class LTKExchanger( // send SP0GP0 throwOnSendErrorSending(sp0gp0().messagePacket, "SP0GP0") - // No exception throwing after this point. It is possible that the pod saved the LTK msgIO.receiveMessage() ?.let { validateP0(it) } @@ -67,7 +64,7 @@ internal class LTKExchanger( @Throws(PairingException::class) private fun throwOnSendError(msg: MessagePacket, msgType: String) { - val result = msgIO.sendMessage(msg) + val result = msgIO.sendMessage(msg) if (result !is MessageSendSuccess) { throw PairingException("Could not send or confirm $msgType: $result") } @@ -75,7 +72,7 @@ internal class LTKExchanger( @Throws(PairingException::class) private fun throwOnSendErrorSending(msg: MessagePacket, msgType: String) { - val result = msgIO.sendMessage(msg) + val result = msgIO.sendMessage(msg) if (result is MessageSendErrorSending) { throw PairingException("Could not send $msgType: $result") } 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 d24e8520ee..9f4ab8e347 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 @@ -116,9 +116,11 @@ class SessionEstablisher( when (attr) { is EapAkaAttributeRes -> if (!milenage.res.contentEquals(attr.payload)) { - throw SessionEstablishmentException("RES mismatch." + - "Expected: ${milenage.res.toHex()}." + - "Actual: ${attr.payload.toHex()}.") + throw SessionEstablishmentException( + "RES mismatch." + + "Expected: ${milenage.res.toHex()}." + + "Actual: ${attr.payload.toHex()}." + ) } is EapAkaAttributeCustomIV -> nodeIV = attr.payload.copyOfRange(0, IV_SIZE) @@ -135,7 +137,7 @@ class SessionEstablisher( if (eapMsg.attributes.size == 1 && eapMsg.attributes[0] is EapAkaAttributeClientErrorCode) { throw SessionEstablishmentException( "Received CLIENT_ERROR_CODE for EAP-AKA challenge: ${ - eapMsg.attributes[0].toByteArray().toHex() + eapMsg.attributes[0].toByteArray().toHex() }" ) } @@ -146,7 +148,8 @@ class SessionEstablisher( private fun isResynchronization(eapMsg: EapMessage): EapSqn? { if (eapMsg.subType != EapMessage.SUBTYPE_SYNCRONIZATION_FAILURE || eapMsg.attributes.size != 1 || - eapMsg.attributes[0] !is EapAkaAttributeAuts) + eapMsg.attributes[0] !is EapAkaAttributeAuts + ) return null val auts = eapMsg.attributes[0] as EapAkaAttributeAuts @@ -175,7 +178,6 @@ class SessionEstablisher( ) } return EapSqn(autsMilenage.synchronizationSqn) - } private fun eapSuccess(): MessagePacket {