Keep mouse pointer hidden while typing
An optimisation causes mouse pointer to remain visible while user is
typing.
As Mouse pointer may reappear while user is typing and may
not hide again if IME connection remains active and touchpad is used.
This leads to an incosistent state where toucpad-pad is disabled but
cursor is visible while user is actively typing on PK.
Bug: 301055381
Test: atest KeyboardInputMapperUnitTest
Change-Id: Id37d57d924e4f1f1b8875b078c48762a5d523acc
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index 58b29b8..531fc67 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -451,7 +451,8 @@
void KeyboardInputMapper::onKeyDownProcessed() {
InputReaderContext& context = *getContext();
if (context.isPreventingTouchpadTaps()) {
- // avoid pinging java service unnecessarily
+ // avoid pinging java service unnecessarily, just fade pointer again if it became visible
+ context.fadePointer();
return;
}
// Ignore meta keys or multiple simultaneous down keys as they are likely to be keyboard
diff --git a/services/inputflinger/tests/KeyboardInputMapper_test.cpp b/services/inputflinger/tests/KeyboardInputMapper_test.cpp
index 08a5559..48f5673 100644
--- a/services/inputflinger/tests/KeyboardInputMapper_test.cpp
+++ b/services/inputflinger/tests/KeyboardInputMapper_test.cpp
@@ -112,6 +112,15 @@
}
/**
+ * Pointer should still hide if touchpad taps are already disabled
+ */
+TEST_F(KeyboardInputMapperUnitTest, AlphanumericKeystrokesWithTouchpadTapDisabledHidePointer) {
+ mFakePolicy->setIsInputMethodConnectionActive(true);
+ EXPECT_CALL(mMockInputReaderContext, isPreventingTouchpadTaps).WillRepeatedly(Return(true));
+ testPointerVisibilityForKeys({KEY_0, KEY_A}, /* expectVisible= */ false);
+}
+
+/**
* Pointer visibility should remain unaffected by meta keys even if Input Method Connection is
* active
*/