Don't crash if a drag recipient throws an uncaught exception

There turn out to be two distinct bugs leading to runtime restarts.

The first, dating from at least Android 3.1, is that following certain kinds
of app crashes we properly clean up the drag-state bookkeeping, but aren't
prepared in the case of the drag-target timeout clock firing with a now-
null drag state in effect.  We now catch that edge condition and don't NPE
(and note that there was already similar code around the separate timeout
when an app is *starting* the drag process).

The second bug is that some new-in-ICS code in the input channel management
wasn't prepared for certain cases where the current touch window could have
become unusable and its input channel torn down summarily in the case of the
aforesaid app crash during drag.  The code now makes sure that there really
is an input channel that needs to be flushed / cancelled prior to attempting
that operation.

Fixes bug 5173534

Change-Id: Idaae158ecfb4b93456ab1425769b669962893c00
2 files changed