fix crash
This commit is contained in:
parent
cd0ec5ef24
commit
accae18af0
1 changed files with 35 additions and 30 deletions
|
@ -16,8 +16,6 @@ import info.nightscout.androidaps.extensions.convertedToAbsolute
|
||||||
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
|
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
|
||||||
import info.nightscout.androidaps.extensions.toStringFull
|
import info.nightscout.androidaps.extensions.toStringFull
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.shared.logging.AAPSLogger
|
|
||||||
import info.nightscout.shared.logging.LTag
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType
|
import info.nightscout.androidaps.plugins.common.ManufacturerType
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||||
|
@ -52,6 +50,8 @@ import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.TimeChangeType
|
import info.nightscout.androidaps.utils.TimeChangeType
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
import info.nightscout.shared.logging.AAPSLogger
|
||||||
|
import info.nightscout.shared.logging.LTag
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import io.reactivex.rxjava3.core.Completable
|
import io.reactivex.rxjava3.core.Completable
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
|
@ -119,10 +119,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
updatePodWarnings()
|
updatePodWarnings()
|
||||||
aapsLogger.info(LTag.PUMP, "statusChecker")
|
aapsLogger.info(LTag.PUMP, "statusChecker")
|
||||||
|
|
||||||
createFakeTBRWhenNoActivePod()
|
try {
|
||||||
.subscribeOn(aapsSchedulers.io)
|
createFakeTBRWhenNoActivePod()
|
||||||
.doOnError { aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$it") }
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.blockingSubscribe()
|
.blockingAwait()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
aapsLogger.warn(LTag.PUMP, "Error on createFakeTBRWhenNoActivePod=$e")
|
||||||
|
}
|
||||||
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
|
handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,10 +250,11 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
try {
|
try {
|
||||||
stopConnecting?.let {
|
stopConnecting?.let {
|
||||||
omnipodManager.connect(it).ignoreElements()
|
omnipodManager.connect(it).ignoreElements()
|
||||||
.doOnError { aapsLogger.info(LTag.PUMPCOMM, "connect error=$it") }
|
|
||||||
.doOnComplete { podStateManager.incrementSuccessfulConnectionAttemptsAfterRetries() }
|
.doOnComplete { podStateManager.incrementSuccessfulConnectionAttemptsAfterRetries() }
|
||||||
.blockingSubscribe()
|
.blockingAwait()
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
aapsLogger.info(LTag.PUMPCOMM, "connect error=$e")
|
||||||
} finally {
|
} finally {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
stopConnecting = null
|
stopConnecting = null
|
||||||
|
@ -279,21 +283,21 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
getPodStatus()
|
try {
|
||||||
.doOnComplete {
|
getPodStatus()
|
||||||
aapsLogger.info(LTag.PUMP, "getPumpStatus executed with success")
|
.doOnComplete {
|
||||||
if (!podStateManager.isActivationCompleted) {
|
aapsLogger.info(LTag.PUMP, "getPumpStatus executed with success")
|
||||||
val msg = podStateManager.recoverActivationFromPodStatus()
|
if (!podStateManager.isActivationCompleted) {
|
||||||
msg?.let {
|
val msg = podStateManager.recoverActivationFromPodStatus()
|
||||||
// TODO: show dialog with "try again, the pod is busy now"
|
msg?.let {
|
||||||
aapsLogger.info(LTag.PUMP, "recoverActivationFromPodStatus msg=$msg")
|
// TODO: show dialog with "try again, the pod is busy now"
|
||||||
|
aapsLogger.info(LTag.PUMP, "recoverActivationFromPodStatus msg=$msg")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}.blockingAwait()
|
||||||
}
|
} catch (e: Exception) {
|
||||||
.doOnError {
|
aapsLogger.error(LTag.PUMP, "Error in getPumpStatus", e)
|
||||||
aapsLogger.error(LTag.PUMP, "Error in getPumpStatus", it)
|
}
|
||||||
}
|
|
||||||
.blockingSubscribe()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPodStatus(): Completable = Completable.concat(
|
private fun getPodStatus(): Completable = Completable.concat(
|
||||||
|
@ -564,7 +568,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
.comment(rh.gs(R.string.omnipod_dash_not_enough_insulin))
|
.comment(rh.gs(R.string.omnipod_dash_not_enough_insulin))
|
||||||
}
|
}
|
||||||
if (podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_BASAL_ACTIVE ||
|
if (podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_BASAL_ACTIVE ||
|
||||||
podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE) {
|
podStateManager.deliveryStatus == DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE
|
||||||
|
) {
|
||||||
return PumpEnactResult(injector)
|
return PumpEnactResult(injector)
|
||||||
.success(false)
|
.success(false)
|
||||||
.enacted(false)
|
.enacted(false)
|
||||||
|
@ -722,13 +727,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
getPodStatus()
|
getPodStatus()
|
||||||
|
|
||||||
var errorGettingStatus: Throwable? = null
|
var errorGettingStatus: Throwable? = null
|
||||||
cmd
|
try {
|
||||||
.doOnError {
|
cmd.blockingAwait()
|
||||||
errorGettingStatus = it
|
} catch (e: Exception) {
|
||||||
aapsLogger.debug(LTag.PUMP, "waitForBolusDeliveryToComplete errorGettingStatus=$errorGettingStatus")
|
errorGettingStatus = e
|
||||||
Thread.sleep(BOLUS_RETRY_INTERVAL_MS) // retry every 3 sec
|
aapsLogger.debug(LTag.PUMP, "waitForBolusDeliveryToComplete errorGettingStatus=$errorGettingStatus")
|
||||||
}
|
Thread.sleep(BOLUS_RETRY_INTERVAL_MS) // retry every 3 sec
|
||||||
.blockingSubscribe()
|
}
|
||||||
if (errorGettingStatus != null) {
|
if (errorGettingStatus != null) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue