Loading core/java/android/view/InputEvent.java +15 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,21 @@ public abstract class InputEvent implements Parcelable { } } /** * Conditionally recycled the event if it is appropriate to do so after * dispatching the event to an application. * * If the event is a {@link MotionEvent} then it is recycled. * * If the event is a {@link KeyEvent} then it is NOT recycled, because applications * expect key events to be immutable so once the event has been dispatched to * the application we can no longer recycle it. * @hide */ public void recycleIfNeededAfterDispatch() { recycle(); } /** * Reinitializes the event on reuse (after recycling). * @hide Loading core/java/android/view/InputEventReceiver.java +1 −11 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ public abstract class InputEventReceiver { nativeFinishInputEvent(mReceiverPtr, handled); } } recycleInputEvent(event); event.recycleIfNeededAfterDispatch(); } // Called from native code. Loading @@ -134,16 +134,6 @@ public abstract class InputEventReceiver { onInputEvent(event); } private static void recycleInputEvent(InputEvent event) { if (event instanceof MotionEvent) { // Event though key events are also recyclable, we only recycle motion events. // Historically, key events were not recyclable and applications expect // them to be immutable. We only ever recycle key events behind the // scenes where an application never sees them (so, not here). event.recycle(); } } public static interface Factory { public InputEventReceiver createInputEventReceiver( InputChannel inputChannel, Looper looper); Loading core/java/android/view/KeyEvent.java +7 −0 Original line number Diff line number Diff line Loading @@ -1596,6 +1596,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * * @hide */ @Override public final void recycle() { super.recycle(); mCharacters = null; Loading @@ -1609,6 +1610,12 @@ public class KeyEvent extends InputEvent implements Parcelable { } } /** @hide */ @Override public final void recycleIfNeededAfterDispatch() { // Do nothing. } /** * 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 core/java/android/view/MotionEvent.java +1 −0 Original line number Diff line number Diff line Loading @@ -1642,6 +1642,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { * Recycle the MotionEvent, to be re-used by a later caller. After calling * this function you must not ever touch the event again. */ @Override public final void recycle() { super.recycle(); Loading core/java/android/view/ViewRootImpl.java +2 −6 Original line number Diff line number Diff line Loading @@ -3848,12 +3848,8 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (q.mReceiver != null) { q.mReceiver.finishInputEvent(q.mEvent, handled); } else if (q.mEvent instanceof MotionEvent) { // Event though key events are also recyclable, we only recycle motion events. // Historically, key events were not recyclable and applications expect // them to be immutable. We only ever recycle key events behind the // scenes where an application never sees them (so, not here). q.mEvent.recycle(); } else { q.mEvent.recycleIfNeededAfterDispatch(); } recycleQueuedInputEvent(q); Loading Loading
core/java/android/view/InputEvent.java +15 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,21 @@ public abstract class InputEvent implements Parcelable { } } /** * Conditionally recycled the event if it is appropriate to do so after * dispatching the event to an application. * * If the event is a {@link MotionEvent} then it is recycled. * * If the event is a {@link KeyEvent} then it is NOT recycled, because applications * expect key events to be immutable so once the event has been dispatched to * the application we can no longer recycle it. * @hide */ public void recycleIfNeededAfterDispatch() { recycle(); } /** * Reinitializes the event on reuse (after recycling). * @hide Loading
core/java/android/view/InputEventReceiver.java +1 −11 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ public abstract class InputEventReceiver { nativeFinishInputEvent(mReceiverPtr, handled); } } recycleInputEvent(event); event.recycleIfNeededAfterDispatch(); } // Called from native code. Loading @@ -134,16 +134,6 @@ public abstract class InputEventReceiver { onInputEvent(event); } private static void recycleInputEvent(InputEvent event) { if (event instanceof MotionEvent) { // Event though key events are also recyclable, we only recycle motion events. // Historically, key events were not recyclable and applications expect // them to be immutable. We only ever recycle key events behind the // scenes where an application never sees them (so, not here). event.recycle(); } } public static interface Factory { public InputEventReceiver createInputEventReceiver( InputChannel inputChannel, Looper looper); Loading
core/java/android/view/KeyEvent.java +7 −0 Original line number Diff line number Diff line Loading @@ -1596,6 +1596,7 @@ public class KeyEvent extends InputEvent implements Parcelable { * * @hide */ @Override public final void recycle() { super.recycle(); mCharacters = null; Loading @@ -1609,6 +1610,12 @@ public class KeyEvent extends InputEvent implements Parcelable { } } /** @hide */ @Override public final void recycleIfNeededAfterDispatch() { // Do nothing. } /** * 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
core/java/android/view/MotionEvent.java +1 −0 Original line number Diff line number Diff line Loading @@ -1642,6 +1642,7 @@ public final class MotionEvent extends InputEvent implements Parcelable { * Recycle the MotionEvent, to be re-used by a later caller. After calling * this function you must not ever touch the event again. */ @Override public final void recycle() { super.recycle(); Loading
core/java/android/view/ViewRootImpl.java +2 −6 Original line number Diff line number Diff line Loading @@ -3848,12 +3848,8 @@ public final class ViewRootImpl extends Handler implements ViewParent, if (q.mReceiver != null) { q.mReceiver.finishInputEvent(q.mEvent, handled); } else if (q.mEvent instanceof MotionEvent) { // Event though key events are also recyclable, we only recycle motion events. // Historically, key events were not recyclable and applications expect // them to be immutable. We only ever recycle key events behind the // scenes where an application never sees them (so, not here). q.mEvent.recycle(); } else { q.mEvent.recycleIfNeededAfterDispatch(); } recycleQueuedInputEvent(q); Loading