From 6abad56b1f814377b7024831b808df4e8477a6ea Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 22 Jun 2018 18:11:57 +0200 Subject: [PATCH] Replace BgSourceInterface.advancedFilteringSupported. Replaced by 'filtered' property on BgReading. --- .../androidaps/Services/DataService.java | 139 +++++++++--------- .../androidaps/data/ConstraintChecker.java | 19 +-- .../interfaces/BgSourceInterface.java | 4 +- .../interfaces/ConstraintsInterface.java | 4 - .../interfaces/PluginDescription.java | 6 + .../ConfigBuilder/ConfigBuilderPlugin.java | 8 +- .../ConstraintsSafety/SafetyPlugin.java | 11 -- .../plugins/OpenAPSSMB/OpenAPSSMBPlugin.java | 11 +- .../plugins/Source/SourceDexcomG5Plugin.java | 4 - .../plugins/Source/SourceGlimpPlugin.java | 4 - .../plugins/Source/SourceMM640gPlugin.java | 4 - .../plugins/Source/SourceNSClientPlugin.java | 17 --- .../plugins/Source/SourcePoctechPlugin.java | 5 - .../plugins/Source/SourceXdripPlugin.java | 11 -- .../interfaces/ConstraintsCheckerTest.java | 18 +-- .../ConstraintsSafety/SafetyPluginTest.java | 19 +-- .../Source/SourceDexcomG5PluginTest.java | 8 +- .../plugins/Source/SourceGlimpPluginTest.java | 8 +- .../Source/SourceMM640gPluginTest.java | 8 +- .../Source/SourceNSClientPluginTest.java | 8 +- .../plugins/Source/SourceXdripPluginTest.java | 8 +- 21 files changed, 124 insertions(+), 200 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 9f3873cb93..e7dd87ab44 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -12,6 +12,8 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Objects; + import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; @@ -60,56 +62,58 @@ public class DataService extends IntentService { public DataService() { super("DataService"); - registerBus(); + MainApp.subscribe(this); } @Override protected void onHandleIntent(final Intent intent) { + if (intent == null) + return; if (Config.logFunctionCalls) log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras())); - if (ConfigBuilderPlugin.getPlugin().getActiveBgSource() == null) { + if (ConfigBuilderPlugin.getActiveBgSource() == null) { xDripEnabled = true; nsClientEnabled = false; mm640gEnabled = false; glimpEnabled = false; dexcomG5Enabled = false; poctechEnabled = false; - } else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) { + } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) { xDripEnabled = true; nsClientEnabled = false; mm640gEnabled = false; glimpEnabled = false; dexcomG5Enabled = false; poctechEnabled = false; - } else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) { + } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) { xDripEnabled = false; nsClientEnabled = true; mm640gEnabled = false; glimpEnabled = false; dexcomG5Enabled = false; poctechEnabled = false; - } else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) { + } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) { xDripEnabled = false; nsClientEnabled = false; mm640gEnabled = true; glimpEnabled = false; dexcomG5Enabled = false; poctechEnabled = false; - } else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) { + } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) { xDripEnabled = false; nsClientEnabled = false; mm640gEnabled = false; glimpEnabled = true; dexcomG5Enabled = false; poctechEnabled = false; - } else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) { + } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) { xDripEnabled = false; nsClientEnabled = false; mm640gEnabled = false; glimpEnabled = false; dexcomG5Enabled = true; poctechEnabled = false; - } else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourcePoctechPlugin.class)) { + } else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourcePoctechPlugin.class)) { xDripEnabled = false; nsClientEnabled = false; mm640gEnabled = false; @@ -126,55 +130,53 @@ public class DataService extends IntentService { acceptNSData = acceptNSData || bundles.getBoolean("islocal"); } - - if (intent != null) { - final String action = intent.getAction(); - if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) { - if (xDripEnabled) { - handleNewDataFromXDrip(intent); - } - } else if (Intents.NS_EMULATOR.equals(action)) { - if (mm640gEnabled) { - handleNewDataFromMM640g(intent); - } - } else if (Intents.GLIMP_BG.equals(action)) { - if (glimpEnabled) { - handleNewDataFromGlimp(intent); - } - } else if (Intents.DEXCOMG5_BG.equals(action)) { - if (dexcomG5Enabled) { - handleNewDataFromDexcomG5(intent); - } - } else if (Intents.POCTECH_BG.equals(action)) { - if (poctechEnabled) { - handleNewDataFromPoctech(intent); - } - } else if (Intents.ACTION_NEW_SGV.equals(action)) { - if (nsClientEnabled || SP.getBoolean(R.string.key_ns_autobackfill, true)) - handleNewDataFromNSClient(intent); - // Objectives 0 - ObjectivesPlugin.bgIsAvailableInNS = true; - ObjectivesPlugin.saveProgress(); - } else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) { - // always handle Profile if NSProfile is enabled without looking at nsUploadOnly - handleNewDataFromNSClient(intent); - } else if (acceptNSData && - (Intents.ACTION_NEW_TREATMENT.equals(action) || - Intents.ACTION_CHANGED_TREATMENT.equals(action) || - Intents.ACTION_REMOVED_TREATMENT.equals(action) || - Intents.ACTION_NEW_STATUS.equals(action) || - Intents.ACTION_NEW_DEVICESTATUS.equals(action) || - Intents.ACTION_NEW_FOOD.equals(action) || - Intents.ACTION_CHANGED_FOOD.equals(action) || - Intents.ACTION_REMOVED_FOOD.equals(action) || - Intents.ACTION_NEW_CAL.equals(action) || - Intents.ACTION_NEW_MBG.equals(action)) - ) { - handleNewDataFromNSClient(intent); - } else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) { - handleNewSMS(intent); + final String action = intent.getAction(); + if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) { + if (xDripEnabled) { + handleNewDataFromXDrip(intent); } + } else if (Intents.NS_EMULATOR.equals(action)) { + if (mm640gEnabled) { + handleNewDataFromMM640g(intent); + } + } else if (Intents.GLIMP_BG.equals(action)) { + if (glimpEnabled) { + handleNewDataFromGlimp(intent); + } + } else if (Intents.DEXCOMG5_BG.equals(action)) { + if (dexcomG5Enabled) { + handleNewDataFromDexcomG5(intent); + } + } else if (Intents.POCTECH_BG.equals(action)) { + if (poctechEnabled) { + handleNewDataFromPoctech(intent); + } + } else if (Intents.ACTION_NEW_SGV.equals(action)) { + if (nsClientEnabled || SP.getBoolean(R.string.key_ns_autobackfill, true)) + handleNewDataFromNSClient(intent); + // Objectives 0 + ObjectivesPlugin.bgIsAvailableInNS = true; + ObjectivesPlugin.saveProgress(); + } else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) { + // always handle Profile if NSProfile is enabled without looking at nsUploadOnly + handleNewDataFromNSClient(intent); + } else if (acceptNSData && + (Intents.ACTION_NEW_TREATMENT.equals(action) || + Intents.ACTION_CHANGED_TREATMENT.equals(action) || + Intents.ACTION_REMOVED_TREATMENT.equals(action) || + Intents.ACTION_NEW_STATUS.equals(action) || + Intents.ACTION_NEW_DEVICESTATUS.equals(action) || + Intents.ACTION_NEW_FOOD.equals(action) || + Intents.ACTION_CHANGED_FOOD.equals(action) || + Intents.ACTION_REMOVED_FOOD.equals(action) || + Intents.ACTION_NEW_CAL.equals(action) || + Intents.ACTION_NEW_MBG.equals(action)) + ) { + handleNewDataFromNSClient(intent); + } else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) { + handleNewSMS(intent); } + if (Config.logFunctionCalls) log.debug("onHandleIntent exit " + intent); DataReceiver.completeWakefulIntent(intent); @@ -195,16 +197,7 @@ public class DataService extends IntentService { @Override public void onDestroy() { super.onDestroy(); - MainApp.bus().unregister(this); - } - - private void registerBus() { - try { - MainApp.bus().unregister(this); - } catch (RuntimeException x) { - // Ignore - } - MainApp.bus().register(this); + MainApp.unsubscribe(this); } private void handleNewDataFromXDrip(Intent intent) { @@ -217,8 +210,9 @@ public class DataService extends IntentService { bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME); bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP); bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW); - String source = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "no Source specified"); - SourceXdripPlugin.getPlugin().setSource(source); + bgReading.sourcePlugin = SourceXdripPlugin.getPlugin().pluginDescription.getUserfriendlyName(); + bgReading.filtered = Objects.equals(bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION), "G5 Native"); + MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP"); } @@ -232,6 +226,8 @@ public class DataService extends IntentService { bgReading.direction = bundle.getString("myTrend"); bgReading.date = bundle.getLong("myTimestamp"); bgReading.raw = 0; + bgReading.filtered = false; + bgReading.sourcePlugin = SourceGlimpPlugin.getPlugin().pluginDescription.getUserfriendlyName(); MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP"); } @@ -256,6 +252,8 @@ public class DataService extends IntentService { bgReading.direction = json.getString("m_trend"); bgReading.date = json.getLong("m_time") * 1000L; bgReading.raw = 0; + bgReading.filtered = true; + bgReading.sourcePlugin = SourceDexcomG5Plugin.getPlugin().pluginDescription.getUserfriendlyName(); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5"); if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) { NSUpload.uploadBg(bgReading); @@ -264,9 +262,8 @@ public class DataService extends IntentService { NSUpload.sendToXdrip(bgReading); } } - } catch (JSONException e) { - e.printStackTrace(); + log.error("Unhandled exception", e); } } @@ -329,6 +326,8 @@ public class DataService extends IntentService { bgReading.direction = json_object.getString("direction"); bgReading.date = json_object.getLong("date"); bgReading.raw = json_object.getDouble("sgv"); + bgReading.filtered = true; + bgReading.sourcePlugin = SourceMM640gPlugin.getPlugin().pluginDescription.getUserfriendlyName(); MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g"); break; @@ -545,7 +544,7 @@ public class DataService extends IntentService { MainApp.getDbHelper().deleteProfileSwitchById(_id); } - private void handleTreatmentFromNS(JSONObject json, Intent intent) throws JSONException { + private void handleTreatmentFromNS(JSONObject json, Intent intent) { // new DB model int mode = Intents.ACTION_NEW_TREATMENT.equals(intent.getAction()) ? EventNsTreatment.ADD : EventNsTreatment.UPDATE; double insulin = JsonHelper.safeGetDouble(json, "insulin"); diff --git a/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java b/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java index bfbbfedbd1..272158f2ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java +++ b/app/src/main/java/info/nightscout/androidaps/data/ConstraintChecker.java @@ -42,10 +42,6 @@ public class ConstraintChecker implements ConstraintsInterface { return isSMBModeEnabled(new Constraint<>(true)); } - public Constraint isAdvancedFilteringEnabled() { - return isAdvancedFilteringEnabled(new Constraint<>(true)); - } - public Constraint getMaxBasalAllowed(Profile profile) { return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile); } @@ -69,7 +65,7 @@ public class ConstraintChecker implements ConstraintsInterface { @Override public Constraint isLoopInvocationAllowed(Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -81,7 +77,7 @@ public class ConstraintChecker implements ConstraintsInterface { @Override public Constraint isClosedLoopAllowed(Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); + ArrayList constraintsPlugins = MainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); for (PluginBase p : constraintsPlugins) { ConstraintsInterface constraint = (ConstraintsInterface) p; if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; @@ -126,17 +122,6 @@ public class ConstraintChecker implements ConstraintsInterface { return value; } - @Override - public Constraint isAdvancedFilteringEnabled(Constraint value) { - ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); - for (PluginBase p : constraintsPlugins) { - ConstraintsInterface constraint = (ConstraintsInterface) p; - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue; - constraint.isAdvancedFilteringEnabled(value); - } - return value; - } - @Override public Constraint applyBasalConstraints(Constraint absoluteRate, Profile profile) { ArrayList constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class); diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java index a45ab083e7..429bfff8fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/BgSourceInterface.java @@ -3,6 +3,4 @@ package info.nightscout.androidaps.interfaces; /** * Created by mike on 20.06.2016. */ -public interface BgSourceInterface { - boolean advancedFilteringSupported(); -} +public interface BgSourceInterface {} diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java index 820170dc0f..4404379196 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/ConstraintsInterface.java @@ -27,10 +27,6 @@ public interface ConstraintsInterface { return value; } - default Constraint isAdvancedFilteringEnabled(Constraint value) { - return value; - } - default Constraint applyBasalConstraints(Constraint absoluteRate, Profile profile) { return absoluteRate; } diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java index 1634fc672d..4b073443bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PluginDescription.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.interfaces; +import info.nightscout.androidaps.MainApp; + public class PluginDescription { PluginType mainType = PluginType.GENERAL; String fragmentClass = null; @@ -87,4 +89,8 @@ public class PluginDescription { public PluginType getType() { return mainType; } + + public String getUserfriendlyName() { + return MainApp.gs(pluginName); + } } 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 5bb810274e..e28f0782da 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 @@ -65,12 +65,11 @@ public class ConfigBuilderPlugin extends PluginBase { return configBuilderPlugin; } - private BgSourceInterface activeBgSource; + private static BgSourceInterface activeBgSource; private static PumpInterface activePump; private static ProfileInterface activeProfile; private static TreatmentsInterface activeTreatments; private static APSInterface activeAPS; - private static LoopPlugin activeLoop; private static InsulinInterface activeInsulin; private static SensitivityInterface activeSensitivity; @@ -249,7 +248,7 @@ public class ConfigBuilderPlugin extends PluginBase { return commandQueue; } - public BgSourceInterface getActiveBgSource() { + public static BgSourceInterface getActiveBgSource() { return activeBgSource; } @@ -329,9 +328,6 @@ public class ConfigBuilderPlugin extends PluginBase { } this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP); - // PluginType.LOOP - activeLoop = this.determineActivePlugin(PluginType.LOOP); - // PluginType.TREATMENT activeTreatments = this.determineActivePlugin(PluginType.TREATMENT); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java index 3d17970edc..d68d4a2edc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java @@ -92,17 +92,6 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { return value; } - @Override - public Constraint isAdvancedFilteringEnabled(Constraint value) { - BgSourceInterface bgSource = MainApp.getConfigBuilder().getActiveBgSource(); - - if (bgSource != null) { - if (!bgSource.advancedFilteringSupported()) - value.set(false, MainApp.gs(R.string.smbalwaysdisabled), this); - } - return value; - } - @Override public Constraint applyBasalConstraints(Constraint absoluteRate, Profile profile) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index f28a6eff8e..54bfd9d780 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -14,6 +14,8 @@ import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.db.BgReading; +import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.interfaces.APSInterface; @@ -104,6 +106,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { } GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); + BgReading bgReading = DatabaseHelper.actualBg(); Profile profile = MainApp.getConfigBuilder().getProfile(); PumpInterface pump = ConfigBuilderPlugin.getActivePump(); @@ -121,7 +124,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { return; } - if (glucoseStatus == null) { + if (glucoseStatus == null || bgReading == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); if (Config.logAPSResult) log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); @@ -189,10 +192,6 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { MainApp.getConstraintChecker().isSMBModeEnabled(smbAllowed); inputConstraints.copyReasons(smbAllowed); - Constraint advancedFiltering = new Constraint<>(!tempBasalFallback); - MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering); - inputConstraints.copyReasons(advancedFiltering); - Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); Profiler.log(log, "SMB data gathering", start); @@ -202,7 +201,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { lastAutosensResult.ratio, //autosensDataRatio isTempTarget, smbAllowed.value(), - advancedFiltering.value() + bgReading.filtered ); } catch (JSONException e) { log.error(e.getMessage()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java index af040c8c90..64fa05fca8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java @@ -33,8 +33,4 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac ); } - @Override - public boolean advancedFilteringSupported() { - return true; - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java index 38b891ff65..bc3bb0dcd3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java @@ -28,8 +28,4 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface { ); } - @Override - public boolean advancedFilteringSupported() { - return false; - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java index 041b084efd..e2a73c46fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java @@ -27,8 +27,4 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface ); } - @Override - public boolean advancedFilteringSupported() { - return false; - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java index c99fbcb9bb..d5f30b1a37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java @@ -20,9 +20,6 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac return plugin; } - private long lastBGTimeStamp = 0; - private boolean isAdvancedFilteringEnabled = false; - private SourceNSClientPlugin() { super(new PluginDescription() .mainType(PluginType.BGSOURCE) @@ -34,18 +31,4 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac ); } - @Override - public boolean advancedFilteringSupported() { - return isAdvancedFilteringEnabled; - } - - public void detectSource(String source, long timeStamp) { - if (timeStamp > lastBGTimeStamp) { - if (source.contains("G5 Native") || source.contains("AndroidAPS-DexcomG5")) - isAdvancedFilteringEnabled = true; - else - isAdvancedFilteringEnabled = false; - lastBGTimeStamp = timeStamp; - } - } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java index 13cb99d392..9f15bd9b29 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java @@ -31,9 +31,4 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface ); } - @Override - public boolean advancedFilteringSupported() { - return false; - } - } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java index fa61c9ea61..a69ff84c2d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java @@ -13,8 +13,6 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { private static SourceXdripPlugin plugin = null; - boolean advancedFiltering; - public static SourceXdripPlugin getPlugin() { if (plugin == null) plugin = new SourceXdripPlugin(); @@ -29,13 +27,4 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { .description(R.string.description_source_xdrip) ); } - - @Override - public boolean advancedFilteringSupported() { - return advancedFiltering; - } - - public void setSource(String source) { - this.advancedFiltering = source.contains("G5 Native"); - } } diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java index 655cc23282..6b584a365d 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java @@ -111,15 +111,15 @@ public class ConstraintsCheckerTest { Assert.assertEquals(Boolean.FALSE, c.value()); } - @Test - public void isAdvancedFilteringEnabledTest() throws Exception { - when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); - - Constraint c = constraintChecker.isAdvancedFilteringEnabled(); - Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety - Assert.assertEquals(true, c.getMostLimitedReasonList().size() == 1); // Safety - Assert.assertEquals(Boolean.FALSE, c.value()); - } +// @Test +// public void isAdvancedFilteringEnabledTest() throws Exception { +// when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); +// +// Constraint c = constraintChecker.isAdvancedFilteringEnabled(); +// Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety +// Assert.assertEquals(true, c.getMostLimitedReasonList().size() == 1); // Safety +// Assert.assertEquals(Boolean.FALSE, c.value()); +// } @Test public void isSMBModeEnabledTest() throws Exception { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java index 77a91046ab..ee3359c84e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java @@ -89,15 +89,16 @@ public class SafetyPluginTest { Assert.assertEquals(Boolean.FALSE, c.value()); } - @Test - public void bgsourceShouldPreventSMBAlways() throws Exception { - when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); - - Constraint c = new Constraint<>(true); - c = safetyPlugin.isAdvancedFilteringEnabled(c); - Assert.assertEquals("Safety: SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering", c.getReasons()); - Assert.assertEquals(Boolean.FALSE, c.value()); - } + // TODO +// @Test +// public void bgsourceShouldPreventSMBAlways() throws Exception { +// when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); +// +// Constraint c = new Constraint<>(true); +// c = safetyPlugin.isAdvancedFilteringEnabled(c); +// Assert.assertEquals("Safety: SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering", c.getReasons()); +// Assert.assertEquals(Boolean.FALSE, c.value()); +// } @Test public void basalRateShouldBeLimited() throws Exception { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5PluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5PluginTest.java index 042aaeadbf..7f160ce1d2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5PluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5PluginTest.java @@ -15,8 +15,8 @@ public class SourceDexcomG5PluginTest { Assert.assertNotEquals(null, SourceDexcomG5Plugin.getPlugin()); } - @Test - public void advancedFilteringSupported() { - Assert.assertEquals(true, SourceDexcomG5Plugin.getPlugin().advancedFilteringSupported()); - } +// @Test +// public void advancedFilteringSupported() { +// Assert.assertEquals(true, SourceDexcomG5Plugin.getPlugin().advancedFilteringSupported()); +// } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPluginTest.java index 045552c8da..0910442be8 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPluginTest.java @@ -15,8 +15,8 @@ public class SourceGlimpPluginTest { Assert.assertNotEquals(null, SourceGlimpPlugin.getPlugin()); } - @Test - public void advancedFilteringSupported() { - Assert.assertEquals(false, SourceGlimpPlugin.getPlugin().advancedFilteringSupported()); - } +// @Test +// public void advancedFilteringSupported() { +// Assert.assertEquals(false, SourceGlimpPlugin.getPlugin().advancedFilteringSupported()); +// } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPluginTest.java index 9bbe86da40..e40f9bb492 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPluginTest.java @@ -15,8 +15,8 @@ public class SourceMM640gPluginTest { Assert.assertNotEquals(null, SourceMM640gPlugin.getPlugin()); } - @Test - public void advancedFilteringSupported() { - Assert.assertEquals(false, SourceMM640gPlugin.getPlugin().advancedFilteringSupported()); - } +// @Test +// public void advancedFilteringSupported() { +// Assert.assertEquals(false, SourceMM640gPlugin.getPlugin().advancedFilteringSupported()); +// } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPluginTest.java index 3ca70a900b..fecf0712d8 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPluginTest.java @@ -13,8 +13,8 @@ public class SourceNSClientPluginTest { Assert.assertNotEquals(null, SourceNSClientPlugin.getPlugin()); } - @Test - public void advancedFilteringSupported() { - Assert.assertEquals(false, SourceNSClientPlugin.getPlugin().advancedFilteringSupported()); - } +// @Test +// public void advancedFilteringSupported() { +// Assert.assertEquals(false, SourceNSClientPlugin.getPlugin().advancedFilteringSupported()); +// } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java index f85719dc47..33d9bc45b1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java @@ -15,8 +15,8 @@ public class SourceXdripPluginTest { Assert.assertNotEquals(null, SourceXdripPlugin.getPlugin()); } - @Test - public void advancedFilteringSupported() { - Assert.assertEquals(false, SourceXdripPlugin.getPlugin().advancedFilteringSupported()); - } +// @Test +// public void advancedFilteringSupported() { +// Assert.assertEquals(false, SourceXdripPlugin.getPlugin().advancedFilteringSupported()); +// } } \ No newline at end of file