Skip to content

Commit 6acca24

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Cannot double tap and hold outside of the input focused window." into jb-dev
2 parents ea01e4a + 238099c commit 6acca24

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,25 +1247,45 @@ private boolean isPenidng() {
12471247

12481248
@Override
12491249
public void run() {
1250-
final int pointerIndex = mEvent.getActionIndex();
1250+
// If the last touched explored location is not within the focused
1251+
// window we will long press at that exact spot, otherwise we find the
1252+
// accessibility focus and if the tap is within its bounds we long press
1253+
// there, otherwise we pick the middle of the focus rectangle.
1254+
MotionEvent lastEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
1255+
if (lastEvent == null) {
1256+
return;
1257+
}
1258+
1259+
final int exploreLocationX = (int) lastEvent.getX(lastEvent.getActionIndex());
1260+
final int exploreLocationY = (int) lastEvent.getY(lastEvent.getActionIndex());
1261+
1262+
Rect bounds = mTempRect;
1263+
boolean useFocusedBounds = false;
1264+
1265+
final int pointerId = mEvent.getPointerId(mEvent.getActionIndex());
1266+
final int pointerIndex = mEvent.findPointerIndex(pointerId);
1267+
if (mAms.getAccessibilityFocusBounds(exploreLocationX, exploreLocationY, bounds)) {
1268+
// If the user's last touch explored location is not
1269+
// within the accessibility focus bounds we use the center
1270+
// of the accessibility focused rectangle.
1271+
if (!bounds.contains((int) mEvent.getX(pointerIndex),
1272+
(int) mEvent.getY(pointerIndex))) {
1273+
useFocusedBounds = true;
1274+
}
1275+
}
1276+
1277+
mLongPressingPointerId = mEvent.getPointerId(pointerIndex);
1278+
12511279
final int eventX = (int) mEvent.getX(pointerIndex);
12521280
final int eventY = (int) mEvent.getY(pointerIndex);
1253-
Rect bounds = mTempRect;
1254-
if (mAms.getAccessibilityFocusBounds(eventX, eventY, bounds)
1255-
&& !bounds.contains(eventX, eventY)) {
1256-
mLongPressingPointerId = mEvent.getPointerId(pointerIndex);
1281+
if (useFocusedBounds) {
12571282
mLongPressingPointerDeltaX = eventX - bounds.centerX();
12581283
mLongPressingPointerDeltaY = eventY - bounds.centerY();
12591284
} else {
1260-
mLongPressingPointerId = -1;
1261-
mLongPressingPointerDeltaX = 0;
1262-
mLongPressingPointerDeltaY = 0;
1285+
mLongPressingPointerDeltaX = eventX - exploreLocationX;
1286+
mLongPressingPointerDeltaY = eventY - exploreLocationY;
12631287
}
1264-
// We are sending events so send exit and gesture
1265-
// end since we transition to another state.
1266-
final int pointerId = mReceivedPointerTracker.getPrimaryActivePointerId();
1267-
final int pointerIdBits = (1 << pointerId);
1268-
mAms.touchExplorationGestureEnded();
1288+
12691289
sendExitEventsIfNeeded(mPolicyFlags);
12701290

12711291
mCurrentState = STATE_DELEGATING;

0 commit comments

Comments
 (0)