Record last keypress timestamp on physical keyboard while typing
Added method to record keypress timestamp while typing. This will be
used by touchpad to trigger additional palm rejection logic.
Bug: 301055381
Test: atest KeyboardInputMapperUnitTest
Change-Id: I4bbfe4c5fefc687a4901e46c9d4c6f832ec1a245
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index 531fc67..f068cc8 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -270,7 +270,7 @@
keyDown.flags = flags;
mKeyDowns.push_back(keyDown);
}
- onKeyDownProcessed();
+ onKeyDownProcessed(downTime);
} else {
// Remove key down.
if (keyDownIndex) {
@@ -448,8 +448,9 @@
return out;
}
-void KeyboardInputMapper::onKeyDownProcessed() {
+void KeyboardInputMapper::onKeyDownProcessed(nsecs_t downTime) {
InputReaderContext& context = *getContext();
+ context.setLastKeyDownTimestamp(downTime);
if (context.isPreventingTouchpadTaps()) {
// avoid pinging java service unnecessarily, just fade pointer again if it became visible
context.fadePointer();
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.h b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
index 09808df..500256b 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.h
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
@@ -107,7 +107,7 @@
void updateLedStateForModifier(LedState& ledState, int32_t led, int32_t modifier, bool reset);
std::optional<DisplayViewport> findViewport(const InputReaderConfiguration& readerConfig);
[[nodiscard]] std::list<NotifyArgs> cancelAllDownKeys(nsecs_t when);
- void onKeyDownProcessed();
+ void onKeyDownProcessed(nsecs_t downTime);
};
} // namespace android