diff options
| -rw-r--r-- | libs/input/input_flags.aconfig | 7 | ||||
| -rw-r--r-- | services/inputflinger/reader/mapper/gestures/GestureConverter.cpp | 9 | ||||
| -rw-r--r-- | services/inputflinger/tests/GestureConverter_test.cpp | 19 |
3 files changed, 29 insertions, 6 deletions
diff --git a/libs/input/input_flags.aconfig b/libs/input/input_flags.aconfig index 6302ff5ff3..978a80f9b3 100644 --- a/libs/input/input_flags.aconfig +++ b/libs/input/input_flags.aconfig @@ -41,3 +41,10 @@ flag { 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 7006e9efc1..4d2b66d56d 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 @@ NotifyMotionArgs GestureConverter::handleMove(nsecs_t when, nsecs_t readTime, 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 @@ std::list<NotifyArgs> GestureConverter::handleButtonsChange(nsecs_t when, nsecs_ 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 d7dc800c82..41c7392cbc 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 @@ TEST_F(GestureConverterTest, Click) { 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 @@ TEST_F(GestureConverterTest, TapWithTapToClickDisabled) { 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 @@ TEST_F(GestureConverterTest, ClickWithTapToClickDisabled) { 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); |