Make MotionEvent.getEventTimeNano API public.
We need a nanosecond precision for the resampling algorithm in Chrome. Currently we use a reflection to access these methods https://crrev.com/c/4282897, but we get an approval to make these methods public. Test: atest cts/tests/tests/view/src/android/view/cts/MotionEventTest.java Bug: b/269238283 Change-Id: I2ac814e777ab954268a450987d11481e6bd32ff9
This commit is contained in:
@@ -51282,10 +51282,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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) ");
|
||||
|
||||
@@ -2711,7 +2711,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public final long getEventTimeNano() {
|
||||
public final long getEventTimeNanos() {
|
||||
return mEventTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
* <p>
|
||||
* The value is in nanosecond precision but it may not have nanosecond accuracy.
|
||||
* </p>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user