From 832138398f2000ce8a56545c070cf10f7e288579 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 18 Feb 2018 11:53:41 +0100 Subject: [PATCH 1/3] Crappy hack to deal with applying the first profile switch. --- .../androidaps/queue/CommandQueue.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 bb226c6167..62d861b27d 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.queue; import android.content.Context; import android.content.Intent; +import android.os.SystemClock; import android.support.v7.app.AppCompatActivity; import android.text.Html; import android.text.Spanned; @@ -289,13 +290,17 @@ public class CommandQueue { // Check that there is a valid profileSwitch NOW if (MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis())==null) { - Notification noProfileSwitchNotif = new Notification(Notification.PROFILE_SWITCH_MISSING, MainApp.sResources.getString(R.string.profileswitch_ismissing), Notification.NORMAL); - MainApp.bus().post(new EventNewNotification(noProfileSwitchNotif)); - if (callback != null) { - PumpEnactResult result = new PumpEnactResult().success(false).enacted(false).comment("Refuse to send profile to pump! No ProfileSwitch!"); - callback.result(result).run(); + // wait for DatabaseHelper.scheduleProfiSwitch() to do the profile switch // TODO clean this crap up + SystemClock.sleep(5000); + if (MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis())==null) { + Notification noProfileSwitchNotif = new Notification(Notification.PROFILE_SWITCH_MISSING, MainApp.sResources.getString(R.string.profileswitch_ismissing), Notification.NORMAL); + MainApp.bus().post(new EventNewNotification(noProfileSwitchNotif)); + if (callback != null) { + PumpEnactResult result = new PumpEnactResult().success(false).enacted(false).comment("Refuse to send profile to pump! No ProfileSwitch!"); + callback.result(result).run(); + } + return false; } - return false; } // Compare with pump limits From 71dfb6d314be1537f5d9b4bdb34271db235c808e Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 18 Feb 2018 12:42:18 +0100 Subject: [PATCH 2/3] Set combo version. --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 96513dbb09..15a3a1dfd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { targetSdkVersion 23 multiDexEnabled true versionCode 1500 - version "1.57-combo-csv2-beta-6" + version "1.58-combo-phantom-fusion" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", generateGitBuild() From a42d95df14b55d798589c69418d9d193a027155b Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 18 Feb 2018 13:29:35 +0100 Subject: [PATCH 3/3] Unbreak unit test. --- .../info/nightscout/androidaps/queue/CommandQueue.java | 2 +- .../nightscout/androidaps/queue/CommandQueueTest.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) 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 62d861b27d..517a4f45c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -293,7 +293,7 @@ public class CommandQueue { // wait for DatabaseHelper.scheduleProfiSwitch() to do the profile switch // TODO clean this crap up SystemClock.sleep(5000); if (MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis())==null) { - Notification noProfileSwitchNotif = new Notification(Notification.PROFILE_SWITCH_MISSING, MainApp.sResources.getString(R.string.profileswitch_ismissing), Notification.NORMAL); + Notification noProfileSwitchNotif = new Notification(Notification.PROFILE_SWITCH_MISSING, MainApp.gs(R.string.profileswitch_ismissing), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(noProfileSwitchNotif)); if (callback != null) { PumpEnactResult result = new PumpEnactResult().success(false).enacted(false).comment("Refuse to send profile to pump! No ProfileSwitch!"); diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java index 31d8636de2..3e5864a1cc 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java @@ -81,17 +81,18 @@ public class CommandQueueTest extends CommandQueue { extendedBolus(1, 30, null); Assert.assertEquals(2, size()); - // add setProfile + // add setProfile (command is not queued before unless a ProfileSwitch exists) + // TODO test with profile switch set setProfile(new Profile(new JSONObject(profileJson), Constants.MGDL), null); - Assert.assertEquals(3, size()); + Assert.assertEquals(2, size()); // add loadHistory loadHistory((byte) 0, null); - Assert.assertEquals(4, size()); + Assert.assertEquals(3, size()); // add loadEvents loadEvents(null); - Assert.assertEquals(5, size()); + Assert.assertEquals(4, size()); clear(); tempBasalAbsolute(0, 30, true, null);