Fix for UiDevice press button operations wait for idle

This cl#299334 attempted to address a missing wait for idle
on the UiDevice main pressXXX operation since issues related to
reliability were surfacing. These are pressHome, pressBack
and pressMenu. In error, I added the waitForIdle after and
not before the operation where it should've been in the first place.

Operations should never count on other operations to guarantee
waitForIdle for them. Each operation should ensure its own device
idle before performing any action. The existing implementation
unfortunately didn't improve the reliability and issues remained.

This fix should put these pressXXX commands inline with all the
UiAutomator APIs where everything  performs a waitForIdle _before_
performing any action.

Change-Id: I76d7ec50fb822d41a0be4808a0d3e61bdde17935
1 file changed