Skip to content

Commit 95068e5

Browse files
committed
If a gesture cannot be detected the device should transition to touch exploration state.
1. We are deciding whether the user is performing a gesture or an exploration based on the gesture velocity. If we are detecting gesture we do the recognition at the gesture end which is when the finger goes up. This is better than having a mode toggle gesture for exploring and gestures detection. However, it is possible that the user really wanted to perform an exploration but was moving too fast and unless he lifts his finger the device is in gesture detection mode. This is frustrating since the user has no feedback and assumes exploration does not work. We want to perform gesture detection only for a maximal time frame and if the user did not lift his finger we transition into touch exploration state. bug:6663173 Change-Id: I954ff937cca902e31b51325d1e1dfce84d239624
1 parent 4365d06 commit 95068e5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

services/java/com/android/server/accessibility/TouchExplorer.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public class TouchExplorer {
9898
// the two dragging pointers as opposed to use the location of the primary one.
9999
private static final int MIN_POINTER_DISTANCE_TO_USE_MIDDLE_LOCATION_DIP = 200;
100100

101+
// The timeout after which we are no longer trying to detect a gesture.
102+
private static final int EXIT_GESTURE_DETECTION_TIMEOUT = 2000;
103+
101104
// Temporary array for storing pointer IDs.
102105
private final int[] mTempPointerIds = new int[MAX_POINTER_COUNT];
103106

@@ -138,6 +141,9 @@ public class TouchExplorer {
138141
// Command for delayed sending of a long press.
139142
private final PerformLongPressDelayed mPerformLongPressDelayed;
140143

144+
// Command for exiting gesture detection mode after a timeout.
145+
private final ExitGestureDetectionModeDelayed mExitGestureDetectionModeDelayed;
146+
141147
// Helper to detect and react to double tap in touch explore mode.
142148
private final DoubleTapDetector mDoubleTapDetector;
143149

@@ -212,6 +218,7 @@ public TouchExplorer(InputFilter inputFilter, Context context,
212218
mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop();
213219
mHandler = new Handler(context.getMainLooper());
214220
mPerformLongPressDelayed = new PerformLongPressDelayed();
221+
mExitGestureDetectionModeDelayed = new ExitGestureDetectionModeDelayed();
215222
mGestureLibrary = GestureLibraries.fromRawResource(context, R.raw.accessibility_gestures);
216223
mGestureLibrary.setOrientationStyle(4);
217224
mGestureLibrary.load();
@@ -257,6 +264,7 @@ public void clear(MotionEvent event, int policyFlags) {
257264
mSendHoverEnterDelayed.remove();
258265
mSendHoverExitDelayed.remove();
259266
mPerformLongPressDelayed.remove();
267+
mExitGestureDetectionModeDelayed.remove();
260268
// Reset the pointer trackers.
261269
mReceivedPointerTracker.clear();
262270
mInjectedPointerTracker.clear();
@@ -420,6 +428,7 @@ private void handleMotionEventStateTouchExploring(MotionEvent event, int policyF
420428
mSendHoverEnterDelayed.remove();
421429
mSendHoverExitDelayed.remove();
422430
mPerformLongPressDelayed.remove();
431+
mExitGestureDetectionModeDelayed.post();
423432
} else {
424433
// We have just decided that the user is touch,
425434
// exploring so start sending events.
@@ -727,6 +736,7 @@ private void handleMotionEventGestureDetecting(MotionEvent event, int policyFlag
727736
}
728737

729738
mStrokeBuffer.clear();
739+
mExitGestureDetectionModeDelayed.remove();
730740
mCurrentState = STATE_TOUCH_EXPLORING;
731741
} break;
732742
case MotionEvent.ACTION_CANCEL: {
@@ -1262,6 +1272,25 @@ private int getNotInjectedActivePointerCount(ReceivedPointerTracker receivedTrac
12621272
return Integer.bitCount(pointerState);
12631273
}
12641274

1275+
/**
1276+
* Class for delayed exiting from gesture detecting mode.
1277+
*/
1278+
private final class ExitGestureDetectionModeDelayed implements Runnable {
1279+
1280+
public void post() {
1281+
mHandler.postDelayed(this, EXIT_GESTURE_DETECTION_TIMEOUT);
1282+
}
1283+
1284+
public void remove() {
1285+
mHandler.removeCallbacks(this);
1286+
}
1287+
1288+
@Override
1289+
public void run() {
1290+
clear();
1291+
}
1292+
}
1293+
12651294
/**
12661295
* Class for delayed sending of long press.
12671296
*/

0 commit comments

Comments
 (0)