Skip to content

Commit ff6c329

Browse files
committed
Cannot pan in browser if magnification is enabled.
1. We cache some events to see if the user wants to trigger magnification. If no magnification is triggered we inject these events with adjusted time and down time to prevent subsequent transformations being confused by stale events. After the cached events, which always have a down, are injected we need to also update the down time of all subsequent non cached events. bug:7379388 Change-Id: I41d8b831cc1016a0ee8f9c5ef5f42eb60a6f64d9
1 parent a1f739e commit ff6c329

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ public final class ScreenMagnifier implements EventStreamTransformation {
176176
private PointerCoords[] mTempPointerCoords;
177177
private PointerProperties[] mTempPointerProperties;
178178

179+
private long mDelegatingStateDownTime;
180+
179181
public ScreenMagnifier(Context context) {
180182
mContext = context;
181183
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
@@ -265,10 +267,15 @@ public void onDestroy() {
265267

266268
private void handleMotionEventStateDelegating(MotionEvent event,
267269
MotionEvent rawEvent, int policyFlags) {
268-
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
269-
if (mDetectingStateHandler.mDelayedEventQueue == null) {
270-
transitionToState(STATE_DETECTING);
271-
}
270+
switch (event.getActionMasked()) {
271+
case MotionEvent.ACTION_DOWN: {
272+
mDelegatingStateDownTime = event.getDownTime();
273+
} break;
274+
case MotionEvent.ACTION_UP: {
275+
if (mDetectingStateHandler.mDelayedEventQueue == null) {
276+
transitionToState(STATE_DETECTING);
277+
}
278+
} break;
272279
}
273280
if (mNext != null) {
274281
// If the event is within the magnified portion of the screen we have
@@ -295,6 +302,13 @@ private void handleMotionEventStateDelegating(MotionEvent event,
295302
coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(),
296303
event.getFlags());
297304
}
305+
// We cache some events to see if the user wants to trigger magnification.
306+
// If no magnification is triggered we inject these events with adjusted
307+
// time and down time to prevent subsequent transformations being confused
308+
// by stale events. After the cached events, which always have a down, are
309+
// injected we need to also update the down time of all subsequent non cached
310+
// events. All delegated events cached and non-cached are delivered here.
311+
event.setDownTime(mDelegatingStateDownTime);
298312
mNext.onMotionEvent(event, rawEvent, policyFlags);
299313
}
300314
}

0 commit comments

Comments
 (0)