From b9a3a72e863c05d8181746affcc69c2f456ce832 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 9 Nov 2021 17:45:20 +0100 Subject: [PATCH 1/3] fix BG backfill rule --- .../androidaps/plugins/source/NSClientSourcePlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index a21bdbe145..e1d1238e0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -116,7 +116,7 @@ class NSClientSourcePlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_receive_cgm, false) && !dexcomPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Sync not enabled")) + if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_receive_cgm, false)) return Result.success(workDataOf("Result" to "Sync not enabled")) val sgvs = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) ?: return Result.failure(workDataOf("Error" to "missing input data")) From 04de964e97941f08a46ee44d30c183d6b5c333e4 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 9 Nov 2021 17:57:51 +0100 Subject: [PATCH 2/3] cleanup --- .../nightscout/androidaps/MainActivity.kt | 2 +- .../androidaps/dialogs/LoopDialog.kt | 2 +- .../androidaps/plugins/aps/loop/LoopPlugin.kt | 4 +-- .../objectives/objectives/Objective0.kt | 6 ++-- .../objectives/objectives/Objective1.kt | 2 +- .../constraints/safety/SafetyPlugin.kt | 2 +- .../nsclient/services/NSClientService.kt | 4 +-- .../general/overview/OverviewFragment.kt | 16 +++++----- .../plugins/general/wear/WearPlugin.kt | 2 +- .../wearintegration/WatchUpdaterService.java | 4 +-- .../xdripStatusline/StatusLinePlugin.kt | 6 ++-- .../iob/iobCobCalculator/IobCobThread.kt | 2 +- .../androidaps/plugins/source/DexcomPlugin.kt | 2 +- .../plugins/source/EversensePlugin.kt | 2 +- .../androidaps/plugins/source/GlimpPlugin.kt | 2 +- .../androidaps/plugins/source/MM640gPlugin.kt | 2 +- .../plugins/source/PoctechPlugin.kt | 2 +- .../plugins/source/RandomBgPlugin.kt | 2 +- .../androidaps/plugins/source/TomatoPlugin.kt | 2 +- .../androidaps/plugins/source/XdripPlugin.kt | 2 +- .../queue/commands/CommandSetProfile.kt | 2 +- .../androidaps/setupwizard/SWDefinition.kt | 8 ++--- .../androidaps/utils/AndroidPermission.kt | 2 +- .../androidaps/utils/wizard/BolusWizard.kt | 2 +- .../plugins/aps/loop/LoopPluginTest.kt | 6 ++-- .../SmsCommunicatorPluginTest.kt | 6 ++-- .../configBuilder/ConstraintChecker.kt | 30 +++++++++---------- .../androidaps/danar/comm/MsgSettingMeal.kt | 2 +- 28 files changed, 63 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index d947f63c7a..0db09d5348 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -124,7 +124,7 @@ class MainActivity : NoSplashAppCompatActivity() { }) //Check here if loop plugin is disabled. Else check via constraints - if (!loopPlugin.isEnabled(PluginType.LOOP)) versionCheckerUtils.triggerCheckVersion() + if (!loopPlugin.isEnabled()) versionCheckerUtils.triggerCheckVersion() setUserStats() setupViews() disposable += rxBus diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index be49719527..12b04b97f6 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -190,7 +190,7 @@ class LoopDialog : DaggerDialogFragment() { binding.overviewReconnect.visibility = View.VISIBLE } - !loopPlugin.isEnabled(PluginType.LOOP) -> { + !loopPlugin.isEnabled() -> { binding.overviewLoop.visibility = View.VISIBLE binding.overviewEnable.visibility = View.VISIBLE binding.overviewDisable.visibility = View.GONE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt index 82f8d7f9aa..e0c875da46 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt @@ -250,7 +250,7 @@ class LoopPlugin @Inject constructor( // Check if pump info is loaded if (pump.baseBasalRate < 0.01) return val usedAPS = activePlugin.activeAPS - if ((usedAPS as PluginBase).isEnabled(PluginType.APS)) { + if ((usedAPS as PluginBase).isEnabled()) { usedAPS.invoke(initiator, tempBasalFallback) apsResult = usedAPS.lastAPSResult } @@ -616,7 +616,7 @@ class LoopPlugin @Inject constructor( } private fun allowPercentage(): Boolean { - return virtualPumpPlugin.isEnabled(PluginType.PUMP) + return virtualPumpPlugin.isEnabled() } override fun goToZeroTemp(durationInMinutes: Int, profile: Profile, reason: OfflineEvent.Reason) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt index c58e0cb355..abb56ccf0f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt @@ -39,7 +39,7 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R } override fun shouldBeIgnored(): Boolean { - return !virtualPumpPlugin.isEnabled(PluginType.PUMP) + return !virtualPumpPlugin.isEnabled() } }) tasks.add(object : Task(this, R.string.objectives_pumpstatusavailableinns) { @@ -54,13 +54,13 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R }) tasks.add(object : Task(this, R.string.loopenabled) { override fun isCompleted(): Boolean { - return loopPlugin.isEnabled(PluginType.LOOP) + return loopPlugin.isEnabled() } }) tasks.add(object : Task(this, R.string.apsselected) { override fun isCompleted(): Boolean { val usedAPS = activePlugin.activeAPS - return (usedAPS as PluginBase).isEnabled(PluginType.APS) + return (usedAPS as PluginBase).isEnabled() } }) tasks.add(object : Task(this, R.string.activate_profile) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt index 91fb901033..936065ee0f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt @@ -33,7 +33,7 @@ class Objective1 @Inject constructor(injector: HasAndroidInjector) : Objective(i }.hint(Hint(R.string.usetemptarget_hint))) tasks.add(object : Task(this, R.string.objectives_useactions) { override fun isCompleted(): Boolean { - return sp.getBoolean(R.string.key_objectiveuseactions, false) && actionsPlugin.isEnabled(PluginType.GENERAL) && actionsPlugin.isFragmentVisible() + return sp.getBoolean(R.string.key_objectiveuseactions, false) && actionsPlugin.isEnabled() && actionsPlugin.isFragmentVisible() } }.hint(Hint(R.string.useaction_hint))) tasks.add(object : Task(this, R.string.objectives_useloop) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt index b630e5bcff..8e55ff8de9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt @@ -95,7 +95,7 @@ class SafetyPlugin @Inject constructor( override fun isUAMEnabled(value: Constraint): Constraint { val enabled = sp.getBoolean(R.string.key_use_uam, false) if (!enabled) value[aapsLogger, false, rh.gs(R.string.uamdisabledinpreferences)] = this - val oref1Enabled = sensitivityOref1Plugin.isEnabled(PluginType.SENSITIVITY) + val oref1Enabled = sensitivityOref1Plugin.isEnabled() if (!oref1Enabled) value[aapsLogger, false, rh.gs(R.string.uamdisabledoref1notselected)] = this return value } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.kt index 7cb59631ee..770c72ec94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.kt @@ -119,7 +119,7 @@ class NSClientService : DaggerService() { .toObservable(EventConfigBuilderChange::class.java) .observeOn(aapsSchedulers.io) .subscribe({ - if (nsEnabled != nsClientPlugin.isEnabled(PluginType.GENERAL)) { + if (nsEnabled != nsClientPlugin.isEnabled()) { latestDateInReceivedData = 0 destroy() initialize() @@ -356,7 +356,7 @@ class NSClientService : DaggerService() { } fun readPreferences() { - nsEnabled = nsClientPlugin.isEnabled(PluginType.GENERAL) + nsEnabled = nsClientPlugin.isEnabled() nsURL = sp.getString(R.string.key_nsclientinternal_url, "") nsAPISecret = sp.getString(R.string.key_nsclientinternal_api_secret, "") nsDevice = sp.getString("careportal_enteredby", "") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index fd08cb8418..6b9b78ae3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -300,9 +300,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } R.id.cgm_button -> { - if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) + if (xdripPlugin.isEnabled()) openCgmApp("com.eveningoutpost.dexdrip") - else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) { + else if (dexcomPlugin.isEnabled()) { dexcomMediator.findDexcomPackageName()?.let { openCgmApp(it) } @@ -311,9 +311,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } R.id.calibration_button -> { - if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) { + if (xdripPlugin.isEnabled()) { CalibrationDialog().show(childFragmentManager, "CalibrationDialog") - } else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) { + } else if (dexcomPlugin.isEnabled()) { try { dexcomMediator.findDexcomPackageName()?.let { startActivity(Intent("com.dexcom.cgm.activities.MeterEntryActivity").setPackage(it)) @@ -327,7 +327,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.accept_temp_button -> { profileFunction.getProfile() ?: return - if (loopPlugin.isEnabled(PluginType.LOOP)) { + if (loopPlugin.isEnabled()) { handler.post { val lastRun = loopPlugin.lastRun loopPlugin.invoke("Accept temp button", false) @@ -445,7 +445,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList (lastRun.lastOpenModeAccept == 0L || lastRun.lastOpenModeAccept < lastRun.lastAPSRun) &&// never accepted or before last result lastRun.constraintsProcessed?.isChangeRequested == true // change is requested - if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && loopPlugin.isEnabled(PluginType.LOOP)) { + if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && loopPlugin.isEnabled()) { binding.buttonsLayout.acceptTempButton.visibility = View.VISIBLE binding.buttonsLayout.acceptTempButton.text = "${rh.gs(R.string.setbasalquestion)}\n${lastRun!!.constraintsProcessed}" } else { @@ -459,8 +459,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList binding.buttonsLayout.insulinButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility() // **** Calibration & CGM buttons **** - val xDripIsBgSource = xdripPlugin.isEnabled(PluginType.BGSOURCE) - val dexcomIsSource = dexcomPlugin.isEnabled(PluginType.BGSOURCE) + val xDripIsBgSource = xdripPlugin.isEnabled() + val dexcomIsSource = dexcomPlugin.isEnabled() binding.buttonsLayout.calibrationButton.visibility = ((xDripIsBgSource || dexcomIsSource) && actualBG != null && sp.getBoolean(R.string.key_show_calibration_button, true)).toVisibility() binding.buttonsLayout.cgmButton.visibility = (sp.getBoolean(R.string.key_show_cgm_button, false) && (xDripIsBgSource || dexcomIsSource)).toVisibility() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt index f47f762fe9..d7666098c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt @@ -88,7 +88,7 @@ class WearPlugin @Inject constructor( .toObservable(EventRefreshOverview::class.java) .observeOn(aapsSchedulers.io) .subscribe({ - if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled(PluginType.LOOP))) + if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled())) sendDataToWatch(status = true, basals = false, bgValue = false) }, fabricPrivacy::logException)) disposable.add(rxBus diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index 477f9c7118..2583996995 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -133,7 +133,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog } private boolean wearIntegration() { - return wearPlugin.isEnabled(PluginType.GENERAL); + return wearPlugin.isEnabled(); } private void googleApiConnect() { @@ -740,7 +740,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog return status; } - if (!loopPlugin.isEnabled(PluginType.LOOP)) { + if (!loopPlugin.isEnabled()) { status += rh.gs(R.string.disabledloop) + "\n"; lastLoopStatus = false; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt index 2f863fb7cc..5eb9ac1c47 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt @@ -66,7 +66,7 @@ class StatusLinePlugin @Inject constructor( super.onStart() disposable += rxBus.toObservable(EventRefreshOverview::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ if (lastLoopStatus != loopPlugin.isEnabled(PluginType.LOOP)) sendStatus() }, fabricPrivacy::logException) + .subscribe({ if (lastLoopStatus != loopPlugin.isEnabled()) sendStatus() }, fabricPrivacy::logException) disposable += rxBus.toObservable(EventExtendedBolusChange::class.java) .observeOn(aapsSchedulers.io) .subscribe({ sendStatus() }, fabricPrivacy::logException) @@ -113,10 +113,10 @@ class StatusLinePlugin @Inject constructor( private fun buildStatusString(profile: Profile): String { var status = "" - if (!loopPlugin.isEnabled(PluginType.LOOP)) { + if (!loopPlugin.isEnabled()) { status += rh.gs(R.string.disabledloop) + "\n" lastLoopStatus = false - } else if (loopPlugin.isEnabled(PluginType.LOOP)) { + } else if (loopPlugin.isEnabled()) { lastLoopStatus = true } //Temp basal diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt index bd61168345..1561575796 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt @@ -204,7 +204,7 @@ class IobCobThread @Inject internal constructor( if (previous != null && previous.cob > 0) { // calculate sum of min carb impact from all active treatments var totalMinCarbsImpact = 0.0 - if (sensitivityAAPSPlugin.isEnabled(PluginType.SENSITIVITY) || sensitivityWeightedAveragePlugin.isEnabled(PluginType.SENSITIVITY)) { + if (sensitivityAAPSPlugin.isEnabled() || sensitivityWeightedAveragePlugin.isEnabled()) { //when the impact depends on a max time, sum them up as smaller carb sizes make them smaller for (ii in autosensData.activeCarbsList.indices) { val c = autosensData.activeCarbsList[ii] diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 2260474270..f4eddb4a5e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -94,7 +94,7 @@ class DexcomPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success(workDataOf("Result" to "Plugin not enabled")) + if (!dexcomPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) ?: return Result.failure(workDataOf("Error" to "missing input data")) try { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 1d950d1919..6efc905729 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -69,7 +69,7 @@ class EversensePlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.success(workDataOf("Result" to "Plugin not enabled")) + if (!eversensePlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) ?: return Result.failure(workDataOf("Error" to "missing input data")) if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase")) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index 0670608c3b..9429e3b7c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -58,7 +58,7 @@ class GlimpPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success(workDataOf("Result" to "Plugin not enabled")) + if (!glimpPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}") val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index acb90276ca..3b756c9f1c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -61,7 +61,7 @@ class MM640gPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() + if (!mM640gPlugin.isEnabled()) return Result.success() val collection = inputData.getString("collection") ?: return Result.failure(workDataOf("Error" to "missing collection")) if (collection == "entries") { val data = inputData.getString("data") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 8dba9103bc..4fe6fe5532 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -60,7 +60,7 @@ class PoctechPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success(workDataOf("Result" to "Plugin not enabled")) + if (!poctechPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData") try { val glucoseValues = mutableListOf() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index 2e22db0164..1a55c23a35 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -84,7 +84,7 @@ class RandomBgPlugin @Inject constructor( } override fun specialEnableCondition(): Boolean { -// return isRunningTest() || virtualPumpPlugin.isEnabled(PluginType.PUMP) && buildHelper.isEngineeringMode() +// return isRunningTest() || virtualPumpPlugin.isEnabled() && buildHelper.isEngineeringMode() return true } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index b3974892e8..5c8e98190b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -59,7 +59,7 @@ class TomatoPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success(workDataOf("Result" to "Plugin not enabled")) + if (!tomatoPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt index ac626cdb98..80a656b82f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt @@ -73,7 +73,7 @@ class XdripPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success(workDataOf("Result" to "Plugin not enabled")) + if (!xdripPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled")) val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) ?: return Result.failure(workDataOf("Error" to "missing input data")) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt index c388afb187..fdf3fb28fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.kt @@ -40,7 +40,7 @@ class CommandSetProfile constructor( // Send SMS notification if ProfileSwitch is coming from NS val profileSwitch = repository.getEffectiveProfileSwitchActiveAt(dateUtil.now()).blockingGet() if (profileSwitch is ValueWrapper.Existing && r.enacted && hasNsId && !config.NSCLIENT) { - if (smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) + if (smsCommunicatorPlugin.isEnabled()) smsCommunicatorPlugin.sendNotificationToAllNumbers(rh.gs(R.string.profile_set_ok)) } } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index 4de8c0d810..e79221c2c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -170,7 +170,7 @@ class SWDefinition @Inject constructor( configBuilder.performPluginSwitch(nsClientPlugin, true, PluginType.GENERAL) rxBus.send(EventSWUpdate(true)) } - .visibility { !nsClientPlugin.isEnabled(PluginType.GENERAL) }) + .visibility { !nsClientPlugin.isEnabled() }) .add(SWEditUrl(injector) .preferenceId(R.string.key_nsclientinternal_url) .updateDelay(5) @@ -343,9 +343,9 @@ class SWDefinition @Inject constructor( configBuilder.performPluginSwitch(loopPlugin, true, PluginType.LOOP) rxBus.send(EventSWUpdate(true)) } - .visibility { !loopPlugin.isEnabled(PluginType.LOOP) }) - .validator { loopPlugin.isEnabled(PluginType.LOOP) } - .visibility { !loopPlugin.isEnabled(PluginType.LOOP) && config.APS } + .visibility { !loopPlugin.isEnabled() }) + .validator { loopPlugin.isEnabled() } + .visibility { !loopPlugin.isEnabled() && config.APS } private val screenSensitivity = SWScreen(injector, R.string.configbuilder_sensitivity) .skippable(false) .add(SWInfoText(injector) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt b/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt index 73a27bfe6b..90f9af31c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt @@ -79,7 +79,7 @@ class AndroidPermission @Inject constructor( @Synchronized fun notifyForSMSPermissions(activity: FragmentActivity, smsCommunicatorPlugin: SmsCommunicatorPlugin) { - if (smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) { + if (smsCommunicatorPlugin.isEnabled()) { if (permissionNotGranted(activity, Manifest.permission.RECEIVE_SMS)) { val notification = NotificationWithAction(injector, Notification.PERMISSION_SMS, rh.gs(R.string.smscommunicator_missingsmspermission), Notification.URGENT) notification.action(R.string.request) { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index f0726fb1d0..ccdef22e95 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -373,7 +373,7 @@ class BolusWizard @Inject constructor( if (insulinAfterConstraints > 0 || carbs > 0) { if (useSuperBolus) { uel.log(Action.SUPERBOLUS_TBR, Sources.WizardDialog) - if (loopPlugin.isEnabled(PluginType.LOOP)) { + if (loopPlugin.isEnabled()) { loopPlugin.goToZeroTemp(2 * 60, profile, OfflineEvent.Reason.SUPER_BOLUS) rxBus.send(EventRefreshOverview("WizardDialog")) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt index 4114996027..50f7692b8d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt @@ -71,13 +71,13 @@ class LoopPluginTest : TestBase() { Assert.assertEquals(R.xml.pref_loop.toLong(), loopPlugin.preferencesId.toLong()) // Plugin is disabled by default - Assert.assertEquals(false, loopPlugin.isEnabled(PluginType.LOOP)) + Assert.assertEquals(false, loopPlugin.isEnabled()) loopPlugin.setPluginEnabled(PluginType.LOOP, true) - Assert.assertEquals(true, loopPlugin.isEnabled(PluginType.LOOP)) + Assert.assertEquals(true, loopPlugin.isEnabled()) // No temp basal capable pump should disable plugin virtualPumpPlugin.pumpDescription.isTempBasalCapable = false - Assert.assertEquals(false, loopPlugin.isEnabled(PluginType.LOOP)) + Assert.assertEquals(false, loopPlugin.isEnabled()) virtualPumpPlugin.pumpDescription.isTempBasalCapable = true // Fragment is hidden by default diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 8c9ed1fb89..186c7a4465 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -465,7 +465,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) //NSCLIENT RESTART - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) + `when`(loopPlugin.isEnabled()).thenReturn(true) `when`(loopPlugin.isSuspended).thenReturn(false) smsCommunicatorPlugin.messages = ArrayList() sms = Sms("1234", "NSCLIENT RESTART") @@ -475,7 +475,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("NSCLIENT RESTART")) //NSCLIENT BLA BLA - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) + `when`(loopPlugin.isEnabled()).thenReturn(true) `when`(loopPlugin.isSuspended).thenReturn(false) smsCommunicatorPlugin.messages = ArrayList() sms = Sms("1234", "NSCLIENT BLA BLA") @@ -485,7 +485,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) //NSCLIENT BLABLA - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) + `when`(loopPlugin.isEnabled()).thenReturn(true) `when`(loopPlugin.isSuspended).thenReturn(false) smsCommunicatorPlugin.messages = ArrayList() sms = Sms("1234", "NSCLIENT BLABLA") diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt index 3b47c4670a..0aa41d107e 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt @@ -63,7 +63,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isLoopInvocationAllowed(value) } return value @@ -73,7 +73,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isClosedLoopAllowed(value) } return value @@ -83,7 +83,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isLgsAllowed(value) } return value @@ -93,7 +93,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isAutosensModeEnabled(value) } return value @@ -103,7 +103,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isSMBModeEnabled(value) } return value @@ -113,7 +113,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isUAMEnabled(value) } return value @@ -123,7 +123,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isAdvancedFilteringEnabled(value) } return value @@ -133,7 +133,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isSuperBolusEnabled(value) } return value @@ -143,7 +143,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.applyBasalConstraints(absoluteRate, profile) } return absoluteRate @@ -153,7 +153,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constrain = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constrain.applyBasalPercentConstraints(percentRate, profile) } return percentRate @@ -163,7 +163,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constrain = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constrain.applyBolusConstraints(insulin) } return insulin @@ -173,7 +173,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constrain = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constrain.applyExtendedBolusConstraints(insulin) } return insulin @@ -183,7 +183,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constrain = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constrain.applyCarbsConstraints(carbs) } return carbs @@ -193,7 +193,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constrain = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constrain.applyMaxIOBConstraints(maxIob) } return maxIob @@ -203,7 +203,7 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { val constraint = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + if (!p.isEnabled()) continue constraint.isAutomationEnabled(value) } return value diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingMeal.kt b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingMeal.kt index a6f4308314..10da26bab5 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingMeal.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgSettingMeal.kt @@ -31,7 +31,7 @@ class MsgSettingMeal( aapsLogger.debug(LTag.PUMPCOMM, "Block time: $blockTime") aapsLogger.debug(LTag.PUMPCOMM, "Is Config U/d: " + danaPump.isConfigUD) // DanaRKorean is not possible to set to 0.01 but it works when controlled from AAPS - if (danaRKoreanPlugin.isEnabled(PluginType.PUMP)) { + if (danaRKoreanPlugin.isEnabled()) { danaPump.basalStep = 0.01 } if (danaPump.basalStep != 0.01) { From aa58b37643453fc019024912f2b15ac25f5c0030 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 9 Nov 2021 18:13:41 +0100 Subject: [PATCH 3/3] call connectNewPump() in NSClient mode --- .../plugins/configBuilder/RunningConfiguration.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt index 0b4a573681..2e5b3871b5 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt @@ -25,7 +25,8 @@ class RunningConfiguration @Inject constructor( private val aapsLogger: AAPSLogger, private val config: Config, private val rh: ResourceHelper, - private val rxBus: RxBus + private val rxBus: RxBus, + private val pumpSync: PumpSync ) { private var counter = 0 @@ -96,9 +97,12 @@ class RunningConfiguration @Inject constructor( if (configuration.has("pump")) { val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GENERIC_AAPS.description) - sp.putString(R.string.key_virtualpump_type, pumpType) - activePlugin.activePump.pumpDescription.fillFor(PumpType.getByDescription(pumpType)) - aapsLogger.debug(LTag.CORE, "Changing pump type to $pumpType") + if (sp.getString(R.string.key_virtualpump_type, "fake") != pumpType) { + sp.putString(R.string.key_virtualpump_type, pumpType) + activePlugin.activePump.pumpDescription.fillFor(PumpType.getByDescription(pumpType)) + pumpSync.connectNewPump() + aapsLogger.debug(LTag.CORE, "Changing pump type to $pumpType") + } } if (configuration.has("overviewConfiguration"))