From c211c2e4c3abf1b71557751e58b02088cbe062e1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 17 Jun 2022 11:24:51 +0200 Subject: [PATCH] resolve deadlock in Objective 7 --- .../objectives/objectives/Objective6.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt index edcdf54bd5..dd10f4a33d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt @@ -2,7 +2,9 @@ package info.nightscout.androidaps.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin import info.nightscout.androidaps.utils.T 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) { @Inject lateinit var constraintChecker: ConstraintChecker + @Inject lateinit var safetyPlugin: SafetyPlugin init { tasks.add(MinimumDurationTask(this, T.days(1).msecs())) - tasks.add(object : Task(this, R.string.maxiobset) { - override fun isCompleted(): Boolean { - val maxIOB = constraintChecker.getMaxIOBAllowed().value() - return maxIOB > 0 - } - }) + tasks.add( + object : Task(this, R.string.closedmodeenabled) { + override fun isCompleted(): Boolean = sp.getString(R.string.key_aps_mode, "open") == "closed" + }) + tasks.add( + object : Task(this, R.string.maxiobset) { + + override fun isCompleted(): Boolean { + val maxIOB = constraintChecker.getMaxIOBAllowed().value() + return maxIOB > 0 + } + }) } } \ No newline at end of file