diff --git a/core/api/current.txt b/core/api/current.txt index cbaff720eb730..072a96be9108e 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -51293,10 +51293,12 @@ package android.view { method public long getDownTime(); method public int getEdgeFlags(); method public long getEventTime(); + method public long getEventTimeNanos(); method public int getFlags(); method public float getHistoricalAxisValue(int, int); method public float getHistoricalAxisValue(int, int, int); method public long getHistoricalEventTime(int); + method public long getHistoricalEventTimeNanos(int); method public float getHistoricalOrientation(int); method public float getHistoricalOrientation(int, int); method public void getHistoricalPointerCoords(int, int, android.view.MotionEvent.PointerCoords); diff --git a/core/java/android/view/InputEvent.java b/core/java/android/view/InputEvent.java index cb9e746543f61..0b4adaeb98906 100644 --- a/core/java/android/view/InputEvent.java +++ b/core/java/android/view/InputEvent.java @@ -207,7 +207,7 @@ public abstract class InputEvent implements Parcelable { * * @hide */ - public abstract long getEventTimeNano(); + public abstract long getEventTimeNanos(); /** * Marks the input event as being canceled. diff --git a/core/java/android/view/InputEventConsistencyVerifier.java b/core/java/android/view/InputEventConsistencyVerifier.java index c0a3cec4547a4..5c38a1597433b 100644 --- a/core/java/android/view/InputEventConsistencyVerifier.java +++ b/core/java/android/view/InputEventConsistencyVerifier.java @@ -721,7 +721,7 @@ public final class InputEventConsistencyVerifier { private static void appendEvent(StringBuilder message, int index, InputEvent event, boolean unhandled) { - message.append(index).append(": sent at ").append(event.getEventTimeNano()); + message.append(index).append(": sent at ").append(event.getEventTimeNanos()); message.append(", "); if (unhandled) { message.append("(unhandled) "); diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index ab81345591895..2af025469df4a 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -2711,7 +2711,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @hide */ @Override - public final long getEventTimeNano() { + public final long getEventTimeNanos() { return mEventTime; } diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index a71ab8a5852c9..39029896331cf 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -2440,12 +2440,30 @@ public final class MotionEvent extends InputEvent implements Parcelable { * * @hide */ - @Override - @UnsupportedAppUsage + @UnsupportedAppUsage(publicAlternatives = + "Use {@link #getEventTimeNanos()} public API instead.", + maxTargetSdk = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) public final long getEventTimeNano() { return nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT); } + /** + * 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. + */ + @Override + public long getEventTimeNanos() { + return nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT); + } + /** * Equivalent to {@link #getX(int)} for pointer index 0 (regardless of the * pointer identifier). @@ -3104,10 +3122,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { * * @see #getHistorySize * @see #getEventTime - * - * @hide */ - public final long getHistoricalEventTimeNano(int pos) { + public long getHistoricalEventTimeNanos(int pos) { return nativeGetEventTimeNanos(mNativePtr, pos); } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index fb25e7a6bfe15..ef1c19345f855 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -9171,7 +9171,7 @@ public final class ViewRootImpl implements ViewParent, * Represents a pending input event that is waiting in a queue. * * Input events are processed in serial order by the timestamp specified by - * {@link InputEvent#getEventTimeNano()}. In general, the input dispatcher delivers + * {@link InputEvent#getEventTimeNanos()}. In general, the input dispatcher delivers * one input event to the application at a time and waits for the application * to finish handling it before delivering the next one. * @@ -9361,7 +9361,7 @@ public final class ViewRootImpl implements ViewParent, if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) { Trace.traceBegin(Trace.TRACE_TAG_VIEW, "deliverInputEvent src=0x" + Integer.toHexString(q.mEvent.getSource()) + " eventTimeNano=" - + q.mEvent.getEventTimeNano() + " id=0x" + + q.mEvent.getEventTimeNanos() + " id=0x" + Integer.toHexString(q.mEvent.getId())); } try { diff --git a/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java b/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java index e8c83b1e49dda..012385788952b 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java +++ b/packages/SystemUI/src/com/android/systemui/classifier/ProximityClassifier.java @@ -81,19 +81,19 @@ class ProximityClassifier extends FalsingClassifier { int action = motionEvent.getActionMasked(); if (action == MotionEvent.ACTION_DOWN) { - mGestureStartTimeNs = motionEvent.getEventTimeNano(); + mGestureStartTimeNs = motionEvent.getEventTimeNanos(); if (mPrevNearTimeNs > 0) { // We only care about if the proximity sensor is triggered while a move event is // happening. - mPrevNearTimeNs = motionEvent.getEventTimeNano(); + mPrevNearTimeNs = motionEvent.getEventTimeNanos(); } logDebug("Gesture start time: " + mGestureStartTimeNs); mNearDurationNs = 0; } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { - update(mNear, motionEvent.getEventTimeNano()); - long duration = motionEvent.getEventTimeNano() - mGestureStartTimeNs; + update(mNear, motionEvent.getEventTimeNanos()); + long duration = motionEvent.getEventTimeNanos() - mGestureStartTimeNs; logDebug("Gesture duration, Proximity duration: " + duration + ", " + mNearDurationNs);