am 05ad745f: Merge "Long press not working if explore by touch and magnification are on." into jb-mr1-dev
* commit '05ad745ff63ed3bcdb86d42290ddc2ee214fe90f': Long press not working if explore by touch and magnification are on.
This commit is contained in:
@@ -38,6 +38,7 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -662,12 +663,33 @@ public final class ScreenMagnifier implements EventStreamTransformation {
|
|||||||
while (mDelayedEventQueue != null) {
|
while (mDelayedEventQueue != null) {
|
||||||
MotionEventInfo info = mDelayedEventQueue;
|
MotionEventInfo info = mDelayedEventQueue;
|
||||||
mDelayedEventQueue = info.mNext;
|
mDelayedEventQueue = info.mNext;
|
||||||
ScreenMagnifier.this.onMotionEvent(info.mEvent, info.mRawEvent,
|
final long offset = SystemClock.uptimeMillis() - info.mCachedTimeMillis;
|
||||||
info.mPolicyFlags);
|
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();
|
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() {
|
private void clearDelayedMotionEvents() {
|
||||||
while (mDelayedEventQueue != null) {
|
while (mDelayedEventQueue != null) {
|
||||||
MotionEventInfo info = mDelayedEventQueue;
|
MotionEventInfo info = mDelayedEventQueue;
|
||||||
@@ -746,6 +768,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
|
|||||||
public MotionEvent mEvent;
|
public MotionEvent mEvent;
|
||||||
public MotionEvent mRawEvent;
|
public MotionEvent mRawEvent;
|
||||||
public int mPolicyFlags;
|
public int mPolicyFlags;
|
||||||
|
public long mCachedTimeMillis;
|
||||||
|
|
||||||
public static MotionEventInfo obtain(MotionEvent event, MotionEvent rawEvent,
|
public static MotionEventInfo obtain(MotionEvent event, MotionEvent rawEvent,
|
||||||
int policyFlags) {
|
int policyFlags) {
|
||||||
@@ -770,6 +793,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
|
|||||||
mEvent = MotionEvent.obtain(event);
|
mEvent = MotionEvent.obtain(event);
|
||||||
mRawEvent = MotionEvent.obtain(rawEvent);
|
mRawEvent = MotionEvent.obtain(rawEvent);
|
||||||
mPolicyFlags = policyFlags;
|
mPolicyFlags = policyFlags;
|
||||||
|
mCachedTimeMillis = SystemClock.uptimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recycle() {
|
public void recycle() {
|
||||||
@@ -793,6 +817,7 @@ public final class ScreenMagnifier implements EventStreamTransformation {
|
|||||||
mRawEvent.recycle();
|
mRawEvent.recycle();
|
||||||
mRawEvent = null;
|
mRawEvent = null;
|
||||||
mPolicyFlags = 0;
|
mPolicyFlags = 0;
|
||||||
|
mCachedTimeMillis = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user