Fix a race condition where the wait index can be incremented inbetween
the while() loop and the lock
Fix when updateOrientation() is called: after the sleep, otherwise
the last sleep is useless.
Bug 24677424
Change-Id: I03770a0fc8af57f4696ebee7e9c9110e17c55a24