Automatically retry bolus cancellation and show error when setting TBR fails due to a PodFaultException
This commit is contained in:
parent
57c35bad58
commit
b08045b326
|
@ -320,7 +320,7 @@ public class OmnipodManager {
|
|||
}
|
||||
}
|
||||
|
||||
if (activeBolusData != null) {
|
||||
if (hasActiveBolus()) {
|
||||
activeBolusData.bolusCompletionSubject.onSuccess(new BolusDeliveryResult(units));
|
||||
activeBolusData = null;
|
||||
}
|
||||
|
@ -460,6 +460,13 @@ public class OmnipodManager {
|
|||
return podState != null && podState.getSetupProgress() == SetupProgress.COMPLETED;
|
||||
}
|
||||
|
||||
public boolean hasActiveBolus() {
|
||||
synchronized (bolusDataMutex) {
|
||||
return activeBolusData != null;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME this is dirty, we should not expose the original pod state
|
||||
public PodSessionState getPodState() {
|
||||
return this.podState;
|
||||
}
|
||||
|
|
|
@ -331,18 +331,23 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public PumpEnactResult cancelBolus() {
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
delegate.cancelBolus(isBolusBeepsEnabled());
|
||||
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
||||
} catch (PodFaultException ex) {
|
||||
showErrorDialog(createPodFaultErrorMessage(ex.getFaultEvent().getFaultEventType()), null);
|
||||
} catch (Exception ex) {
|
||||
String comment = handleAndTranslateException(ex);
|
||||
addFailureToHistory(time, PodHistoryEntryType.CancelBolus, comment);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
String comment = null;
|
||||
while (delegate.hasActiveBolus()) {
|
||||
try {
|
||||
delegate.cancelBolus(isBolusBeepsEnabled());
|
||||
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
||||
return new PumpEnactResult().success(true).enacted(true);
|
||||
} catch (PodFaultException ex) {
|
||||
showErrorDialog(createPodFaultErrorMessage(ex.getFaultEvent().getFaultEventType()), null);
|
||||
addSuccessToHistory(time, PodHistoryEntryType.CancelBolus, null);
|
||||
return new PumpEnactResult().success(true).enacted(true);
|
||||
} catch (Exception ex) {
|
||||
comment = handleAndTranslateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return new PumpEnactResult().success(true).enacted(true);
|
||||
addFailureToHistory(time, PodHistoryEntryType.CancelBolus, comment);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -353,7 +358,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
delegate.setTemporaryBasal(tempBasalPair, beepsEnabled, beepsEnabled);
|
||||
time = System.currentTimeMillis();
|
||||
} catch (Exception ex) {
|
||||
if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||
if (ex instanceof PodFaultException) {
|
||||
showErrorDialog(createPodFaultErrorMessage(((PodFaultException) ex).getFaultEvent().getFaultEventType()), R.raw.urgentalarm);
|
||||
} else if ((ex instanceof OmnipodException) && !((OmnipodException) ex).isCertainFailure()) {
|
||||
addToHistory(time, PodHistoryEntryType.SetTemporaryBasal, "Uncertain failure", false);
|
||||
return new PumpEnactResult().success(false).enacted(false).comment(getStringResource(R.string.omnipod_error_set_temp_basal_failed_uncertain));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue