From a3de99b993d481219a4e64948f06a54563cabde1 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Sun, 3 Jul 2022 19:36:46 +0200 Subject: [PATCH] Fixing on problem introduced by fixing "Fake TBR": wipe pod adsress on Discard but keep state object --- .../driver/manager/ErosPodStateManager.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java index 27eb849931..caa6d72f4d 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/driver/manager/ErosPodStateManager.java @@ -49,24 +49,38 @@ public abstract class ErosPodStateManager { this.gsonInstance = createGson(); } + /** + * Discard Pod state + */ public final void discardState() { - this.podState = new PodState(this.podState.address); + // Change on commit 4cea57acf6d74baffef83e1f04376b10bb5c1978 Nov 2021 + // As by commit, keep podState object but wipe address to 0x0 to signal hasPodState() + // there is no state ( = no Pod address). + this.podState = new PodState(0x0); storePodState(); } + /** + * Init Pod state but only if it has valid state. + * @param address New Pod address + */ public final void initState(int address) { if (hasPodState()) { - throw new IllegalStateException("Can not init a new pod state: podState <> null"); + throw new IllegalStateException("Can not init a new pod state: State is " + + "null or discarded?"); } podState = new PodState(address); storePodState(); } /** - * @return true if we have a Pod state (which at least contains an address), indicating it is legal to call getters on PodStateManager + * @return true if we have a Pod state (which at least contains an valid address), indicating + * it is legal to call getters on PodStateManager */ public final boolean hasPodState() { - return podState != null; + + return this.podState != null + && this.podState.getAddress() != 0x0; // 0x0=discarded } /**