Merge branch 'omnipod_eros_dev_upstream_merge' into rl_battery_level_medtronic

This commit is contained in:
Bart Sopers 2021-01-07 02:36:04 +01:00
commit 9415fadee0

View file

@ -150,7 +150,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private RileyLinkOmnipodService rileyLinkOmnipodService; private RileyLinkOmnipodService rileyLinkOmnipodService;
private boolean busy = false; private boolean busy = false;
private int timeChangeRetries; private int timeChangeRetries;
private long nextPodCheck; private long nextPodWarningCheck;
private long lastConnectionTimeMillis; private long lastConnectionTimeMillis;
private final Handler loopHandler = new Handler(Looper.getMainLooper()); private final Handler loopHandler = new Handler(Looper.getMainLooper());
@ -255,12 +255,12 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
podStateManager.getActiveAlerts().size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) { podStateManager.getActiveAlerts().size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
queueAcknowledgeAlertsCommand(); queueAcknowledgeAlertsCommand();
} }
doPodCheck();
} else { } else {
aapsLogger.debug(LTag.PUMPCOMM, "Skipping Pod status check because command queue is not empty"); aapsLogger.debug(LTag.PUMPCOMM, "Skipping Pod status check because command queue is not empty");
} }
updatePodWarningNotifications();
loopHandler.postDelayed(this, STATUS_CHECK_INTERVAL_MILLIS); loopHandler.postDelayed(this, STATUS_CHECK_INTERVAL_MILLIS);
} }
}; };
@ -444,19 +444,23 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
}); });
} }
private void doPodCheck() { private void updatePodWarningNotifications() {
if (System.currentTimeMillis() > this.nextPodCheck) { if (System.currentTimeMillis() > this.nextPodWarningCheck) {
if (!podStateManager.isPodRunning()) { if (!podStateManager.isPodRunning()) {
Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, resourceHelper.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL); Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, resourceHelper.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL);
rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNewNotification(notification));
} else { } else {
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED));
if (podStateManager.isSuspended()) { if (podStateManager.isSuspended()) {
Notification notification = new Notification(Notification.OMNIPOD_POD_SUSPENDED, resourceHelper.gs(R.string.omnipod_error_pod_suspended), Notification.NORMAL); Notification notification = new Notification(Notification.OMNIPOD_POD_SUSPENDED, resourceHelper.gs(R.string.omnipod_error_pod_suspended), Notification.NORMAL);
rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNewNotification(notification));
} else {
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED));
} }
} }
this.nextPodCheck = DateTimeUtil.getTimeInFutureFromMinutes(15); this.nextPodWarningCheck = DateTimeUtil.getTimeInFutureFromMinutes(15);
} }
} }