Loading libs/input/input_flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -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" } services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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: Loading Loading @@ -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); Loading Loading @@ -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 Loading services/inputflinger/tests/GestureConverter_test.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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 { Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading
libs/input/input_flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -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" }
services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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: Loading Loading @@ -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); Loading Loading @@ -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 Loading
services/inputflinger/tests/GestureConverter_test.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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 { Loading Loading @@ -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); Loading Loading @@ -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); Loading Loading @@ -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); Loading