From bafffad44a4ebfc203cf4352cc331b840da260cf Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Wed, 6 May 2020 21:41:33 +0200 Subject: [PATCH] Use transient keyword instead of Gson annotation for PodSessionState members that should be exluded of (de)serialization --- .../omnipod/defs/state/PodSessionState.java | 41 ++++++------------- .../pump/omnipod/defs/state/PodState.java | 1 - .../pump/omnipod/util/OmnipodUtil.java | 4 +- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java index 208a9a5051..64cb92e84b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodSessionState.java @@ -1,7 +1,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs.state; import com.google.gson.Gson; -import com.google.gson.annotations.Expose; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -34,42 +33,26 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP; public class PodSessionState extends PodState { - @Inject AAPSLogger aapsLogger; - @Inject SP sp; - @Inject OmnipodUtil omnipodUtil; + @Inject transient AAPSLogger aapsLogger; + @Inject transient SP sp; + @Inject transient OmnipodUtil omnipodUtil; - @Expose - private final Map configuredAlerts; - @Expose private transient PodStateChangedHandler stateChangedHandler; - @Expose - private DateTime activatedAt; - @Expose - private DateTime expiresAt; - @Expose - private final FirmwareVersion piVersion; - @Expose - private final FirmwareVersion pmVersion; - @Expose - private final int lot; - @Expose - private final int tid; - @Expose - private Double reservoirLevel; - @Expose - private boolean suspended; - @Expose + private final Map configuredAlerts; private DateTimeZone timeZone; - @Expose + private DateTime activatedAt; + private DateTime expiresAt; + private final FirmwareVersion piVersion; + private final FirmwareVersion pmVersion; + private final int lot; + private final int tid; + private Double reservoirLevel; + private boolean suspended; private NonceState nonceState; - @Expose private SetupProgress setupProgress; - @Expose private AlertSet activeAlerts; - @Expose private BasalSchedule basalSchedule; - @Expose private DeliveryStatus lastDeliveryStatus; public PodSessionState(DateTimeZone timeZone, int address, FirmwareVersion piVersion, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodState.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodState.java index 8f229f3ec2..c6987c879e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodState.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/state/PodState.java @@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs.state; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent; -import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; public abstract class PodState { protected final int address; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java index 6d4261042f..a0d6203309 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodUtil.java @@ -136,7 +136,7 @@ public class OmnipodUtil { .registerTypeAdapter(DateTimeZone.class, (JsonDeserializer) (json, typeOfT, context) -> DateTimeZone.forID(json.getAsString())); - return gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); + return gsonBuilder.create(); } @@ -195,7 +195,7 @@ public class OmnipodUtil { } public Integer getNextPodAddress() { - if(sp.contains(OmnipodConst.Prefs.NextPodAddress)) { + if (sp.contains(OmnipodConst.Prefs.NextPodAddress)) { int nextPodAddress = sp.getInt(OmnipodConst.Prefs.NextPodAddress, 0); if (OmnipodManager.isValidAddress(nextPodAddress)) { return nextPodAddress;