From cf7069e64b1beb6e3886ce43e7f77727fdce709e Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Thu, 24 Sep 2020 22:52:21 +0200 Subject: [PATCH] Omnipod: improve error messages and notifications and reorganize string resources --- .../comm/MedtronicCommunicationManager.java | 21 +- .../pump/omnipod/OmnipodPumpPlugin.java | 16 +- .../definition/OmnipodStorageKeys.java | 12 +- .../definition/PodHistoryEntryType.java | 2 +- .../action/AcknowledgeAlertsAction.java | 7 +- .../communication/action/BolusAction.java | 5 +- .../action/CancelDeliveryAction.java | 5 +- .../action/ConfigureAlertsAction.java | 5 +- .../action/DeactivatePodAction.java | 3 +- .../action/GetPodInfoAction.java | 5 +- .../communication/action/GetStatusAction.java | 3 +- .../action/InsertCannulaAction.java | 5 +- .../communication/action/PrimeAction.java | 5 +- .../action/SetBasalScheduleAction.java | 7 +- .../action/SetTempBasalAction.java | 5 +- .../message/command/BolusExtraCommand.java | 5 +- .../command/SetInsulinScheduleCommand.java | 7 +- .../command/TempBasalExtraCommand.java | 7 +- .../ActionInitializationException.java | 7 - .../CommandInitializationException.java | 11 - .../exception/CommunicationException.java | 34 --- .../RileyLinkInterruptedException.java | 7 + .../exception/RileyLinkTimeoutException.java | 8 + .../RileyLinkUnexpectedException.java | 7 + .../RileyLinkUnreachableException.java | 8 + .../driver/manager/OmnipodManager.java | 18 +- .../omnipod/manager/AapsOmnipodManager.java | 284 ++++++++---------- .../OmnipodRileyLinkCommunicationManager.java | 72 +++-- .../pump/omnipod/ui/OmnipodFragment.kt | 22 +- .../pump/omnipod/ui/PodHistoryActivity.java | 8 +- .../pump/omnipod/ui/PodManagementActivity.kt | 2 +- .../src/main/res/drawable/ic_access_alarm.xml | 10 +- .../res/drawable/ic_actions_temptarget.xml | 6 +- .../main/res/drawable/ic_cp_aaps_offline.xml | 30 +- .../res/drawable/ic_cp_bolus_correction.xml | 12 +- .../main/res/drawable/ic_cp_pump_canula.xml | 6 +- .../src/main/res/drawable/ic_exit_to_app.xml | 12 +- .../main/res/drawable/ic_local_activate.xml | 12 +- .../main/res/drawable/ic_loop_disabled.xml | 18 +- .../src/main/res/layout/omnipod_fragment.xml | 16 +- .../res/layout/omnipod_initpod_pod_info.xml | 6 +- .../layout/omnipod_initpod_pod_info_item.xml | 6 +- .../layout/omnipod_pod_history_activity.xml | 2 +- .../src/main/res/layout/omnipod_pod_mgmt.xml | 12 +- .../src/main/res/values-bg-rBG/strings.xml | 7 +- .../src/main/res/values-cs-rCZ/strings.xml | 65 ++-- .../src/main/res/values-de-rDE/strings.xml | 55 ++-- .../src/main/res/values-es-rES/strings.xml | 7 +- .../src/main/res/values-fr-rFR/strings.xml | 7 +- .../src/main/res/values-it-rIT/strings.xml | 67 ++--- .../src/main/res/values-lt-rLT/strings.xml | 7 +- .../src/main/res/values-nl-rNL/strings.xml | 8 +- .../src/main/res/values-pl-rPL/strings.xml | 7 +- .../src/main/res/values-pt-rPT/strings.xml | 51 ++-- .../src/main/res/values-ro-rRO/strings.xml | 81 +++-- .../src/main/res/values-ru-rRU/strings.xml | 37 ++- .../src/main/res/values-sk-rSK/strings.xml | 7 +- .../src/main/res/values-sv-rSE/strings.xml | 7 +- omnipod/src/main/res/values/strings.xml | 270 +++++++++-------- omnipod/src/main/res/values/styles.xml | 1 + .../pump/common/dagger/RileyLinkModule.kt | 2 - .../RileyLinkCommunicationManager.java | 23 +- .../pump/common/hw/rileylink/ble/RFSpy.java | 31 +- .../hw/rileylink/ble/data/RFSpyResponse.java | 44 +-- .../rileylink/ble/defs/RileyLinkBLEError.java | 4 +- .../tasks/InitializePumpManagerTask.java | 2 +- 66 files changed, 728 insertions(+), 823 deletions(-) delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/ActionInitializationException.java delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommandInitializationException.java delete mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommunicationException.java create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkInterruptedException.java create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkTimeoutException.java create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnexpectedException.java create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnreachableException.java diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java index 3c1c4b35e1..2fc2313440 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicCommunicationManager.java @@ -13,13 +13,11 @@ import javax.inject.Inject; import javax.inject.Singleton; import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RFSpyResponse; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioPacket; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType; @@ -56,7 +54,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; * functionality added. */ @Singleton -public class MedtronicCommunicationManager extends RileyLinkCommunicationManager { +public class MedtronicCommunicationManager extends RileyLinkCommunicationManager { @Inject MedtronicPumpStatus medtronicPumpStatus; @Inject MedtronicPumpPlugin medtronicPumpPlugin; @@ -75,7 +73,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager // This empty constructor must be kept, otherwise dagger injection might break! @Inject - public MedtronicCommunicationManager() {} + public MedtronicCommunicationManager() { + } @Inject public void onInit() { @@ -85,9 +84,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager } @Override - public RLMessage createResponseMessage(byte[] payload) { - PumpMessage pumpMessage = new PumpMessage(aapsLogger, payload); - return pumpMessage; + public PumpMessage createResponseMessage(byte[] payload) { + return new PumpMessage(aapsLogger, payload); } @Override @@ -170,7 +168,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager if (radioResponse.isValid()) { - PumpMessage pumpResponse = (PumpMessage) createResponseMessage(radioResponse.getPayload()); + PumpMessage pumpResponse = createResponseMessage(radioResponse.getPayload()); if (!pumpResponse.isValid()) { aapsLogger.warn(LTag.PUMPCOMM, "Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(), @@ -545,14 +543,15 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager } - private PumpMessage sendAndListen(RLMessage msg) throws RileyLinkCommunicationException { + private PumpMessage sendAndListen(PumpMessage msg) throws RileyLinkCommunicationException { return sendAndListen(msg, 4000); // 2000 } // All pump communications go through this function. - protected PumpMessage sendAndListen(RLMessage msg, int timeout_ms) throws RileyLinkCommunicationException { - return (PumpMessage) super.sendAndListen(msg, timeout_ms); + @Override + protected PumpMessage sendAndListen(PumpMessage msg, int timeout_ms) throws RileyLinkCommunicationException { + return super.sendAndListen(msg, timeout_ms); } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 5f39e7570b..f904d28b7f 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -52,7 +52,6 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper; 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.queue.commands.CustomCommand; 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; @@ -87,6 +86,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.service.RileyLi import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodFragment; import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodAlertUtil; +import info.nightscout.androidaps.queue.commands.CustomCommand; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.FabricPrivacy; @@ -358,7 +358,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, rxBus.send(new EventNewNotification(notification)); } else { 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_pod_suspended), Notification.NORMAL); rxBus.send(new EventNewNotification(notification)); } } @@ -711,7 +711,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, public PumpEnactResult executeCustomCommand(CustomCommand command) { if (!(command instanceof OmnipodCustomCommand)) { aapsLogger.warn(LTag.PUMP, "Unknown custom command: " + command.getClass().getName()); - return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(resourceHelper.gs(R.string.omnipod_unknown_custom_command, command.getClass().getName())); + return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(resourceHelper.gs(R.string.omnipod_error_unknown_custom_command, command.getClass().getName())); } OmnipodCustomCommandType commandType = ((OmnipodCustomCommand) command).getType(); @@ -735,7 +735,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return updateAlertConfiguration(); default: aapsLogger.warn(LTag.PUMP, "Unknown custom command: " + commandType); - return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(resourceHelper.gs(R.string.omnipod_unknown_custom_command, commandType)); + return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(resourceHelper.gs(R.string.omnipod_error_unknown_custom_command, commandType)); } } @@ -777,7 +777,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, Notification notification = new Notification( Notification.OMNIPOD_POD_ALERTS_UPDATED, - resourceHelper.gs(R.string.omnipod_expiration_alerts_updated), + resourceHelper.gs(R.string.omnipod_confirmation_expiration_alerts_updated), Notification.INFO, 60); rxBus.send(new EventNewNotification(notification)); } else { @@ -806,7 +806,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, if (!requestedByUser && aapsOmnipodManager.isTimeChangeEventEnabled()) { Notification notification = new Notification( Notification.TIME_OR_TIMEZONE_CHANGE, - resourceHelper.gs(R.string.omnipod_time_or_timezone_change), + resourceHelper.gs(R.string.omnipod_confirmation_time_or_timezone_change), Notification.INFO, 60); rxBus.send(new EventNewNotification(notification)); } @@ -819,7 +819,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, if (aapsOmnipodManager.isTimeChangeEventEnabled()) { Notification notification = new Notification( Notification.TIME_OR_TIMEZONE_CHANGE, - resourceHelper.gs(R.string.omnipod_time_or_timezone_change_failed), + resourceHelper.gs(R.string.omnipod_error_automatic_time_or_timezone_change_failed), Notification.INFO, 60); rxBus.send(new EventNewNotification(notification)); } @@ -982,7 +982,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return true; } - private void incrementStatistics(String statsKey) { + private void incrementStatistics(int statsKey) { long currentCount = sp.getLong(statsKey, 0L); currentCount++; sp.putLong(statsKey, currentCount); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java index 9dae97c900..557e8352db 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java @@ -3,11 +3,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.definition; import info.nightscout.androidaps.plugins.pump.omnipod.R; public class OmnipodStorageKeys { - private static final String PREFIX = "AAPS.Omnipod."; - public static class Preferences { - public static final String POD_STATE = PREFIX + "pod_state"; - public static final String ACTIVE_BOLUS = PREFIX + "current_bolus"; + public static final int POD_STATE = R.string.key_omnipod_pod_state; + public static final int ACTIVE_BOLUS = R.string.key_omnipod_current_bolus; public static final int BASAL_BEEPS_ENABLED = R.string.key_omnipod_basal_beeps_enabled; public static final int BOLUS_BEEPS_ENABLED = R.string.key_omnipod_bolus_beeps_enabled; public static final int SMB_BEEPS_ENABLED = R.string.key_omnipod_smb_beeps_enabled; @@ -22,8 +20,8 @@ public class OmnipodStorageKeys { } public static class Statistics { - public static final String TBRS_SET = PREFIX + "tbrs_set"; - public static final String STANDARD_BOLUSES_DELIVERED = PREFIX + "std_boluses_delivered"; - public static final String SMB_BOLUSES_DELIVERED = PREFIX + "smb_boluses_delivered"; + public static final int TBRS_SET = R.string.key_omnipod_tbrs_set; + public static final int STANDARD_BOLUSES_DELIVERED = R.string.key_omnipod_std_boluses_delivered; + public static final int SMB_BOLUSES_DELIVERED = R.string.key_omnipod_smb_boluses_delivered; } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java index cd15bac1a4..84720d3238 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java @@ -16,7 +16,7 @@ public enum PodHistoryEntryType { PAIR_AND_PRIME(1, R.string.omnipod_init_pod_wizard_step2_title, PumpHistoryEntryGroup.Prime), FILL_CANNULA_SET_BASAL_PROFILE(2, R.string.omnipod_init_pod_wizard_step4_title, PumpHistoryEntryGroup.Prime), DEACTIVATE_POD(3, R.string.omnipod_cmd_deactivate_pod, PumpHistoryEntryGroup.Prime), - RESET_POD_STATE(4, R.string.omnipod_cmd_discard_pod, PumpHistoryEntryGroup.Prime), + DISCARD_POD_STATE(4, R.string.omnipod_cmd_discard_pod, PumpHistoryEntryGroup.Prime), SET_TEMPORARY_BASAL(10, R.string.omnipod_cmd_set_tbr, PumpHistoryEntryGroup.Basal), CANCEL_TEMPORARY_BASAL_BY_DRIVER(11, R.string.omnipod_cmd_cancel_tbr_by_driver, PumpHistoryEntryGroup.Basal), diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/AcknowledgeAlertsAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/AcknowledgeAlertsAction.java index 6ae13b159c..5b6da7d781 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/AcknowledgeAlertsAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/AcknowledgeAlertsAction.java @@ -6,7 +6,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSlot; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -16,12 +15,12 @@ public class AcknowledgeAlertsAction implements OmnipodAction { public AcknowledgeAlertsAction(PodStateManager podStateManager, AlertSet alerts) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (alerts == null) { - throw new ActionInitializationException("Alert set can not be null"); + throw new IllegalArgumentException("Alert set can not be null"); } else if (alerts.size() == 0) { - throw new ActionInitializationException("Alert set can not be empty"); + throw new IllegalArgumentException("Alert set can not be empty"); } this.podStateManager = podStateManager; this.alerts = alerts; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/BolusAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/BolusAction.java index c87ccdb497..b58935eeb5 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/BolusAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/BolusAction.java @@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.SetInsulinScheduleCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BolusDeliverySchedule; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -23,10 +22,10 @@ public class BolusAction implements OmnipodAction { public BolusAction(PodStateManager podStateManager, double units, Duration timeBetweenPulses, boolean acknowledgementBeep, boolean completionBeep) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (timeBetweenPulses == null) { - throw new ActionInitializationException("Time between pulses cannot be null"); + throw new IllegalArgumentException("Time between pulses cannot be null"); } this.podStateManager = podStateManager; this.units = units; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/CancelDeliveryAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/CancelDeliveryAction.java index 7b83b3ee96..b0b4c0ad18 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/CancelDeliveryAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/CancelDeliveryAction.java @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryType; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -22,10 +21,10 @@ public class CancelDeliveryAction implements OmnipodAction { public CancelDeliveryAction(PodStateManager podStateManager, EnumSet deliveryTypes, boolean acknowledgementBeep) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (deliveryTypes == null) { - throw new ActionInitializationException("Delivery types cannot be null"); + throw new IllegalArgumentException("Delivery types cannot be null"); } this.podStateManager = podStateManager; this.deliveryTypes = deliveryTypes; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureAlertsAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureAlertsAction.java index bc4235c2e0..345127e91e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureAlertsAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureAlertsAction.java @@ -5,7 +5,6 @@ import java.util.List; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.ConfigureAlertsCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -15,10 +14,10 @@ public class ConfigureAlertsAction implements OmnipodAction { public ConfigureAlertsAction(PodStateManager podStateManager, List alertConfigurations) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (alertConfigurations == null) { - throw new ActionInitializationException("Alert configurations cannot be null"); + throw new IllegalArgumentException("Alert configurations cannot be null"); } this.podStateManager = podStateManager; this.alertConfigurations = alertConfigurations; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/DeactivatePodAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/DeactivatePodAction.java index efe855b82f..266396d6e4 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/DeactivatePodAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/DeactivatePodAction.java @@ -5,7 +5,6 @@ import java.util.EnumSet; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.DeactivatePodCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryType; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFaultException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -16,7 +15,7 @@ public class DeactivatePodAction implements OmnipodAction { public DeactivatePodAction(PodStateManager podStateManager, boolean acknowledgementBeep) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } this.podStateManager = podStateManager; this.acknowledgementBeep = acknowledgementBeep; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetPodInfoAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetPodInfoAction.java index cc925c6e4c..217c768a78 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetPodInfoAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetPodInfoAction.java @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.act import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.GetStatusCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -13,10 +12,10 @@ public class GetPodInfoAction implements OmnipodAction { public GetPodInfoAction(PodStateManager podStateManager, PodInfoType podInfoType) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (podInfoType == null) { - throw new ActionInitializationException("Pod info type cannot be null"); + throw new IllegalArgumentException("Pod info type cannot be null"); } this.podStateManager = podStateManager; this.podInfoType = podInfoType; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetStatusAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetStatusAction.java index aac7b55d6c..27d1f3a129 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetStatusAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/GetStatusAction.java @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.act import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.GetStatusCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -12,7 +11,7 @@ public class GetStatusAction implements OmnipodAction { public GetStatusAction(PodStateManager podState) { if (podState == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } this.podStateManager = podState; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java index b364aa8c81..7dae20fea9 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java @@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertCo import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -26,10 +25,10 @@ public class InsertCannulaAction implements OmnipodAction { public InsertCannulaAction(PodStateManager podStateManager, BasalSchedule initialBasalSchedule, Duration expirationReminderTimeBeforeShutdown, Integer lowReservoirAlertUnits) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (initialBasalSchedule == null) { - throw new ActionInitializationException("Initial basal schedule cannot be null"); + throw new IllegalArgumentException("Initial basal schedule cannot be null"); } this.podStateManager = podStateManager; this.initialBasalSchedule = initialBasalSchedule; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/PrimeAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/PrimeAction.java index 115ad1c6b1..44c50e1a38 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/PrimeAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/PrimeAction.java @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.act import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.service.PrimeService; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -15,10 +14,10 @@ public class PrimeAction implements OmnipodAction { public PrimeAction(PrimeService primeService, PodStateManager podStateManager) { if (primeService == null) { - throw new ActionInitializationException("Prime service cannot be null"); + throw new IllegalArgumentException("Prime service cannot be null"); } if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } this.service = primeService; this.podStateManager = podStateManager; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetBasalScheduleAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetBasalScheduleAction.java index a64766c5d3..4b35bb781c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetBasalScheduleAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetBasalScheduleAction.java @@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.SetInsulinScheduleCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -23,13 +22,13 @@ public class SetBasalScheduleAction implements OmnipodAction { public SetBasalScheduleAction(PodStateManager podStateManager, BasalSchedule basalSchedule, boolean confidenceReminder, Duration scheduleOffset, boolean acknowledgementBeep) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (basalSchedule == null) { - throw new ActionInitializationException("Basal schedule cannot be null"); + throw new IllegalArgumentException("Basal schedule cannot be null"); } if (scheduleOffset == null) { - throw new ActionInitializationException("Schedule offset cannot be null"); + throw new IllegalArgumentException("Schedule offset cannot be null"); } this.podStateManager = podStateManager; this.basalSchedule = basalSchedule; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetTempBasalAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetTempBasalAction.java index cadb602f68..e33de1f8c5 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetTempBasalAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/SetTempBasalAction.java @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.SetInsulinScheduleCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.TempBasalExtraCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; @@ -24,10 +23,10 @@ public class SetTempBasalAction implements OmnipodAction { public SetTempBasalAction(PodStateManager podStateManager, double rate, Duration duration, boolean acknowledgementBeep, boolean completionBeep) { if (podStateManager == null) { - throw new ActionInitializationException("Pod state manager cannot be null"); + throw new IllegalArgumentException("Pod state manager cannot be null"); } if (duration == null) { - throw new ActionInitializationException("Duration cannot be null"); + throw new IllegalArgumentException("Duration cannot be null"); } this.podStateManager = podStateManager; this.rate = rate; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BolusExtraCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BolusExtraCommand.java index 465d1dee13..6ec315aa16 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BolusExtraCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BolusExtraCommand.java @@ -6,7 +6,6 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.MessageBlock; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.MessageBlockType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandInitializationException; public class BolusExtraCommand extends MessageBlock { private final boolean acknowledgementBeep; @@ -29,9 +28,9 @@ public class BolusExtraCommand extends MessageBlock { boolean acknowledgementBeep, boolean completionBeep, Duration programReminderInterval, Duration timeBetweenPulses) { if (units <= 0D) { - throw new CommandInitializationException("Units should be > 0"); + throw new IllegalArgumentException("Units should be > 0"); } else if (units > OmnipodConstants.MAX_BOLUS) { - throw new CommandInitializationException("Units exceeds max bolus"); + throw new IllegalArgumentException("Units exceeds max bolus"); } this.units = units; this.squareWaveUnits = squareWaveUnits; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/SetInsulinScheduleCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/SetInsulinScheduleCommand.java index 88ad5d206d..c9089559cb 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/SetInsulinScheduleCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/SetInsulinScheduleCommand.java @@ -12,7 +12,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedul import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BolusDeliverySchedule; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.DeliverySchedule; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.TempBasalDeliverySchedule; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandInitializationException; public class SetInsulinScheduleCommand extends NonceResyncableMessageBlock { @@ -51,12 +50,12 @@ public class SetInsulinScheduleCommand extends NonceResyncableMessageBlock { // Temp basal public SetInsulinScheduleCommand(int nonce, double tempBasalRate, Duration duration) { if (tempBasalRate < 0D) { - throw new CommandInitializationException("Rate should be >= 0"); + throw new IllegalArgumentException("Rate should be >= 0"); } else if (tempBasalRate > OmnipodConstants.MAX_BASAL_RATE) { - throw new CommandInitializationException("Rate exceeds max basal rate"); + throw new IllegalArgumentException("Rate exceeds max basal rate"); } if (duration.isLongerThan(OmnipodConstants.MAX_TEMP_BASAL_DURATION)) { - throw new CommandInitializationException("Duration exceeds max temp basal duration"); + throw new IllegalArgumentException("Duration exceeds max temp basal duration"); } int pulsesPerHour = (int) Math.round(tempBasalRate / OmnipodConstants.POD_PULSE_SIZE); int pulsesPerSegment = pulsesPerHour / 2; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java index 031b36af71..baac0f9305 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/TempBasalExtraCommand.java @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.MessageBlockType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.RateEntry; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandInitializationException; public class TempBasalExtraCommand extends MessageBlock { private final boolean acknowledgementBeep; @@ -24,12 +23,12 @@ public class TempBasalExtraCommand extends MessageBlock { public TempBasalExtraCommand(double rate, Duration duration, boolean acknowledgementBeep, boolean completionBeep, Duration programReminderInterval) { if (rate < 0D) { - throw new CommandInitializationException("Rate should be >= 0"); + throw new IllegalArgumentException("Rate should be >= 0"); } else if (rate > OmnipodConstants.MAX_BASAL_RATE) { - throw new CommandInitializationException("Rate exceeds max basal rate"); + throw new IllegalArgumentException("Rate exceeds max basal rate"); } if (duration.isLongerThan(OmnipodConstants.MAX_TEMP_BASAL_DURATION)) { - throw new CommandInitializationException("Duration exceeds max temp basal duration"); + throw new IllegalArgumentException("Duration exceeds max temp basal duration"); } this.acknowledgementBeep = acknowledgementBeep; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/ActionInitializationException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/ActionInitializationException.java deleted file mode 100644 index 1de5bf13dc..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/ActionInitializationException.java +++ /dev/null @@ -1,7 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; - -public class ActionInitializationException extends OmnipodException { - public ActionInitializationException(String message) { - super(message, true); - } -} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommandInitializationException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommandInitializationException.java deleted file mode 100644 index 57bd2c0189..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommandInitializationException.java +++ /dev/null @@ -1,11 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; - -public class CommandInitializationException extends OmnipodException { - public CommandInitializationException(String message) { - super(message, true); - } - - public CommandInitializationException(String message, Throwable cause) { - super(message, cause, true); - } -} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommunicationException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommunicationException.java deleted file mode 100644 index e9a7eb3bd0..0000000000 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/CommunicationException.java +++ /dev/null @@ -1,34 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; - -public class CommunicationException extends OmnipodException { - private final Type type; - - public CommunicationException(Type type) { - super(type.getDescription(), false); - this.type = type; - } - - public CommunicationException(Type type, Throwable cause) { - super(type.getDescription() + ": " + cause, cause, false); - this.type = type; - } - - public Type getType() { - return type; - } - - public enum Type { - TIMEOUT("Communication timeout"), - UNEXPECTED_EXCEPTION("Caught an unexpected Exception"); - - private final String description; - - Type(String description) { - this.description = description; - } - - public String getDescription() { - return description; - } - } -} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkInterruptedException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkInterruptedException.java new file mode 100644 index 0000000000..3cb5f18267 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkInterruptedException.java @@ -0,0 +1,7 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; + +public class RileyLinkInterruptedException extends OmnipodException { + public RileyLinkInterruptedException() { + super("RileyLink interrupted", false); + } +} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkTimeoutException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkTimeoutException.java new file mode 100644 index 0000000000..7e4b48a226 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkTimeoutException.java @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; + +// Response indicating that there was a timeout in communication between the RileyLink and the Pod +public class RileyLinkTimeoutException extends OmnipodException { + public RileyLinkTimeoutException() { + super("Timeout in communication between RileyLink and Pod", false); + } +} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnexpectedException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnexpectedException.java new file mode 100644 index 0000000000..e844eca158 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnexpectedException.java @@ -0,0 +1,7 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; + +public class RileyLinkUnexpectedException extends OmnipodException { + public RileyLinkUnexpectedException(Throwable cause) { + super("Unexpected Exception during RileyLink communication", cause, false); + } +} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnreachableException.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnreachableException.java new file mode 100644 index 0000000000..05320c051d --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/exception/RileyLinkUnreachableException.java @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.driver.exception; + +// Indicates that we didn't get any response from the RL +public class RileyLinkUnreachableException extends OmnipodException { + public RileyLinkUnreachableException() { + super("Timeout in communication between phone and RileyLink", false); + } +} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java index 6cd271ffeb..0672b6ee93 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java @@ -41,7 +41,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfo import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandFailedAfterChangingDeliveryStatusException; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommunicationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.DeliveryStatusVerificationFailedException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalDeliveryStatusException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException; @@ -595,7 +594,7 @@ public class OmnipodManager { logStartingCommandExecution("verifyCommand"); try { return supplier.get(); - } catch (Exception originalException) { + } catch (OmnipodException originalException) { if (isCertainFailure(originalException)) { throw originalException; } else { @@ -608,18 +607,11 @@ public class OmnipodManager { return statusResponse; } catch (NonceOutOfSyncException verificationException) { - aapsLogger.error(LTag.PUMPCOMM, "Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException); - - if (originalException instanceof OmnipodException) { - ((OmnipodException) originalException).setCertainFailure(true); - throw originalException; - } else { - OmnipodException newException = new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, originalException); - newException.setCertainFailure(true); - throw newException; - } + aapsLogger.info(LTag.PUMPCOMM, "Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException); + originalException.setCertainFailure(true); + throw originalException; } catch (Exception verificationException) { - aapsLogger.error(LTag.PUMPCOMM, "Command unresolved (UNCERTAIN_FAILURE)", verificationException); + aapsLogger.warn(LTag.PUMPCOMM, "Command unresolved (UNCERTAIN_FAILURE)", verificationException); throw originalException; } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java index 1ce873c46a..afb3ade3cb 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java @@ -47,10 +47,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Omnipod import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalSchedule; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.schedule.BasalScheduleEntry; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.ActionInitializationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandFailedAfterChangingDeliveryStatusException; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandInitializationException; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommunicationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CrcMismatchException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.DeliveryStatusVerificationFailedException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalDeliveryStatusException; @@ -67,6 +64,10 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NotEnoug import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.OmnipodException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFaultException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodReturnedErrorResponseException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkInterruptedException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkTimeoutException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkUnexpectedException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkUnreachableException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.OmnipodManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.SetupActionResult; @@ -153,10 +154,10 @@ public class AapsOmnipodManager { return new PumpEnactResult(injector).success(true).enacted(true); } catch (Exception ex) { - String comment = translateException(ex); - podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment); - addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.PAIR_AND_PRIME, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + podInitReceiver.returnInitTaskStatus(podInitActionType, false, errorMessage); + addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.PAIR_AND_PRIME, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } } @@ -173,20 +174,15 @@ public class AapsOmnipodManager { } try { - BasalSchedule basalSchedule; - try { - basalSchedule = mapProfileToBasalSchedule(profile); - } catch (Exception ex) { - throw new CommandInitializationException("Basal profile mapping failed", ex); - } + BasalSchedule basalSchedule = mapProfileToBasalSchedule(profile); executeCommand(() -> delegate.insertCannula(basalSchedule, omnipodAlertUtil.getExpirationReminderTimeBeforeShutdown(), omnipodAlertUtil.getLowReservoirAlertUnits()).subscribe(res -> // handleSetupActionResult(podInitActionType, podInitReceiver, res, System.currentTimeMillis(), profile))); } catch (Exception ex) { - String comment = translateException(ex); - podInitReceiver.returnInitTaskStatus(podInitActionType, false, comment); - addFailureToHistory(PodHistoryEntryType.FILL_CANNULA_SET_BASAL_PROFILE, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + podInitReceiver.returnInitTaskStatus(podInitActionType, false, errorMessage); + addFailureToHistory(PodHistoryEntryType.FILL_CANNULA_SET_BASAL_PROFILE, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } rxBus.send(new EventDismissNotification(Notification.OMNIPOD_POD_NOT_ATTACHED)); @@ -200,9 +196,9 @@ public class AapsOmnipodManager { try { executeCommand(() -> delegate.configureAlerts(alertConfigurations)); } catch (Exception ex) { - String comment = translateException(ex); - addFailureToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } addSuccessToHistory(PodHistoryEntryType.CONFIGURE_ALERTS, alertConfigurations); @@ -215,9 +211,9 @@ public class AapsOmnipodManager { try { statusResponse = executeCommand(delegate::getPodStatus); } catch (Exception ex) { - String comment = translateException(ex); - addFailureToHistory(PodHistoryEntryType.GET_POD_STATUS, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.GET_POD_STATUS, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } addSuccessToHistory(PodHistoryEntryType.GET_POD_STATUS, statusResponse); @@ -228,10 +224,10 @@ public class AapsOmnipodManager { try { executeCommand(delegate::deactivatePod); } catch (Exception ex) { - String comment = translateException(ex); - podInitReceiver.returnInitTaskStatus(PodInitActionType.DEACTIVATE_POD_WIZARD_STEP, false, comment); - addFailureToHistory(PodHistoryEntryType.DEACTIVATE_POD, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + podInitReceiver.returnInitTaskStatus(PodInitActionType.DEACTIVATE_POD_WIZARD_STEP, false, errorMessage); + addFailureToHistory(PodHistoryEntryType.DEACTIVATE_POD, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } addSuccessToHistory(PodHistoryEntryType.DEACTIVATE_POD, null); @@ -243,50 +239,46 @@ public class AapsOmnipodManager { public PumpEnactResult setBasalProfile(Profile profile, boolean showNotifications) { if (profile == null) { - String comment = getStringResource(R.string.omnipod_error_failed_to_set_profile_empty_profile); - showNotification(Notification.FAILED_UDPATE_PROFILE, comment, Notification.URGENT, R.raw.boluserror); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String note = getStringResource(R.string.omnipod_error_failed_to_set_profile_empty_profile); + showNotification(Notification.FAILED_UDPATE_PROFILE, note, Notification.URGENT, R.raw.boluserror); + return new PumpEnactResult(injector).success(false).enacted(false).comment(note); } PodHistoryEntryType historyEntryType = podStateManager.isSuspended() ? PodHistoryEntryType.RESUME_DELIVERY : PodHistoryEntryType.SET_BASAL_SCHEDULE; try { - BasalSchedule basalSchedule; - try { - basalSchedule = mapProfileToBasalSchedule(profile); - } catch (Exception ex) { - throw new CommandInitializationException("Basal profile mapping failed", ex); - } + BasalSchedule basalSchedule = mapProfileToBasalSchedule(profile); executeCommand(() -> delegate.setBasalSchedule(basalSchedule, isBasalBeepsEnabled())); } catch (CommandFailedAfterChangingDeliveryStatusException ex) { createSuspendedFakeTbrIfNotExists(); - String comment = getStringResource(R.string.omnipod_error_set_basal_failed_delivery_suspended); if (showNotifications) { - showNotification(Notification.FAILED_UDPATE_PROFILE, comment, Notification.URGENT, R.raw.boluserror); + showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_error_set_basal_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror); } - addFailureToHistory(historyEntryType, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex.getCause()); + addFailureToHistory(historyEntryType, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (DeliveryStatusVerificationFailedException ex) { - String comment; - if (ex.getExpectedStatus() == DeliveryStatus.SUSPENDED) { - // Happened when suspending delivery before setting the new profile - comment = getStringResource(R.string.omnipod_error_set_basal_failed_delivery_might_be_suspended); - } else { - // Happened when setting the new profile (after suspending delivery) - comment = getStringResource(R.string.omnipod_error_set_basal_might_have_failed_delivery_might_be_suspended); - } if (showNotifications) { - showNotification(Notification.FAILED_UDPATE_PROFILE, comment, Notification.URGENT, R.raw.boluserror); + String note; + if (ex.getExpectedStatus() == DeliveryStatus.SUSPENDED) { + // Happened when suspending delivery before setting the new profile + note = getStringResource(R.string.omnipod_error_set_basal_failed_delivery_might_be_suspended); + } else { + // Happened when setting the new profile (after suspending delivery) + note = getStringResource(R.string.omnipod_error_set_basal_might_have_failed_delivery_might_be_suspended); + } + showNotification(Notification.FAILED_UDPATE_PROFILE, note, Notification.URGENT, R.raw.boluserror); } - addFailureToHistory(historyEntryType, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex.getCause()); + addFailureToHistory(historyEntryType, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (Exception ex) { - String comment = translateException(ex); if (showNotifications) { - showNotification(Notification.FAILED_UDPATE_PROFILE, comment, Notification.URGENT, R.raw.boluserror); + showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_error_set_basal_failed), Notification.URGENT, R.raw.boluserror); } - addFailureToHistory(historyEntryType, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(historyEntryType, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } if (historyEntryType == PodHistoryEntryType.RESUME_DELIVERY) { @@ -305,7 +297,7 @@ public class AapsOmnipodManager { public PumpEnactResult discardPodState() { podStateManager.discardState(); - addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.RESET_POD_STATE, null); + addSuccessToHistory(System.currentTimeMillis(), PodHistoryEntryType.DISCARD_POD_STATE, null); createSuspendedFakeTbrIfNotExists(); @@ -329,17 +321,17 @@ public class AapsOmnipodManager { bolusStarted = new Date(); } catch (Exception ex) { - String comment = translateException(ex); - addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SET_BOLUS, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.SET_BOLUS, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } 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_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, R.raw.boluserror); + showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, R.raw.boluserror); } else { - showNotification(getStringResource(R.string.omnipod_bolus_failed_uncertain), Notification.URGENT, R.raw.boluserror); + showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain), Notification.URGENT, R.raw.boluserror); } } @@ -399,7 +391,7 @@ public class AapsOmnipodManager { aapsLogger.debug(LTag.PUMP, "Bolus command successfully executed. Proceeding bolus cancellation"); } else { aapsLogger.debug(LTag.PUMP, "Not cancelling bolus: bolus command failed"); - String comment = getStringResource(R.string.omnipod_bolus_did_not_succeed); + String comment = getStringResource(R.string.omnipod_error_bolus_did_not_succeed); addFailureToHistory(System.currentTimeMillis(), PodHistoryEntryType.CANCEL_BOLUS, comment); return new PumpEnactResult(injector).success(true).enacted(false).comment(comment); } @@ -433,17 +425,17 @@ public class AapsOmnipodManager { try { executeCommand(() -> delegate.setTemporaryBasal(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate()), Duration.standardMinutes(tempBasalPair.getDurationMinutes()), beepsEnabled, beepsEnabled)); } catch (CommandFailedAfterChangingDeliveryStatusException ex) { - String comment = getStringResource(R.string.omnipod_cancelled_old_tbr_failed_to_set_new); - addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, comment); - showNotification(comment, Notification.NORMAL, null); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + showNotification(getStringResource(R.string.omnipod_error_cancelled_old_tbr_failed_to_set_new), Notification.NORMAL, null); + String errorMessage = translateException(ex.getCause()); + addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (DeliveryStatusVerificationFailedException ex) { - String comment; + String errorMessage = translateException(ex.getCause()); + + String note; if (ex.getExpectedStatus() == DeliveryStatus.TEMP_BASAL_RUNNING) { // Happened after cancelling the old TBR, when attempting to set new TBR - - comment = getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed); - long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, comment); + note = getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_cancelled_new_might_have_failed); // 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 @@ -451,19 +443,20 @@ public class AapsOmnipodManager { // If we would assume that the TBR didn't succeed, we couldn't properly recover upon the next StatusResponse, // as we could only see that the Pod is running a TBR, but we don't know the rate and duration as // the Pod doesn't provide this information + long pumpId = addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); addTempBasalTreatment(System.currentTimeMillis(), pumpId, tempBasalPair); } else { // Happened when attempting to cancel the old TBR - comment = getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled); - addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, comment); + note = getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled); + addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); } + showNotification(note, Notification.URGENT, R.raw.boluserror); - showNotification(comment, Notification.URGENT, R.raw.boluserror); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (Exception ex) { - String comment = translateException(ex); - addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } long pumpId = addSuccessToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, tempBasalPair); @@ -477,15 +470,12 @@ public class AapsOmnipodManager { try { executeCommand(() -> delegate.cancelTemporaryBasal(isTbrBeepsEnabled())); } catch (Exception ex) { - String comment; if (ex instanceof OmnipodException && !((OmnipodException) ex).isCertainFailure()) { - comment = getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain); - showNotification(comment, Notification.URGENT, R.raw.boluserror); - } else { - comment = translateException(ex); + showNotification(getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, R.raw.boluserror); } - addFailureToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } long pumpId = addSuccessToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, null); @@ -505,9 +495,9 @@ public class AapsOmnipodManager { try { executeCommand(delegate::acknowledgeAlerts); } catch (Exception ex) { - String comment = translateException(ex); - addFailureToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } addSuccessToHistory(PodHistoryEntryType.ACKNOWLEDGE_ALERTS, null); @@ -518,14 +508,9 @@ public class AapsOmnipodManager { try { executeCommand(() -> delegate.suspendDelivery(isBasalBeepsEnabled())); } catch (Exception ex) { - String comment; - if (ex instanceof OmnipodException && !((OmnipodException) ex).isCertainFailure()) { - comment = getStringResource(R.string.omnipod_error_suspend_delivery_failed_uncertain); - } else { - comment = getStringResource(R.string.omnipod_error_suspend_delivery_failed); - } - addFailureToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } addSuccessToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, null); @@ -540,23 +525,23 @@ public class AapsOmnipodManager { executeCommand(() -> delegate.setTime(isBasalBeepsEnabled())); } catch (CommandFailedAfterChangingDeliveryStatusException ex) { createSuspendedFakeTbrIfNotExists(); - String comment = getStringResource(R.string.omnipod_error_set_time_failed_delivery_suspended); if (showNotifications) { - showNotification(comment, Notification.URGENT, R.raw.boluserror); + showNotification(getStringResource(R.string.omnipod_error_set_time_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror); } - addFailureToHistory(PodHistoryEntryType.SET_TIME, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex.getCause()); + addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (DeliveryStatusVerificationFailedException ex) { - String comment = getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended); if (showNotifications) { - showNotification(comment, Notification.URGENT, R.raw.boluserror); + showNotification(getStringResource(R.string.omnipod_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror); } - addFailureToHistory(PodHistoryEntryType.SET_TIME, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex.getCause()); + addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (Exception ex) { - String comment = translateException(ex); - addFailureToHistory(PodHistoryEntryType.SET_TIME, comment); - return new PumpEnactResult(injector).success(false).enacted(false).comment(comment); + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } addSuccessToHistory(PodHistoryEntryType.SET_TIME, null); @@ -732,12 +717,12 @@ public class AapsOmnipodManager { switch (res.getResultType()) { case FAILURE: { aapsLogger.error(LTag.PUMP, "Setup action failed: illegal setup progress: {}", res.getPodProgressStatus()); - comment = getStringResource(R.string.omnipod_driver_error_invalid_progress_state, res.getPodProgressStatus()); + comment = getStringResource(R.string.omnipod_error_invalid_progress_state, res.getPodProgressStatus()); } break; case VERIFICATION_FAILURE: { aapsLogger.error(LTag.PUMP, "Setup action verification failed: caught exception", res.getException()); - comment = getStringResource(R.string.omnipod_driver_error_setup_action_verification_failed); + comment = getStringResource(R.string.omnipod_error_setup_action_verification_failed); } break; } @@ -781,51 +766,48 @@ public class AapsOmnipodManager { } } - public String translateException(Exception ex) { + public String translateException(Throwable ex) { String comment; - if (ex instanceof OmnipodException) { - if (ex instanceof ActionInitializationException || ex instanceof CommandInitializationException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_parameters); - } else if (ex instanceof CommunicationException) { - if (((CommunicationException) ex).getType() == CommunicationException.Type.TIMEOUT) { - comment = getStringResource(R.string.omnipod_driver_error_communication_failed_timeout); - } else { - comment = getStringResource(R.string.omnipod_driver_error_communication_failed_unexpected_exception); - } - } else if (ex instanceof CrcMismatchException) { - comment = getStringResource(R.string.omnipod_driver_error_crc_mismatch); - } else if (ex instanceof IllegalPacketTypeException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_packet_type); - } else if (ex instanceof IllegalPodProgressException || ex instanceof IllegalDeliveryStatusException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_progress_state); - } else if (ex instanceof IllegalVersionResponseTypeException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_response); - } else if (ex instanceof IllegalResponseException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_response); - } else if (ex instanceof IllegalMessageSequenceNumberException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_message_sequence_number); - } else if (ex instanceof IllegalMessageAddressException) { - comment = getStringResource(R.string.omnipod_driver_error_invalid_message_address); - } else if (ex instanceof MessageDecodingException) { - comment = getStringResource(R.string.omnipod_driver_error_message_decoding_failed); - } else if (ex instanceof NonceOutOfSyncException) { - comment = getStringResource(R.string.omnipod_driver_error_nonce_out_of_sync); - } else if (ex instanceof NonceResyncException) { - comment = getStringResource(R.string.omnipod_driver_error_nonce_resync_failed); - } else if (ex instanceof NotEnoughDataException) { - comment = getStringResource(R.string.omnipod_driver_error_not_enough_data); - } else if (ex instanceof PodFaultException) { - FaultEventCode faultEventCode = ((PodFaultException) ex).getFaultEvent().getFaultEventCode(); - comment = createPodFaultErrorMessage(faultEventCode); - } else if (ex instanceof PodReturnedErrorResponseException) { - comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response); - } else { - // Shouldn't be reachable - comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName(), ex.getMessage()); - } + if (ex instanceof CrcMismatchException) { + comment = getStringResource(R.string.omnipod_error_crc_mismatch); + } else if (ex instanceof IllegalPacketTypeException) { + comment = getStringResource(R.string.omnipod_error_invalid_packet_type); + } else if (ex instanceof IllegalPodProgressException || ex instanceof IllegalDeliveryStatusException) { + comment = getStringResource(R.string.omnipod_error_invalid_progress_state); + } else if (ex instanceof IllegalVersionResponseTypeException) { + comment = getStringResource(R.string.omnipod_error_invalid_response); + } else if (ex instanceof IllegalResponseException) { + comment = getStringResource(R.string.omnipod_error_invalid_response); + } else if (ex instanceof IllegalMessageSequenceNumberException) { + comment = getStringResource(R.string.omnipod_error_invalid_message_sequence_number); + } else if (ex instanceof IllegalMessageAddressException) { + comment = getStringResource(R.string.omnipod_error_invalid_message_address); + } else if (ex instanceof MessageDecodingException) { + comment = getStringResource(R.string.omnipod_error_message_decoding_failed); + } else if (ex instanceof NonceOutOfSyncException) { + comment = getStringResource(R.string.omnipod_error_nonce_out_of_sync); + } else if (ex instanceof NonceResyncException) { + comment = getStringResource(R.string.omnipod_error_nonce_resync_failed); + } else if (ex instanceof NotEnoughDataException) { + comment = getStringResource(R.string.omnipod_error_not_enough_data); + } else if (ex instanceof PodFaultException) { + FaultEventCode faultEventCode = ((PodFaultException) ex).getFaultEvent().getFaultEventCode(); + comment = createPodFaultErrorMessage(faultEventCode); + } else if (ex instanceof PodReturnedErrorResponseException) { + comment = getStringResource(R.string.omnipod_error_pod_returned_error_response); + } else if (ex instanceof RileyLinkUnreachableException) { + comment = getStringResource(R.string.omnipod_error_communication_failed_no_response_from_riley_link); + } else if (ex instanceof RileyLinkInterruptedException) { + comment = getStringResource(R.string.omnipod_error_communication_failed_riley_link_interrupted); + } else if (ex instanceof RileyLinkTimeoutException) { + comment = getStringResource(R.string.omnipod_error_communication_failed_no_response_from_pod); + } else if (ex instanceof RileyLinkUnexpectedException) { + Throwable cause = ex.getCause(); + comment = getStringResource(R.string.omnipod_error_unexpected_exception, cause.getClass().getName(), cause.getMessage()); } else { - comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName(), ex.getMessage()); + // Shouldn't be reachable + comment = getStringResource(R.string.omnipod_error_unexpected_exception, ex.getClass().getName(), ex.getMessage()); } return comment; @@ -833,7 +815,7 @@ public class AapsOmnipodManager { private String createPodFaultErrorMessage(FaultEventCode faultEventCode) { String comment; - comment = getStringResource(R.string.omnipod_driver_error_pod_fault, + comment = getStringResource(R.string.omnipod_error_pod_fault, ByteUtil.convertUnsignedByteToInt(faultEventCode.getValue()), faultEventCode.name()); return comment; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java index 8473daae0c..3dca3d3228 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/rileylink/manager/OmnipodRileyLinkCommunicationManager.java @@ -12,7 +12,6 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; @@ -30,7 +29,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Message import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PacketType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommunicationException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageAddressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageSequenceNumberException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException; @@ -41,13 +39,16 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NotEnoug import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.OmnipodException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodFaultException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.PodReturnedErrorResponseException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkTimeoutException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkUnexpectedException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.RileyLinkUnreachableException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; /** * Created by andy on 6/29/18. */ @Singleton -public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunicationManager { +public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunicationManager { // This empty constructor must be kept, otherwise dagger injection might break! @Inject public OmnipodRileyLinkCommunicationManager() { @@ -69,7 +70,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication } @Override - public RLMessage createResponseMessage(byte[] payload) { + public OmnipodPacket createResponseMessage(byte[] payload) { return new OmnipodPacket(payload); } @@ -137,7 +138,7 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication if (responseClass.isInstance(responseMessageBlock)) { podStateManager.setLastSuccessfulCommunication(DateTime.now()); - return (T) responseMessageBlock; + return responseClass.cast(responseMessageBlock); } else { if (responseMessageBlock.getType() == MessageBlockType.ERROR_RESPONSE) { ErrorResponse error = (ErrorResponse) responseMessageBlock; @@ -219,23 +220,16 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication try { // We actually ignore previous (ack) responses if it was not last packet to send response = exchangePackets(podStateManager, packet); - } catch (Exception ex) { - OmnipodException newException; - if (ex instanceof OmnipodException) { - newException = (OmnipodException) ex; - } else { - newException = new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex); - } - + } catch (OmnipodException ex) { boolean lastPacket = encodedMessage.length == 0; // If this is not the last packet, the message wasn't fully sent, // so it's impossible for the pod to have received the message - newException.setCertainFailure(!lastPacket); + ex.setCertainFailure(!lastPacket); - aapsLogger.debug(LTag.PUMPBTCOMM, "Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length); + aapsLogger.debug(LTag.PUMPBTCOMM, "Caught OmnipodException in transportMessages. Set certainFailure to {} because encodedMessage.length={}", ex.isCertainFailure(), encodedMessage.length); - throw newException; + throw ex; } } @@ -261,18 +255,11 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication OmnipodPacket ackForCon = createAckPacket(podStateManager, packetAddress, ackAddressOverride); - try { - OmnipodPacket conPacket = exchangePackets(podStateManager, ackForCon, 3, 40); - if (conPacket.getPacketType() != PacketType.CON) { - throw new IllegalPacketTypeException(PacketType.CON, conPacket.getPacketType()); - } - receivedMessageData = ByteUtil.concat(receivedMessageData, conPacket.getEncodedMessage()); - } catch (OmnipodException ex2) { - throw ex2; - } catch (Exception ex2) { - throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex2); + OmnipodPacket conPacket = exchangePackets(podStateManager, ackForCon, 3, 40); + if (conPacket.getPacketType() != PacketType.CON) { + throw new IllegalPacketTypeException(PacketType.CON, conPacket.getPacketType()); } - + receivedMessageData = ByteUtil.concat(receivedMessageData, conPacket.getEncodedMessage()); } } @@ -317,8 +304,6 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication } } catch (OmnipodException ex) { aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in ackUntilQuiet", ex); - } catch (Exception ex) { - throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex); } podStateManager.increasePacketNumber(); @@ -337,24 +322,32 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication podStateManager.increasePacketNumber(); + boolean gotResponseFromRileyLink = false; + while (System.currentTimeMillis() < timeoutTime) { OmnipodPacket response; try { - response = (OmnipodPacket) sendAndListen(packet, responseTimeoutMilliseconds, repeatCount, 9, preambleExtensionMilliseconds); - } catch (RileyLinkCommunicationException | OmnipodException ex) { + response = sendAndListen(packet, responseTimeoutMilliseconds, repeatCount, 9, preambleExtensionMilliseconds); + gotResponseFromRileyLink = true; + } catch (RileyLinkCommunicationException ex) { + if (ex.getErrorCode() != RileyLinkBLEError.NoResponse) { + gotResponseFromRileyLink = true; + } + aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in exchangePackets: " + ex.getClass().getSimpleName() + ": " + ex.getMessage()); + continue; + } catch (OmnipodException ex) { + gotResponseFromRileyLink = true; aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in exchangePackets: " + ex.getClass().getSimpleName() + ": " + ex.getMessage()); continue; } catch (Exception ex) { - throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex); + throw new RileyLinkUnexpectedException(ex); } - if (response == null) { - aapsLogger.debug(LTag.PUMPBTCOMM, "exchangePackets response is null"); - continue; - } else if (!response.isValid()) { + if (!response.isValid()) { aapsLogger.debug(LTag.PUMPBTCOMM, "exchangePackets response is invalid: " + response); continue; } + if (response.getAddress() != packet.getAddress() && response.getAddress() != OmnipodConstants.DEFAULT_ADDRESS) { // In some (strange) cases, the Pod remains a packet address of 0xffffffff during it's lifetime aapsLogger.debug(LTag.PUMPBTCOMM, "Packet address " + response.getAddress() + " doesn't match " + packet.getAddress()); @@ -371,7 +364,12 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication return response; } - throw new CommunicationException(CommunicationException.Type.TIMEOUT); + + if (gotResponseFromRileyLink) { + throw new RileyLinkTimeoutException(); + } + + throw new RileyLinkUnreachableException(); } } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt index 22b773ac73..6c597f613d 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodFragment.kt @@ -108,13 +108,13 @@ class OmnipodFragment : DaggerFragment() { omnipod_button_resume_delivery.setOnClickListener { disablePodActionButtons() commandQueue.customCommand(CommandResumeDelivery(), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_failed_to_resume_delivery), true).messageOnSuccess(resourceHelper.gs(R.string.omnipod_delivery_resumed))) + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_resume_delivery), true).messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_delivery_resumed))) } omnipod_button_refresh_status.setOnClickListener { disablePodActionButtons() commandQueue.customCommand(CommandGetPodStatus(), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_failed_to_refresh_status), false)) + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status), false)) } omnipod_button_rileylink_stats.setOnClickListener { @@ -128,28 +128,28 @@ class OmnipodFragment : DaggerFragment() { omnipod_button_acknowledge_active_alerts.setOnClickListener { disablePodActionButtons() commandQueue.customCommand(CommandAcknowledgeAlerts(), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_failed_to_acknowledge_alerts), false) - .messageOnSuccess(resourceHelper.gs(R.string.omnipod_acknowledged_alerts))) + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_acknowledge_alerts), false) + .messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_acknowledged_alerts))) } omnipod_button_suspend_delivery.setOnClickListener { disablePodActionButtons() commandQueue.customCommand(CommandSuspendDelivery(), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_failed_to_suspend_delivery), true) - .messageOnSuccess(resourceHelper.gs(R.string.omnipod_suspended_delivery))) + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_suspend_delivery), true) + .messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_suspended_delivery))) } omnipod_button_set_time.setOnClickListener { disablePodActionButtons() commandQueue.customCommand(CommandHandleTimeChange(true), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_failed_to_set_time), true) - .messageOnSuccess(resourceHelper.gs(R.string.omnipod_time_on_pod_updated))) + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_set_time), true) + .messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_time_on_pod_updated))) } omnipod_button_pulse_log.setOnClickListener { disablePodActionButtons() commandQueue.customCommand(CommandReadPulseLog(), - DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_failed_to_read_pulse_log), false)) + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_read_pulse_log), false)) } } @@ -380,7 +380,7 @@ class OmnipodFragment : DaggerFragment() { private fun updateLastBolus() { if (podStateManager.isPodActivationCompleted && podStateManager.hasLastBolus()) { - var text = resourceHelper.gs(R.string.omnipod_last_bolus, omnipodPumpPlugin.model().determineCorrectBolusSize(podStateManager.lastBolusAmount), resourceHelper.gs(R.string.insulin_unit_shortname), readableDuration(podStateManager.lastBolusStartTime)) + var text = resourceHelper.gs(R.string.omnipod_last_bolus_value, omnipodPumpPlugin.model().determineCorrectBolusSize(podStateManager.lastBolusAmount), resourceHelper.gs(R.string.insulin_unit_shortname), readableDuration(podStateManager.lastBolusStartTime)) val textColor: Int if (podStateManager.isLastBolusCertain) { @@ -411,7 +411,7 @@ class OmnipodFragment : DaggerFragment() { var text: String val textColor: Int - text = resourceHelper.gs(R.string.omnipod_temp_basal, amount, dateUtil.timeString(startTime.millis), minutesRunning, duration.standardMinutes) + text = resourceHelper.gs(R.string.omnipod_temp_basal_value, amount, dateUtil.timeString(startTime.millis), minutesRunning, duration.standardMinutes) if (podStateManager.isTempBasalCertain) { textColor = Color.WHITE } else { diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java index 4913bb6614..6f3b627842 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java @@ -250,7 +250,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { case SET_TEMPORARY_BASAL: { TempBasalPair tempBasalPair = aapsOmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class); - valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes())); + valueView.setText(resourceHelper.gs(R.string.omnipod_history_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes())); } break; @@ -265,9 +265,9 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { case SET_BOLUS: { if (historyEntry.getData().contains(";")) { String[] splitVal = historyEntry.getData().split(";"); - valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1]))); + valueView.setText(resourceHelper.gs(R.string.omnipod_history_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1]))); } else { - valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData()))); + valueView.setText(resourceHelper.gs(R.string.omnipod_history_bolus_value, Double.valueOf(historyEntry.getData()))); } } break; @@ -281,7 +281,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { case CONFIGURE_ALERTS: case CANCEL_BOLUS: case DEACTIVATE_POD: - case RESET_POD_STATE: + case DISCARD_POD_STATE: case ACKNOWLEDGE_ALERTS: case SUSPEND_DELIVERY: case RESUME_DELIVERY: diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt index 43f4046a5e..1e53a1be49 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodManagementActivity.kt @@ -145,7 +145,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() { private fun discardPodAction() { OKDialog.showConfirmation(this, - resourceHelper.gs(R.string.omnipod_cmd_discard_pod_desc), Thread { + resourceHelper.gs(R.string.omnipod_discard_pod_state_confirmation), Thread { aapsOmnipodManager.discardPodState() rxBus.send(EventOmnipodPumpValuesChanged()) }) diff --git a/omnipod/src/main/res/drawable/ic_access_alarm.xml b/omnipod/src/main/res/drawable/ic_access_alarm.xml index f3520e7799..48a463f81b 100644 --- a/omnipod/src/main/res/drawable/ic_access_alarm.xml +++ b/omnipod/src/main/res/drawable/ic_access_alarm.xml @@ -1,9 +1,9 @@ + android:width="48dp" + android:height="48dp" + android:viewportWidth="24" + android:viewportHeight="24"> + android:pathData="M22,5.72l-4.6,-3.86 -1.29,1.53 4.6,3.86L22,5.72zM7.88,3.39L6.6,1.86 2,5.71l1.29,1.53 4.59,-3.85zM12.5,8L11,8v6l4.75,2.85 0.75,-1.23 -4,-2.37L12.5,8zM12,4c-4.97,0 -9,4.03 -9,9s4.02,9 9,9c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,20c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z" /> diff --git a/omnipod/src/main/res/drawable/ic_actions_temptarget.xml b/omnipod/src/main/res/drawable/ic_actions_temptarget.xml index 5dbd5d8b0c..28aed597c8 100644 --- a/omnipod/src/main/res/drawable/ic_actions_temptarget.xml +++ b/omnipod/src/main/res/drawable/ic_actions_temptarget.xml @@ -3,7 +3,7 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/omnipod/src/main/res/drawable/ic_cp_aaps_offline.xml b/omnipod/src/main/res/drawable/ic_cp_aaps_offline.xml index 0b267a6d88..ab562c35a6 100644 --- a/omnipod/src/main/res/drawable/ic_cp_aaps_offline.xml +++ b/omnipod/src/main/res/drawable/ic_cp_aaps_offline.xml @@ -3,19 +3,19 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - - - - - + + + + + diff --git a/omnipod/src/main/res/drawable/ic_cp_bolus_correction.xml b/omnipod/src/main/res/drawable/ic_cp_bolus_correction.xml index e14bb7c14f..49d6332c8e 100644 --- a/omnipod/src/main/res/drawable/ic_cp_bolus_correction.xml +++ b/omnipod/src/main/res/drawable/ic_cp_bolus_correction.xml @@ -3,10 +3,10 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - - + + diff --git a/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml b/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml index b43de7ceaa..f302f9770c 100644 --- a/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml +++ b/omnipod/src/main/res/drawable/ic_cp_pump_canula.xml @@ -3,7 +3,7 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/omnipod/src/main/res/drawable/ic_exit_to_app.xml b/omnipod/src/main/res/drawable/ic_exit_to_app.xml index 37a6c7d058..17a3d659a1 100644 --- a/omnipod/src/main/res/drawable/ic_exit_to_app.xml +++ b/omnipod/src/main/res/drawable/ic_exit_to_app.xml @@ -3,10 +3,10 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - - + + diff --git a/omnipod/src/main/res/drawable/ic_local_activate.xml b/omnipod/src/main/res/drawable/ic_local_activate.xml index 905ade57d3..c171fe367e 100644 --- a/omnipod/src/main/res/drawable/ic_local_activate.xml +++ b/omnipod/src/main/res/drawable/ic_local_activate.xml @@ -3,10 +3,10 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - - + + diff --git a/omnipod/src/main/res/drawable/ic_loop_disabled.xml b/omnipod/src/main/res/drawable/ic_loop_disabled.xml index ed79c96429..81dabea9d6 100644 --- a/omnipod/src/main/res/drawable/ic_loop_disabled.xml +++ b/omnipod/src/main/res/drawable/ic_loop_disabled.xml @@ -3,13 +3,13 @@ android:height="48dp" android:viewportWidth="24" android:viewportHeight="24"> - - - + + + diff --git a/omnipod/src/main/res/layout/omnipod_fragment.xml b/omnipod/src/main/res/layout/omnipod_fragment.xml index 9c84d746be..deb485b2da 100644 --- a/omnipod/src/main/res/layout/omnipod_fragment.xml +++ b/omnipod/src/main/res/layout/omnipod_fragment.xml @@ -759,7 +759,7 @@ android:drawableTop="@drawable/ic_actions_refill" android:paddingLeft="0dp" android:paddingRight="0dp" - android:text="@string/omnipod_refresh" /> + android:text="@string/omnipod_button_refresh" />