extra keys: avoid scheduled executor leak

Under certain cases scheduled executor may leak causing repeatable input to
stuck.

Issue: https://github.com/termux/termux-app/issues/2156
This commit is contained in:
Leonid Pliushch
2021-07-11 18:13:32 +03:00
parent 1b62f7c9a9
commit 0308d6a6ca

View File

@@ -302,6 +302,10 @@ public final class ExtraKeysView extends GridLayout {
case MotionEvent.ACTION_DOWN:
longPressCount = 0;
v.setBackgroundColor(BUTTON_PRESSED_COLOR);
if (scheduledExecutor != null) {
scheduledExecutor.shutdownNow();
scheduledExecutor = null;
}
if (Arrays.asList("UP", "DOWN", "LEFT", "RIGHT", "BKSP", "DEL").contains(buttonInfo.getKey())) {
// autorepeat
scheduledExecutor = Executors.newSingleThreadScheduledExecutor();