Merge branch 'omnipod_eros_dev' into omnipod_eros_dev_upstream_merge
This commit is contained in:
commit
23eee4207d
|
@ -67,13 +67,17 @@ public class Notification {
|
|||
public static final int OVER_24H_TIME_CHANGE_REQUESTED = 54;
|
||||
public static final int INVALID_VERSION = 55;
|
||||
public static final int PERMISSION_SYSTEM_WINDOW = 56;
|
||||
public static final int OMNIPOD_PUMP_ALARM = 57;
|
||||
public static final int TIME_OR_TIMEZONE_CHANGE = 58;
|
||||
public static final int OMNIPOD_POD_NOT_ATTACHED = 59;
|
||||
public static final int CARBS_REQUIRED = 60;
|
||||
public static final int OMNIPOD_POD_SUSPENDED = 61;
|
||||
public static final int OMNIPOD_POD_ALERTS_UPDATED = 62;
|
||||
public static final int OMNIPOD_POD_ALERTS = 63;
|
||||
public static final int OMNIPOD_UNCERTAIN_TBR = 64;
|
||||
public static final int OMNIPOD_POD_FAULT = 66;
|
||||
public static final int OMNIPOD_UNCERTAIN_SMB = 67;
|
||||
public static final int OMNIPOD_UNKNOWN_TBR = 68;
|
||||
public static final int OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69;
|
||||
|
||||
public static final int IMPORTANCE_HIGH = 2;
|
||||
|
||||
|
|
|
@ -54,6 +54,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.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||
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.data.TempBasalPair;
|
||||
|
@ -381,12 +382,14 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
} else {
|
||||
// Not sure what's going on. Notify the user
|
||||
aapsLogger.error(LTag.PUMP, "Unknown TBR in both Pod state and AAPS");
|
||||
rxBus.send(new EventNewNotification(new Notification(Notification.OMNIPOD_PUMP_ALARM, resourceHelper.gs(R.string.omnipod_error_tbr_running_but_aaps_not_aware), Notification.NORMAL).sound(R.raw.boluserror)));
|
||||
rxBus.send(new EventNewNotification(new Notification(Notification.OMNIPOD_UNKNOWN_TBR, resourceHelper.gs(R.string.omnipod_error_tbr_running_but_aaps_not_aware), Notification.NORMAL).sound(R.raw.boluserror)));
|
||||
}
|
||||
} else if (!podStateManager.isTempBasalRunning() && tempBasal != null) {
|
||||
aapsLogger.warn(LTag.PUMP, "Removing AAPS TBR that actually hadn't succeeded");
|
||||
activePlugin.getActiveTreatments().removeTempBasal(tempBasal);
|
||||
}
|
||||
|
||||
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_UNCERTAIN_TBR));
|
||||
}
|
||||
|
||||
private void handleActivePodAlerts() {
|
||||
|
@ -1027,9 +1030,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
if (success) {
|
||||
rxBus.send(new EventDismissNotification(Notification.OMNIPOD_STARTUP_STATUS_REFRESH_FAILED));
|
||||
} else {
|
||||
aapsLogger.warn(LTag.PUMP, "Failed to retrieve Pod status on startup");
|
||||
rxBus.send(new EventNewNotification(new Notification(Notification.OMNIPOD_PUMP_ALARM, resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status_on_startup), Notification.NORMAL)));
|
||||
rxBus.send(new EventNewNotification(new Notification(Notification.OMNIPOD_STARTUP_STATUS_REFRESH_FAILED, resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status_on_startup), Notification.NORMAL)));
|
||||
}
|
||||
} else {
|
||||
aapsLogger.debug(LTag.PUMP, "Not retrieving Pod status on startup: no Pod running");
|
||||
|
|
|
@ -269,6 +269,9 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -284,13 +287,17 @@ public class AapsOmnipodManager {
|
|||
addSuccessToHistory(PodHistoryEntryType.DEACTIVATE_POD, null);
|
||||
createSuspendedFakeTbrIfNotExists();
|
||||
|
||||
sendEvent(new EventDismissNotification(Notification.OMNIPOD_POD_FAULT));
|
||||
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
}
|
||||
|
||||
public PumpEnactResult setBasalProfile(Profile profile, boolean showNotifications) {
|
||||
if (profile == null) {
|
||||
String note = getStringResource(R.string.omnipod_error_failed_to_set_profile_empty_profile);
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, note, Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(note);
|
||||
}
|
||||
|
||||
|
@ -329,10 +336,13 @@ public class AapsOmnipodManager {
|
|||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
}
|
||||
|
||||
sendEvent(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
|
||||
if (historyEntryType == PodHistoryEntryType.RESUME_DELIVERY) {
|
||||
cancelSuspendedFakeTbrIfExists();
|
||||
sendEvent(new EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED));
|
||||
}
|
||||
|
||||
addSuccessToHistory(historyEntryType, profile.getBasalValues());
|
||||
|
||||
if (showNotifications) {
|
||||
|
@ -349,8 +359,9 @@ public class AapsOmnipodManager {
|
|||
|
||||
createSuspendedFakeTbrIfNotExists();
|
||||
|
||||
sendEvent(new EventDismissNotification(Notification.OMNIPOD_POD_FAULT));
|
||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||
rxBus.send(new EventRefreshOverview("Omnipod command: " + OmnipodCommandType.DISCARD_POD, false));
|
||||
sendEvent(new EventRefreshOverview("Omnipod command: " + OmnipodCommandType.DISCARD_POD, false));
|
||||
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
}
|
||||
|
@ -380,7 +391,7 @@ public class AapsOmnipodManager {
|
|||
if (OmnipodManager.CommandDeliveryStatus.UNCERTAIN_FAILURE.equals(bolusCommandResult.getCommandDeliveryStatus())) {
|
||||
// For safety reasons, we treat this as a bolus that has successfully been delivered, in order to prevent insulin overdose
|
||||
if (detailedBolusInfo.isSMB) {
|
||||
showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, isNotificationUncertainSmbSoundEnabled() ? R.raw.boluserror : null);
|
||||
showNotification(Notification.OMNIPOD_UNCERTAIN_SMB, getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, isNotificationUncertainSmbSoundEnabled() ? R.raw.boluserror : null);
|
||||
} else {
|
||||
showErrorDialog(getStringResource(R.string.omnipod_error_bolus_failed_uncertain), isNotificationUncertainBolusSoundEnabled() ? R.raw.boluserror : null);
|
||||
}
|
||||
|
@ -483,7 +494,7 @@ public class AapsOmnipodManager {
|
|||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
|
||||
|
||||
showNotification(getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
|
||||
showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
|
||||
|
||||
splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation
|
||||
|
||||
|
@ -493,7 +504,7 @@ public class AapsOmnipodManager {
|
|||
long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage);
|
||||
|
||||
if (!OmnipodManager.isCertainFailure(ex)) {
|
||||
showNotification(getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
|
||||
showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
|
||||
|
||||
// Assume that setting the temp basal succeeded here, because in case it didn't succeed,
|
||||
// The next StatusResponse that we receive will allow us to recover from the wrong state
|
||||
|
@ -523,7 +534,7 @@ public class AapsOmnipodManager {
|
|||
executeCommand(() -> delegate.cancelTemporaryBasal(isTbrBeepsEnabled()));
|
||||
} catch (Exception ex) {
|
||||
if (OmnipodManager.isCertainFailure(ex)) {
|
||||
showNotification(getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
|
||||
showNotification(Notification.OMNIPOD_UNCERTAIN_TBR, getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null);
|
||||
} else {
|
||||
splitActiveTbr(); // Split any active TBR so when we recover from the uncertain TBR status,we only cancel the part after the cancellation
|
||||
}
|
||||
|
@ -580,27 +591,29 @@ public class AapsOmnipodManager {
|
|||
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
|
||||
createSuspendedFakeTbrIfNotExists();
|
||||
if (showNotifications) {
|
||||
showNotification(getStringResource(R.string.omnipod_error_set_time_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_error_set_time_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
} catch (PrecedingCommandFailedUncertainlyException ex) {
|
||||
if (showNotifications) {
|
||||
showNotification(getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
} catch (Exception ex) {
|
||||
if (showNotifications) {
|
||||
showNotification(getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex);
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
}
|
||||
|
||||
sendEvent(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
|
||||
addSuccessToHistory(PodHistoryEntryType.SET_TIME, null);
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
}
|
||||
|
@ -937,11 +950,7 @@ public class AapsOmnipodManager {
|
|||
}
|
||||
|
||||
private void showPodFaultNotification(FaultEventCode faultEventCode, Integer sound) {
|
||||
showNotification(createPodFaultErrorMessage(faultEventCode), Notification.URGENT, sound);
|
||||
}
|
||||
|
||||
private void showNotification(String message, int urgency, Integer sound) {
|
||||
showNotification(Notification.OMNIPOD_PUMP_ALARM, message, urgency, sound);
|
||||
showNotification(Notification.OMNIPOD_POD_FAULT, createPodFaultErrorMessage(faultEventCode), Notification.URGENT, sound);
|
||||
}
|
||||
|
||||
private void showNotification(int id, String message, int urgency, Integer sound) {
|
||||
|
|
|
@ -16,6 +16,8 @@ import info.nightscout.androidaps.events.EventPreferenceChange
|
|||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
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.common.events.EventRileyLinkDeviceStatusChange
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||
|
@ -126,7 +128,8 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandAcknowledgeAlerts(),
|
||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_acknowledge_alerts), false)
|
||||
.messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_acknowledged_alerts)))
|
||||
.messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_acknowledged_alerts))
|
||||
.actionOnSuccess { rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_ALERTS)) })
|
||||
}
|
||||
|
||||
omnipod_overview_button_suspend_delivery.setOnClickListener {
|
||||
|
@ -599,6 +602,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
inner class DisplayResultDialogCallback(private val errorMessagePrefix: String, private val withSoundOnError: Boolean) : Callback() {
|
||||
|
||||
private var messageOnSuccess: String? = null
|
||||
private var actionOnSuccess: Runnable? = null
|
||||
|
||||
override fun run() {
|
||||
if (result.success) {
|
||||
|
@ -606,6 +610,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
if (messageOnSuccess != null) {
|
||||
displayOkDialog(resourceHelper.gs(R.string.omnipod_confirmation), messageOnSuccess)
|
||||
}
|
||||
actionOnSuccess?.run()
|
||||
} else {
|
||||
displayErrorDialog(resourceHelper.gs(R.string.omnipod_warning), resourceHelper.gs(R.string.omnipod_two_strings_concatenated_by_colon, errorMessagePrefix, result.comment), withSoundOnError)
|
||||
}
|
||||
|
@ -615,6 +620,11 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
messageOnSuccess = message
|
||||
return this
|
||||
}
|
||||
|
||||
fun actionOnSuccess(action: Runnable): DisplayResultDialogCallback {
|
||||
actionOnSuccess = action
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue