Fix issues catching up to touch events after a short pause.

When the app spends more than half a second responding to a touch
event, the input dispatch eventually decides to stop sending it
events until it catches up.  (This is when the ANR clock starts.)
However, due to a bug in the timing logic, if the app eventually
does respond again we would resume delivery but only send one
event at a time until the queue was completely drained again.
This meant it could take a long time to catch up and process all
events.

The problem is that we were comparing the current time with the
waiting event time.  So when events became older than half a second,
we would simply stop streaming and end up serialized.

This change fixes the timing logic such that the streaming timeout
is based on the delivery time of the waiting event rather than
the event time itself.  Now we only stop streaming when it has
been over half a second since the waiting event was delivered
so we resume streaming immediately as soon as some waiting
events are handled.

Bug: 11278743
Change-Id: Ic8c68ee372a07f7caa4168eefcabf9b8a8ad5d87
1 file changed