Skip to content

Commit 435f0c5

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "HardwareStateConverter: clean up palm reporting flag" into main
2 parents 2662709 + 577119b commit 435f0c5

3 files changed

Lines changed: 6 additions & 97 deletions

File tree

libs/input/input_flags.aconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ flag {
6060
bug: "299977100"
6161
}
6262

63-
flag {
64-
name: "report_palms_to_gestures_library"
65-
namespace: "input"
66-
description: "Report touches marked as palm by firmware to gestures library"
67-
bug: "302505955"
68-
}
69-
7063
flag {
7164
name: "enable_touchpad_typing_palm_rejection"
7265
namespace: "input"

services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525
#include <com_android_input_flags.h>
2626
#include <linux/input-event-codes.h>
2727

28-
namespace input_flags = com::android::input::flags;
29-
3028
namespace android {
3129

32-
const bool REPORT_PALMS_TO_GESTURES_LIBRARY = input_flags::report_palms_to_gestures_library();
33-
3430
HardwareStateConverter::HardwareStateConverter(const InputDeviceContext& deviceContext,
3531
MultiTouchMotionAccumulator& motionAccumulator)
3632
: mDeviceContext(deviceContext),
@@ -81,18 +77,11 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t
8177
}
8278

8379
schs.fingers.clear();
84-
size_t numPalms = 0;
8580
for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) {
8681
MultiTouchMotionAccumulator::Slot slot = mMotionAccumulator.getSlot(i);
8782
if (!slot.isInUse()) {
8883
continue;
8984
}
90-
// Some touchpads continue to report contacts even after they've identified them as palms.
91-
// We want to exclude these contacts from the HardwareStates.
92-
if (!REPORT_PALMS_TO_GESTURES_LIBRARY && slot.getToolType() == ToolType::PALM) {
93-
numPalms++;
94-
continue;
95-
}
9685

9786
FingerState& fingerState = schs.fingers.emplace_back();
9887
fingerState = {};
@@ -105,15 +94,13 @@ SelfContainedHardwareState HardwareStateConverter::produceHardwareState(nsecs_t
10594
fingerState.position_x = slot.getX();
10695
fingerState.position_y = slot.getY();
10796
fingerState.tracking_id = slot.getTrackingId();
108-
if (REPORT_PALMS_TO_GESTURES_LIBRARY) {
109-
fingerState.tool_type = slot.getToolType() == ToolType::PALM
110-
? FingerState::ToolType::kPalm
111-
: FingerState::ToolType::kFinger;
112-
}
97+
fingerState.tool_type = slot.getToolType() == ToolType::PALM
98+
? FingerState::ToolType::kPalm
99+
: FingerState::ToolType::kFinger;
113100
}
114101
schs.state.fingers = schs.fingers.data();
115102
schs.state.finger_cnt = schs.fingers.size();
116-
schs.state.touch_cnt = mTouchButtonAccumulator.getTouchCount() - numPalms;
103+
schs.state.touch_cnt = mTouchButtonAccumulator.getTouchCount();
117104
return schs;
118105
}
119106

services/inputflinger/tests/HardwareStateConverter_test.cpp

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333

3434
namespace android {
3535

36-
namespace {
37-
38-
const auto REPORT_PALMS =
39-
ACONFIG_FLAG(com::android::input::flags, report_palms_to_gestures_library);
40-
41-
} // namespace
42-
4336
class HardwareStateConverterTest : public testing::Test {
4437
public:
4538
HardwareStateConverterTest()
@@ -201,24 +194,7 @@ TEST_F(HardwareStateConverterTest, TwoFingers) {
201194
EXPECT_EQ(0u, finger2.flags);
202195
}
203196

204-
TEST_F_WITH_FLAGS(HardwareStateConverterTest, OnePalmDisableReportPalms,
205-
REQUIRES_FLAGS_DISABLED(REPORT_PALMS)) {
206-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_SLOT, 0);
207-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM);
208-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TRACKING_ID, 123);
209-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_X, 50);
210-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_Y, 100);
211-
212-
processAxis(ARBITRARY_TIME, EV_KEY, BTN_TOUCH, 1);
213-
processAxis(ARBITRARY_TIME, EV_KEY, BTN_TOOL_FINGER, 1);
214-
std::optional<SelfContainedHardwareState> schs = processSync(ARBITRARY_TIME);
215-
ASSERT_TRUE(schs.has_value());
216-
EXPECT_EQ(0, schs->state.touch_cnt);
217-
EXPECT_EQ(0, schs->state.finger_cnt);
218-
}
219-
220-
TEST_F_WITH_FLAGS(HardwareStateConverterTest, OnePalmEnableReportPalms,
221-
REQUIRES_FLAGS_ENABLED(REPORT_PALMS)) {
197+
TEST_F(HardwareStateConverterTest, OnePalm) {
222198
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_SLOT, 0);
223199
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM);
224200
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TRACKING_ID, 123);
@@ -234,54 +210,7 @@ TEST_F_WITH_FLAGS(HardwareStateConverterTest, OnePalmEnableReportPalms,
234210
EXPECT_EQ(FingerState::ToolType::kPalm, schs->state.fingers[0].tool_type);
235211
}
236212

237-
TEST_F_WITH_FLAGS(HardwareStateConverterTest, OneFingerTurningIntoAPalmDisableReportPalms,
238-
REQUIRES_FLAGS_DISABLED(REPORT_PALMS)) {
239-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_SLOT, 0);
240-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
241-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TRACKING_ID, 123);
242-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_X, 50);
243-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_Y, 100);
244-
245-
processAxis(ARBITRARY_TIME, EV_KEY, BTN_TOUCH, 1);
246-
processAxis(ARBITRARY_TIME, EV_KEY, BTN_TOOL_FINGER, 1);
247-
248-
std::optional<SelfContainedHardwareState> schs = processSync(ARBITRARY_TIME);
249-
ASSERT_TRUE(schs.has_value());
250-
EXPECT_EQ(1, schs->state.touch_cnt);
251-
EXPECT_EQ(1, schs->state.finger_cnt);
252-
253-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_PALM);
254-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_X, 51);
255-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_Y, 99);
256-
257-
schs = processSync(ARBITRARY_TIME);
258-
ASSERT_TRUE(schs.has_value());
259-
EXPECT_EQ(0, schs->state.touch_cnt);
260-
ASSERT_EQ(0, schs->state.finger_cnt);
261-
262-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_X, 53);
263-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_Y, 97);
264-
265-
schs = processSync(ARBITRARY_TIME);
266-
ASSERT_TRUE(schs.has_value());
267-
EXPECT_EQ(0, schs->state.touch_cnt);
268-
EXPECT_EQ(0, schs->state.finger_cnt);
269-
270-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
271-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_X, 55);
272-
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_POSITION_Y, 95);
273-
schs = processSync(ARBITRARY_TIME);
274-
ASSERT_TRUE(schs.has_value());
275-
EXPECT_EQ(1, schs->state.touch_cnt);
276-
ASSERT_EQ(1, schs->state.finger_cnt);
277-
const FingerState& newFinger = schs->state.fingers[0];
278-
EXPECT_EQ(123, newFinger.tracking_id);
279-
EXPECT_NEAR(55, newFinger.position_x, EPSILON);
280-
EXPECT_NEAR(95, newFinger.position_y, EPSILON);
281-
}
282-
283-
TEST_F_WITH_FLAGS(HardwareStateConverterTest, OneFingerTurningIntoAPalmEnableReportPalms,
284-
REQUIRES_FLAGS_ENABLED(REPORT_PALMS)) {
213+
TEST_F(HardwareStateConverterTest, OneFingerTurningIntoAPalmEnableReportPalms) {
285214
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_SLOT, 0);
286215
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
287216
processAxis(ARBITRARY_TIME, EV_ABS, ABS_MT_TRACKING_ID, 123);

0 commit comments

Comments
 (0)