From 090e1b13f8b31363dd95ddddb6302bc3ee2fb700 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 5 Mar 2018 22:30:48 +0100 Subject: [PATCH 1/5] Add basic Engineering mode. - Insight plugin disabled unless EM enabled - Closed loop constrainted unless EM enabled. --- app/src/main/java/info/nightscout/androidaps/MainApp.java | 8 +++++++- .../plugins/ConstraintsSafety/SafetyPlugin.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 412383c6e1..5599e26a68 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -20,6 +20,7 @@ import net.danlew.android.joda.JodaTimeAndroid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.util.ArrayList; import info.nightscout.androidaps.Services.Intents; @@ -95,6 +96,9 @@ public class MainApp extends Application { private static AckAlarmReceiver ackAlarmReciever = new AckAlarmReceiver(); private LocalBroadcastManager lbm; + public static boolean devBranch; + public static boolean engineeringMode; + @Override public void onCreate() { super.onCreate(); @@ -139,7 +143,7 @@ public class MainApp extends Application { if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin()); if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin()); pluginsList.add(CareportalPlugin.getPlugin()); - // if (Config.DANAR) pluginsList.add(InsightPumpPlugin.getPlugin()); // <-- Enable Insight plugin here + if (Config.DANAR && engineeringMode) pluginsList.add(InsightPumpPlugin.getPlugin()); // <-- Enable Insight plugin here if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin()); if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getPlugin()); if (Config.APS) pluginsList.add(LoopPlugin.getPlugin()); @@ -195,6 +199,8 @@ public class MainApp extends Application { } }).start(); + engineeringMode = new File(System.getProperty("EXT_FILES_DIR"),"engineering_mode").canRead(); + devBranch = BuildConfig.VERSION.contains("dev"); } private void registerLocalBroadcastReceiver() { 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 ef30a0ebb9..37000f345c 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 @@ -102,6 +102,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface { **/ @Override public boolean isClosedModeEnabled() { + if (MainApp.devBranch && !MainApp.engineeringMode) return false; String mode = SP.getString("aps_mode", "open"); return mode.equals("closed") && BuildConfig.CLOSEDLOOP; } From 637b0c6189bdccab5ae8afca88de9582bb5618c2 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 10 Mar 2018 09:58:47 +0100 Subject: [PATCH 2/5] On start, show notification if on dev-branch, but not EM, so CL is disabled. --- app/src/main/java/info/nightscout/androidaps/MainApp.java | 7 +++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 5599e26a68..8b85b5ecab 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -47,6 +47,8 @@ import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin; import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin; import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin; @@ -201,6 +203,11 @@ public class MainApp extends Application { engineeringMode = new File(System.getProperty("EXT_FILES_DIR"),"engineering_mode").canRead(); devBranch = BuildConfig.VERSION.contains("dev"); + + if (devBranch && !engineeringMode) { + Notification n = new Notification(Notification.TOAST_ALARM, gs(R.string.closed_loop_disabled_on_dev_branch), Notification.NORMAL); + bus().post(new EventNewNotification(n)); + } } private void registerLocalBroadcastReceiver() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3e923bf821..e9bb24c95f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -969,5 +969,6 @@ Fabric Upload Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service. Please update your G5 app to supported version + Running dev version. Closed loop is disabled From a398d95bb4a232140e6dd95e39f13cb0aaf5dba8 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 12 Mar 2018 23:03:14 +0100 Subject: [PATCH 3/5] Add info to About dialog when engineering mode is enabled. --- app/src/main/java/info/nightscout/androidaps/MainActivity.java | 2 ++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 3 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 91446ada32..ef4908a9f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -396,6 +396,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe builder.setIcon(R.mipmap.blueowl); String message = "Build: " + BuildConfig.BUILDVERSION + "\n"; message += MainApp.sResources.getString(R.string.configbuilder_nightscoutversion_label) + " " + ConfigBuilderPlugin.nightscoutVersionName; + if (MainApp.engineeringMode) + message += MainApp.gs(R.string.engineering_mode_enabled); builder.setMessage(message); builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null); AlertDialog alertDialog = builder.create(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e9bb24c95f..fd190bf531 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -970,5 +970,6 @@ Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service. Please update your G5 app to supported version Running dev version. Closed loop is disabled + Engineering mode enabled From 39aae28101ea7e679211bacbcd25f57abe228349 Mon Sep 17 00:00:00 2001 From: "Markus M. May" Date: Thu, 15 Mar 2018 21:51:43 +0100 Subject: [PATCH 4/5] Disable profile switch if not in Engineering mode and on dev branch --- app/src/main/java/info/nightscout/androidaps/MainApp.java | 8 +++++++- .../androidaps/plugins/Actions/ActionsFragment.java | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 7db2bbb739..711261ca36 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -201,7 +201,9 @@ public class MainApp extends Application { } }).start(); - engineeringMode = new File(System.getProperty("EXT_FILES_DIR"),"engineering_mode").canRead(); + File engineeringModeSemaphore = new File(System.getProperty("EXT_FILES_DIR"),"engineering_mode"); + + engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile(); devBranch = BuildConfig.VERSION.contains("dev"); if (devBranch && !engineeringMode) { @@ -374,6 +376,10 @@ public class MainApp extends Application { return null; } + public static boolean isDevModeOrRelease() { + return (devBranch && engineeringMode) || !devBranch; + } + @Override public void onTerminate() { super.onTerminate(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index 0edf29c1e4..08e0ae96d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -127,7 +127,10 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL return; } final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); - if (!pump.getPumpDescription().isSetBasalProfileCapable || !pump.isInitialized() || pump.isSuspended()) + final boolean basalprofileEnabled = MainApp.isDevModeOrRelease() + && pump.getPumpDescription().isSetBasalProfileCapable; + + if (!basalprofileEnabled || !pump.isInitialized() || pump.isSuspended()) profileSwitch.setVisibility(View.GONE); else profileSwitch.setVisibility(View.VISIBLE); From 2c3f28670c3a43c939b44a8fa156fc2459484087 Mon Sep 17 00:00:00 2001 From: "Markus M. May" Date: Thu, 15 Mar 2018 23:00:08 +0100 Subject: [PATCH 5/5] Disallow profile store on pump if on dev branch but not in engineering mode --- .../androidaps/plugins/Actions/ActionsFragment.java | 1 - .../plugins/Overview/notifications/Notification.java | 1 + .../info/nightscout/androidaps/queue/CommandQueue.java | 8 ++++++++ app/src/main/res/values/strings.xml | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index 08e0ae96d1..12c24b1595 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -135,7 +135,6 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL else profileSwitch.setVisibility(View.VISIBLE); - if (!pump.getPumpDescription().isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || pump.isFakingTempsByExtendedBoluses()) { extendedBolus.setVisibility(View.GONE); extendedBolusCancel.setVisibility(View.GONE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java index 7f8b94cfa9..38d54bc6fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java @@ -59,6 +59,7 @@ public class Notification { public static final int MINIMAL_BASAL_VALUE_REPLACED = 29; public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30; public static final int ZERO_VALUE_IN_PROFILE = 31; + public static final int NOT_ENG_MODE_OR_RELEASE = 32; public int id; public Date date; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index b41a1727b3..3977178e73 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -293,6 +293,14 @@ public class CommandQueue { return false; } + if (!MainApp.isDevModeOrRelease()) { + Notification notification = new Notification(Notification.NOT_ENG_MODE_OR_RELEASE, MainApp.sResources.getString(R.string.not_eng_mode_or_release), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + if (callback != null) + callback.result(new PumpEnactResult().success(false).comment(MainApp.sResources.getString(R.string.not_eng_mode_or_release))).run(); + return false; + } + // Compare with pump limits Profile.BasalValue[] basalValues = profile.getBasalValues(); PumpInterface pump = ConfigBuilderPlugin.getActivePump(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7097b5879d..06f61ac006 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -971,7 +971,6 @@ Fabric Upload Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service. Please update your G5 app to supported version - Suspend for 30 min Start Activity TT Start Eating soon TT @@ -984,5 +983,6 @@ ns_autobackfill Running dev version. Closed loop is disabled Engineering mode enabled + Engineering mode not enabled and not on release branch