Mir

Merge lp:~dandrader/mir/pressure_lp1238417 into lp:mir

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 1335
Proposed branch: lp:~dandrader/mir/pressure_lp1238417
Merge into: lp:mir
Diff against target: 89 lines (+37/-1)
3 files modified
3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp (+4/-1)
3rd_party/android-input/android/frameworks/base/services/input/InputReader.h (+2/-0)
tests/unit-tests/android_input/input_reader.cpp (+31/-0)
To merge this branch: bzr merge lp:~dandrader/mir/pressure_lp1238417
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Review via email: mp+201998@code.launchpad.net

Commit message

Don't assume pressure value is zero if not yet known

Instead, ignore pressure axis until its value is known.
Otherwise a touch point coulbe be wrongly considered as hovering.

Description of the change

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Looks good.

I have previously encountered problems on N7 (and N10?) where touch events weren't registered unless I pushed very hard. Would that be related?... Can't reproduce the issue today though.

review: Approve
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> I have previously encountered problems on N7 (and N10?) where touch events
> weren't registered unless I pushed very hard. Would that be related?... Can't
> reproduce the issue today though.

Not to this specific bug at least. You experience the bug fixed here only when there were input events before mir was runnning and the pressure value is constant, which is the case for a fake touch device. On a real touch device, if it does have a pressure axis, it will surely change its value and therefore mir will be aware of its state.

If you got responses only when you pushed very hard, one explanation would be that the pressure values were not going beyond zero (i.e., they were all zero or negative), which is the boundary android-input considers between a pressed touch point and a hovering one. But I don't believe that would be happening as android works fine in all those devices, of course.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good (AFAICT).

Nit:
// which is de default value when the accumulator is cleared

s/de /the /

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp'
2--- 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2014-01-10 03:59:43 +0000
3+++ 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2014-01-16 20:44:57 +0000
4@@ -1676,6 +1676,7 @@
5 case ABS_MT_PRESSURE:
6 slot->mInUse = true;
7 slot->mAbsMTPressure = rawEvent->value;
8+ slot->mHaveAbsMTPressure = true;
9 break;
10 case ABS_MT_DISTANCE:
11 slot->mInUse = true;
12@@ -1715,6 +1716,7 @@
13 mInUse = false;
14 mHaveAbsMTTouchMinor = false;
15 mHaveAbsMTWidthMinor = false;
16+ mHaveAbsMTPressure = false;
17 mHaveAbsMTToolType = false;
18 mAbsMTPositionX = 0;
19 mAbsMTPositionY = 0;
20@@ -5909,7 +5911,8 @@
21
22 bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE
23 && (mTouchButtonAccumulator.isHovering()
24- || (mRawPointerAxes.pressure.valid && inSlot->getPressure() <= 0));
25+ || (mRawPointerAxes.pressure.valid
26+ && inSlot->havePressure() && inSlot->getPressure() <= 0));
27 outPointer.isHovering = isHovering;
28
29 // Assign pointer id using tracking id if available.
30
31=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputReader.h'
32--- 3rd_party/android-input/android/frameworks/base/services/input/InputReader.h 2014-01-10 03:59:43 +0000
33+++ 3rd_party/android-input/android/frameworks/base/services/input/InputReader.h 2014-01-16 20:44:57 +0000
34@@ -812,6 +812,7 @@
35 inline int32_t getOrientation() const { return mAbsMTOrientation; }
36 inline int32_t getTrackingId() const { return mAbsMTTrackingId; }
37 inline int32_t getPressure() const { return mAbsMTPressure; }
38+ inline bool havePressure() const { return mHaveAbsMTPressure; }
39 inline int32_t getDistance() const { return mAbsMTDistance; }
40 inline int32_t getToolType() const;
41
42@@ -821,6 +822,7 @@
43 bool mInUse;
44 bool mHaveAbsMTTouchMinor;
45 bool mHaveAbsMTWidthMinor;
46+ bool mHaveAbsMTPressure;
47 bool mHaveAbsMTToolType;
48
49 int32_t mAbsMTPositionX;
50
51=== modified file 'tests/unit-tests/android_input/input_reader.cpp'
52--- tests/unit-tests/android_input/input_reader.cpp 2014-01-10 03:59:43 +0000
53+++ tests/unit-tests/android_input/input_reader.cpp 2014-01-16 20:44:57 +0000
54@@ -4785,4 +4785,35 @@
55 process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0x00000000);
56 }
57
58+// Regression test for LP#1238417:
59+// https://bugs.launchpad.net/mir/+bug/1238417
60+//
61+// Don't assume that ABS_MT_PRESSURE is 0 if you haven't heard from it yet. Instead,
62+// the pressure axis should be considered as absent.
63+// If a touch point has always the same positive, non-zero, pressure, that value
64+// will be informed only once, on its first event. But if mir wasn't running at
65+// that time, it would consider the pressure to be zero and therefore the point to be
66+// hovering, which is wrong.
67+TEST_F(MultiTouchInputMapperTest, Process_IgnorePressureAxisIfValueUnknown) {
68+ MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
69+ addConfigurationProperty("touch.deviceType", "touchScreen");
70+ addConfigurationProperty("device.internal", "1");
71+ setDisplayInfoAndReconfigure(DISPLAY_ID, 1024, 768, DISPLAY_ORIENTATION_0);
72+ prepareAxes(POSITION | PRESSURE | ID);
73+ addMapperAndConfigure(mapper);
74+
75+ // Note that there's no ABS_MT_PRESSURE
76+ process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_TRACKING_ID, 0x00000018);
77+ process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_POSITION_X, 500);
78+ process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_MT_POSITION_Y, 300);
79+ process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0x00000000);
80+
81+ NotifyMotionArgs args;
82+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
83+
84+ // Would be AMOTION_EVENT_ACTION_HOVER_ENTER if pressure value was assumed to be 0 (zero),
85+ // which is de default value when the accumulator is cleared.
86+ ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
87+}
88+
89 } // namespace android

Subscribers

People subscribed via source and target branches