Loading core/java/android/view/GestureDetector.java +20 −6 Original line number Diff line number Diff line Loading @@ -18,10 +18,10 @@ package android.view; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__FLING; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -797,7 +797,6 @@ public class GestureDetector { mDoubleTapListener.onSingleTapConfirmed(ev); } } else if (!mIgnoreNextUpEvent) { // A fling must travel the minimum tap distance final VelocityTracker velocityTracker = mVelocityTracker; final int pointerId = ev.getPointerId(0); Loading @@ -807,6 +806,9 @@ public class GestureDetector { if ((Math.abs(velocityY) > mMinimumFlingVelocity) || (Math.abs(velocityX) > mMinimumFlingVelocity)) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__FLING, (float) Math.hypot(velocityX, velocityY) / 1000); handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY); } } Loading Loading @@ -942,10 +944,14 @@ public class GestureDetector { } private void recordGestureClassification(int classification) { recordGestureClassification(classification, 0 /* velocity */); } private void recordGestureClassification(int classification, float velocity) { // Only record the first classification for an event stream -- except for FLING, // which can occur at the end of an event stream after a SCROLL. if (mHasRecordedClassification || classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { // Only record the first classification for an event stream. && classification != TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__FLING) { return; } if (mCurrentDownEvent == null || mCurrentMotionEvent == null) { Loading @@ -953,13 +959,21 @@ public class GestureDetector { mHasRecordedClassification = true; return; } if (velocity == 0 && mVelocityTracker != null) { // Compute velocity if it was not provided (i.e. for non-FLING gestures). mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); final int pointerId = mCurrentMotionEvent.getPointerId(0); velocity = (float) Math.hypot(mVelocityTracker.getXVelocity(pointerId), mVelocityTracker.getYVelocity(pointerId)) / 1000; } FrameworkStatsLog.write( FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification, (int) (SystemClock.uptimeMillis() - mCurrentMotionEvent.getDownTime()), (float) Math.hypot(mCurrentMotionEvent.getRawX() - mCurrentDownEvent.getRawX(), mCurrentMotionEvent.getRawY() - mCurrentDownEvent.getRawY())); mCurrentMotionEvent.getRawY() - mCurrentDownEvent.getRawY()), (float) velocity); mHasRecordedClassification = true; } } core/java/android/view/View.java +2 −1 Original line number Diff line number Diff line Loading @@ -31928,7 +31928,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // To avoid negatively impacting View performance, the latency and displacement metrics // are omitted. FrameworkStatsLog.write(FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification); classification, (int) 0 /* latency_millis */, (float) 0 /* displacement_px */, (float) 0 /* velocity_px_millis */); } /** Loading
core/java/android/view/GestureDetector.java +20 −6 Original line number Diff line number Diff line Loading @@ -18,10 +18,10 @@ package android.view; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__FLING; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -797,7 +797,6 @@ public class GestureDetector { mDoubleTapListener.onSingleTapConfirmed(ev); } } else if (!mIgnoreNextUpEvent) { // A fling must travel the minimum tap distance final VelocityTracker velocityTracker = mVelocityTracker; final int pointerId = ev.getPointerId(0); Loading @@ -807,6 +806,9 @@ public class GestureDetector { if ((Math.abs(velocityY) > mMinimumFlingVelocity) || (Math.abs(velocityX) > mMinimumFlingVelocity)) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__FLING, (float) Math.hypot(velocityX, velocityY) / 1000); handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY); } } Loading Loading @@ -942,10 +944,14 @@ public class GestureDetector { } private void recordGestureClassification(int classification) { recordGestureClassification(classification, 0 /* velocity */); } private void recordGestureClassification(int classification, float velocity) { // Only record the first classification for an event stream -- except for FLING, // which can occur at the end of an event stream after a SCROLL. if (mHasRecordedClassification || classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { // Only record the first classification for an event stream. && classification != TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__FLING) { return; } if (mCurrentDownEvent == null || mCurrentMotionEvent == null) { Loading @@ -953,13 +959,21 @@ public class GestureDetector { mHasRecordedClassification = true; return; } if (velocity == 0 && mVelocityTracker != null) { // Compute velocity if it was not provided (i.e. for non-FLING gestures). mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); final int pointerId = mCurrentMotionEvent.getPointerId(0); velocity = (float) Math.hypot(mVelocityTracker.getXVelocity(pointerId), mVelocityTracker.getYVelocity(pointerId)) / 1000; } FrameworkStatsLog.write( FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification, (int) (SystemClock.uptimeMillis() - mCurrentMotionEvent.getDownTime()), (float) Math.hypot(mCurrentMotionEvent.getRawX() - mCurrentDownEvent.getRawX(), mCurrentMotionEvent.getRawY() - mCurrentDownEvent.getRawY())); mCurrentMotionEvent.getRawY() - mCurrentDownEvent.getRawY()), (float) velocity); mHasRecordedClassification = true; } }
core/java/android/view/View.java +2 −1 Original line number Diff line number Diff line Loading @@ -31928,7 +31928,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // To avoid negatively impacting View performance, the latency and displacement metrics // are omitted. FrameworkStatsLog.write(FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification); classification, (int) 0 /* latency_millis */, (float) 0 /* displacement_px */, (float) 0 /* velocity_px_millis */); } /**