Wait for KEY_SLEEP UP event before calling goToSleep()

Calling goToSleep() on the KEY_SLEEP DOWN event causes a race
condition with the touch driver when the KEY_SLEEP event is generated
via a palm press if the touch controller is told to go into
AMBIENT_ON mode (touch controller goes into suspend mode) while the
user's palm is still on the touch panel.  If touch controller gets
into suspend mode before user removes their palm, the act of removing
the palm from the screen will cause the touch controller to generate a
wake event and the device will "wake back up" into interactive mode.

Waiting for the KEY_SLEEP UP event before putting the device to sleep
assures palm is off the panel and thus removes this race case.

Bug: 19951365
Change-Id: Id4e3313caa264f43e37994ed37015de87b8ff662
1 file changed