sanders: KeyHandler: Don't allow multiple calls for fp gestures

This commit is contained in:
jhenrique09
2017-11-01 17:48:10 -02:00
committed by therootlord
parent 596f5e602d
commit d72b752882

View File

@@ -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)) {