From b11499d2db0ba9782363ec6bf714b583e8585212 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Fri, 20 Apr 2012 19:54:22 -0700 Subject: Make InputEvent.getEventTime() public. Also add new methods to access the event timestamp in nanoseconds. Hidden for now but useful for prototyping. Bug: 6374616 Change-Id: I7030734a908e8e31a17a356debc269db7c0f0783 --- core/java/android/view/MotionEvent.java | 52 +++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'core/java/android/view/MotionEvent.java') diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index e51ba3d..78fa2d7 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1781,18 +1781,32 @@ public final class MotionEvent extends InputEvent implements Parcelable { } /** - * Returns the time (in ms) when this specific event was generated. + * Retrieve the time this event occurred, + * in the {@link android.os.SystemClock#uptimeMillis} time base. + * + * @return Returns the time this event occurred, + * in the {@link android.os.SystemClock#uptimeMillis} time base. */ + @Override public final long getEventTime() { return nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT) / NS_PER_MS; } /** - * Returns the time (in ns) when this specific event was generated. + * Retrieve the time this event occurred, + * in the {@link android.os.SystemClock#uptimeMillis} time base but with + * nanosecond precision. + *

* The value is in nanosecond precision but it may not have nanosecond accuracy. + *

+ * + * @return Returns the time this event occurred, + * in the {@link android.os.SystemClock#uptimeMillis} time base but with + * nanosecond precision. * * @hide */ + @Override public final long getEventTimeNano() { return nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT); } @@ -2234,10 +2248,16 @@ public final class MotionEvent extends InputEvent implements Parcelable { /** * Returns the time that a historical movement occurred between this event - * and the previous event. Only applies to ACTION_MOVE events. + * and the previous event, in the {@link android.os.SystemClock#uptimeMillis} time base. + *

+ * This only applies to ACTION_MOVE events. + *

* * @param pos Which historical value to return; must be less than * {@link #getHistorySize} + * @return Returns the time that a historical movement occurred between this + * event and the previous event, + * in the {@link android.os.SystemClock#uptimeMillis} time base. * * @see #getHistorySize * @see #getEventTime @@ -2247,6 +2267,32 @@ public final class MotionEvent extends InputEvent implements Parcelable { } /** + * Returns the time that a historical movement occurred between this event + * and the previous event, in the {@link android.os.SystemClock#uptimeMillis} time base + * but with nanosecond (instead of millisecond) precision. + *

+ * This only applies to ACTION_MOVE events. + *

+ * The value is in nanosecond precision but it may not have nanosecond accuracy. + *

+ * + * @param pos Which historical value to return; must be less than + * {@link #getHistorySize} + * @return Returns the time that a historical movement occurred between this + * event and the previous event, + * in the {@link android.os.SystemClock#uptimeMillis} time base but with + * nanosecond (instead of millisecond) precision. + * + * @see #getHistorySize + * @see #getEventTime + * + * @hide + */ + public final long getHistoricalEventTimeNano(int pos) { + return nativeGetEventTimeNanos(mNativePtr, pos); + } + + /** * {@link #getHistoricalX(int, int)} for the first pointer index (may be an * arbitrary pointer identifier). * -- cgit v1.1