summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/accessibility
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-10-16 18:17:38 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-10-16 18:26:57 -0700
commit72e351296046d61ecc5863da2faca0ab4ba0fd62 (patch)
tree6e24100d8837c41740c6c2462a258628ee119c3e /services/java/com/android/server/accessibility
parent48994ce9451cccb9ee6a6a27c18dbaaddffca452 (diff)
downloadframeworks_base-72e351296046d61ecc5863da2faca0ab4ba0fd62.zip
frameworks_base-72e351296046d61ecc5863da2faca0ab4ba0fd62.tar.gz
frameworks_base-72e351296046d61ecc5863da2faca0ab4ba0fd62.tar.bz2
Long press not working if explore by touch and magnification are on.
1. In the magnifier we are caching the touch events until we figure out whether the user is triple tapping to enable magnification. If the user is not trying to engage magnification we deliver the stashed events. However, these events are stale and the subsequent transformations such as the touch explorer get confused when trying to detect a tap since the delay is longer than the tap slop. This change compensates for the time the events were cached before sending them to the next transformation in the chain. bug:7362365 Change-Id: Idd8539ffed7ba4892c5a916bd34910fd2ef50f75
Diffstat (limited to 'services/java/com/android/server/accessibility')
-rw-r--r--services/java/com/android/server/accessibility/ScreenMagnifier.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/services/java/com/android/server/accessibility/ScreenMagnifier.java b/services/java/com/android/server/accessibility/ScreenMagnifier.java
index d5a8537..caf37b7 100644
--- a/services/java/com/android/server/accessibility/ScreenMagnifier.java
+++ b/services/java/com/android/server/accessibility/ScreenMagnifier.java
@@ -38,6 +38,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemClock;
import android.provider.Settings;
import android.util.Property;
import android.util.Slog;
@@ -662,12 +663,33 @@ public final class ScreenMagnifier implements EventStreamTransformation {
while (mDelayedEventQueue != null) {
MotionEventInfo info = mDelayedEventQueue;
mDelayedEventQueue = info.mNext;
- ScreenMagnifier.this.onMotionEvent(info.mEvent, info.mRawEvent,
- info.mPolicyFlags);
+ final long offset = SystemClock.uptimeMillis() - info.mCachedTimeMillis;
+ MotionEvent event = obtainEventWithOffsetTimeAndDownTime(info.mEvent, offset);
+ MotionEvent rawEvent = obtainEventWithOffsetTimeAndDownTime(info.mRawEvent, offset);
+ ScreenMagnifier.this.onMotionEvent(event, rawEvent, info.mPolicyFlags);
+ event.recycle();
+ rawEvent.recycle();
info.recycle();
}
}
+ private MotionEvent obtainEventWithOffsetTimeAndDownTime(MotionEvent event, long offset) {
+ final int pointerCount = event.getPointerCount();
+ PointerCoords[] coords = getTempPointerCoordsWithMinSize(pointerCount);
+ PointerProperties[] properties = getTempPointerPropertiesWithMinSize(pointerCount);
+ for (int i = 0; i < pointerCount; i++) {
+ event.getPointerCoords(i, coords[i]);
+ event.getPointerProperties(i, properties[i]);
+ }
+ final long downTime = event.getDownTime() + offset;
+ final long eventTime = event.getEventTime() + offset;
+ return MotionEvent.obtain(downTime, eventTime,
+ event.getAction(), pointerCount, properties, coords,
+ event.getMetaState(), event.getButtonState(),
+ 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(),
+ event.getSource(), event.getFlags());
+ }
+
private void clearDelayedMotionEvents() {
while (mDelayedEventQueue != null) {
MotionEventInfo info = mDelayedEventQueue;
@@ -746,6 +768,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
public MotionEvent mEvent;
public MotionEvent mRawEvent;
public int mPolicyFlags;
+ public long mCachedTimeMillis;
public static MotionEventInfo obtain(MotionEvent event, MotionEvent rawEvent,
int policyFlags) {
@@ -770,6 +793,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
mEvent = MotionEvent.obtain(event);
mRawEvent = MotionEvent.obtain(rawEvent);
mPolicyFlags = policyFlags;
+ mCachedTimeMillis = SystemClock.uptimeMillis();
}
public void recycle() {
@@ -793,6 +817,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
mRawEvent.recycle();
mRawEvent = null;
mPolicyFlags = 0;
+ mCachedTimeMillis = 0;
}
}