simplify: use lastUpdatedSystem for lastConnection

This commit is contained in:
Andrei Vereha 2021-06-01 21:50:55 +02:00
parent b91e8506a0
commit 432e06adaa
4 changed files with 2 additions and 13 deletions
omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash

View file

@ -103,7 +103,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
?: Connection(podDevice, aapsLogger, context, podState)
connection = conn
if (conn.connectionState() is Connected) {
podState.lastConnection = System.currentTimeMillis()
if (conn.session == null) {
emitter.onNext(PodEvent.EstablishingSession)
establishSession(1.toByte())
@ -116,7 +115,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
}
conn.connect()
emitter.onNext(PodEvent.BluetoothConnected(podAddress))
podState.lastConnection = System.currentTimeMillis()
emitter.onNext(PodEvent.EstablishingSession)
establishSession(1.toByte())
emitter.onNext(PodEvent.Connected)

View file

@ -28,7 +28,6 @@ interface OmnipodDashPodStateManager {
val isActivationCompleted: Boolean
val isSuspended: Boolean
val isPodRunning: Boolean
var lastConnection: Long
var bluetoothConnectionState: BluetoothConnectionState
val lastUpdatedSystem: Long // System.currentTimeMillis()

View file

@ -58,13 +58,6 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
override val isPodRunning: Boolean
get() = podState.podStatus?.isRunning() ?: false
override var lastConnection: Long
get() = podState.lastConnection
set(lastConnection) {
podState.lastConnection = lastConnection
store()
}
override val lastUpdatedSystem: Long
get() = podState.lastUpdatedSystem
@ -422,7 +415,6 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
class PodState : Serializable {
var activationProgress: ActivationProgress = ActivationProgress.NOT_STARTED
var lastConnection: Long = 0
var lastUpdatedSystem: Long = 0
var lastStatusResponseReceived: Long = 0
var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState =

View file

@ -357,7 +357,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
private fun updateLastConnection() {
if (podStateManager.isUniqueIdSet) {
podInfoBinding.lastConnection.text = readableDuration(podStateManager.lastConnection)
podInfoBinding.lastConnection.text = readableDuration(podStateManager.lastUpdatedSystem)
val lastConnectionColor =
if (omnipodDashPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().millis)) {
Color.RED
@ -367,7 +367,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
podInfoBinding.lastConnection.setTextColor(lastConnectionColor)
} else {
podInfoBinding.lastConnection.setTextColor(Color.WHITE)
podInfoBinding.lastConnection.text = readableDuration(podStateManager.lastConnection)
podInfoBinding.lastConnection.text = readableDuration(podStateManager.lastUpdatedSystem)
}
}