Loading core/java/android/view/InputEvent.java +15 −0 Original line number Diff line number Diff line Loading @@ -233,6 +233,21 @@ public abstract class InputEvent implements Parcelable { return mSeq; } /** * Gets the ID of this event. This is generated when an event is created and preserved until its * last stage. It won't change just because the event crosses process boundary, but should * change when making a copy with modifications. * <p> * To avoid exposing app usage to other processes this ID is generated from a CSPRNG. Therefore * there isn't 100% guarantee on the uniqueness of this ID, though the chance of ID collisions * is considerably low. The rule of thumb is not to rely on the uniqueness for production logic, * but a good source for tracking an event (e.g. logging and profiling). * * @return The ID of this event. * @hide */ public abstract int getId(); public int describeContents() { return 0; } Loading core/java/android/view/KeyEvent.java +40 −5 Original line number Diff line number Diff line Loading @@ -1265,6 +1265,7 @@ public class KeyEvent extends InputEvent implements Parcelable { private KeyEvent mNext; private int mId; @UnsupportedAppUsage private int mDeviceId; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) Loading Loading @@ -1350,9 +1351,9 @@ public class KeyEvent extends InputEvent implements Parcelable { private static native String nativeKeyCodeToString(int keyCode); private static native int nativeKeyCodeFromString(String keyCode); private static native int nativeNextId(); private KeyEvent() { } private KeyEvent() {} /** * Create a new key event. Loading @@ -1362,6 +1363,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @param code The key code. */ public KeyEvent(int action, int code) { mId = nativeNextId(); mAction = action; mKeyCode = code; mRepeatCount = 0; Loading @@ -1383,6 +1385,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public KeyEvent(long downTime, long eventTime, int action, int code, int repeat) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading @@ -1407,6 +1410,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading Loading @@ -1435,6 +1439,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading Loading @@ -1465,6 +1470,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading Loading @@ -1497,6 +1503,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading @@ -1523,6 +1530,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @param flags The flags for this key event */ public KeyEvent(long time, String characters, int deviceId, int flags) { mId = nativeNextId(); mDownTime = time; mEventTime = time; mCharacters = characters; Loading @@ -1539,6 +1547,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * Make an exact copy of an existing key event. */ public KeyEvent(KeyEvent origEvent) { mId = origEvent.mId; mDownTime = origEvent.mDownTime; mEventTime = origEvent.mEventTime; mAction = origEvent.mAction; Loading Loading @@ -1567,6 +1576,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ @Deprecated public KeyEvent(KeyEvent origEvent, long eventTime, int newRepeat) { mId = nativeNextId(); // Not an exact copy so assign a new ID. mDownTime = origEvent.mDownTime; mEventTime = eventTime; mAction = origEvent.mAction; Loading Loading @@ -1598,15 +1608,16 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** * Obtains a (potentially recycled) key event. * Obtains a (potentially recycled) key event. Used by native code to create a Java object. * * @hide */ public static KeyEvent obtain(long downTime, long eventTime, int action, public static KeyEvent obtain(int id, long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source, int displayId, @Nullable byte[] hmac, String characters) { KeyEvent ev = obtain(); ev.mId = id; ev.mDownTime = downTime; ev.mEventTime = eventTime; ev.mAction = action; Loading @@ -1623,6 +1634,18 @@ public class KeyEvent extends InputEvent implements Parcelable { return ev; } /** * Obtains a (potentially recycled) key event. * * @hide */ public static KeyEvent obtain(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scanCode, int flags, int source, int displayId, String characters) { return obtain(nativeNextId(), downTime, eventTime, action, code, repeat, metaState, deviceId, scanCode, flags, source, displayId, null /* hmac */, characters); } /** * Obtains a (potentially recycled) key event. * Loading @@ -1633,7 +1656,7 @@ public class KeyEvent extends InputEvent implements Parcelable { int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source, String characters) { return obtain(downTime, eventTime, action, code, repeat, metaState, deviceId, scancode, flags, source, INVALID_DISPLAY, null /* hmac */, characters); flags, source, INVALID_DISPLAY, characters); } /** Loading @@ -1645,6 +1668,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public static KeyEvent obtain(KeyEvent other) { KeyEvent ev = obtain(); ev.mId = other.mId; ev.mDownTime = other.mDownTime; ev.mEventTime = other.mEventTime; ev.mAction = other.mAction; Loading Loading @@ -1695,6 +1719,12 @@ public class KeyEvent extends InputEvent implements Parcelable { // Do nothing. } /** @hide */ @Override public int getId() { return mId; } /** * Create a new key event that is the same as the given one, but whose * event time and repeat count are replaced with the given value. Loading Loading @@ -1723,6 +1753,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public static KeyEvent changeTimeRepeat(KeyEvent event, long eventTime, int newRepeat, int newFlags) { KeyEvent ret = new KeyEvent(event); ret.mId = nativeNextId(); // Not an exact copy so assign a new ID. ret.mEventTime = eventTime; ret.mRepeatCount = newRepeat; ret.mFlags = newFlags; Loading @@ -1736,6 +1767,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @param action The new action code of the event. */ private KeyEvent(KeyEvent origEvent, int action) { mId = nativeNextId(); // Not an exact copy so assign a new ID. mDownTime = origEvent.mDownTime; mEventTime = origEvent.mEventTime; mAction = action; Loading Loading @@ -1772,6 +1804,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public static KeyEvent changeFlags(KeyEvent event, int flags) { event = new KeyEvent(event); event.mId = nativeNextId(); // Not an exact copy so assign a new ID. event.mFlags = flags; return event; } Loading Loading @@ -3095,6 +3128,7 @@ public class KeyEvent extends InputEvent implements Parcelable { } private KeyEvent(Parcel in) { mId = in.readInt(); mDeviceId = in.readInt(); mSource = in.readInt(); mDisplayId = in.readInt(); Loading @@ -3114,6 +3148,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeInt(PARCEL_TOKEN_KEY_EVENT); out.writeInt(mId); out.writeInt(mDeviceId); out.writeInt(mSource); out.writeInt(mDisplayId); Loading core/java/android/view/MotionEvent.java +8 −0 Original line number Diff line number Diff line Loading @@ -1550,6 +1550,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { private static native long nativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory); @CriticalNative private static native int nativeGetId(long nativePtr); @CriticalNative private static native int nativeGetDeviceId(long nativePtr); @CriticalNative private static native int nativeGetSource(long nativePtr); Loading Loading @@ -2024,6 +2026,12 @@ public final class MotionEvent extends InputEvent implements Parcelable { } } /** @hide */ @Override public int getId() { return nativeGetId(mNativePtr); } /** {@inheritDoc} */ @Override public final int getDeviceId() { Loading core/java/android/view/ViewRootImpl.java +6 −4 Original line number Diff line number Diff line Loading @@ -5379,7 +5379,8 @@ public final class ViewRootImpl implements ViewParent, if (mTracePrefix == null) { mTracePrefix = getClass().getSimpleName(); } Trace.traceBegin(traceTag, mTracePrefix + " seq#=" + q.mEvent.getSequenceNumber()); Trace.traceBegin(traceTag, mTracePrefix + " id=0x" + Integer.toHexString(q.mEvent.getId())); } } Loading Loading @@ -7986,12 +7987,13 @@ public final class ViewRootImpl implements ViewParent, private void deliverInputEvent(QueuedInputEvent q) { Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, "deliverInputEvent", q.mEvent.getSequenceNumber()); q.mEvent.getId()); 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() + " seq#=" + q.mEvent.getSequenceNumber()); + q.mEvent.getEventTimeNano() + " id=0x" + Integer.toHexString(q.mEvent.getId())); } try { if (mInputEventConsistencyVerifier != null) { Loading Loading @@ -8032,7 +8034,7 @@ public final class ViewRootImpl implements ViewParent, private void finishInputEvent(QueuedInputEvent q) { Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "deliverInputEvent", q.mEvent.getSequenceNumber()); q.mEvent.getId()); if (q.mReceiver != null) { boolean handled = (q.mFlags & QueuedInputEvent.FLAG_FINISHED_HANDLED) != 0; Loading core/jni/android_view_KeyEvent.cpp +14 −6 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ static struct { jmethodID obtain; jmethodID recycle; jfieldID mId; jfieldID mDeviceId; jfieldID mSource; jfieldID mDisplayId; Loading @@ -96,6 +97,7 @@ jobject android_view_KeyEvent_fromNative(JNIEnv* env, const KeyEvent* event) { ScopedLocalRef<jbyteArray> hmac = toJbyteArray(env, event->getHmac()); jobject eventObj = env->CallStaticObjectMethod(gKeyEventClassInfo.clazz, gKeyEventClassInfo.obtain, event->getId(), nanoseconds_to_milliseconds(event->getDownTime()), nanoseconds_to_milliseconds(event->getEventTime()), event->getAction(), event->getKeyCode(), Loading @@ -114,6 +116,7 @@ jobject android_view_KeyEvent_fromNative(JNIEnv* env, const KeyEvent* event) { status_t android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj, KeyEvent* event) { jint id = env->GetIntField(eventObj, gKeyEventClassInfo.mId); jint deviceId = env->GetIntField(eventObj, gKeyEventClassInfo.mDeviceId); jint source = env->GetIntField(eventObj, gKeyEventClassInfo.mSource); jint displayId = env->GetIntField(eventObj, gKeyEventClassInfo.mDisplayId); Loading @@ -131,7 +134,7 @@ status_t android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj, jlong downTime = env->GetLongField(eventObj, gKeyEventClassInfo.mDownTime); jlong eventTime = env->GetLongField(eventObj, gKeyEventClassInfo.mEventTime); event->initialize(deviceId, source, displayId, *hmac, action, flags, keyCode, scanCode, event->initialize(id, deviceId, source, displayId, *hmac, action, flags, keyCode, scanCode, metaState, repeatCount, milliseconds_to_nanoseconds(downTime), milliseconds_to_nanoseconds(eventTime)); return OK; Loading Loading @@ -159,6 +162,9 @@ static jint android_view_KeyEvent_nativeKeyCodeFromString(JNIEnv* env, jobject c return KeyEvent::getKeyCodeFromLabel(keyLabel.c_str()); } static jint android_view_KeyEvent_nativeNextId() { return static_cast<jint>(InputEvent::nextId()); } // ---------------------------------------------------------------------------- Loading @@ -167,6 +173,7 @@ static const JNINativeMethod g_methods[] = { (void*)android_view_KeyEvent_nativeKeyCodeToString}, {"nativeKeyCodeFromString", "(Ljava/lang/String;)I", (void*)android_view_KeyEvent_nativeKeyCodeFromString}, {"nativeNextId", "()I", (void*)android_view_KeyEvent_nativeNextId}, }; int register_android_view_KeyEvent(JNIEnv* env) { Loading @@ -175,10 +182,11 @@ int register_android_view_KeyEvent(JNIEnv* env) { gKeyEventClassInfo.obtain = GetStaticMethodIDOrDie(env, gKeyEventClassInfo.clazz, "obtain", "(JJIIIIIIIII[BLjava/lang/String;)Landroid/view/KeyEvent;"); "(IJJIIIIIIIII[BLjava/lang/String;)Landroid/view/KeyEvent;"); gKeyEventClassInfo.recycle = GetMethodIDOrDie(env, gKeyEventClassInfo.clazz, "recycle", "()V"); gKeyEventClassInfo.mId = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mId", "I"); gKeyEventClassInfo.mDeviceId = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mDeviceId", "I"); gKeyEventClassInfo.mSource = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mSource", "I"); gKeyEventClassInfo.mDisplayId = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mDisplayId", Loading Loading
core/java/android/view/InputEvent.java +15 −0 Original line number Diff line number Diff line Loading @@ -233,6 +233,21 @@ public abstract class InputEvent implements Parcelable { return mSeq; } /** * Gets the ID of this event. This is generated when an event is created and preserved until its * last stage. It won't change just because the event crosses process boundary, but should * change when making a copy with modifications. * <p> * To avoid exposing app usage to other processes this ID is generated from a CSPRNG. Therefore * there isn't 100% guarantee on the uniqueness of this ID, though the chance of ID collisions * is considerably low. The rule of thumb is not to rely on the uniqueness for production logic, * but a good source for tracking an event (e.g. logging and profiling). * * @return The ID of this event. * @hide */ public abstract int getId(); public int describeContents() { return 0; } Loading
core/java/android/view/KeyEvent.java +40 −5 Original line number Diff line number Diff line Loading @@ -1265,6 +1265,7 @@ public class KeyEvent extends InputEvent implements Parcelable { private KeyEvent mNext; private int mId; @UnsupportedAppUsage private int mDeviceId; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) Loading Loading @@ -1350,9 +1351,9 @@ public class KeyEvent extends InputEvent implements Parcelable { private static native String nativeKeyCodeToString(int keyCode); private static native int nativeKeyCodeFromString(String keyCode); private static native int nativeNextId(); private KeyEvent() { } private KeyEvent() {} /** * Create a new key event. Loading @@ -1362,6 +1363,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @param code The key code. */ public KeyEvent(int action, int code) { mId = nativeNextId(); mAction = action; mKeyCode = code; mRepeatCount = 0; Loading @@ -1383,6 +1385,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public KeyEvent(long downTime, long eventTime, int action, int code, int repeat) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading @@ -1407,6 +1410,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading Loading @@ -1435,6 +1439,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading Loading @@ -1465,6 +1470,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading Loading @@ -1497,6 +1503,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source) { mId = nativeNextId(); mDownTime = downTime; mEventTime = eventTime; mAction = action; Loading @@ -1523,6 +1530,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @param flags The flags for this key event */ public KeyEvent(long time, String characters, int deviceId, int flags) { mId = nativeNextId(); mDownTime = time; mEventTime = time; mCharacters = characters; Loading @@ -1539,6 +1547,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * Make an exact copy of an existing key event. */ public KeyEvent(KeyEvent origEvent) { mId = origEvent.mId; mDownTime = origEvent.mDownTime; mEventTime = origEvent.mEventTime; mAction = origEvent.mAction; Loading Loading @@ -1567,6 +1576,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ @Deprecated public KeyEvent(KeyEvent origEvent, long eventTime, int newRepeat) { mId = nativeNextId(); // Not an exact copy so assign a new ID. mDownTime = origEvent.mDownTime; mEventTime = eventTime; mAction = origEvent.mAction; Loading Loading @@ -1598,15 +1608,16 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** * Obtains a (potentially recycled) key event. * Obtains a (potentially recycled) key event. Used by native code to create a Java object. * * @hide */ public static KeyEvent obtain(long downTime, long eventTime, int action, public static KeyEvent obtain(int id, long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source, int displayId, @Nullable byte[] hmac, String characters) { KeyEvent ev = obtain(); ev.mId = id; ev.mDownTime = downTime; ev.mEventTime = eventTime; ev.mAction = action; Loading @@ -1623,6 +1634,18 @@ public class KeyEvent extends InputEvent implements Parcelable { return ev; } /** * Obtains a (potentially recycled) key event. * * @hide */ public static KeyEvent obtain(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scanCode, int flags, int source, int displayId, String characters) { return obtain(nativeNextId(), downTime, eventTime, action, code, repeat, metaState, deviceId, scanCode, flags, source, displayId, null /* hmac */, characters); } /** * Obtains a (potentially recycled) key event. * Loading @@ -1633,7 +1656,7 @@ public class KeyEvent extends InputEvent implements Parcelable { int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source, String characters) { return obtain(downTime, eventTime, action, code, repeat, metaState, deviceId, scancode, flags, source, INVALID_DISPLAY, null /* hmac */, characters); flags, source, INVALID_DISPLAY, characters); } /** Loading @@ -1645,6 +1668,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public static KeyEvent obtain(KeyEvent other) { KeyEvent ev = obtain(); ev.mId = other.mId; ev.mDownTime = other.mDownTime; ev.mEventTime = other.mEventTime; ev.mAction = other.mAction; Loading Loading @@ -1695,6 +1719,12 @@ public class KeyEvent extends InputEvent implements Parcelable { // Do nothing. } /** @hide */ @Override public int getId() { return mId; } /** * Create a new key event that is the same as the given one, but whose * event time and repeat count are replaced with the given value. Loading Loading @@ -1723,6 +1753,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public static KeyEvent changeTimeRepeat(KeyEvent event, long eventTime, int newRepeat, int newFlags) { KeyEvent ret = new KeyEvent(event); ret.mId = nativeNextId(); // Not an exact copy so assign a new ID. ret.mEventTime = eventTime; ret.mRepeatCount = newRepeat; ret.mFlags = newFlags; Loading @@ -1736,6 +1767,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * @param action The new action code of the event. */ private KeyEvent(KeyEvent origEvent, int action) { mId = nativeNextId(); // Not an exact copy so assign a new ID. mDownTime = origEvent.mDownTime; mEventTime = origEvent.mEventTime; mAction = action; Loading Loading @@ -1772,6 +1804,7 @@ public class KeyEvent extends InputEvent implements Parcelable { */ public static KeyEvent changeFlags(KeyEvent event, int flags) { event = new KeyEvent(event); event.mId = nativeNextId(); // Not an exact copy so assign a new ID. event.mFlags = flags; return event; } Loading Loading @@ -3095,6 +3128,7 @@ public class KeyEvent extends InputEvent implements Parcelable { } private KeyEvent(Parcel in) { mId = in.readInt(); mDeviceId = in.readInt(); mSource = in.readInt(); mDisplayId = in.readInt(); Loading @@ -3114,6 +3148,7 @@ public class KeyEvent extends InputEvent implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeInt(PARCEL_TOKEN_KEY_EVENT); out.writeInt(mId); out.writeInt(mDeviceId); out.writeInt(mSource); out.writeInt(mDisplayId); Loading
core/java/android/view/MotionEvent.java +8 −0 Original line number Diff line number Diff line Loading @@ -1550,6 +1550,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { private static native long nativeCopy(long destNativePtr, long sourceNativePtr, boolean keepHistory); @CriticalNative private static native int nativeGetId(long nativePtr); @CriticalNative private static native int nativeGetDeviceId(long nativePtr); @CriticalNative private static native int nativeGetSource(long nativePtr); Loading Loading @@ -2024,6 +2026,12 @@ public final class MotionEvent extends InputEvent implements Parcelable { } } /** @hide */ @Override public int getId() { return nativeGetId(mNativePtr); } /** {@inheritDoc} */ @Override public final int getDeviceId() { Loading
core/java/android/view/ViewRootImpl.java +6 −4 Original line number Diff line number Diff line Loading @@ -5379,7 +5379,8 @@ public final class ViewRootImpl implements ViewParent, if (mTracePrefix == null) { mTracePrefix = getClass().getSimpleName(); } Trace.traceBegin(traceTag, mTracePrefix + " seq#=" + q.mEvent.getSequenceNumber()); Trace.traceBegin(traceTag, mTracePrefix + " id=0x" + Integer.toHexString(q.mEvent.getId())); } } Loading Loading @@ -7986,12 +7987,13 @@ public final class ViewRootImpl implements ViewParent, private void deliverInputEvent(QueuedInputEvent q) { Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, "deliverInputEvent", q.mEvent.getSequenceNumber()); q.mEvent.getId()); 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() + " seq#=" + q.mEvent.getSequenceNumber()); + q.mEvent.getEventTimeNano() + " id=0x" + Integer.toHexString(q.mEvent.getId())); } try { if (mInputEventConsistencyVerifier != null) { Loading Loading @@ -8032,7 +8034,7 @@ public final class ViewRootImpl implements ViewParent, private void finishInputEvent(QueuedInputEvent q) { Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "deliverInputEvent", q.mEvent.getSequenceNumber()); q.mEvent.getId()); if (q.mReceiver != null) { boolean handled = (q.mFlags & QueuedInputEvent.FLAG_FINISHED_HANDLED) != 0; Loading
core/jni/android_view_KeyEvent.cpp +14 −6 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ static struct { jmethodID obtain; jmethodID recycle; jfieldID mId; jfieldID mDeviceId; jfieldID mSource; jfieldID mDisplayId; Loading @@ -96,6 +97,7 @@ jobject android_view_KeyEvent_fromNative(JNIEnv* env, const KeyEvent* event) { ScopedLocalRef<jbyteArray> hmac = toJbyteArray(env, event->getHmac()); jobject eventObj = env->CallStaticObjectMethod(gKeyEventClassInfo.clazz, gKeyEventClassInfo.obtain, event->getId(), nanoseconds_to_milliseconds(event->getDownTime()), nanoseconds_to_milliseconds(event->getEventTime()), event->getAction(), event->getKeyCode(), Loading @@ -114,6 +116,7 @@ jobject android_view_KeyEvent_fromNative(JNIEnv* env, const KeyEvent* event) { status_t android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj, KeyEvent* event) { jint id = env->GetIntField(eventObj, gKeyEventClassInfo.mId); jint deviceId = env->GetIntField(eventObj, gKeyEventClassInfo.mDeviceId); jint source = env->GetIntField(eventObj, gKeyEventClassInfo.mSource); jint displayId = env->GetIntField(eventObj, gKeyEventClassInfo.mDisplayId); Loading @@ -131,7 +134,7 @@ status_t android_view_KeyEvent_toNative(JNIEnv* env, jobject eventObj, jlong downTime = env->GetLongField(eventObj, gKeyEventClassInfo.mDownTime); jlong eventTime = env->GetLongField(eventObj, gKeyEventClassInfo.mEventTime); event->initialize(deviceId, source, displayId, *hmac, action, flags, keyCode, scanCode, event->initialize(id, deviceId, source, displayId, *hmac, action, flags, keyCode, scanCode, metaState, repeatCount, milliseconds_to_nanoseconds(downTime), milliseconds_to_nanoseconds(eventTime)); return OK; Loading Loading @@ -159,6 +162,9 @@ static jint android_view_KeyEvent_nativeKeyCodeFromString(JNIEnv* env, jobject c return KeyEvent::getKeyCodeFromLabel(keyLabel.c_str()); } static jint android_view_KeyEvent_nativeNextId() { return static_cast<jint>(InputEvent::nextId()); } // ---------------------------------------------------------------------------- Loading @@ -167,6 +173,7 @@ static const JNINativeMethod g_methods[] = { (void*)android_view_KeyEvent_nativeKeyCodeToString}, {"nativeKeyCodeFromString", "(Ljava/lang/String;)I", (void*)android_view_KeyEvent_nativeKeyCodeFromString}, {"nativeNextId", "()I", (void*)android_view_KeyEvent_nativeNextId}, }; int register_android_view_KeyEvent(JNIEnv* env) { Loading @@ -175,10 +182,11 @@ int register_android_view_KeyEvent(JNIEnv* env) { gKeyEventClassInfo.obtain = GetStaticMethodIDOrDie(env, gKeyEventClassInfo.clazz, "obtain", "(JJIIIIIIIII[BLjava/lang/String;)Landroid/view/KeyEvent;"); "(IJJIIIIIIIII[BLjava/lang/String;)Landroid/view/KeyEvent;"); gKeyEventClassInfo.recycle = GetMethodIDOrDie(env, gKeyEventClassInfo.clazz, "recycle", "()V"); gKeyEventClassInfo.mId = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mId", "I"); gKeyEventClassInfo.mDeviceId = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mDeviceId", "I"); gKeyEventClassInfo.mSource = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mSource", "I"); gKeyEventClassInfo.mDisplayId = GetFieldIDOrDie(env, gKeyEventClassInfo.clazz, "mDisplayId", Loading