Fix bug in KeyButtonView key injection logic.
Bug: 5299191
Bug: 5300282

Only send keys when mCode != 0.

Simplified the logic for repeating / non-repeating keys.
Key down / up are always correlated with touch down / up, the
only thing that's special is that we detect long press for
repeating keys and not for others.

Ensure that up or cancel is always sent for every key
that is generated.  Previously it was possible for keys to get
stuck down if touch moved out of the button's active area.

Removed the funky HOME long press timer.  We don't need it
since we can rely on the long-press flag instead.  Since the
system UI is in direct control of key repeating and long-press
behavior for the keys it inject, this eliminates the need for
special hacks to circumvent the timer.

Ensure that the same haptic feedback is provided for all keys,
including the recent apps key.  Previously this only worked
because the code was injecting a bogus key with code 0.

Don't generate repeated haptic feedback for virtual keys
even when those keys are injected.  This doesn't happen
for virtual keys synthesized by the InputReader because it
never injects repeats itself (the InputDispatcher synthesizes
them), but it is an issue for the KeyButtonView.

Change-Id: I8b3615dde738af28e76898d161d6ce9a883b59ec
2 files changed