From d72b752882ebb4e6be7ef5715a273b7a2e86f14b Mon Sep 17 00:00:00 2001 From: jhenrique09 Date: Wed, 1 Nov 2017 17:48:10 -0200 Subject: [PATCH] sanders: KeyHandler: Don't allow multiple calls for fp gestures --- .../lineageos/settings/device/KeyHandler.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/LineageActions/src/org/lineageos/settings/device/KeyHandler.java b/LineageActions/src/org/lineageos/settings/device/KeyHandler.java index 30c89e9..bfbf428 100644 --- a/LineageActions/src/org/lineageos/settings/device/KeyHandler.java +++ b/LineageActions/src/org/lineageos/settings/device/KeyHandler.java @@ -108,6 +108,7 @@ public class KeyHandler implements DeviceKeyHandler { private Handler mHandler; private int fpTapCounts = 0; private boolean fpTapPending = false; + private boolean fpGesturePending = false; private SettingsObserver mSettingsObserver; private Runnable doubleTapRunnable = new Runnable() { public void run() { @@ -129,6 +130,11 @@ public class KeyHandler implements DeviceKeyHandler { resetDoubleTapOnFP(); } }; + private Runnable fpGestureRunnable = new Runnable() { + public void run() { + resetFPGestureDelay(); + } + }; public KeyHandler(Context context) { mContext = context; @@ -476,6 +482,16 @@ public class KeyHandler implements DeviceKeyHandler { if (event.getAction() != KeyEvent.ACTION_UP) { return true; } + + if (isFPScanCode){ + if (fpGesturePending) { + return false; + } else { + resetFPGestureDelay(); + fpGesturePending = true; + mHandler.postDelayed(fpGestureRunnable, 10); + } + } if (scanCode != FP_TAP_SCANCODE) { resetDoubleTapOnFP(); @@ -734,6 +750,11 @@ public class KeyHandler implements DeviceKeyHandler { } + private void resetFPGestureDelay() { + fpGesturePending = false; + mHandler.removeCallbacks(fpGestureRunnable); + } + private void fireScreenOffAction(int action) { boolean haptic = Settings.System.getInt(mContext.getContentResolver(), KEY_GESTURE_ENABLE_HAPTIC_FEEDBACK, 1) != 0; if (haptic && (action == ACTION_CAMERA || action == ACTION_FLASHLIGHT)) {