diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt index 78abec823f..c581a7a3ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt @@ -8,9 +8,11 @@ import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.events.EventConfigBuilderChange import info.nightscout.androidaps.events.EventRebuildTabs +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.logging.L.isEnabled import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui import info.nightscout.androidaps.utils.OKDialog.showConfirmation @@ -20,7 +22,7 @@ import org.slf4j.LoggerFactory /** * Created by mike on 09.06.2016. */ -abstract class PluginBase(public val pluginDescription: PluginDescription) { +abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: RxBusWrapper, val aapsLogger: AAPSLogger ) { companion object { private val log = LoggerFactory.getLogger(L.CORE) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index c05ed706b8..0bd57e4647 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -68,8 +68,6 @@ import io.reactivex.schedulers.Schedulers; @Singleton public class LoopPlugin extends PluginBase { - private final AAPSLogger aapsLogger; - private final RxBusWrapper rxBus; private final SP sp; private final ConstraintChecker constraintChecker; private final ResourceHelper resourceHelper; @@ -106,7 +104,7 @@ public class LoopPlugin extends PluginBase { @Inject public LoopPlugin( AAPSLogger aapsLogger, - RxBusWrapper rxBus, + RxBusWrapper rxBusWrapper, SP sp, ConstraintChecker constraintChecker, ResourceHelper resourceHelper, @@ -123,10 +121,9 @@ public class LoopPlugin extends PluginBase { .pluginName(R.string.loop) .shortName(R.string.loop_shortname) .preferencesId(R.xml.pref_loop) - .description(R.string.description_loop) + .description(R.string.description_loop), + rxBusWrapper, aapsLogger ); - this.aapsLogger = aapsLogger; - this.rxBus = rxBus; this.sp = sp; this.constraintChecker = constraintChecker; this.resourceHelper = resourceHelper; @@ -146,7 +143,7 @@ public class LoopPlugin extends PluginBase { protected void onStart() { createNotificationChannel(); super.onStart(); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventTempTargetChange.class) .observeOn(Schedulers.io()) .subscribe(event -> invoke("EventTempTargetChange", true), exception -> FabricPrivacy.getInstance().logException(exception)) @@ -158,7 +155,7 @@ public class LoopPlugin extends PluginBase { * the event causing the calculation is not EventNewBg. *

*/ - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventAutosensCalculationFinished.class) .observeOn(Schedulers.io()) .subscribe(event -> { @@ -294,13 +291,13 @@ public class LoopPlugin extends PluginBase { public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) { try { - aapsLogger.debug(LTag.APS, "invoke from " + initiator); + getAapsLogger().debug(LTag.APS, "invoke from " + initiator); Constraint loopEnabled = constraintChecker.isLoopInvocationAllowed(); if (!loopEnabled.value()) { String message = resourceHelper.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons(); - aapsLogger.debug(LTag.APS, message); - rxBus.send(new EventLoopSetLastRunGui(message)); + getAapsLogger().debug(LTag.APS, message); + getRxBus().send(new EventLoopSetLastRunGui(message)); return; } final PumpInterface pump = configBuilderPlugin.getActivePump(); @@ -315,8 +312,8 @@ public class LoopPlugin extends PluginBase { if (profile == null || !profileFunction.isProfileValid("Loop")) { if (L.isEnabled(L.APS)) - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected)); - rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected)); + getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected))); return; } @@ -331,7 +328,7 @@ public class LoopPlugin extends PluginBase { // Check if we have any result if (result == null) { - rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected))); + getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected))); return; } @@ -355,7 +352,7 @@ public class LoopPlugin extends PluginBase { // safety check for multiple SMBs long lastBolusTime = treatmentsPlugin.getLastBolusTime(); if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > System.currentTimeMillis()) { - aapsLogger.debug(LTag.APS, "SMB requsted but still in 3 min interval"); + getAapsLogger().debug(LTag.APS, "SMB requsted but still in 3 min interval"); resultAfterConstraints.smb = 0; } @@ -370,14 +367,14 @@ public class LoopPlugin extends PluginBase { NSUpload.uploadDeviceStatus(this); if (isSuspended()) { - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended)); - rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended)); + getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended))); return; } if (pump.isSuspended()) { - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended)); - rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended)); + getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended))); return; } @@ -393,7 +390,7 @@ public class LoopPlugin extends PluginBase { lastRun.tbrSetByPump = waiting; if (resultAfterConstraints.bolusRequested) lastRun.smbSetByPump = waiting; - rxBus.send(new EventLoopUpdateGui()); + getRxBus().send(new EventLoopUpdateGui()); FabricPrivacy.getInstance().logCustom("APSRequest"); applyTBRRequest(resultAfterConstraints, profile, new Callback() { @Override @@ -414,11 +411,11 @@ public class LoopPlugin extends PluginBase { invoke("tempBasalFallback", allowNotification, true); }).start(); } - rxBus.send(new EventLoopUpdateGui()); + getRxBus().send(new EventLoopUpdateGui()); } }); } - rxBus.send(new EventLoopUpdateGui()); + getRxBus().send(new EventLoopUpdateGui()); } }); } else { @@ -459,7 +456,7 @@ public class LoopPlugin extends PluginBase { (NotificationManager) mainApp.getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(Constants.notificationID, builder.build()); - rxBus.send(new EventNewOpenLoopNotification()); + getRxBus().send(new EventNewOpenLoopNotification()); // Send to Wear actionStringHandler.get().handleInitiate("changeRequest"); @@ -472,9 +469,9 @@ public class LoopPlugin extends PluginBase { } } - rxBus.send(new EventLoopUpdateGui()); + getRxBus().send(new EventLoopUpdateGui()); } finally { - aapsLogger.debug(LTag.APS, "invoke end"); + getAapsLogger().debug(LTag.APS, "invoke end"); } } @@ -491,7 +488,7 @@ public class LoopPlugin extends PluginBase { NSUpload.uploadDeviceStatus(lp); sp.incInt(R.string.key_ObjectivesmanualEnacts); } - rxBus.send(new EventAcceptOpenLoopChange()); + getRxBus().send(new EventAcceptOpenLoopChange()); } }); FabricPrivacy.getInstance().logCustom("AcceptTemp"); @@ -520,7 +517,7 @@ public class LoopPlugin extends PluginBase { } if (!pump.isInitialized()) { - aapsLogger.debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpNotInitialized)); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpNotInitialized)); if (callback != null) { callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); } @@ -528,24 +525,24 @@ public class LoopPlugin extends PluginBase { } if (pump.isSuspended()) { - aapsLogger.debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpsuspended)); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpsuspended)); if (callback != null) { callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false)).run(); } return; } - aapsLogger.debug(LTag.APS, "applyAPSRequest: " + request.toString()); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: " + request.toString()); long now = System.currentTimeMillis(); TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now); if (request.usePercent && allowPercentage) { if (request.percent == 100 && request.duration == 0) { if (activeTemp != null) { - aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()"); configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback); } else { - aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly"); if (callback != null) { callback.result(new PumpEnactResult().percent(request.percent).duration(0) .enacted(false).success(true).comment(resourceHelper.gs(R.string.basal_set_correctly))).run(); @@ -555,23 +552,23 @@ public class LoopPlugin extends PluginBase { && activeTemp.getPlannedRemainingMinutes() > 5 && request.duration - activeTemp.getPlannedRemainingMinutes() < 30 && request.percent == activeTemp.percentRate) { - aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: Temp basal set correctly"); if (callback != null) { callback.result(new PumpEnactResult().percent(request.percent) .enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes()) .comment(resourceHelper.gs(R.string.let_temp_basal_run))).run(); } } else { - aapsLogger.debug(LTag.APS, "applyAPSRequest: tempBasalPercent()"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: tempBasalPercent()"); configBuilderPlugin.getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback); } } else { if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) { if (activeTemp != null) { - aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()"); configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback); } else { - aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly"); if (callback != null) { callback.result(new PumpEnactResult().absolute(request.rate).duration(0) .enacted(false).success(true).comment(resourceHelper.gs(R.string.basal_set_correctly))).run(); @@ -581,14 +578,14 @@ public class LoopPlugin extends PluginBase { && activeTemp.getPlannedRemainingMinutes() > 5 && request.duration - activeTemp.getPlannedRemainingMinutes() < 30 && Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) { - aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: Temp basal set correctly"); if (callback != null) { callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile)) .enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes()) .comment(resourceHelper.gs(R.string.let_temp_basal_run))).run(); } } else { - aapsLogger.debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()"); configBuilderPlugin.getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback); } } @@ -608,7 +605,7 @@ public class LoopPlugin extends PluginBase { long lastBolusTime = treatmentsPlugin.getLastBolusTime(); if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { - aapsLogger.debug(LTag.APS, "SMB requested but still in 3 min interval"); + getAapsLogger().debug(LTag.APS, "SMB requested but still in 3 min interval"); if (callback != null) { callback.result(new PumpEnactResult() .comment(resourceHelper.gs(R.string.smb_frequency_exceeded)) @@ -618,7 +615,7 @@ public class LoopPlugin extends PluginBase { } if (!pump.isInitialized()) { - aapsLogger.debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpNotInitialized)); + getAapsLogger().debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpNotInitialized)); if (callback != null) { callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); } @@ -626,14 +623,14 @@ public class LoopPlugin extends PluginBase { } if (pump.isSuspended()) { - aapsLogger.debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpsuspended)); + getAapsLogger().debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpsuspended)); if (callback != null) { callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false)).run(); } return; } - aapsLogger.debug(LTag.APS, "applySMBRequest: " + request.toString()); + getAapsLogger().debug(LTag.APS, "applySMBRequest: " + request.toString()); // deliver SMB DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); @@ -643,7 +640,7 @@ public class LoopPlugin extends PluginBase { detailedBolusInfo.isSMB = true; detailedBolusInfo.source = Source.USER; detailedBolusInfo.deliverAt = request.deliverAt; - aapsLogger.debug(LTag.APS, "applyAPSRequest: bolus()"); + getAapsLogger().debug(LTag.APS, "applyAPSRequest: bolus()"); configBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, callback); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java index e67a265e8e..2b8f4fd984 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.java @@ -74,7 +74,8 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { .pluginName(R.string.openapsama) .shortName(R.string.oaps_shortname) .preferencesId(R.xml.pref_openapsama) - .description(R.string.description_ama) + .description(R.string.description_ama), + rxBus, aapsLogger ); this.aapsLogger = aapsLogger; this.rxBus = rxBus; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java index 7fbbf60335..c18c80a6db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSMA/OpenAPSMAPlugin.java @@ -41,8 +41,6 @@ import static info.nightscout.androidaps.utils.HardLimits.verifyHardLimits; @Singleton public class OpenAPSMAPlugin extends PluginBase implements APSInterface { - private final AAPSLogger aapsLogger; - private final RxBusWrapper rxBus; private final ConstraintChecker constraintChecker; private final ResourceHelper resourceHelper; private final ProfileFunction profileFunction; @@ -59,7 +57,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { @Inject public OpenAPSMAPlugin( AAPSLogger aapsLogger, - RxBusWrapper rxBus, + RxBusWrapper rxBusWrapper, ConstraintChecker constraintChecker, ResourceHelper resourceHelper, ProfileFunction profileFunction, @@ -69,15 +67,15 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { IobCobCalculatorPlugin iobCobCalculatorPlugin ) { super(new PluginDescription() - .mainType(PluginType.APS) - .fragmentClass(OpenAPSMAFragment.class.getName()) - .pluginName(R.string.openapsma) - .shortName(R.string.oaps_shortname) - .preferencesId(R.xml.pref_openapsma) - .description(R.string.description_ma) + .mainType(PluginType.APS) + .fragmentClass(OpenAPSMAFragment.class.getName()) + .pluginName(R.string.openapsma) + .shortName(R.string.oaps_shortname) + .preferencesId(R.xml.pref_openapsma) + .description(R.string.description_ma), + rxBusWrapper, aapsLogger ); - this.aapsLogger = aapsLogger; - this.rxBus = rxBus; + this.constraintChecker = constraintChecker; this.resourceHelper = resourceHelper; this.profileFunction = profileFunction; @@ -111,36 +109,36 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { @Override public void invoke(String initiator, boolean tempBasalFallback) { - aapsLogger.debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); + getAapsLogger().debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); lastAPSResult = null; DetermineBasalAdapterMAJS determineBasalAdapterMAJS; - determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(mainApp), aapsLogger); + determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(mainApp), getAapsLogger()); GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); Profile profile = profileFunction.getProfile(); PumpInterface pump = configBuilderPlugin.getActivePump(); if (profile == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected)); return; } if (pump == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected)); return; } if (!isEnabled(PluginType.APS)) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata)); return; } @@ -164,7 +162,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { MealData mealData = iobCobCalculatorPlugin.getMealData(); double maxIob = constraintChecker.getMaxIOBAllowed().value(); - Profiler.log(aapsLogger, LTag.APS, "MA data gathering", start); + Profiler.log(getAapsLogger(), LTag.APS, "MA data gathering", start); minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]); maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]); @@ -195,14 +193,14 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { FabricPrivacy.getInstance().logException(e); return; } - Profiler.log(aapsLogger, LTag.APS, "MA calculation", start); + Profiler.log(getAapsLogger(), LTag.APS, "MA calculation", start); long now = System.currentTimeMillis(); DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke(); if (determineBasalResultMA == null) { - aapsLogger.error(LTag.APS, "MA calculation returned null"); + getAapsLogger().error(LTag.APS, "MA calculation returned null"); lastDetermineBasalAdapterMAJS = null; lastAPSResult = null; lastAPSRun = 0; @@ -216,14 +214,14 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { try { determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now)); } catch (JSONException e) { - aapsLogger.error(LTag.APS, "Unhandled exception", e); + getAapsLogger().error(LTag.APS, "Unhandled exception", e); } lastDetermineBasalAdapterMAJS = determineBasalAdapterMAJS; lastAPSResult = determineBasalResultMA; lastAPSRun = now; } - rxBus.send(new EventOpenAPSUpdateGui()); + getRxBus().send(new EventOpenAPSUpdateGui()); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java index 10040543dd..7915a888c3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.java @@ -45,8 +45,6 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper; @Singleton public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, ConstraintsInterface { - private final AAPSLogger aapsLogger; - private final RxBusWrapper rxBus; private final ConstraintChecker constraintChecker; private final ResourceHelper resourceHelper; private final ProfileFunction profileFunction; @@ -76,7 +74,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr @Inject public OpenAPSSMBPlugin( AAPSLogger aapsLogger, - RxBusWrapper rxBus, + RxBusWrapper rxBusWrapper, ConstraintChecker constraintChecker, ResourceHelper resourceHelper, ProfileFunction profileFunction, @@ -84,19 +82,18 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr ConfigBuilderPlugin configBuilderPlugin, TreatmentsPlugin treatmentsPlugin, IobCobCalculatorPlugin iobCobCalculatorPlugin - - ) { + ) { super(new PluginDescription() - .mainType(PluginType.APS) - .fragmentClass(OpenAPSSMBFragment.class.getName()) - .pluginName(R.string.openapssmb) - .shortName(R.string.smb_shortname) - .preferencesId(R.xml.pref_openapssmb) - .description(R.string.description_smb) + .mainType(PluginType.APS) + .fragmentClass(OpenAPSSMBFragment.class.getName()) + .pluginName(R.string.openapssmb) + .shortName(R.string.smb_shortname) + .preferencesId(R.xml.pref_openapssmb) + .description(R.string.description_smb), + rxBusWrapper, aapsLogger ); this.openAPSSMBPlugin = this; // TODO: only while transitioning to Dagger - this.aapsLogger = aapsLogger; - this.rxBus = rxBus; + this.constraintChecker = constraintChecker; this.resourceHelper = resourceHelper; this.profileFunction = profileFunction; @@ -130,36 +127,36 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr @Override public void invoke(String initiator, boolean tempBasalFallback) { - aapsLogger.debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); + getAapsLogger().debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); lastAPSResult = null; DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS; - determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(mainApp), aapsLogger); + determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(mainApp), getAapsLogger()); GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); Profile profile = profileFunction.getProfile(); PumpInterface pump = configBuilderPlugin.getActivePump(); if (profile == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected)); return; } if (pump == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected)); return; } if (!isEnabled(PluginType.APS)) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata))); - aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata)); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata))); + getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata)); return; } @@ -179,7 +176,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr long startPart = System.currentTimeMillis(); MealData mealData = iobCobCalculatorPlugin.getMealData(); - Profiler.log(aapsLogger, LTag.APS, "getMealData()", startPart); + Profiler.log(getAapsLogger(), LTag.APS, "getMealData()", startPart); Constraint maxIOBAllowedConstraint = constraintChecker.getMaxIOBAllowed(); inputConstraints.copyReasons(maxIOBAllowedConstraint); @@ -214,7 +211,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr if (constraintChecker.isAutosensModeEnabled().value()) { AutosensData autosensData = iobCobCalculatorPlugin.getLastAutosensDataSynchronized("OpenAPSPlugin"); if (autosensData == null) { - rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openaps_noasdata))); + getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openaps_noasdata))); return; } lastAutosensResult = autosensData.autosensResult; @@ -224,7 +221,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr } IobTotal[] iobArray = iobCobCalculatorPlugin.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget); - Profiler.log(aapsLogger, LTag.APS, "calculateIobArrayInDia()", startPart); + Profiler.log(getAapsLogger(), LTag.APS, "calculateIobArrayInDia()", startPart); startPart = System.currentTimeMillis(); Constraint smbAllowed = new Constraint<>(!tempBasalFallback); @@ -239,8 +236,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr constraintChecker.isUAMEnabled(uam); inputConstraints.copyReasons(uam); - Profiler.log(aapsLogger, LTag.APS, "detectSensitivityandCarbAbsorption()", startPart); - Profiler.log(aapsLogger, LTag.APS, "SMB data gathering", start); + Profiler.log(getAapsLogger(), LTag.APS, "detectSensitivityandCarbAbsorption()", startPart); + Profiler.log(getAapsLogger(), LTag.APS, "SMB data gathering", start); start = System.currentTimeMillis(); try { @@ -259,9 +256,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr long now = System.currentTimeMillis(); DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke(); - Profiler.log(aapsLogger, LTag.APS, "SMB calculation", start); + Profiler.log(getAapsLogger(), LTag.APS, "SMB calculation", start); if (determineBasalResultSMB == null) { - aapsLogger.error(LTag.APS, "SMB calculation returned null"); + getAapsLogger().error(LTag.APS, "SMB calculation returned null"); lastDetermineBasalAdapterSMBJS = null; lastAPSResult = null; lastAPSRun = 0; @@ -276,7 +273,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr try { determineBasalResultSMB.json.put("timestamp", DateUtil.toISOString(now)); } catch (JSONException e) { - aapsLogger.error(LTag.APS, "Unhandled exception", e); + getAapsLogger().error(LTag.APS, "Unhandled exception", e); } determineBasalResultSMB.inputConstraints = inputConstraints; @@ -285,7 +282,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr lastAPSResult = determineBasalResultSMB; lastAPSRun = now; } - rxBus.send(new EventOpenAPSUpdateGui()); + getRxBus().send(new EventOpenAPSUpdateGui()); //deviceStatus.suggested = determineBasalResultAMA.json; } @@ -303,7 +300,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr String msg = String.format(resourceHelper.gs(R.string.valueoutofrange), valueName); msg += ".\n"; msg += String.format(resourceHelper.gs(R.string.valuelimitedto), value, newvalue); - aapsLogger.error(LTag.APS, msg); + getAapsLogger().error(LTag.APS, msg); NSUpload.uploadError(msg); ToastUtils.showToastInUiThread(mainApp, msg, R.raw.error); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.java index 53e8c3d7e8..daa490e75c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.java @@ -40,9 +40,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; @Singleton public class ConfigBuilderPlugin extends PluginBase { private static ConfigBuilderPlugin configBuilderPlugin; - private final AAPSLogger aapsLogger; // TODO move to plugin base - private final SP sp; - private final RxBusWrapper rxBus; + private final SP sp; /** @@ -82,26 +80,24 @@ public class ConfigBuilderPlugin extends PluginBase { Lazy insulinOrefRapidActingPlugin, Lazy localProfilePlugin, Lazy virtualPumpPlugin, - AAPSLogger aapsLogger, SP sp, - RxBusWrapper rxBus - ) { + RxBusWrapper rxBus, + AAPSLogger aapsLogger) { super(new PluginDescription() - .mainType(PluginType.GENERAL) - .fragmentClass(ConfigBuilderFragment.class.getName()) - .showInList(true) - .alwaysEnabled(true) - .alwaysVisible(false) - .pluginName(R.string.configbuilder) - .shortName(R.string.configbuilder_shortname) - .description(R.string.description_config_builder) + .mainType(PluginType.GENERAL) + .fragmentClass(ConfigBuilderFragment.class.getName()) + .showInList(true) + .alwaysEnabled(true) + .alwaysVisible(false) + .pluginName(R.string.configbuilder) + .shortName(R.string.configbuilder_shortname) + .description(R.string.description_config_builder), + rxBus, aapsLogger ); this.insulinOrefRapidActingPlugin = insulinOrefRapidActingPlugin; this.localProfilePlugin = localProfilePlugin; this.virtualPumpPlugin = virtualPumpPlugin; - this.aapsLogger = aapsLogger; this.sp = sp; - this.rxBus =rxBus; configBuilderPlugin = this; // TODO: only while transitioning to Dagger } @@ -123,7 +119,7 @@ public class ConfigBuilderPlugin extends PluginBase { public void storeSettings(String from) { if (pluginList != null) { - aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: " + from); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing settings from: " + from); verifySelectionInCategories(); @@ -146,16 +142,16 @@ public class ConfigBuilderPlugin extends PluginBase { private void savePref(PluginBase p, PluginType type, boolean storeVisible) { String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled"; sp.putBoolean(settingEnabled, p.isEnabled(type)); - aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type)); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type)); if (storeVisible) { String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible"; sp.putBoolean(settingVisible, p.isFragmentVisible()); - aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible()); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible()); } } private void loadSettings() { - aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings"); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Loading stored settings"); for (PluginBase p : pluginList) { PluginType type = p.getType(); loadPref(p, type, true); @@ -175,7 +171,7 @@ public class ConfigBuilderPlugin extends PluginBase { else if (p.getType() == type && (p.getPluginDescription().enableByDefault || p.getPluginDescription().alwaysEnabled)) { p.setPluginEnabled(type, true); } - aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type)); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type)); if (loadVisible) { String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible"; if (sp.contains(settingVisible)) @@ -183,7 +179,7 @@ public class ConfigBuilderPlugin extends PluginBase { else if (p.getType() == type && p.getPluginDescription().visibleByDefault) { p.setFragmentVisible(type, true); } - aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible()); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible()); } } @@ -191,9 +187,9 @@ public class ConfigBuilderPlugin extends PluginBase { private void upgradeSettings() { if (!sp.contains("ConfigBuilder_1_NSProfilePlugin_Enabled")) return; - aapsLogger.debug(LTag.CONFIGBUILDER, "Upgrading stored settings"); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Upgrading stored settings"); for (PluginBase p : pluginList) { - aapsLogger.debug(LTag.CONFIGBUILDER, "Processing " + p.getName()); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Processing " + p.getName()); for (int type = 1; type < 11; type++) { PluginType newType; switch (type) { @@ -285,7 +281,7 @@ public class ConfigBuilderPlugin extends PluginBase { public void logPluginStatus() { for (PluginBase p : pluginList) { - aapsLogger.debug(LTag.CONFIGBUILDER, p.getName() + ":" + + getAapsLogger().debug(LTag.CONFIGBUILDER, p.getName() + ":" + (p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") + (p.isEnabled(PluginType.TREATMENT) ? " TREATMENT" : "") + (p.isEnabled(PluginType.SENSITIVITY) ? " SENSITIVITY" : "") + @@ -312,7 +308,7 @@ public class ConfigBuilderPlugin extends PluginBase { if (activeInsulin == null) { activeInsulin = insulinOrefRapidActingPlugin.get(); insulinOrefRapidActingPlugin.get().setPluginEnabled(PluginType.INSULIN, true); - aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting InsulinOrefRapidActingPlugin"); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting InsulinOrefRapidActingPlugin"); } this.setFragmentVisiblities(((PluginBase) activeInsulin).getName(), pluginsInCategory, PluginType.INSULIN); @@ -322,7 +318,7 @@ public class ConfigBuilderPlugin extends PluginBase { if (activeSensitivity == null) { activeSensitivity = SensitivityOref0Plugin.getPlugin(); SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true); - aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin"); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin"); } this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY); @@ -338,7 +334,7 @@ public class ConfigBuilderPlugin extends PluginBase { if (activePump == null) { activePump = virtualPumpPlugin.get(); virtualPumpPlugin.get().setPluginEnabled(PluginType.PUMP, true); - aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting VirtualPumpPlugin"); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting VirtualPumpPlugin"); } this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP); @@ -396,7 +392,7 @@ public class ConfigBuilderPlugin extends PluginBase { private void setFragmentVisiblities(String activePluginName, ArrayList pluginsInCategory, PluginType pluginType) { - aapsLogger.debug(LTag.CONFIGBUILDER, "Selected interface: " + activePluginName); + getAapsLogger().debug(LTag.CONFIGBUILDER, "Selected interface: " + activePluginName); for (PluginBase p : pluginsInCategory) { if (!p.getName().equals(activePluginName)) { p.setFragmentVisible(pluginType, false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.kt index 91925e598c..90d3be398f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.kt @@ -23,22 +23,23 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class DstHelperPlugin @Inject constructor(): PluginBase(PluginDescription() +class DstHelperPlugin @Inject constructor( + aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, + var resourceHelper: ResourceHelper, + var mainApp: MainApp, + var sp: SP, + var configBuilderPlugin: ConfigBuilderPlugin, + var loopPlugin: LoopPlugin + ) : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) .neverVisible(true) .alwaysEnabled(true) .showInList(false) - .pluginName(R.string.dst_plugin_name) + .pluginName(R.string.dst_plugin_name), + rxBus, aapsLogger ), ConstraintsInterface { - @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var rxBus: RxBusWrapper - @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var mainApp: MainApp - @Inject lateinit var sp : SP - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin - @Inject lateinit var loopPlugin: LoopPlugin - private val DISABLE_TIMEFRAME_HOURS = -3 private val WARN_PRIOR_TIMEFRAME_HOURS = 12 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index acd8b83a13..5ea50555c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -11,6 +11,8 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* import info.nightscout.androidaps.utils.DateUtil @@ -25,7 +27,9 @@ import javax.inject.Singleton class ObjectivesPlugin @Inject constructor( private val sp: SP, private val resourceHelper: ResourceHelper, - private val configBuilderPlugin: ConfigBuilderPlugin + private val configBuilderPlugin: ConfigBuilderPlugin, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger + ) : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) .fragmentClass(ObjectivesFragment::class.qualifiedName) @@ -33,7 +37,9 @@ class ObjectivesPlugin @Inject constructor( .showInList(Config.APS) .pluginName(R.string.objectives) .shortName(R.string.objectives_shortname) - .description(R.string.description_objectives)), ConstraintsInterface { + .description(R.string.description_objectives), + rxBus, aapsLogger +), ConstraintsInterface { var objectives: MutableList = ArrayList() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java index 12f150e6eb..16006bd40b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.java @@ -15,10 +15,12 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; @@ -32,6 +34,8 @@ import info.nightscout.androidaps.utils.SP; @Singleton public class SafetyPlugin extends PluginBase implements ConstraintsInterface { + //TODO: dagger + @Inject OpenAPSAMAPlugin openAPSAMAPlugin; @@ -42,14 +46,14 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { OpenAPSSMBPlugin openAPSSMBPlugin; @Inject - public SafetyPlugin() { + public SafetyPlugin(RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) { super(new PluginDescription() .mainType(PluginType.CONSTRAINTS) .neverVisible(true) .alwaysEnabled(true) .showInList(false) .pluginName(R.string.safety) - .preferencesId(R.xml.pref_safety) + .preferencesId(R.xml.pref_safety), rxBusWrapper, aapsLogger ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.kt index 11c1c43fa2..7ff7e36f01 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.kt @@ -8,6 +8,7 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -34,15 +35,17 @@ import javax.inject.Singleton @Singleton class SignatureVerifierPlugin @Inject constructor( private val sp: SP, - private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, - private val mainApp: MainApp + private val mainApp: MainApp, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) .neverVisible(true) .alwaysEnabled(true) .showInList(false) - .pluginName(R.string.signature_verifier)), ConstraintsInterface { + .pluginName(R.string.signature_verifier), + rxBus, aapsLogger +), ConstraintsInterface { private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/src/main/assets/revoked_certs.txt" private val UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(1) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/storage/StorageConstraintPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/storage/StorageConstraintPlugin.java index e5111b9a5b..0d1c2bab68 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/storage/StorageConstraintPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/storage/StorageConstraintPlugin.java @@ -16,8 +16,10 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; @@ -36,13 +38,16 @@ public class StorageConstraintPlugin extends PluginBase implements ConstraintsIn return plugin; } + // TODO: dagger + public StorageConstraintPlugin() { super(new PluginDescription() - .mainType(PluginType.CONSTRAINTS) - .neverVisible(true) - .alwaysEnabled(true) - .showInList(false) - .pluginName(R.string.storage) + .mainType(PluginType.CONSTRAINTS) + .neverVisible(true) + .alwaysEnabled(true) + .showInList(false) + .pluginName(R.string.storage), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt index 8ec5a156d9..f4ff61319f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification @@ -20,16 +21,18 @@ import kotlin.math.roundToInt @Singleton class VersionCheckerPlugin @Inject constructor( - private val rxBus: RxBusWrapper, private val sp: SP, private val resourceHelper: ResourceHelper, - private val versionCheckerUtils: VersionCheckerUtils + private val versionCheckerUtils: VersionCheckerUtils, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) .neverVisible(true) .alwaysEnabled(true) .showInList(false) - .pluginName(R.string.versionChecker)), ConstraintsInterface { + .pluginName(R.string.versionChecker), + rxBus, aapsLogger +), ConstraintsInterface { enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) { RELEASE(30, 60, 90), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt index 92247c6295..ab0f0c0ef0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt @@ -5,15 +5,20 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import javax.inject.Inject import javax.inject.Singleton @Singleton -class ActionsPlugin @Inject constructor(): PluginBase(PluginDescription() - .mainType(PluginType.GENERAL) - .fragmentClass(ActionsFragment::class.qualifiedName) - .enableByDefault(Config.APS || Config.PUMPCONTROL) - .visibleByDefault(Config.APS || Config.PUMPCONTROL) - .pluginName(R.string.actions) - .shortName(R.string.actions_shortname) - .description(R.string.description_actions)) +class ActionsPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : PluginBase(PluginDescription() + .mainType(PluginType.GENERAL) + .fragmentClass(ActionsFragment::class.qualifiedName) + .enableByDefault(Config.APS || Config.PUMPCONTROL) + .visibleByDefault(Config.APS || Config.PUMPCONTROL) + .pluginName(R.string.actions) + .shortName(R.string.actions_shortname) + .description(R.string.description_actions), + rxBus, aapsLogger +) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index 5b6bf4e3e8..dc56d305b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -40,20 +40,20 @@ import javax.inject.Singleton @Singleton class AutomationPlugin @Inject constructor( - private val rxBus: RxBusWrapper, - private val aapsLogger: AAPSLogger, private val resourceHelper: ResourceHelper, private val mainApp: MainApp, private val sp: SP, private val fabricPrivacy: FabricPrivacy, - private val loopPlugin: LoopPlugin + private val loopPlugin: LoopPlugin, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(AutomationFragment::class.qualifiedName) .pluginName(R.string.automation) .shortName(R.string.automation_short) .preferencesId(R.xml.pref_automation) - .description(R.string.automation_description)) { + .description(R.string.automation_description), rxBus, aapsLogger +) { private var disposable: CompositeDisposable = CompositeDisposable() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt index 184db3c1cf..c7e921e36d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/careportal/CareportalPlugin.kt @@ -5,18 +5,23 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import javax.inject.Inject import javax.inject.Singleton @Singleton -class CareportalPlugin @Inject constructor() : PluginBase(PluginDescription() +class CareportalPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(CareportalFragment::class.java.name) .pluginName(R.string.careportal) .shortName(R.string.careportal_shortname) .visibleByDefault(Config.NSCLIENT) .enableByDefault(Config.NSCLIENT) - .description(R.string.description_careportal) + .description(R.string.description_careportal), + rxBus, aapsLogger + ) { override fun specialEnableCondition(): Boolean { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt index 55705a4d9f..3758090cbf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt @@ -4,16 +4,20 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import javax.inject.Inject import javax.inject.Singleton @Singleton -class FoodPlugin @Inject constructor() : PluginBase(PluginDescription() +class FoodPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(FoodFragment::class.java.name) .pluginName(R.string.food) .shortName(R.string.food_short) - .description(R.string.description_food) + .description(R.string.description_food), + rxBus, aapsLogger ) { var service: FoodService? = null diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt index 54364ec2fb..082c1aa581 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenancePlugin.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -23,11 +24,11 @@ import javax.inject.Singleton @Singleton class MaintenancePlugin @Inject constructor( - private val aapsLogger: AAPSLogger, private val mainApp: MainApp, private val resourceHelper: ResourceHelper, private val sp: SP, - private val nsSettingsStatus: NSSettingsStatus + private val nsSettingsStatus: NSSettingsStatus, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(MaintenanceFragment::class.java.name) @@ -36,7 +37,8 @@ class MaintenancePlugin @Inject constructor( .pluginName(R.string.maintenance) .shortName(R.string.maintenance_shortname) .preferencesId(R.xml.pref_maintenance) - .description(R.string.description_maintenance) + .description(R.string.description_maintenance), + rxBus, aapsLogger ) { fun sendLogs() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index a8c41048ad..a056c7a726 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -30,8 +30,10 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.data.AlarmAck; import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog; @@ -71,6 +73,8 @@ public class NSClientPlugin extends PluginBase { private NsClientReceiverDelegate nsClientReceiverDelegate; + // TODO: dagger + private NSClientPlugin() { super(new PluginDescription() .mainType(PluginType.GENERAL) @@ -78,7 +82,8 @@ public class NSClientPlugin extends PluginBase { .pluginName(R.string.nsclientinternal) .shortName(R.string.nsclientinternal_shortname) .preferencesId(R.xml.pref_nsclientinternal) - .description(R.string.description_ns_client) + .description(R.string.description_ns_client), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); if (Config.NSCLIENT) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt index 6c5b73f979..8e30734dba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt @@ -5,6 +5,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -18,9 +19,9 @@ import javax.inject.Singleton @Singleton class OverviewPlugin @Inject constructor( - private val rxBus: RxBusWrapper, private val notificationStore: NotificationStore, - private val fabricPrivacy: FabricPrivacy + private val fabricPrivacy: FabricPrivacy, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(OverviewFragment::class.qualifiedName) @@ -29,7 +30,8 @@ class OverviewPlugin @Inject constructor( .pluginName(R.string.overview) .shortName(R.string.overview_shortname) .preferencesId(R.xml.pref_overview) - .description(R.string.description_overview)) { + .description(R.string.description_overview), rxBus, aapsLogger +) { private var disposable: CompositeDisposable = CompositeDisposable() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt index 8614f69948..2bdf8795b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.general.persistentNotification -import android.app.Notification import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent @@ -20,6 +19,7 @@ import info.nightscout.androidaps.events.* import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction @@ -36,25 +36,27 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class PersistentNotificationPlugin @Inject constructor() : PluginBase(PluginDescription() +class PersistentNotificationPlugin @Inject constructor( + var mainApp: MainApp, + var resourceHelper: ResourceHelper, + var profileFunction: ProfileFunction, + var fabricPrivacy: FabricPrivacy, + var configBuilderPlugin: ConfigBuilderPlugin, + var treatmentsPlugin: TreatmentsPlugin, + var iobCobCalculatorPlugin: IobCobCalculatorPlugin, + rxBus: RxBusWrapper, + aapsLogger: AAPSLogger +) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .neverVisible(true) .pluginName(R.string.ongoingnotificaction) .enableByDefault(true) .alwaysEnabled(true) .showInList(false) - .description(R.string.description_persistent_notification) + .description(R.string.description_persistent_notification), + rxBus, aapsLogger ) { - @Inject lateinit var rxBus: RxBusWrapper - @Inject lateinit var mainApp: MainApp - @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var profileFunction: ProfileFunction - @Inject lateinit var fabricPrivacy: FabricPrivacy - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin - @Inject lateinit var treatmentsPlugin: TreatmentsPlugin - @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin - // For Android Auto // Intents are not declared in manifest and not consumed, this is intentionally because actually we can't do anything with private val PACKAGE = "info.nightscout" @@ -66,7 +68,7 @@ class PersistentNotificationPlugin @Inject constructor() : PluginBase(PluginDesc private val disposable = CompositeDisposable() - override fun onStart() { + override fun onStart() { super.onStart() createNotificationChannel() // make sure channels exist before triggering updates through the bus disposable.add(rxBus diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 7a0bcbbd45..78326b4f24 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -55,8 +55,8 @@ class SmsCommunicatorPlugin @Inject constructor( private val sp: SP, private val resourceHelper: ResourceHelper, private val constraintChecker: ConstraintChecker, - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, + aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, private val profileFunction: ProfileFunction, private val fabricPrivacy: FabricPrivacy, private val configBuilderPlugin: ConfigBuilderPlugin, @@ -69,7 +69,8 @@ class SmsCommunicatorPlugin @Inject constructor( .pluginName(R.string.smscommunicator) .shortName(R.string.smscommunicator_shortname) .preferencesId(R.xml.pref_smscommunicator) - .description(R.string.description_sms_communicator) + .description(R.string.description_sms_communicator), + rxBus, aapsLogger ) { private val disposable = CompositeDisposable() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt index 29e23b58a8..663c408ee8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/TidepoolPlugin.kt @@ -40,8 +40,8 @@ import javax.inject.Singleton @Singleton class TidepoolPlugin @Inject constructor( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, + aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, private val mainApp: MainApp, private val resourceHelper: ResourceHelper, private val fabricPrivacy: FabricPrivacy, @@ -54,7 +54,8 @@ class TidepoolPlugin @Inject constructor( .shortName(R.string.tidepool_shortname) .fragmentClass(TidepoolFragment::class.qualifiedName) .preferencesId(R.xml.pref_tidepool) - .description(R.string.description_tidepool) + .description(R.string.description_tidepool), + rxBus, aapsLogger ) { private var disposable: CompositeDisposable = CompositeDisposable() 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 49f2a075bc..c19aacc054 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 @@ -8,6 +8,7 @@ import info.nightscout.androidaps.events.* import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -25,19 +26,21 @@ import javax.inject.Singleton @Singleton class WearPlugin @Inject constructor( - private val rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, private val sp: SP, private val mainApp: MainApp, private val fabricPrivacy: FabricPrivacy, - private val loopPlugin: Lazy + private val loopPlugin: Lazy, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger + ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .fragmentClass(WearFragment::class.java.name) .pluginName(R.string.wear) .shortName(R.string.wear_shortname) .preferencesId(R.xml.pref_wear) - .description(R.string.description_wear) + .description(R.string.description_wear), + rxBus, aapsLogger ) { private val disposable = CompositeDisposable() 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 d9392c26d4..0552600d86 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 @@ -9,6 +9,7 @@ import info.nightscout.androidaps.events.* import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin @@ -29,7 +30,6 @@ import javax.inject.Singleton @Singleton class StatusLinePlugin @Inject constructor( private val sp: SP, - private val rxBus: RxBusWrapper, private val profileFunction: ProfileFunction, private val resourceHelper: ResourceHelper, private val mainApp: MainApp, @@ -37,7 +37,8 @@ class StatusLinePlugin @Inject constructor( private val configBuilderPlugin: ConfigBuilderPlugin, private val treatmentsPlugin: TreatmentsPlugin, private val loopPlugin: LoopPlugin, - private val iobCobCalculatorPlugin: IobCobCalculatorPlugin + private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase( PluginDescription() .mainType(PluginType.GENERAL) @@ -45,7 +46,7 @@ class StatusLinePlugin @Inject constructor( .shortName(R.string.xdripstatus_shortname) .neverVisible(true) .preferencesId(R.xml.pref_xdripstatus) - .description(R.string.description_xdrip_status_line)) { + .description(R.string.description_xdrip_status_line), rxBus, aapsLogger) { private val disposable = CompositeDisposable() private var lastLoopStatus = false diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt index 4e210e15a8..39a66246d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt @@ -6,6 +6,7 @@ import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -20,14 +21,15 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper * */ abstract class InsulinOrefBasePlugin( - val rxBus: RxBusWrapper, val resourceHelper: ResourceHelper, - val profileFunction: ProfileFunction + val profileFunction: ProfileFunction, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.INSULIN) .fragmentClass(InsulinFragment::class.java.name) .shortName(R.string.insulin_shortname) - .visibleByDefault(false) + .visibleByDefault(false), + rxBus, aapsLogger ), InsulinInterface { private var lastWarned: Long = 0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt index c8bc87ff40..4448be63fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -16,9 +17,9 @@ import javax.inject.Singleton class InsulinOrefFreePeakPlugin @Inject constructor( private val sp: SP, resourceHelper: ResourceHelper, - rxBus: RxBusWrapper, - profileFunction: ProfileFunction -) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) { + profileFunction: ProfileFunction, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : InsulinOrefBasePlugin(resourceHelper, profileFunction, rxBus, aapsLogger) { override fun getId(): Int { return InsulinInterface.OREF_FREE_PEAK diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt index 43dbbe733d..8aed4d24aa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt @@ -1,12 +1,11 @@ package info.nightscout.androidaps.plugins.insulin -import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper -import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject import javax.inject.Singleton @@ -16,9 +15,9 @@ import javax.inject.Singleton @Singleton class InsulinOrefRapidActingPlugin @Inject constructor( resourceHelper: ResourceHelper, - rxBus: RxBusWrapper, - profileFunction: ProfileFunction -) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) { + profileFunction: ProfileFunction, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : InsulinOrefBasePlugin(resourceHelper, profileFunction, rxBus, aapsLogger) { override fun getId(): Int { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt index 75a757065c..f5c26e9eda 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.insulin -import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.InsulinInterface +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -15,11 +15,10 @@ import javax.inject.Singleton */ @Singleton class InsulinOrefUltraRapidActingPlugin @Inject constructor( - private val sp: SP, resourceHelper: ResourceHelper, - rxBus: RxBusWrapper, - profileFunction: ProfileFunction -) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) { + profileFunction: ProfileFunction, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : InsulinOrefBasePlugin(resourceHelper, profileFunction, rxBus, aapsLogger) { override fun getId(): Int { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index f51bebe435..d618ed64f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -55,8 +55,6 @@ import static info.nightscout.androidaps.utils.DateUtil.now; @Singleton public class IobCobCalculatorPlugin extends PluginBase { - private final AAPSLogger aapsLogger; - private final RxBusWrapper rxBus; private final SP sp; private final ResourceHelper resourceHelper; private final ProfileFunction profileFunction; @@ -101,11 +99,10 @@ public class IobCobCalculatorPlugin extends PluginBase { .pluginName(R.string.iobcobcalculator) .showInList(false) .neverVisible(true) - .alwaysEnabled(true) + .alwaysEnabled(true), + rxBus, aapsLogger ); this.plugin = this; - this.aapsLogger = aapsLogger; - this.rxBus = rxBus; this.sp = sp; this.resourceHelper = resourceHelper; this.profileFunction = profileFunction; @@ -117,13 +114,13 @@ public class IobCobCalculatorPlugin extends PluginBase { protected void onStart() { super.onStart(); // EventConfigBuilderChange - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventConfigBuilderChange.class) .observeOn(Schedulers.io()) .subscribe(event -> { stopCalculation("onEventConfigBuilderChange"); synchronized (dataLock) { - aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); + getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); } @@ -131,7 +128,7 @@ public class IobCobCalculatorPlugin extends PluginBase { }, exception -> FabricPrivacy.getInstance().logException(exception)) ); // EventNewBasalProfile - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventNewBasalProfile.class) .observeOn(Schedulers.io()) .subscribe(event -> { @@ -140,7 +137,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } stopCalculation("onNewProfile"); synchronized (dataLock) { - aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); + getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); basalDataTable = new LongSparseArray<>(); @@ -149,7 +146,7 @@ public class IobCobCalculatorPlugin extends PluginBase { }, exception -> FabricPrivacy.getInstance().logException(exception)) ); // EventNewBG - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventNewBG.class) .observeOn(Schedulers.io()) .subscribe(event -> { @@ -158,7 +155,7 @@ public class IobCobCalculatorPlugin extends PluginBase { }, exception -> FabricPrivacy.getInstance().logException(exception)) ); // EventPreferenceChange - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventPreferenceChange.class) .observeOn(Schedulers.io()) .subscribe(event -> { @@ -173,7 +170,7 @@ public class IobCobCalculatorPlugin extends PluginBase { ) { stopCalculation("onEventPreferenceChange"); synchronized (dataLock) { - aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records" + " BasalData: " + basalDataTable.size() + " records"); + getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records" + " BasalData: " + basalDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); basalDataTable = new LongSparseArray<>(); @@ -183,13 +180,13 @@ public class IobCobCalculatorPlugin extends PluginBase { }, exception -> FabricPrivacy.getInstance().logException(exception)) ); // EventAppInitialized - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventAppInitialized.class) .observeOn(Schedulers.io()) .subscribe(event -> runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, event), exception -> FabricPrivacy.getInstance().logException(exception)) ); // EventNewHistoryData - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventNewHistoryData.class) .observeOn(Schedulers.io()) .subscribe(event -> newHistoryData(event), exception -> FabricPrivacy.getInstance().logException(exception)) @@ -239,10 +236,10 @@ public class IobCobCalculatorPlugin extends PluginBase { // if close to now expect there can be some readings with time in close future (caused by wrong time setting) // so read all records bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false); - aapsLogger.debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start)); + getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start)); } else { bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false); - aapsLogger.debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to)); + getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to)); } } @@ -262,13 +259,13 @@ public class IobCobCalculatorPlugin extends PluginBase { totalDiff += diff; diff = Math.abs(diff); if (diff > T.secs(30).msecs()) { - aapsLogger.debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "[s] is5minData: " + false); + getAapsLogger().debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "[s] is5minData: " + false); return false; } } long averageDiff = totalDiff / bgReadings.size() / 1000; boolean is5mindata = averageDiff < 1; - aapsLogger.debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff + "[s] is5minData: " + is5mindata); + getAapsLogger().debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff + "[s] is5minData: " + is5mindata); return is5mindata; } } @@ -350,7 +347,7 @@ public class IobCobCalculatorPlugin extends PluginBase { bucketed_data = new ArrayList<>(); bucketed_data.add(bgReadings.get(0)); - aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString()); + getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString()); int j = 0; for (int i = 1; i < bgReadings.size(); ++i) { long bgTime = bgReadings.get(i).date; @@ -378,7 +375,7 @@ public class IobCobCalculatorPlugin extends PluginBase { newBgreading.value = Math.round(nextbg); //console.error("Interpolated", bucketed_data[j]); bucketed_data.add(newBgreading); - aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); + getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); elapsed_minutes = elapsed_minutes - 5; lastbg = nextbg; @@ -389,14 +386,14 @@ public class IobCobCalculatorPlugin extends PluginBase { newBgreading.value = bgReadings.get(i).value; newBgreading.date = bgTime; bucketed_data.add(newBgreading); - aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); + getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); } else if (Math.abs(elapsed_minutes) > 2) { j++; BgReading newBgreading = new BgReading(); newBgreading.value = bgReadings.get(i).value; newBgreading.date = bgTime; bucketed_data.add(newBgreading); - aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); + getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); } else { bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2; //log.error("***** Average"); @@ -409,17 +406,17 @@ public class IobCobCalculatorPlugin extends PluginBase { BgReading previous = bucketed_data.get(i + 1); long msecDiff = current.date - previous.date; long adjusted = (msecDiff - T.mins(5).msecs()) / 1000; - aapsLogger.debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec"); + getAapsLogger().debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec"); if (Math.abs(adjusted) > 90) { // too big adjustment, fallback to non 5 min data - aapsLogger.debug(LTag.AUTOSENS, "Fallback to non 5 min data"); + getAapsLogger().debug(LTag.AUTOSENS, "Fallback to non 5 min data"); createBucketedDataRecalculated(); return; } current.date = previous.date + T.mins(5).msecs(); } - aapsLogger.debug(LTag.AUTOSENS, "Bucketed data created. Size: " + bucketed_data.size()); + getAapsLogger().debug(LTag.AUTOSENS, "Bucketed data created. Size: " + bucketed_data.size()); } long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) { @@ -432,7 +429,7 @@ public class IobCobCalculatorPlugin extends PluginBase { if (limitDataToOldestAvailable) { getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia))); if (getBGDataFrom == oldestDataAvailable) - aapsLogger.debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + DateUtil.dateAndTimeFullString(oldestDataAvailable)); + getAapsLogger().debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + DateUtil.dateAndTimeFullString(oldestDataAvailable)); } else getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia)); return getBGDataFrom; @@ -571,12 +568,12 @@ public class IobCobCalculatorPlugin extends PluginBase { @Nullable public AutosensData getLastAutosensDataSynchronized(String reason) { if (thread != null && thread.isAlive()) { - aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA is waiting for calculation thread: " + reason); + getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA is waiting for calculation thread: " + reason); try { thread.join(5000); } catch (InterruptedException ignored) { } - aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA finished waiting for calculation thread: " + reason); + getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA finished waiting for calculation thread: " + reason); } synchronized (dataLock) { return getLastAutosensData(reason); @@ -628,7 +625,7 @@ public class IobCobCalculatorPlugin extends PluginBase { @Nullable public AutosensData getLastAutosensData(String reason) { if (autosensDataTable.size() < 1) { - aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: autosensDataTable empty (" + reason + ")"); + getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: autosensDataTable empty (" + reason + ")"); return null; } AutosensData data; @@ -638,18 +635,18 @@ public class IobCobCalculatorPlugin extends PluginBase { // data can be processed on the background // in this rare case better return null and do not block UI // APS plugin should use getLastAutosensDataSynchronized where the blocking is not an issue - aapsLogger.error("AUTOSENSDATA null: Exception catched (" + reason + ")"); + getAapsLogger().error("AUTOSENSDATA null: Exception catched (" + reason + ")"); return null; } if (data == null) { - aapsLogger.error("AUTOSENSDATA null: data==null"); + getAapsLogger().error("AUTOSENSDATA null: data==null"); return null; } if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) { - aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); + getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); return null; } else { - aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString()); + getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString()); return data; } } @@ -769,16 +766,16 @@ public class IobCobCalculatorPlugin extends PluginBase { public void stopCalculation(String from) { if (thread != null && thread.getState() != Thread.State.TERMINATED) { stopCalculationTrigger = true; - aapsLogger.debug(LTag.AUTOSENS, "Stopping calculation thread: " + from); + getAapsLogger().debug(LTag.AUTOSENS, "Stopping calculation thread: " + from); while (thread.getState() != Thread.State.TERMINATED) { SystemClock.sleep(100); } - aapsLogger.debug(LTag.AUTOSENS, "Calculation thread stopped: " + from); + getAapsLogger().debug(LTag.AUTOSENS, "Calculation thread stopped: " + from); } } public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { - aapsLogger.debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); + getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) thread = new IobCobOref1Thread(this, from, end, bgDataReload, limitDataToOldestAvailable, cause); @@ -795,10 +792,10 @@ public class IobCobCalculatorPlugin extends PluginBase { synchronized (dataLock) { // clear up 5 min back for proper COB calculation long time = ev.getTime() - 5 * 60 * 1000L; - aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data to: " + DateUtil.dateAndTimeFullString(time)); + getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data to: " + DateUtil.dateAndTimeFullString(time)); for (int index = iobTable.size() - 1; index >= 0; index--) { if (iobTable.keyAt(index) > time) { - aapsLogger.debug(LTag.AUTOSENS, "Removing from iobTable: " + DateUtil.dateAndTimeFullString(iobTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from iobTable: " + DateUtil.dateAndTimeFullString(iobTable.keyAt(index))); iobTable.removeAt(index); } else { break; @@ -806,7 +803,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } for (int index = autosensDataTable.size() - 1; index >= 0; index--) { if (autosensDataTable.keyAt(index) > time) { - aapsLogger.debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index))); autosensDataTable.removeAt(index); } else { break; @@ -814,7 +811,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } for (int index = basalDataTable.size() - 1; index >= 0; index--) { if (basalDataTable.keyAt(index) > time) { - aapsLogger.debug(LTag.AUTOSENS, "Removing from basalDataTable: " + DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index))); + getAapsLogger().debug(LTag.AUTOSENS, "Removing from basalDataTable: " + DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index))); basalDataTable.removeAt(index); } else { break; @@ -827,7 +824,7 @@ public class IobCobCalculatorPlugin extends PluginBase { public void clearCache() { synchronized (dataLock) { - aapsLogger.debug(LTag.AUTOSENS, "Clearing cached data."); + getAapsLogger().debug(LTag.AUTOSENS, "Clearing cached data."); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); basalDataTable = new LongSparseArray<>(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 5cbb67f3f2..c76dc47af4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -14,7 +14,6 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction -import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter @@ -31,8 +30,8 @@ import kotlin.collections.ArrayList @Singleton class LocalProfilePlugin @Inject constructor( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, + aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, private val resourceHelper: ResourceHelper, private val sp: SP, private val profileFunction: ProfileFunction @@ -42,7 +41,7 @@ class LocalProfilePlugin @Inject constructor( .enableByDefault(true) .pluginName(R.string.localprofile) .shortName(R.string.localprofile_shortname) - .description(R.string.description_profile_local)), ProfileInterface { + .description(R.string.description_profile_local), rxBus, aapsLogger), ProfileInterface { var rawProfile: ProfileStore? = null diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.java index e9fa64484b..934dc34b44 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.java @@ -19,8 +19,10 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileInterface; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart; import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI; import info.nightscout.androidaps.utils.SP; @@ -50,7 +52,8 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface { .alwaysEnabled(Config.NSCLIENT) .alwaysVisible(Config.NSCLIENT) .showInList(!Config.NSCLIENT) - .description(R.string.description_profile_nightscout) + .description(R.string.description_profile_nightscout), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); loadNSProfile(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index ef6c0f2717..91cba80fbe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -37,8 +37,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; @@ -130,13 +132,16 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint private static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult() .success(false).enacted(false).comment(MainApp.gs(R.string.combo_pump_unsupported_operation)); + // TODO: dagger + private ComboPlugin() { super(new PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(ComboFragment.class.getName()) .pluginName(R.string.combopump) .shortName(R.string.combopump_shortname) - .description(R.string.description_pump_combo) + .description(R.string.description_pump_combo), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext()); pumpDescription.setPumpDescription(PumpType.AccuChekCombo); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index 715b373502..f1d8ad8294 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -28,8 +28,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState; @@ -68,9 +70,9 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter protected boolean displayConnectionMessages = false; - protected PumpPluginAbstract(PluginDescription pluginDescription, PumpType pumpType) { + protected PumpPluginAbstract(PluginDescription pluginDescription, PumpType pumpType, RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) { - super(pluginDescription); + super(pluginDescription, rxBusWrapper, aapsLogger); pumpDescription.setPumpDescription(pumpType); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index 78bfb1b520..e053132977 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -25,8 +25,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; @@ -56,14 +58,15 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte public PumpDescription pumpDescription = new PumpDescription(); - protected AbstractDanaRPlugin() { + protected AbstractDanaRPlugin(RxBusWrapper rxBus, AAPSLogger aapsLogger) { super(new PluginDescription() .mainType(PluginType.PUMP) .fragmentClass(DanaRFragment.class.getName()) .pluginName(R.string.danarspump) .shortName(R.string.danarpump_shortname) .preferencesId(R.xml.pref_danars) - .description(R.string.description_pump_dana_r) + .description(R.string.description_pump_dana_r), + rxBus, aapsLogger ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java index ba51f690e5..9599013240 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPlugin.java @@ -69,7 +69,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { TreatmentsPlugin treatmentsPlugin, SP sp ) { - super(); + super(rxBus, aapsLogger); plugin = this; this.aapsLogger = aapsLogger; this.rxBus = rxBus; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java index 47a66007b2..7427c55590 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/DanaRKoreanPlugin.java @@ -71,7 +71,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { TreatmentsPlugin treatmentsPlugin, SP sp ) { - super(); + super(rxBus, aapsLogger); plugin = this; this.aapsLogger = aapsLogger; this.rxBus = rxBus; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index 874398e722..7b700a2cd4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -70,9 +70,7 @@ import io.reactivex.schedulers.Schedulers; @Singleton public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface { private CompositeDisposable disposable = new CompositeDisposable(); - - private final AAPSLogger aapsLogger; - private final RxBusWrapper rxBus; + private final MainApp mainApp; private final ResourceHelper resourceHelper; private final ConstraintChecker constraintChecker; @@ -113,11 +111,10 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte .pluginName(R.string.danarspump) .shortName(R.string.danarspump_shortname) .preferencesId(R.xml.pref_danars) - .description(R.string.description_pump_dana_rs) + .description(R.string.description_pump_dana_rs), + rxBus, aapsLogger ); plugin = this; - this.aapsLogger = aapsLogger; - this.rxBus = rxBus; this.mainApp = maiApp; this.resourceHelper = resourceHelper; this.constraintChecker = constraintChecker; @@ -141,12 +138,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte Intent intent = new Intent(mainApp, DanaRSService.class); mainApp.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventAppExit.class) .observeOn(Schedulers.io()) .subscribe(event -> mainApp.unbindService(mConnection), exception -> FabricPrivacy.getInstance().logException(exception)) ); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventDanaRSDeviceChange.class) .observeOn(Schedulers.io()) .subscribe(event -> loadAddress(), exception -> FabricPrivacy.getInstance().logException(exception)) @@ -171,12 +168,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - aapsLogger.debug(LTag.PUMP, "Service is disconnected"); + getAapsLogger().debug(LTag.PUMP, "Service is disconnected"); danaRSService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - aapsLogger.debug(LTag.PUMP, "Service is connected"); + getAapsLogger().debug(LTag.PUMP, "Service is connected"); DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service; danaRSService = mLocalBinder.getServiceInstance(); } @@ -189,7 +186,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void connect(String from) { - aapsLogger.debug(LTag.PUMP, "RS connect from: " + from); + getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { final Object o = new Object(); @@ -218,7 +215,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void disconnect(String from) { - aapsLogger.debug(LTag.PUMP, "RS disconnect from: " + from); + getAapsLogger().debug(LTag.PUMP, "RS disconnect from: " + from); if (danaRSService != null) danaRSService.disconnect(from); } @@ -308,29 +305,29 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte PumpEnactResult result = new PumpEnactResult(); if (danaRSService == null) { - aapsLogger.error("setNewBasalProfile sExecutionService is null"); + getAapsLogger().error("setNewBasalProfile sExecutionService is null"); result.comment = "setNewBasalProfile sExecutionService is null"; return result; } if (!isInitialized()) { - aapsLogger.error("setNewBasalProfile not initialized"); + getAapsLogger().error("setNewBasalProfile not initialized"); Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT); - rxBus.send(new EventNewNotification(notification)); + getRxBus().send(new EventNewNotification(notification)); result.comment = resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet); return result; } else { - rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); + getRxBus().send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); } if (!danaRSService.updateBasalsInPump(profile)) { Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT); - rxBus.send(new EventNewNotification(notification)); + getRxBus().send(new EventNewNotification(notification)); result.comment = resourceHelper.gs(R.string.failedupdatebasalprofile); return result; } else { - rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); - rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); + getRxBus().send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); + getRxBus().send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); Notification notification = new Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60); - rxBus.send(new EventNewNotification(notification)); + getRxBus().send(new EventNewNotification(notification)); result.success = true; result.enacted = true; result.comment = "OK"; @@ -351,7 +348,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte Double pumpValue = pump.pumpProfiles[pump.activeProfile][h]; Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement); if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { - aapsLogger.debug(LTag.PUMP, "Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); + getAapsLogger().debug(LTag.PUMP, "Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); return false; } } @@ -437,7 +434,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, error); } else result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); + getAapsLogger().debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); return result; } else { PumpEnactResult result = new PumpEnactResult(); @@ -445,7 +442,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.bolusDelivered = 0d; result.carbsDelivered = 0d; result.comment = resourceHelper.gs(R.string.danar_invalidinput); - aapsLogger.error("deliverTreatment: Invalid input"); + getAapsLogger().error("deliverTreatment: Invalid input"); return result; } } @@ -453,7 +450,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void stopBolusDelivering() { if (danaRSService == null) { - aapsLogger.error("stopBolusDelivering sExecutionService is null"); + getAapsLogger().error("stopBolusDelivering sExecutionService is null"); return; } danaRSService.bolusStop(); @@ -480,7 +477,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte if (doTempOff) { // If temp in progress if (treatmentsPlugin.isTempBasalInProgress()) { - aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelTempBasal(false); } result.success = true; @@ -488,7 +485,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.percent = 100; result.isPercent = true; result.isTempCancel = true; - aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK"); return result; } @@ -501,7 +498,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte // Check if some temp is already in progress TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()); if (activeTemp != null) { - aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: currently running: " + activeTemp.toString()); + getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: currently running: " + activeTemp.toString()); // Correct basal already set ? if (activeTemp.percentRate == percentRate && activeTemp.getPlannedRemainingMinutes() > 4) { if (!enforceNew) { @@ -511,13 +508,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); if (percentRate == 0 && durationInMinutes > 30) { result = setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew); } else { @@ -525,14 +522,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result = setHighTempBasalPercent(percentRate); } if (!result.success) { - aapsLogger.error("setTempBasalAbsolute: Failed to set hightemp basal"); + getAapsLogger().error("setTempBasalAbsolute: Failed to set hightemp basal"); return result; } - aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: hightemp basal set ok"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: hightemp basal set ok"); return result; } // We should never end here - aapsLogger.error("setTempBasalAbsolute: Internal error"); + getAapsLogger().error("setTempBasalAbsolute: Internal error"); result.success = false; result.comment = "Internal error"; return result; @@ -548,7 +545,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.enacted = false; result.success = false; result.comment = resourceHelper.gs(R.string.danar_invalidinput); - aapsLogger.error("setTempBasalPercent: Invalid input"); + getAapsLogger().error("setTempBasalPercent: Invalid input"); return result; } if (percent > getPumpDescription().maxTempPercent) @@ -563,7 +560,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent: Correct value already set"); return result; } boolean connectionOK; @@ -581,13 +578,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: OK"); + getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent: OK"); return result; } result.enacted = false; result.success = false; result.comment = resourceHelper.gs(R.string.tempbasaldeliveryerror); - aapsLogger.error("setTempBasalPercent: Failed to set temp basal"); + getAapsLogger().error("setTempBasalPercent: Failed to set temp basal"); return result; } @@ -603,13 +600,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - aapsLogger.debug(LTag.PUMP, "setHighTempBasalPercent: OK"); + getAapsLogger().debug(LTag.PUMP, "setHighTempBasalPercent: OK"); return result; } result.enacted = false; result.success = false; result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - aapsLogger.error("setHighTempBasalPercent: Failed to set temp basal"); + getAapsLogger().error("setHighTempBasalPercent: Failed to set temp basal"); return result; } @@ -630,7 +627,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.absolute = pump.extendedBolusAbsoluteRate; result.isPercent = false; result.isTempCancel = false; - aapsLogger.debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); + getAapsLogger().debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); return result; } boolean connectionOK = danaRSService.extendedBolus(insulin, durationInHalfHours); @@ -643,13 +640,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.absolute = pump.extendedBolusAbsoluteRate; result.bolusDelivered = pump.extendedBolusAmount; result.isPercent = false; - aapsLogger.debug(LTag.PUMP, "setExtendedBolus: OK"); + getAapsLogger().debug(LTag.PUMP, "setExtendedBolus: OK"); return result; } result.enacted = false; result.success = false; result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - aapsLogger.error("setExtendedBolus: Failed to extended bolus"); + getAapsLogger().error("setExtendedBolus: Failed to extended bolus"); return result; } @@ -666,13 +663,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.success = true; result.isTempCancel = true; result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: OK"); + getAapsLogger().debug(LTag.PUMP, "cancelRealTempBasal: OK"); return result; } else { result.success = false; result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); result.isTempCancel = true; - aapsLogger.error("cancelRealTempBasal: Failed to cancel temp basal"); + getAapsLogger().error("cancelRealTempBasal: Failed to cancel temp basal"); return result; } } @@ -689,12 +686,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte if (!DanaRPump.getInstance().isExtendedInProgress) { result.success = true; result.comment = resourceHelper.gs(R.string.virtualpump_resultok); - aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: OK"); + getAapsLogger().debug(LTag.PUMP, "cancelExtendedBolus: OK"); return result; } else { result.success = false; result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly); - aapsLogger.error("cancelExtendedBolus: Failed to cancel extended bolus"); + getAapsLogger().error("cancelExtendedBolus: Failed to cancel extended bolus"); return result; } } @@ -736,7 +733,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte try { extended.put("ActiveProfile", profileFunction.getProfileName()); } catch (Exception e) { - aapsLogger.error("Unhandled exception", e); + getAapsLogger().error("Unhandled exception", e); } pumpjson.put("battery", battery); @@ -745,7 +742,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte pumpjson.put("reservoir", (int) pump.reservoirRemainingUnits); pumpjson.put("clock", DateUtil.toISOString(now)); } catch (JSONException e) { - aapsLogger.error("Unhandled exception", e); + getAapsLogger().error("Unhandled exception", e); } return pumpjson; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java index 39795ed9e2..aa03757b80 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2Plugin.java @@ -71,7 +71,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { TreatmentsPlugin treatmentsPlugin, SP sp ) { - super(); + super(rxBus, aapsLogger); plugin = this; this.aapsLogger = aapsLogger; this.rxBus = rxBus; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 5cdb682b5e..df3ec733df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -42,8 +42,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; @@ -195,7 +197,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con .description(R.string.description_pump_insight_local) .fragmentClass(LocalInsightFragment.class.getName()) .preferencesId(MainApp.instance().getPackageName().equals("info.nightscout.androidaps") - ? R.xml.pref_insight_local_full : R.xml.pref_insight_local_pumpcontrol)); + ? R.xml.pref_insight_local_full : R.xml.pref_insight_local_pumpcontrol), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger + + ); pumpDescription = new PumpDescription(); pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java index 868beef7b4..8113734335 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java @@ -18,7 +18,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; @@ -45,11 +48,14 @@ public class MDIPlugin extends PluginBase implements PumpInterface { private PumpDescription pumpDescription = new PumpDescription(); + //TODO dagger + private MDIPlugin() { super(new PluginDescription() - .mainType(PluginType.PUMP) - .pluginName(R.string.mdi) - .description(R.string.description_pump_mdi) + .mainType(PluginType.PUMP) + .pluginName(R.string.mdi) + .description(R.string.description_pump_mdi), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); pumpDescription.isBolusCapable = true; pumpDescription.bolusStep = 0.5d; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 89b2ec6054..ccd28fecc4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -37,8 +37,10 @@ import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.bus.RxBus; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.common.ManufacturerType; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; @@ -117,7 +119,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter .pluginName(R.string.medtronic_name) // .shortName(R.string.medtronic_name_short) // .preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), // - PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later + PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); displayConnectionMessages = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 82fb4f3917..84ce57ced1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -45,8 +45,8 @@ import javax.inject.Singleton @Singleton class VirtualPumpPlugin @Inject constructor( - private val aapsLogger: AAPSLogger, - private val rxBus: RxBusWrapper, + aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, private var fabricPrivacy: FabricPrivacy, private val resourceHelper: ResourceHelper, private val sp: SP, @@ -59,7 +59,8 @@ class VirtualPumpPlugin @Inject constructor( .shortName(R.string.virtualpump_shortname) .preferencesId(R.xml.pref_virtualpump) .neverVisible(Config.NSCLIENT) - .description(R.string.description_pump_virtual) + .description(R.string.description_pump_virtual), + rxBus, aapsLogger ), PumpInterface { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.java index 6c8a9e8ba5..b860694473 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/AbstractSensitivityPlugin.java @@ -7,7 +7,9 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.SensitivityInterface; +import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.utils.Round; @@ -18,8 +20,8 @@ public abstract class AbstractSensitivityPlugin extends PluginBase implements Se private static final Logger log = LoggerFactory.getLogger(L.AUTOSENS); - public AbstractSensitivityPlugin(PluginDescription pluginDescription) { - super(pluginDescription); + public AbstractSensitivityPlugin(PluginDescription pluginDescription, RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) { + super(pluginDescription, rxBusWrapper, aapsLogger); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java index d6f256e10f..30b1e57c68 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityAAPSPlugin.java @@ -17,7 +17,9 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; @@ -41,13 +43,16 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { return plugin; } + // TODO: dagger + public SensitivityAAPSPlugin() { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) .pluginName(R.string.sensitivityaaps) .shortName(R.string.sensitivity_shortname) .preferencesId(R.xml.pref_absorption_aaps) - .description(R.string.description_sensitivity_aaps) + .description(R.string.description_sensitivity_aaps), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref0Plugin.java index e96825b09a..9beb9578db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref0Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref0Plugin.java @@ -17,7 +17,9 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; @@ -40,13 +42,16 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { return plugin; } + // TODO: dagger + public SensitivityOref0Plugin() { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) .pluginName(R.string.sensitivityoref0) .shortName(R.string.sensitivity_shortname) .preferencesId(R.xml.pref_absorption_oref0) - .description(R.string.description_sensitivity_oref0) + .description(R.string.description_sensitivity_oref0), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java index fb39859355..334f785549 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.java @@ -17,7 +17,9 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; @@ -46,7 +48,8 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { .pluginName(R.string.sensitivityoref1) .shortName(R.string.sensitivity_shortname) .preferencesId(R.xml.pref_absorption_oref1) - .description(R.string.description_sensitivity_oref1) + .description(R.string.description_sensitivity_oref1), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: Dagger ); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java index b954423bb1..00005eda57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityWeightedAveragePlugin.java @@ -15,7 +15,9 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.AAPSLoggerProduction; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult; @@ -39,13 +41,16 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin return plugin; } + // TODO: dagger + public SensitivityWeightedAveragePlugin() { super(new PluginDescription() .mainType(PluginType.SENSITIVITY) .pluginName(R.string.sensitivityweightedaverage) .shortName(R.string.sensitivity_shortname) .preferencesId(R.xml.pref_absorption_aaps) - .description(R.string.description_sensitivity_weighted_average) + .description(R.string.description_sensitivity_weighted_average), + new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger ); } 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 134b23d8db..d58ed8b428 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 @@ -14,26 +14,29 @@ import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.DateUtil -import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONObject import javax.inject.Inject import javax.inject.Singleton @Singleton class DexcomPlugin @Inject constructor( - private val aapsLogger: AAPSLogger, private val sp: SP, - private val mainApp: MainApp + private val mainApp: MainApp, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.dexcom_app_patched) .shortName(R.string.dexcom_short) .preferencesId(R.xml.pref_bgsourcedexcom) - .description(R.string.description_source_dexcom)), BgSourceInterface { + .description(R.string.description_source_dexcom), + rxBus, + aapsLogger), BgSourceInterface { private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol", "com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol", 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 f3f248610f..2d45e20396 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 @@ -14,6 +14,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.logging.L.isEnabled import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -25,15 +26,17 @@ import javax.inject.Singleton @Singleton class EversensePlugin @Inject constructor( - private val aapsLogger: AAPSLogger, - private val sp: SP + private val sp: SP, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.eversense) .shortName(R.string.eversense_shortname) .preferencesId(R.xml.pref_bgsource) - .description(R.string.description_source_eversense) + .description(R.string.description_source_eversense), + rxBus, + aapsLogger ), BgSourceInterface { override fun advancedFilteringSupported(): Boolean { 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 8706140982..ecae346008 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 @@ -11,18 +11,21 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.BundleLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import javax.inject.Inject import javax.inject.Singleton @Singleton class GlimpPlugin @Inject constructor( - private val aapsLogger: AAPSLogger + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.Glimp) .preferencesId(R.xml.pref_bgsource) - .description(R.string.description_source_glimp) + .description(R.string.description_source_glimp), + rxBus, + aapsLogger ), BgSourceInterface { override fun advancedFilteringSupported(): Boolean { 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 3ae360deb9..517901b0c4 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 @@ -10,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import org.json.JSONArray import org.json.JSONException import javax.inject.Inject @@ -17,12 +18,14 @@ import javax.inject.Singleton @Singleton class MM640gPlugin @Inject constructor( - private val aapsLogger: AAPSLogger + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.MM640g) - .description(R.string.description_source_mm640g) + .description(R.string.description_source_mm640g), + rxBus, + aapsLogger ), BgSourceInterface { override fun advancedFilteringSupported(): Boolean { 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 075437ca29..cdf579d09e 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 @@ -10,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv import info.nightscout.androidaps.utils.JsonHelper.safeGetLong import info.nightscout.androidaps.utils.JsonHelper.safeGetString @@ -21,13 +22,15 @@ import javax.inject.Singleton @Singleton class NSClientSourcePlugin @Inject constructor( - private val aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger, private val sp: SP ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.nsclientbg) - .description(R.string.description_source_ns_client) + .description(R.string.description_source_ns_client), + rxBus, + aapsLogger ), BgSourceInterface { private var lastBGTimeStamp: Long = 0 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 2097f56cc3..07587e8fb3 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 @@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.JsonHelper.safeGetString import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -21,14 +22,16 @@ import javax.inject.Singleton @Singleton class PoctechPlugin @Inject constructor( - private val aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger, private val sp: SP ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.poctech) .preferencesId(R.xml.pref_bgsource) - .description(R.string.description_source_poctech) + .description(R.string.description_source_poctech), + rxBus, + aapsLogger ), BgSourceInterface { override fun advancedFilteringSupported(): Boolean { 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 e40d352366..78a1970a4d 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 @@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T @@ -23,14 +24,16 @@ import kotlin.math.sin @Singleton class RandomBgPlugin @Inject constructor( - private val aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger, private var virtualPumpPlugin: VirtualPumpPlugin ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.randombg) .shortName(R.string.randombg_short) - .description(R.string.description_source_randombg)), BgSourceInterface { + .description(R.string.description_source_randombg), + rxBus, + aapsLogger), BgSourceInterface { private val loopHandler = Handler() private lateinit var refreshLoop: Runnable 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 9076ea6b9d..018fbcd9e2 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 @@ -10,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject @@ -17,7 +18,7 @@ import javax.inject.Singleton @Singleton class TomatoPlugin @Inject constructor( - private val aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger, private val sp: SP ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) @@ -25,7 +26,9 @@ class TomatoPlugin @Inject constructor( .pluginName(R.string.tomato) .preferencesId(R.xml.pref_bgsource) .shortName(R.string.tomato_short) - .description(R.string.description_source_tomato) + .description(R.string.description_source_tomato), + rxBus, + aapsLogger ), BgSourceInterface { override fun advancedFilteringSupported(): Boolean { 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 59bbd6b215..a198bc75de 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 @@ -11,18 +11,21 @@ import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.BundleLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.services.Intents import javax.inject.Inject import javax.inject.Singleton @Singleton class XdripPlugin @Inject constructor( - private val aapsLogger: AAPSLogger + rxBus: RxBusWrapper, aapsLogger: AAPSLogger ) : PluginBase(PluginDescription() .mainType(PluginType.BGSOURCE) .fragmentClass(BGSourceFragment::class.java.name) .pluginName(R.string.xdrip) - .description(R.string.description_source_xdrip) + .description(R.string.description_source_xdrip), + rxBus, + aapsLogger ), BgSourceInterface { var advancedFiltering = false diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index f95b6ebe20..1dfaa12729 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -64,8 +64,7 @@ import io.reactivex.schedulers.Schedulers; @Singleton public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface { - private final AAPSLogger aapsLogger; - private final RxBusWrapper rxBus; + private final MainApp mainApp; private final SP sp; private final ResourceHelper resourceHelper; @@ -112,10 +111,10 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface .pluginName(R.string.treatments) .shortName(R.string.treatments_shortname) .alwaysEnabled(true) - .description(R.string.description_treatments) + .description(R.string.description_treatments), + rxBus, + aapsLogger ); - this.aapsLogger = aapsLogger; - this.rxBus = rxBus; this.resourceHelper = resourceHelper; this.mainApp = mainApp; this.sp = sp; @@ -129,35 +128,35 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface this.service = new TreatmentService(); initializeData(range()); super.onStart(); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventReloadTreatmentData.class) .observeOn(Schedulers.io()) .subscribe(event -> { - aapsLogger.debug(LTag.DATATREATMENTS, "EventReloadTreatmentData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTreatmentData"); initializeTreatmentData(range()); initializeExtendedBolusData(range()); updateTotalIOBTreatments(); - rxBus.send(event.getNext()); + getRxBus().send(event.getNext()); }, exception -> FabricPrivacy.getInstance().logException(exception) )); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventReloadProfileSwitchData.class) .observeOn(Schedulers.io()) .subscribe(event -> initializeProfileSwitchData(range()), exception -> FabricPrivacy.getInstance().logException(exception) )); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventTempTargetChange.class) .observeOn(Schedulers.io()) .subscribe(event -> initializeTempTargetData(range()), exception -> FabricPrivacy.getInstance().logException(exception) )); - disposable.add(rxBus + disposable.add(getRxBus() .toObservable(EventReloadTempBasalData.class) .observeOn(Schedulers.io()) .subscribe(event -> { - aapsLogger.debug(LTag.DATATREATMENTS, "EventReloadTempBasalData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTempBasalData"); initializeTempBasalData(range()); updateTotalIOBTempBasals(); }, @@ -191,7 +190,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeTreatmentData(long range) { - aapsLogger.debug(LTag.DATATREATMENTS, "initializeTreatmentData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "initializeTreatmentData"); synchronized (treatments) { treatments.clear(); treatments.addAll(getService().getTreatmentDataFromTime(DateUtil.now() - range, false)); @@ -199,7 +198,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeTempBasalData(long range) { - aapsLogger.debug(LTag.DATATREATMENTS, "initializeTempBasalData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "initializeTempBasalData"); synchronized (tempBasals) { tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(DateUtil.now() - range, false)); } @@ -207,7 +206,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeExtendedBolusData(long range) { - aapsLogger.debug(LTag.DATATREATMENTS, "initializeExtendedBolusData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "initializeExtendedBolusData"); synchronized (extendedBoluses) { extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(DateUtil.now() - range, false)); } @@ -215,14 +214,14 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeTempTargetData(long range) { - aapsLogger.debug(LTag.DATATREATMENTS, "initializeTempTargetData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "initializeTempTargetData"); synchronized (tempTargets) { tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(DateUtil.now() - range, false)); } } private void initializeProfileSwitchData(long range) { - aapsLogger.debug(LTag.DATATREATMENTS, "initializeProfileSwitchData"); + getAapsLogger().debug(LTag.DATATREATMENTS, "initializeProfileSwitchData"); synchronized (profiles) { profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - range, false)); } @@ -310,13 +309,13 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface long time = System.currentTimeMillis(); synchronized (treatments) { - aapsLogger.debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: AllTreatmentsInDb: " + MedtronicUtil.getGsonInstanceCore().toJson(treatments)); + getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: AllTreatmentsInDb: " + MedtronicUtil.getGsonInstanceCore().toJson(treatments)); for (Treatment t : treatments) { if (t.date <= time && t.date >= fromTimestamp) in5minback.add(t); } - aapsLogger.debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={} " + fromTimestamp + " " + MedtronicUtil.getGsonInstanceCore().toJson(in5minback)); + getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={} " + fromTimestamp + " " + MedtronicUtil.getGsonInstanceCore().toJson(in5minback)); return in5minback; } } @@ -348,7 +347,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface last = t.date; } } - aapsLogger.debug(LTag.DATATREATMENTS, "Last bolus time: " + DateUtil.dateAndTimeString(last)); + getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + DateUtil.dateAndTimeString(last)); return last; } @@ -363,7 +362,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface last = t.date; } } - aapsLogger.debug(LTag.DATATREATMENTS, "Last manual bolus time: " + DateUtil.dateAndTimeString(last)); + getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + DateUtil.dateAndTimeString(last)); return last; } @@ -597,7 +596,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) { boolean medtronicPump = MedtronicUtil.isMedtronicPump(); - aapsLogger.debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::isMedtronicPump={} " + medtronicPump); + getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::isMedtronicPump={} " + medtronicPump); Treatment treatment = new Treatment(); treatment.date = detailedBolusInfo.date; @@ -612,7 +611,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null; TreatmentService.UpdateReturn creatOrUpdateResult; - aapsLogger.debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::treatment={} " + treatment); + getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::treatment={} " + treatment); if (!medtronicPump) creatOrUpdateResult = getService().createOrUpdate(treatment); @@ -629,7 +628,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records carbsTreatment.carbs = detailedBolusInfo.carbs; - aapsLogger.debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: carbTime!=0, creating second treatment. CarbsTreatment={}" + carbsTreatment); + getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: carbTime!=0, creating second treatment. CarbsTreatment={}" + carbsTreatment); if (!medtronicPump) getService().createOrUpdate(carbsTreatment); @@ -641,7 +640,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface NSUpload.uploadTreatmentRecord(detailedBolusInfo); if (!allowUpdate && !creatOrUpdateResult.success) { - aapsLogger.error("Treatment could not be added to DB", new Exception()); + getAapsLogger().error("Treatment could not be added to DB", new Exception()); String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, DateUtil.dateAndTimeString(treatment.date)); @@ -728,7 +727,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface @Override public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) { //log.debug("Adding new TemporaryBasal record" + profileSwitch.log()); - rxBus.send(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING)); + getRxBus().send(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING)); MainApp.getDbHelper().createOrUpdate(profileSwitch); NSUpload.uploadProfileSwitch(profileSwitch); } @@ -757,7 +756,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface profileSwitch.percentage = percentage; treatmentsPlugin.addToHistoryProfileSwitch(profileSwitch); } else { - aapsLogger.error(LTag.PROFILE, "No profile switch exists"); + getAapsLogger().error(LTag.PROFILE, "No profile switch exists"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index 62fe9c49ff..585055175f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -21,8 +21,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject class TddCalculator @Inject constructor( - val aapsLogger: AAPSLogger, - val rxBus: RxBusWrapper, + aapsLogger: AAPSLogger, + rxBus: RxBusWrapper, val resourceHelper: ResourceHelper, val mainApp: MainApp, val sp: SP,