Add busy wait for consume() call

We have no guarantee that consume() will find an available event right
away.
If we send an event to InputDispatcher, it may take some time for
dispatcher to process the event. Only when the event is processed can we
expect that it will be written to the socket.

In the test, we currently allow no time for this to complete. For the
upcoming tests, the work performed by dispatcher might be too large, so
the tests would start to fail.

If there is no event available at the socket, WOULD_BLOCK would be
returned. So if we are sure an event is coming, we can busily wait, as
long as the consume call is returning WOULD_BLOCK.

Bug: none
Test: atest inputflinger_tests
The change was tested with a child CL for notifyDeviceReset.

Change-Id: Ib9557c4de03c1b1d4a4eb1573d527f47facbf249
1 file changed