Commit 67d2cf00 authored by Rob Schonberger's avatar Rob Schonberger Committed by Commit Bot

Add a Feature to change behavior of TOOL_TYPE_PALM on touchscreen.


add a feature to disable using TOOL_TYPE_PALM as indicator for
palm-ness. Enable this feature by default, to maintain current
behavior across all devices in chromeos (!!)

Add a comprehensive unit test to test for behavior when this feature
is disabled.

Bug: 1009290
Change-Id: Iea348a37957ba2177c82a31d40029f0b831a578c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094478Reviewed-by: default avatarSean O'Brien <seobrien@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Rob Schonberger <robsc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748490}
parent 37c0c22a
...@@ -120,7 +120,9 @@ TouchEventConverterEvdev::TouchEventConverterEvdev( ...@@ -120,7 +120,9 @@ TouchEventConverterEvdev::TouchEventConverterEvdev(
palm_detection_filter_( palm_detection_filter_(
CreatePalmDetectionFilter(devinfo, shared_palm_state)), CreatePalmDetectionFilter(devinfo, shared_palm_state)),
palm_on_touch_major_max_( palm_on_touch_major_max_(
base::FeatureList::IsEnabled(kEnablePalmOnMaxTouchMajor)) { base::FeatureList::IsEnabled(kEnablePalmOnMaxTouchMajor)),
palm_on_tool_type_palm_(
base::FeatureList::IsEnabled(kEnablePalmOnToolTypePalm)) {
touch_evdev_debug_buffer_.Initialize(devinfo); touch_evdev_debug_buffer_.Initialize(devinfo);
} }
...@@ -516,9 +518,12 @@ bool TouchEventConverterEvdev::MaybeCancelAllTouches() { ...@@ -516,9 +518,12 @@ bool TouchEventConverterEvdev::MaybeCancelAllTouches() {
} }
bool TouchEventConverterEvdev::IsPalm(const InProgressTouchEvdev& touch) { bool TouchEventConverterEvdev::IsPalm(const InProgressTouchEvdev& touch) {
return touch.tool_type == MT_TOOL_PALM || if (palm_on_tool_type_palm_ && touch.tool_type == MT_TOOL_PALM)
(palm_on_touch_major_max_ && major_max_ > 0 && return true;
touch.major == major_max_); else if (palm_on_touch_major_max_ && major_max_ > 0 &&
touch.major == major_max_)
return true;
return false;
} }
void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) {
......
...@@ -192,6 +192,9 @@ class COMPONENT_EXPORT(EVDEV) TouchEventConverterEvdev ...@@ -192,6 +192,9 @@ class COMPONENT_EXPORT(EVDEV) TouchEventConverterEvdev
// Do we mark a touch as palm when touch_major is the max? // Do we mark a touch as palm when touch_major is the max?
const bool palm_on_touch_major_max_; const bool palm_on_touch_major_max_;
// Do we mark a touch as palm when the tool type is marked as TOOL_TYPE_PALM ?
const bool palm_on_tool_type_palm_;
DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev); DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev);
}; };
......
...@@ -237,8 +237,9 @@ class TouchEventConverterEvdevTest : public testing::Test { ...@@ -237,8 +237,9 @@ class TouchEventConverterEvdevTest : public testing::Test {
// By default, tests disable single-cancel and enable palm on touch_major == // By default, tests disable single-cancel and enable palm on touch_major ==
// major_max. // major_max.
scoped_feature_list_.reset(new base::test::ScopedFeatureList); scoped_feature_list_.reset(new base::test::ScopedFeatureList);
scoped_feature_list_->InitWithFeatures({kEnablePalmOnMaxTouchMajor}, scoped_feature_list_->InitWithFeatures(
{kEnableSingleCancelTouch}); {kEnablePalmOnMaxTouchMajor, kEnablePalmOnToolTypePalm},
{kEnableSingleCancelTouch});
SetUpDevice(); SetUpDevice();
} }
...@@ -738,6 +739,101 @@ TEST_F(TouchEventConverterEvdevTest, ShouldRemoveContactsWhenDisabled) { ...@@ -738,6 +739,101 @@ TEST_F(TouchEventConverterEvdevTest, ShouldRemoveContactsWhenDisabled) {
EXPECT_EQ(2u, size()); EXPECT_EQ(2u, size());
} }
TEST_F(TouchEventConverterEvdevTest, ToolTypePalmNotCancelTouch) {
// By default, we use TOOL_TYPE_PALM as a cancellation signal for all touches.
// We disable that behavior and want to see all touches registered as usual.
scoped_feature_list_.reset(new base::test::ScopedFeatureList);
scoped_feature_list_->InitWithFeatures(
{}, {kEnablePalmOnMaxTouchMajor, kEnablePalmOnToolTypePalm,
kEnableSingleCancelTouch});
SetUpDevice();
ui::MockTouchEventConverterEvdev* dev = device();
EventDeviceInfo devinfo;
EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkWithToolTypeTouchscreen, &devinfo));
timeval time;
time = {1429651083, 686882};
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, 200},
{time, EV_ABS, ABS_MT_POSITION_X, 1009},
{time, EV_ABS, ABS_MT_POSITION_Y, 755},
{time, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM},
{time, EV_SYN, SYN_REPORT, 0},
{time, EV_ABS, ABS_MT_SLOT, 1},
{time, EV_ABS, ABS_MT_POSITION_X, 1090},
{time, EV_ABS, ABS_MT_POSITION_Y, 655},
{time, EV_SYN, SYN_REPORT, 0},
{time, EV_ABS, ABS_MT_SLOT, 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(6u, 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);
EXPECT_EQ(1009, ev1_3.location.x());
EXPECT_EQ(755, ev1_3.location.y());
ui::TouchEventParams ev1_4 = dispatched_touch_event(3);
EXPECT_EQ(ET_TOUCH_MOVED, ev1_4.type);
EXPECT_EQ(1, ev1_4.slot);
EXPECT_EQ(1090, ev1_4.location.x());
EXPECT_EQ(655, ev1_4.location.y());
ui::TouchEventParams ev1_5 = dispatched_touch_event(4);
EXPECT_EQ(ET_TOUCH_RELEASED, ev1_5.type);
EXPECT_EQ(0, ev1_5.slot);
ui::TouchEventParams ev1_6 = dispatched_touch_event(5);
EXPECT_EQ(ET_TOUCH_RELEASED, ev1_6.type);
EXPECT_EQ(1, ev1_6.slot);
}
TEST_F(TouchEventConverterEvdevTest, MaxMajorNotCancelTouch) { TEST_F(TouchEventConverterEvdevTest, MaxMajorNotCancelTouch) {
// By default, tests disable single-cancel and enable palm on touch_major == // 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 // major_max. So we disable that behavior: and expect to see a RELEASED rather
......
...@@ -18,6 +18,9 @@ const base::Feature kEnableNeuralStylusReportFilter{ ...@@ -18,6 +18,9 @@ const base::Feature kEnableNeuralStylusReportFilter{
const base::Feature kEnablePalmOnMaxTouchMajor{ const base::Feature kEnablePalmOnMaxTouchMajor{
"EnablePalmOnMaxTouchMajor", base::FEATURE_ENABLED_BY_DEFAULT}; "EnablePalmOnMaxTouchMajor", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kEnablePalmOnToolTypePalm{"EnablePalmOnToolTypePalm",
base::FEATURE_ENABLED_BY_DEFAULT};
extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial{ extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial{
&kEnableNeuralPalmDetectionFilter, "neural_palm_radius_polynomial", ""}; &kEnableNeuralPalmDetectionFilter, "neural_palm_radius_polynomial", ""};
......
...@@ -23,6 +23,9 @@ extern const base::Feature kEnableNeuralStylusReportFilter; ...@@ -23,6 +23,9 @@ extern const base::Feature kEnableNeuralStylusReportFilter;
COMPONENT_EXPORT(EVENTS_OZONE) COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::Feature kEnablePalmOnMaxTouchMajor; extern const base::Feature kEnablePalmOnMaxTouchMajor;
COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::Feature kEnablePalmOnToolTypePalm;
COMPONENT_EXPORT(EVENTS_OZONE) COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial; 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