RuffyScripter.waitForMenuToBeLeft: add timeout.

This commit is contained in:
Johannes Mockenhaupt 2017-07-15 15:00:41 +02:00
parent 77711b2174
commit 952aa0e8a2
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -99,7 +99,7 @@ public class RuffyScripter {
};
public boolean isPumpBusy() {
return activeCmd != null; // || currentMenu == null || currentMenu.getType() != MenuType.MAIN_MENU;
return activeCmd != null;
}
private volatile Command activeCmd = null;
@ -287,8 +287,12 @@ public class RuffyScripter {
* Wait till a menu changed has completed, "away" from the menu provided as argument.
*/
public void waitForMenuToBeLeft(MenuType menuType) {
long timeout = System.currentTimeMillis() + 30 * 1000;
while (currentMenu.getType() == menuType) {
SystemClock.sleep(250);
if (System.currentTimeMillis() > timeout) {
throw new CommandException().message("Timeout waiting for menu " + menuType + " to be left");
}
SystemClock.sleep(50);
}
}