From 832138398f2000ce8a56545c070cf10f7e288579 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 18 Feb 2018 11:53:41 +0100 Subject: [PATCH] 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