dash: ktlintFormat

This commit is contained in:
Andrei Vereha 2021-04-04 13:36:33 +02:00
parent ff6a67cc97
commit 14af90e9e3
6 changed files with 15 additions and 18 deletions

View file

@ -133,4 +133,4 @@ private fun Boolean.assertTrue(operation: String) {
if (!this) {
throw ConnectException("Could not $operation")
}
}
}

View file

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

View file

@ -65,4 +65,4 @@ private fun ByteArray.assertSizeAtLeast(size: Int) {
if (this.size < size) {
throw MessageIOException("Payload too short: ${this.toHex()}")
}
}
}

View file

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

View file

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

View file

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