From 03d53947169f6c73e5619193df719de0f44ec406 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Tue, 15 Dec 2020 01:18:11 +0100 Subject: [PATCH] Automatically dismiss 'Failed to retrieve Pod status on startup' notification upon any update from status response --- .../pump/omnipod/driver/manager/PodStateManager.java | 11 +++++++++-- .../pump/omnipod/manager/AapsOmnipodManager.java | 2 -- .../pump/omnipod/manager/AapsPodStateManager.java | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java index 570289a198..b32dee2ede 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/PodStateManager.java @@ -105,14 +105,14 @@ public abstract class PodStateManager { /** * @return true if the Pod's activation time has been exceeded */ - public boolean isPodActivationTimeExceeded() { + public final boolean isPodActivationTimeExceeded() { return isPodInitialized() && getPodProgressStatus() == PodProgressStatus.ACTIVATION_TIME_EXCEEDED; } /** * @return true if we have a Pod state and the Pod is dead, meaning it is either in a fault state or activation time has been exceeded or it is deactivated */ - public boolean isPodDead() { + public final boolean isPodDead() { return isPodInitialized() && getPodProgressStatus().isDead(); } @@ -603,6 +603,8 @@ public abstract class PodStateManager { podState.setLastUpdatedFromResponse(DateTime.now()); }); + + onUpdatedFromResponse(); } protected void onTbrChanged() { @@ -625,6 +627,11 @@ public abstract class PodStateManager { // Can be overridden in subclasses } + protected void onUpdatedFromResponse() { + // Deliberately left empty + // Can be overridden in subclasses + } + private void setAndStore(Runnable runnable) { setSafe(runnable); storePodState(); 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 025d62a330..d7a81d0393 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 @@ -270,8 +270,6 @@ public class AapsOmnipodManager { addSuccessToHistory(PodHistoryEntryType.GET_POD_STATUS, statusResponse); - sendEvent(new EventDismissNotification(Notification.OMNIPOD_STARTUP_STATUS_REFRESH_FAILED)); - return new PumpEnactResult(injector).success(true).enacted(false); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsPodStateManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsPodStateManager.java index 6ebaa1d3b9..085b16d9a9 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsPodStateManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsPodStateManager.java @@ -5,6 +5,8 @@ import javax.inject.Singleton; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; +import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification; +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.pump.omnipod.definition.OmnipodStorageKeys; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodActiveAlertsChanged; @@ -50,4 +52,8 @@ public class AapsPodStateManager extends PodStateManager { @Override protected void onFaultEventChanged() { rxBus.send(new EventOmnipodFaultEventChanged()); } + + @Override protected void onUpdatedFromResponse() { + rxBus.send(new EventDismissNotification(Notification.OMNIPOD_STARTUP_STATUS_REFRESH_FAILED)); + } }