Commit 398a52ea authored by Rob Schonberger's avatar Rob Schonberger Committed by Commit Bot

Add a Feature, kEnablePalmOnMaxTouchMajor to change max_major behavior.

By default, we mark any touch that has a ABS_MT_TOUCH_MAJOR ==
major_max (as given in device info) to be a palm.

For some experimental situations, we often receive a genuine
TOUCH_MAJOR of this magnitude. We want to be able to treat that as normal.

Adds a Feature, and set it at construction time - this avoids looking
through features on every single touch. Adds a unit test appropriately
to test for this change in behavior (and that current behavior is
maintained).

Bug: 1009290
Change-Id: I4f1c3b2d4733ff00cb13814db4dad834baeb8977
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003166Reviewed-by: default avatarThanh Nguyen <thanhdng@chromium.org>
Commit-Queue: Rob Schonberger <robsc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732267}
parent 23821832
......@@ -18,6 +18,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
......@@ -36,6 +37,7 @@
#include "ui/events/ozone/evdev/touch_filter/false_touch_finder.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h"
#include "ui/events/ozone/features.h"
#include "ui/ozone/public/input_controller.h"
namespace {
......@@ -115,7 +117,9 @@ TouchEventConverterEvdev::TouchEventConverterEvdev(
input_device_fd_(std::move(fd)),
dispatcher_(dispatcher),
palm_detection_filter_(
CreatePalmDetectionFilter(devinfo, shared_palm_state)) {
CreatePalmDetectionFilter(devinfo, shared_palm_state)),
palm_on_touch_major_max_(
base::FeatureList::IsEnabled(kEnablePalmOnMaxTouchMajor)) {
touch_evdev_debug_buffer_.Initialize(devinfo);
}
......@@ -508,7 +512,8 @@ bool TouchEventConverterEvdev::MaybeCancelAllTouches() {
bool TouchEventConverterEvdev::IsPalm(const InProgressTouchEvdev& touch) {
return touch.tool_type == MT_TOOL_PALM ||
(major_max_ > 0 && touch.major == major_max_);
(palm_on_touch_major_max_ && major_max_ > 0 &&
touch.major == major_max_);
}
void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) {
......
......@@ -189,6 +189,9 @@ class COMPONENT_EXPORT(EVDEV) TouchEventConverterEvdev
// Callback to enable/disable palm suppression.
base::RepeatingCallback<void(bool)> enable_palm_suppression_callback_;
// Do we mark a touch as palm when touch_major is the max?
const bool palm_on_touch_major_max_;
DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev);
};
......
......@@ -33,6 +33,7 @@
#include "ui/events/ozone/evdev/touch_filter/false_touch_finder.h"
#include "ui/events/ozone/evdev/touch_filter/shared_palm_detection_filter_state.h"
#include "ui/events/ozone/evdev/touch_filter/touch_filter.h"
#include "ui/events/ozone/features.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/test/scoped_event_test_tick_clock.h"
......@@ -233,6 +234,15 @@ class TouchEventConverterEvdevTest : public testing::Test {
// Overridden from testing::Test:
void SetUp() override {
// By default, tests disable single-cancel and enable palm on touch_major ==
// major_max.
scoped_feature_list_.reset(new base::test::ScopedFeatureList);
scoped_feature_list_->InitWithFeatures({kEnablePalmOnMaxTouchMajor},
{kEnableSingleCancelTouch});
SetUpDevice();
}
void SetUpDevice() {
// Set up pipe to satisfy message pump (unused).
int evdev_io[2];
if (pipe(evdev_io))
......@@ -255,10 +265,6 @@ class TouchEventConverterEvdevTest : public testing::Test {
test_clock_ = std::make_unique<ui::test::ScopedEventTestTickClock>();
ui::DeviceDataManager::CreateInstance();
// By default, tests disable single-cancel.
scoped_feature_list_.reset(new base::test::ScopedFeatureList);
scoped_feature_list_->InitAndDisableFeature(kEnableSingleCancelTouch);
}
void TearDown() override {
......@@ -732,6 +738,88 @@ TEST_F(TouchEventConverterEvdevTest, ShouldRemoveContactsWhenDisabled) {
EXPECT_EQ(2u, size());
}
TEST_F(TouchEventConverterEvdevTest, MaxMajorNotCancelTouch) {
// By default, tests disable single-cancel and enable palm on touch_major ==
// major_max. So we disable that behavior: and expect to see a RELEASED rather
// than cancelled.
scoped_feature_list_.reset(new base::test::ScopedFeatureList);
scoped_feature_list_->InitWithFeatures(
{}, {kEnablePalmOnMaxTouchMajor, kEnableSingleCancelTouch});
SetUpDevice();
ui::MockTouchEventConverterEvdev* dev = device();
EventDeviceInfo devinfo;
EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkWithToolTypeTouchscreen, &devinfo));
timeval time;
time = {1429651083, 686882};
int major_max = devinfo.GetAbsMaximum(ABS_MT_TOUCH_MAJOR);
struct input_event mock_kernel_queue_max_major[] = {
{time, EV_ABS, ABS_MT_SLOT, 0},
{time, EV_ABS, ABS_MT_TRACKING_ID, 0},
{time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER},
{time, EV_ABS, ABS_MT_POSITION_X, 1003},
{time, EV_ABS, ABS_MT_POSITION_Y, 749},
{time, EV_ABS, ABS_MT_PRESSURE, 50},
{time, EV_ABS, ABS_MT_TOUCH_MAJOR, 116},
{time, EV_ABS, ABS_MT_SLOT, 1},
{time, EV_ABS, ABS_MT_TRACKING_ID, 1},
{time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER},
{time, EV_ABS, ABS_MT_POSITION_X, 1103},
{time, EV_ABS, ABS_MT_POSITION_Y, 649},
{time, EV_ABS, ABS_MT_PRESSURE, 50},
{time, EV_ABS, ABS_MT_TOUCH_MAJOR, 116},
{time, EV_KEY, BTN_TOUCH, 1},
{time, EV_ABS, ABS_X, 1003},
{time, EV_ABS, ABS_Y, 749},
{time, EV_ABS, ABS_PRESSURE, 50},
{time, EV_SYN, SYN_REPORT, 0},
{time, EV_ABS, ABS_MT_SLOT, 0},
{time, EV_ABS, ABS_MT_TOUCH_MAJOR, major_max},
{time, EV_SYN, SYN_REPORT, 0},
{time, EV_ABS, ABS_MT_TRACKING_ID, -1},
{time, EV_ABS, ABS_MT_SLOT, 1},
{time, EV_ABS, ABS_MT_TRACKING_ID, -1},
{time, EV_SYN, SYN_REPORT, 0},
};
// Set test now time to ensure above timestamps are in the past.
SetTestNowTime(time);
// Initialize the device.
dev->Initialize(devinfo);
dev->ConfigureReadMock(mock_kernel_queue_max_major,
base::size(mock_kernel_queue_max_major), 0);
dev->ReadNow();
EXPECT_EQ(5u, size());
ui::TouchEventParams ev1_1 = dispatched_touch_event(0);
EXPECT_EQ(ET_TOUCH_PRESSED, ev1_1.type);
EXPECT_EQ(0, ev1_1.slot);
EXPECT_EQ(1003, ev1_1.location.x());
EXPECT_EQ(749, ev1_1.location.y());
ui::TouchEventParams ev1_2 = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_PRESSED, ev1_2.type);
EXPECT_EQ(1, ev1_2.slot);
EXPECT_EQ(1103, ev1_2.location.x());
EXPECT_EQ(649, ev1_2.location.y());
ui::TouchEventParams ev1_3 = dispatched_touch_event(2);
EXPECT_EQ(ET_TOUCH_MOVED, ev1_3.type);
EXPECT_EQ(0, ev1_3.slot);
ui::TouchEventParams ev1_4 = dispatched_touch_event(3);
EXPECT_EQ(ET_TOUCH_RELEASED, ev1_4.type);
EXPECT_EQ(0, ev1_4.slot);
ui::TouchEventParams ev1_5 = dispatched_touch_event(4);
EXPECT_EQ(ET_TOUCH_RELEASED, ev1_5.type);
EXPECT_EQ(1, ev1_5.slot);
}
TEST_F(TouchEventConverterEvdevTest, PalmShouldCancelTouch) {
ui::MockTouchEventConverterEvdev* dev = device();
......
......@@ -15,6 +15,9 @@ const base::Feature kEnableNeuralPalmDetectionFilter{
const base::Feature kEnableNeuralStylusReportFilter{
"EnableNeuralStylusReportFilter", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kEnablePalmOnMaxTouchMajor{
"EnablePalmOnMaxTouchMajor", base::FEATURE_ENABLED_BY_DEFAULT};
extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial{
&kEnableNeuralPalmDetectionFilter, "neural_palm_radius_polynomial", ""};
......
......@@ -20,6 +20,9 @@ extern const base::Feature kEnableNeuralPalmDetectionFilter;
COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::Feature kEnableNeuralStylusReportFilter;
COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::Feature kEnablePalmOnMaxTouchMajor;
COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment