resolve deadlock in Objective 7

This commit is contained in:
Milos Kozak 2022-06-17 11:24:51 +02:00
parent f980d2f73c
commit c211c2e4c3

View file

@ -2,7 +2,9 @@ package info.nightscout.androidaps.plugins.constraints.objectives.objectives
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import javax.inject.Inject import javax.inject.Inject
@ -10,14 +12,21 @@ import javax.inject.Inject
class Objective6(injector: HasAndroidInjector) : Objective(injector, "maxiob", R.string.objectives_maxiob_objective, R.string.objectives_maxiob_gate) { class Objective6(injector: HasAndroidInjector) : Objective(injector, "maxiob", R.string.objectives_maxiob_objective, R.string.objectives_maxiob_gate) {
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var safetyPlugin: SafetyPlugin
init { init {
tasks.add(MinimumDurationTask(this, T.days(1).msecs())) tasks.add(MinimumDurationTask(this, T.days(1).msecs()))
tasks.add(object : Task(this, R.string.maxiobset) { tasks.add(
override fun isCompleted(): Boolean { object : Task(this, R.string.closedmodeenabled) {
val maxIOB = constraintChecker.getMaxIOBAllowed().value() override fun isCompleted(): Boolean = sp.getString(R.string.key_aps_mode, "open") == "closed"
return maxIOB > 0 })
} tasks.add(
}) object : Task(this, R.string.maxiobset) {
override fun isCompleted(): Boolean {
val maxIOB = constraintChecker.getMaxIOBAllowed().value()
return maxIOB > 0
}
})
} }
} }