Add flag for additional touchpad palm rejection while typing
Flag to enable additional touchpad palm rejection while typing on a
physical keyboard. This flag will be used in upcoming changes.
Bug: 301055381
Test: atest GestureConverterTest
Change-Id: Iedc78261fc8973eaf2f8c704674321607517351f
diff --git a/libs/input/input_flags.aconfig b/libs/input/input_flags.aconfig
index 6302ff5..978a80f 100644
--- a/libs/input/input_flags.aconfig
+++ b/libs/input/input_flags.aconfig
@@ -41,3 +41,10 @@
description: "Brings back fatal logging for inconsistent event streams originating from accessibility."
bug: "299977100"
}
+
+flag {
+ name: "enable_touchpad_typing_palm_rejection"
+ namespace: "input"
+ description: "Enable additional palm rejection on touchpad while typing"
+ bug: "301055381"
+}
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index 7006e9e..4d2b66d 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -20,6 +20,7 @@
#include <sstream>
#include <android-base/stringprintf.h>
+#include <com_android_input_flags.h>
#include <ftl/enum.h>
#include <linux/input-event-codes.h>
#include <log/log_main.h>
@@ -28,10 +29,14 @@
#include "TouchCursorInputMapperCommon.h"
#include "input/Input.h"
+namespace input_flags = com::android::input::flags;
+
namespace android {
namespace {
+const bool ENABLE_TOUCHPAD_PALM_REJECTION = input_flags::enable_touchpad_typing_palm_rejection();
+
uint32_t gesturesButtonToMotionEventButton(uint32_t gesturesButton) {
switch (gesturesButton) {
case GESTURES_BUTTON_LEFT:
@@ -158,7 +163,7 @@
const Gesture& gesture) {
float deltaX = gesture.details.move.dx;
float deltaY = gesture.details.move.dy;
- if (std::abs(deltaX) > 0 || std::abs(deltaY) > 0) {
+ if (ENABLE_TOUCHPAD_PALM_REJECTION && (std::abs(deltaX) > 0 || std::abs(deltaY) > 0)) {
enableTapToClick();
}
rotateDelta(mOrientation, &deltaX, &deltaY);
@@ -200,7 +205,7 @@
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
- if (mReaderContext.isPreventingTouchpadTaps()) {
+ if (ENABLE_TOUCHPAD_PALM_REJECTION && mReaderContext.isPreventingTouchpadTaps()) {
enableTapToClick();
if (gesture.details.buttons.is_tap) {
// return early to prevent this tap
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index d7dc800..41c7392 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -16,7 +16,8 @@
#include <memory>
-#include <EventHub.h>
+#include <com_android_input_flags.h>
+#include <flag_macros.h>
#include <gestures/GestureConverter.h>
#include <gtest/gtest.h>
#include <gui/constants.h>
@@ -34,6 +35,13 @@
namespace android {
+namespace {
+
+const auto TOUCHPAD_PALM_REJECTION =
+ ACONFIG_FLAG(com::android::input::flags, enable_touchpad_typing_palm_rejection);
+
+} // namespace
+
using testing::AllOf;
class GestureConverterTest : public testing::Test {
@@ -1161,7 +1169,8 @@
WithDisplayId(ADISPLAY_ID_DEFAULT)));
}
-TEST_F(GestureConverterTest, TapWithTapToClickDisabled) {
+TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabled,
+ REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) {
// Tap should be ignored when disabled
mReader->getContext()->setPreventingTouchpadTaps(true);
@@ -1193,7 +1202,8 @@
ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
}
-TEST_F(GestureConverterTest, ClickWithTapToClickDisabled) {
+TEST_F_WITH_FLAGS(GestureConverterTest, ClickWithTapToClickDisabled,
+ REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) {
// Click should still produce button press/release events
mReader->getContext()->setPreventingTouchpadTaps(true);
@@ -1260,7 +1270,8 @@
ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
}
-TEST_F(GestureConverterTest, MoveEnablesTapToClick) {
+TEST_F_WITH_FLAGS(GestureConverterTest, MoveEnablesTapToClick,
+ REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) {
// initially disable tap-to-click
mReader->getContext()->setPreventingTouchpadTaps(true);