ktlint. update ktlint gradle plugin
This commit is contained in:
parent
9a009d2f96
commit
f289cd50c5
|
@ -63,7 +63,7 @@ buildscript {
|
|||
|
||||
plugins {
|
||||
id "io.gitlab.arturbosch.detekt" version "1.16.0-RC2"
|
||||
id "org.jlleitschuh.gradle.ktlint" version "9.4.1"
|
||||
id "org.jlleitschuh.gradle.ktlint" version "10.1.0"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
|
|
@ -53,7 +53,6 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.exp
|
||||
import kotlin.random.Random
|
||||
|
||||
@Singleton
|
||||
|
@ -75,7 +74,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
@Volatile var bolusCanceled = false
|
||||
private val handler: Handler = Handler(Looper.getMainLooper())
|
||||
private lateinit var statusChecker: Runnable
|
||||
var nextPodWarningCheck : Long = 0
|
||||
var nextPodWarningCheck: Long = 0
|
||||
@Volatile var stopConnecting: CountDownLatch? = null
|
||||
|
||||
companion object {
|
||||
|
@ -99,7 +98,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
statusChecker = Runnable {
|
||||
refreshStatusOnUnacknowledgedCommands()
|
||||
updatePodWarnings()
|
||||
// createFakeTBRWhenNoActivePod()
|
||||
// createFakeTBRWhenNoActivePod()
|
||||
// TODO: this is called from the main thread
|
||||
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
if (!podStateManager.isPodRunning) {
|
||||
val expectedState = pumpSync.expectedPumpState()
|
||||
val tbr = expectedState.temporaryBasal
|
||||
if (tbr == null || tbr.rate!=0.0) {
|
||||
if (tbr == null || tbr.rate != 0.0) {
|
||||
aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod")
|
||||
pumpSync.syncTemporaryBasalWithPumpId(
|
||||
timestamp = System.currentTimeMillis(),
|
||||
|
@ -147,7 +146,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
rxBus.send(EventNewNotification(notification))
|
||||
} else {
|
||||
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED))
|
||||
// TODO: time out of sync notification?
|
||||
if (!TimeZone.getDefault().equals(podStateManager.timeZone)) {
|
||||
val notification =
|
||||
Notification(
|
||||
Notification.OMNIPOD_TIME_OUT_OF_SYNC,
|
||||
"Timezone on pod is different from the timezone on phone. " +
|
||||
"Basal rate is incorrect" +
|
||||
"Switch profile to fix",
|
||||
Notification.NORMAL
|
||||
)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
}
|
||||
}
|
||||
}
|
||||
nextPodWarningCheck = DateTimeUtil.getTimeInFutureFromMinutes(15)
|
||||
|
@ -158,7 +167,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
if (podStateManager.isPodRunning &&
|
||||
podStateManager.activeCommand != null &&
|
||||
commandQueue.size() == 0 &&
|
||||
commandQueue.performing() == null) {
|
||||
commandQueue.performing() == null
|
||||
) {
|
||||
commandQueue.readStatus("Unconfirmed command", null)
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +190,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
|||
override fun isConnected(): Boolean {
|
||||
|
||||
return !podStateManager.isPodRunning ||
|
||||
podStateManager.bluetoothConnectionState == OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTED
|
||||
podStateManager.bluetoothConnectionState == OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTED
|
||||
}
|
||||
|
||||
override fun isConnecting(): Boolean {
|
||||
|
|
|
@ -16,7 +16,7 @@ interface OmnipodDashBleManager {
|
|||
fun getStatus(): ConnectionState
|
||||
|
||||
// used for sync connections
|
||||
fun connect(timeoutMs: Long = Connection.BASE_CONNECT_TIMEOUT_MS*3): Observable<PodEvent>
|
||||
fun connect(timeoutMs: Long = Connection.BASE_CONNECT_TIMEOUT_MS * 3): Observable<PodEvent>
|
||||
|
||||
// used for async connections
|
||||
fun connect(stopConnectionLatch: CountDownLatch): Observable<PodEvent>
|
||||
|
|
|
@ -114,40 +114,40 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
|||
private fun connect(connectionWaitCond: ConnectionWaitCondition): Observable<PodEvent> = Observable
|
||||
.create {
|
||||
emitter ->
|
||||
if (!busy.compareAndSet(false, true)) {
|
||||
throw BusyException()
|
||||
}
|
||||
try {
|
||||
emitter.onNext(PodEvent.BluetoothConnecting)
|
||||
|
||||
val podAddress =
|
||||
podState.bluetoothAddress
|
||||
?: throw FailedToConnectException("Missing bluetoothAddress, activate the pod first")
|
||||
val podDevice = bluetoothAdapter.getRemoteDevice(podAddress)
|
||||
val conn = connection
|
||||
?: Connection(podDevice, aapsLogger, context, podState)
|
||||
connection = conn
|
||||
if (conn.connectionState() is Connected && conn.session != null) {
|
||||
emitter.onNext(PodEvent.AlreadyConnected(podAddress))
|
||||
emitter.onComplete()
|
||||
return@create
|
||||
if (!busy.compareAndSet(false, true)) {
|
||||
throw BusyException()
|
||||
}
|
||||
try {
|
||||
emitter.onNext(PodEvent.BluetoothConnecting)
|
||||
|
||||
conn.connect(connectionWaitCond)
|
||||
val podAddress =
|
||||
podState.bluetoothAddress
|
||||
?: throw FailedToConnectException("Missing bluetoothAddress, activate the pod first")
|
||||
val podDevice = bluetoothAdapter.getRemoteDevice(podAddress)
|
||||
val conn = connection
|
||||
?: Connection(podDevice, aapsLogger, context, podState)
|
||||
connection = conn
|
||||
if (conn.connectionState() is Connected && conn.session != null) {
|
||||
emitter.onNext(PodEvent.AlreadyConnected(podAddress))
|
||||
emitter.onComplete()
|
||||
return@create
|
||||
}
|
||||
|
||||
emitter.onNext(PodEvent.BluetoothConnected(podAddress))
|
||||
emitter.onNext(PodEvent.EstablishingSession)
|
||||
establishSession(1.toByte())
|
||||
emitter.onNext(PodEvent.Connected)
|
||||
conn.connect(connectionWaitCond)
|
||||
|
||||
emitter.onComplete()
|
||||
} catch (ex: Exception) {
|
||||
disconnect()
|
||||
emitter.tryOnError(ex)
|
||||
} finally {
|
||||
busy.set(false)
|
||||
emitter.onNext(PodEvent.BluetoothConnected(podAddress))
|
||||
emitter.onNext(PodEvent.EstablishingSession)
|
||||
establishSession(1.toByte())
|
||||
emitter.onNext(PodEvent.Connected)
|
||||
|
||||
emitter.onComplete()
|
||||
} catch (ex: Exception) {
|
||||
disconnect()
|
||||
emitter.tryOnError(ex)
|
||||
} finally {
|
||||
busy.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun establishSession(msgSeq: Byte) {
|
||||
val conn = assertConnected()
|
||||
|
|
|
@ -24,15 +24,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
sealed class ConnectionState
|
||||
|
||||
object Connecting: ConnectionState()
|
||||
object Connecting : ConnectionState()
|
||||
object Connected : ConnectionState()
|
||||
object NotConnected : ConnectionState()
|
||||
|
||||
data class ConnectionWaitCondition(var timeoutMs: Long?=null, val stopConnection: CountDownLatch?=null) {
|
||||
data class ConnectionWaitCondition(var timeoutMs: Long? = null, val stopConnection: CountDownLatch? = null) {
|
||||
init {
|
||||
if (timeoutMs == null && stopConnection == null) {
|
||||
throw IllegalArgumentException("One of timeoutMs or stopConnection has to be non null")
|
||||
|
@ -68,8 +67,8 @@ class Connection(
|
|||
|
||||
podState.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
|
||||
val autoConnect = false
|
||||
val gatt = gattConnection ?:
|
||||
podDevice.connectGatt(context, autoConnect, bleCommCallbacks, BluetoothDevice.TRANSPORT_LE)
|
||||
val gatt = gattConnection
|
||||
?: podDevice.connectGatt(context, autoConnect, bleCommCallbacks, BluetoothDevice.TRANSPORT_LE)
|
||||
gattConnection = gatt
|
||||
if (!gatt.connect()) {
|
||||
throw FailedToConnectException("connect() returned false")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
|
||||
|
||||
import info.nightscout.androidaps.extensions.toHex
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
|
||||
import java.util.*
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
sealed class CommandSendResult
|
||||
object CommandSendSuccess : CommandSendResult()
|
||||
|
@ -113,10 +112,10 @@ class Session(
|
|||
|
||||
// TODO verify length
|
||||
|
||||
//val uniqueId = data.copyOfRange(0, 4)
|
||||
//val lenghtAndSequenceNumber = data.copyOfRange(4, 6)
|
||||
// val uniqueId = data.copyOfRange(0, 4)
|
||||
// val lenghtAndSequenceNumber = data.copyOfRange(4, 6)
|
||||
val payload = data.copyOfRange(6, data.size - 2)
|
||||
//val crc = data.copyOfRange(data.size - 2, data.size)
|
||||
// val crc = data.copyOfRange(data.size - 2, data.size)
|
||||
|
||||
// TODO validate uniqueId, sequenceNumber and crc
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state
|
|||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
|
||||
|
@ -11,10 +10,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import org.joda.time.Duration
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
|
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.EapSqn
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
|
||||
|
@ -20,10 +19,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
|
|||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import org.joda.time.Duration
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
|
@ -283,29 +280,29 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
|||
requestedBolus: Double?
|
||||
):
|
||||
Single<OmnipodDashPodStateManager.ActiveCommand> {
|
||||
return Single.create { source ->
|
||||
if (activeCommand == null) {
|
||||
val command = OmnipodDashPodStateManager.ActiveCommand(
|
||||
podState.messageSequenceNumber,
|
||||
createdRealtime = SystemClock.elapsedRealtime(),
|
||||
historyId = historyId,
|
||||
sendError = null,
|
||||
basalProgram = basalProgram,
|
||||
tempBasal = tempBasal,
|
||||
requestedBolus = requestedBolus
|
||||
return Single.create { source ->
|
||||
if (activeCommand == null) {
|
||||
val command = OmnipodDashPodStateManager.ActiveCommand(
|
||||
podState.messageSequenceNumber,
|
||||
createdRealtime = SystemClock.elapsedRealtime(),
|
||||
historyId = historyId,
|
||||
sendError = null,
|
||||
basalProgram = basalProgram,
|
||||
tempBasal = tempBasal,
|
||||
requestedBolus = requestedBolus
|
||||
)
|
||||
podState.activeCommand = command
|
||||
source.onSuccess(command)
|
||||
} else {
|
||||
source.onError(
|
||||
java.lang.IllegalStateException(
|
||||
"Trying to send a command " +
|
||||
"and the last command was not confirmed"
|
||||
)
|
||||
podState.activeCommand = command
|
||||
source.onSuccess(command)
|
||||
} else {
|
||||
source.onError(
|
||||
java.lang.IllegalStateException(
|
||||
"Trying to send a command " +
|
||||
"and the last command was not confirmed"
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun observeNoActiveCommand(): Completable {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
|
@ -286,12 +285,13 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
|
|||
// Update Pod expiry time
|
||||
val expiresAt = podStateManager.expiry
|
||||
podInfoBinding.podExpiryDate.text = expiresAt?.let {
|
||||
readableZonedTime(it) }
|
||||
readableZonedTime(it)
|
||||
}
|
||||
?: PLACEHOLDER
|
||||
podInfoBinding.podExpiryDate.setTextColor(
|
||||
if (expiresAt != null && DateTime.now().isAfter(expiresAt))
|
||||
Color.RED
|
||||
else
|
||||
else
|
||||
Color.WHITE
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue