diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
index 0d98c9bfdd..1cd047eccd 100644
--- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
+++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
@@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.common.ManufacturerType;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
+import info.nightscout.androidaps.utils.TimeChangeType;
/**
* Created by mike on 04.06.2016.
@@ -96,8 +97,9 @@ public interface PumpInterface {
/**
* This method will be called when time or Timezone changes, and pump driver can then do a specific action (for
* example update clock on pump).
+ * @param timeChangeType
*/
- void timeDateOrTimeZoneChanged();
+ void timezoneOrDSTChanged(TimeChangeType timeChangeType);
/* Only used for pump types where hasFixedUnreachableAlert=true */
default boolean isFixedUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java
index 32a17f8a89..5c5a842d17 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java
@@ -67,6 +67,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.InstanceId;
import info.nightscout.androidaps.utils.SP;
+import info.nightscout.androidaps.utils.TimeChangeType;
/**
* Created by mike on 05.08.2016.
@@ -1390,7 +1391,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java
index a5ea8b1071..9fe972660e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java
@@ -42,6 +42,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.FabricPrivacy;
+import info.nightscout.androidaps.utils.TimeChangeType;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
@@ -477,7 +478,7 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java
index 1a40e449e5..2ff44380f9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java
@@ -44,6 +44,7 @@ import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.SP;
+import info.nightscout.androidaps.utils.TimeChangeType;
/**
* Created by mike on 28.01.2018.
@@ -506,7 +507,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java
index 55be88996b..752988b331 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java
@@ -63,6 +63,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.SP;
import info.nightscout.androidaps.utils.T;
+import info.nightscout.androidaps.utils.TimeChangeType;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
@@ -849,7 +850,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java
index 5104e70fe8..4608dcc553 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java
@@ -129,6 +129,7 @@ import info.nightscout.androidaps.plugins.treatments.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.SP;
+import info.nightscout.androidaps.utils.TimeChangeType;
public class LocalInsightPlugin extends PluginBase implements PumpInterface, ConstraintsInterface, InsightConnectionService.StateCallback {
@@ -1624,7 +1625,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java
index 21cac73d5d..18964865d8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java
@@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.InstanceId;
+import info.nightscout.androidaps.utils.TimeChangeType;
/**
@@ -279,7 +280,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java
index a3c6f8ced7..d1296d26c9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java
@@ -33,7 +33,6 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
-import info.nightscout.androidaps.events.EventCustomActionsChanged;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
@@ -48,7 +47,6 @@ import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperAc
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
-import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
@@ -81,6 +79,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.SP;
+import info.nightscout.androidaps.utils.TimeChangeType;
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
@@ -1606,7 +1605,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
if (isLoggingEnabled())
LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java
index 0c5daefc5c..c1be954790 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java
@@ -54,7 +54,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.pod
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
-import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
@@ -71,6 +70,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.SP;
+import info.nightscout.androidaps.utils.TimeChangeType;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
@@ -124,13 +124,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
displayConnectionMessages = false;
+ //OmnipodUtil.setDriverState();
-
- if (OmnipodUtil.isOmnipodEros()) {
- OmnipodUtil.setPlugin(this);
- OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
- OmnipodUtil.setPumpType(PumpType.Insulet_Omnipod);
- }
+// TODO loop
+// if (OmnipodUtil.isOmnipodEros()) {
+// OmnipodUtil.setPlugin(this);
+// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
+// OmnipodUtil.setPumpType(PumpType.Insulet_Omnipod);
+// }
// // TODO ccc
// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
@@ -202,7 +203,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
(event.isChanged(R.string.key_omnipod_beep_bolus_enabled)) ||
(event.isChanged(R.string.key_omnipod_beep_tbr_enabled)) ||
(event.isChanged(R.string.key_omnipod_pod_debugging_options_enabled)) ||
- (event.isChanged(R.string.key_omnipod_beep_smb_enabled)))
+ (event.isChanged(R.string.key_omnipod_beep_smb_enabled)) ||
+ (event.isChanged(R.string.key_omnipod_timechange_enabled)))
refreshConfiguration();
}, FabricPrivacy::logException)
);
@@ -488,7 +490,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
//driverState = OmnipodDriverState.Initalized_PodAvailable;
- OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAvailable);
+ //OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAvailable);
// we would probably need to read Basal Profile here too
}
@@ -959,12 +961,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
}
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
if (isLoggingEnabled())
- LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
+ LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. [changeType={}, eventHandlingEnabled={}]", timeChangeType.name(), pumpStatusLocal.timeChangeEventEnabled);
- this.hasTimeDateOrTimeZoneChanged = true;
+ if (OmnipodUtil.getDriverState()==OmnipodDriverState.Initalized_PodAvailable) {
+ if (pumpStatusLocal.timeChangeEventEnabled) {
+ LOG.info(getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver.");
+ this.hasTimeDateOrTimeZoneChanged = true;
+ }
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java
index f4b60d42d9..92b22a82be 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dialogs/PodHistoryActivity.java
@@ -245,6 +245,8 @@ public class PodHistoryActivity extends NoSplashActivity {
private void setValue(PodHistory historyEntry, TextView valueView) {
+ //valueView.setText("");
+
if (historyEntry.isSuccess()) {
switch (historyEntry.getPodDbEntryType()) {
@@ -262,13 +264,6 @@ public class PodHistoryActivity extends NoSplashActivity {
}
break;
- case GetPodStatus:
- break;
- case GetPodInfo:
- break;
- case SetTime:
- break;
-
case SetBolus: {
if (historyEntry.getData().contains(";")) {
String[] splitVal = historyEntry.getData().split(";");
@@ -279,6 +274,9 @@ public class PodHistoryActivity extends NoSplashActivity {
}
break;
+ case GetPodStatus:
+ case GetPodInfo:
+ case SetTime:
case PairAndPrime:
case CancelTemporaryBasal:
case CancelTemporaryBasalForce:
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
index dac4c91844..4fae0302df 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/OmnipodPumpStatus.java
@@ -61,6 +61,7 @@ public class OmnipodPumpStatus extends PumpStatus {
public boolean beepTBREnabled = true;
public boolean podDebuggingOptionsEnabled = false;
public String podLotNumber = "???";
+ public boolean timeChangeEventEnabled = true;
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
@@ -111,6 +112,7 @@ public class OmnipodPumpStatus extends PumpStatus {
this.beepSMBEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true);
this.beepTBREnabled = SP.getBoolean(OmnipodConst.Prefs.BeepTBREnabled, true);
this.podDebuggingOptionsEnabled = SP.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false);
+ this.timeChangeEventEnabled = SP.getBoolean(OmnipodConst.Prefs.TimeChangeEventEnabled, true);
LOG.debug("Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.beepBasalEnabled, this.beepBolusEnabled, this.beepSMBEnabled, this.beepTBREnabled);
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
index dba478b0f6..f7b78250c3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java
@@ -19,17 +19,18 @@ public class OmnipodConst {
public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled;
public static final int BeepTBREnabled = R.string.key_omnipod_beep_tbr_enabled;
public static final int PodDebuggingOptionsEnabled = R.string.key_omnipod_pod_debugging_options_enabled;
+ public static final int TimeChangeEventEnabled = R.string.key_omnipod_timechange_enabled;
}
public class Statistics {
public static final String StatsPrefix = "omnipod_";
public static final String FirstPumpStart = Prefix + "first_pump_use";
public static final String LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime";
- public static final String LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency";
+ //public static final String LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency";
public static final String TBRsSet = StatsPrefix + "tbrs_set";
public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered";
public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered";
- public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry";
+ //public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry";
}
public static final double POD_PULSE_SIZE = 0.05;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java
index daa88bda6e..db3b30534a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java
@@ -29,6 +29,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefres
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.plugins.pump.omnipod_dash.comm.OmnipodDashCommunicationManager;
+import info.nightscout.androidaps.utils.TimeChangeType;
/**
* Created by andy on 23.04.18.
@@ -284,7 +285,7 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
// if (isLoggingEnabled())
// LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java
index 447367c510..b583f63cf8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java
@@ -42,6 +42,7 @@ import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.InstanceId;
import info.nightscout.androidaps.utils.SP;
+import info.nightscout.androidaps.utils.TimeChangeType;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
@@ -504,7 +505,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
@Override
- public void timeDateOrTimeZoneChanged() {
+ public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
}
diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.java
index 3ee5ff24a2..46f7498b8b 100644
--- a/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.java
+++ b/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.java
@@ -1,6 +1,5 @@
package info.nightscout.androidaps.receivers;
-import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -9,37 +8,84 @@ import android.content.IntentFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Date;
+import java.util.TimeZone;
+
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
+import info.nightscout.androidaps.utils.TimeChangeType;
public class TimeDateOrTZChangeReceiver extends BroadcastReceiver {
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
+ private boolean isDST;
+
+ public TimeDateOrTZChangeReceiver() {
+ isDST = calculateDST();
+ }
+
+ private boolean calculateDST() {
+ TimeZone timeZone = TimeZone.getDefault();
+ Date nowDate = new Date();
+
+ if (timeZone.useDaylightTime()) {
+ return (timeZone.inDaylightTime(nowDate));
+ } else {
+ return false;
+ }
+ }
+
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
- LOG.debug("Date, Time and/or TimeZone changed.");
+ if (activePump==null) {
+ LOG.debug("TimeDateOrTZChangeReceiver::Time and/or TimeZone changed. [action={}]. Pump is null, exiting.", action);
+ return;
+ }
+ LOG.debug("TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action);
LOG.debug("TimeDateOrTZChangeReceiver::Intent::{}", OmnipodUtil.getGsonInstance().toJson(intent));
- if (action != null && activePump != null) {
- LOG.debug("Date, Time and/or TimeZone changed. Notifying pump driver.");
- activePump.timeDateOrTimeZoneChanged();
+ if (action==null) {
+ LOG.error("TimeDateOrTZChangeReceiver::Action is null. Exiting.");
+ } else if (Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
+ LOG.info("TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.");
+ activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange);
+ } else if (Intent.ACTION_TIME_CHANGED.equals(action)) {
+ boolean currentDst = calculateDST();
+
+ if (currentDst==isDST) {
+ LOG.info("TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.");
+ activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange);
+ } else {
+ if (currentDst) {
+ LOG.info("TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.");
+ activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started);
+ } else {
+ LOG.info("TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.");
+ activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended);
+ }
+ }
+
+ isDST = currentDst;
+ } else {
+ LOG.error("TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action);
}
+
}
public void registerBroadcasts(MainApp mainApp) {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_CHANGED);
- filter.addAction(Intent.ACTION_DATE_CHANGED);
+ //filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
mainApp.registerReceiver(this, filter);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java b/app/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java
new file mode 100644
index 0000000000..720ecc1a1b
--- /dev/null
+++ b/app/src/main/java/info/nightscout/androidaps/utils/TimeChangeType.java
@@ -0,0 +1,8 @@
+package info.nightscout.androidaps.utils;
+
+public enum TimeChangeType {
+ TimezoneChange,
+ DST_Started,
+ DST_Ended,
+ ManualTimeChange
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c3e523384c..c6944b28b1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1652,11 +1652,13 @@
pref_omnipod_beep_smb_enabled
pref_omnipod_beep_tbr_enabled
pref_omnipod_pod_debugging_options_enabled
+ pref_omnipod_timechange_enabled
Bolus Beep Enabled
Basal Beep Enabled
SMB Beep Enabled
TBR Beep Enabled
Pod Debugging Options Enabled
+ DST/Timezone Detection Enabled
Pod Mgmt
diff --git a/app/src/main/res/xml/pref_omnipod.xml b/app/src/main/res/xml/pref_omnipod.xml
index bd1e0ecf7d..131b9206c1 100644
--- a/app/src/main/res/xml/pref_omnipod.xml
+++ b/app/src/main/res/xml/pref_omnipod.xml
@@ -36,5 +36,10 @@
android:key="@string/key_omnipod_pod_debugging_options_enabled"
android:title="@string/omnipod_config_pod_debugging_options_enabled" />
+
+
\ No newline at end of file