From c9a3d62944bb3b8f034630c00b7715b217c7e113 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Sat, 19 Dec 2020 22:01:16 +0100 Subject: [PATCH] Improve automatic dismissal of Omnipod TBR notifications --- .../general/overview/notifications/Notification.java | 2 +- .../plugins/pump/omnipod/OmnipodPumpPlugin.java | 2 +- .../pump/omnipod/manager/AapsOmnipodManager.java | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java index ff466b409f..b35d65e62c 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java @@ -73,7 +73,7 @@ public class Notification { public static final int OMNIPOD_POD_SUSPENDED = 61; public static final int OMNIPOD_POD_ALERTS_UPDATED = 62; public static final int OMNIPOD_POD_ALERTS = 63; - public static final int OMNIPOD_UNCERTAIN_TBR = 64; + public static final int OMNIPOD_TBR_ALERTS = 64; public static final int OMNIPOD_POD_FAULT = 66; public static final int OMNIPOD_UNCERTAIN_SMB = 67; public static final int OMNIPOD_UNKNOWN_TBR = 68; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 13e4e874fc..fdbc32a199 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -393,7 +393,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, activePlugin.getActiveTreatments().removeTempBasal(tempBasal); } - rxBus.send(new EventDismissNotification(Notification.OMNIPOD_UNCERTAIN_TBR)); + rxBus.send(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); } private void handleActivePodAlerts() { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java index f2f24fd5e7..a18408d47b 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java @@ -493,7 +493,7 @@ public class AapsOmnipodManager { String errorMessage = translateException(ex.getCause()); addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); - showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); + showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation @@ -503,7 +503,7 @@ public class AapsOmnipodManager { long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); if (!OmnipodManager.isCertainFailure(ex)) { - showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); + showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); // Assume that setting the temp basal succeeded here, because in case it didn't succeed, // The next StatusResponse that we receive will allow us to recover from the wrong state @@ -522,6 +522,8 @@ public class AapsOmnipodManager { addTempBasalTreatment(System.currentTimeMillis(), pumpId, tempBasalPair); + sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); + return new PumpEnactResult(injector) .duration(tempBasalPair.getDurationMinutes()) .absolute(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate())) @@ -533,7 +535,7 @@ public class AapsOmnipodManager { executeCommand(() -> delegate.cancelTemporaryBasal(isTbrBeepsEnabled())); } catch (Exception ex) { if (OmnipodManager.isCertainFailure(ex)) { - showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); + showNotification(Notification.OMNIPOD_TBR_ALERTS, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); } else { splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation } @@ -552,6 +554,8 @@ public class AapsOmnipodManager { activePlugin.getActiveTreatments().addToHistoryTempBasal(tempBasal); + sendEvent(new EventDismissNotification(Notification.OMNIPOD_TBR_ALERTS)); + return new PumpEnactResult(injector).success(true).enacted(true); }