Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5791961d authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Merge "Add flag for additional touchpad palm rejection while typing" into main

parents 74f05b4a 3d84add9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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"
}
+7 −2
Original line number Diff line number Diff line
@@ -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
+15 −4
Original line number Diff line number Diff line
@@ -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);