Make CancelTbrCommand more robust.
This commit is contained in:
parent
30fc385970
commit
0345a01fc1
|
@ -13,17 +13,21 @@ public class CancelTbrCommand implements Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(RuffyScripter scripter) {
|
public CommandResult execute(RuffyScripter scripter) {
|
||||||
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
try {
|
||||||
Double tbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR);
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
boolean runtimeDisplayed = scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME);
|
Double tbrPercentage = (Double) scripter.currentMenu.getAttribute(MenuAttribute.TBR);
|
||||||
if (tbrPercentage == 100 && !runtimeDisplayed) {
|
boolean runtimeDisplayed = scripter.currentMenu.attributes().contains(MenuAttribute.RUNTIME);
|
||||||
return new CommandResult()
|
if (tbrPercentage == 100 && !runtimeDisplayed) {
|
||||||
.success(true)
|
return new CommandResult()
|
||||||
.enacted(true) // technically, nothing was enacted, but AAPS needs this to recover
|
.success(true)
|
||||||
// when there was an issue and AAPS thinks a TBR is still active
|
.enacted(true) // technically, nothing was enacted, but AAPS needs this to recover
|
||||||
.message("No TBR active");
|
// when there was an issue and AAPS thinks a TBR is still active
|
||||||
|
.message("No TBR active");
|
||||||
|
}
|
||||||
|
log.debug("Cancelling active TBR of " + tbrPercentage + "% with " + runtimeDisplayed + "min remaining");
|
||||||
|
} catch (CommandException e) {
|
||||||
|
return e.toCommandResult();
|
||||||
}
|
}
|
||||||
log.debug("Cancelling active TBR of " + tbrPercentage + "% with " + runtimeDisplayed + "min remaining");
|
|
||||||
return new SetTbrCommand(100, 0).execute(scripter);
|
return new SetTbrCommand(100, 0).execute(scripter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue