Disable Tap to click while typing on a PK

This change will disable tap to click on touchpad while user is typing
on keyboard. Any move events or new taps will reenable tap to click.

Test: atest GestureConverterTest && atest inputflinger_tests and manual
testing
Bug: 275616121

Change-Id: I5b7d984e5cce7f65c16ec19a0b8373c95e75f30b
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index d51ec45..5c42e10 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -242,7 +242,7 @@
             keyDown.downTime = when;
             mKeyDowns.push_back(keyDown);
         }
-        tryHideCursorOnKeyDown();
+        onKeyDownProcessed();
     } else {
         // Remove key down.
         if (keyDownIndex) {
@@ -420,12 +420,18 @@
     return out;
 }
 
-void KeyboardInputMapper::tryHideCursorOnKeyDown() {
-    // Hide the cursor while user is inputting text, ignoring meta keys or multiple simultaneous
-    // down keys as they are likely to be shortcuts
-    const bool shouldHideCursor = mKeyDowns.size() == 1 && !isMetaKey(mKeyDowns[0].keyCode);
-    if (shouldHideCursor && getContext()->getPolicy()->isInputMethodConnectionActive()) {
-        getContext()->fadePointer();
+void KeyboardInputMapper::onKeyDownProcessed() {
+    InputReaderContext& context = *getContext();
+    if (context.isPreventingTouchpadTaps()) {
+        // avoid pinging java service unnecessarily
+        return;
+    }
+    // Ignore meta keys or multiple simultaneous down keys as they are likely to be keyboard
+    // shortcuts
+    bool shouldHideCursor = mKeyDowns.size() == 1 && !isMetaKey(mKeyDowns[0].keyCode);
+    if (shouldHideCursor && context.getPolicy()->isInputMethodConnectionActive()) {
+        context.fadePointer();
+        context.setPreventingTouchpadTaps(true);
     }
 }