Prevent events from getting backlogged.

This change implements two heuristics.

1. When events are older than 10 seconds, they are dropped.

2. If the application is currently busy processing an event and
   the user touches a window belonging to a different application
   then we drop the currently queued events so the other application
   can start processing the gesture immediately.

Note that the system takes care of synthesizing cancelation events
automatically for any events that it drops.

Added some new handle types to allow the native dispatcher to
indirectly refer to the WindowManager's window state and app window
token.  This was done to enable the dispatcher to identify the
application to which each window belongs but it also eliminates
some lookup tables and linear searches through the window list
on each key press.

Bug: 3224911
Change-Id: I9dae8dfe23d195d76865f97011fe2f1d351e2940
25 files changed