Better fix for race condition in SoundTriggerHw2Enforcer

This reverts commit 139f7c23898bff49ea6eb9a1f6cdb7e43d28d8ac.

That commit had a potential for a deadlock, since calls both to and
from the HAL are synchronized and because of the requirement that
events are not permitted after stop() has been called, the HAL implementation
must block stop() for any outstanding events, but those events might
be blocked during the callback.

This fix avoids the original issue addressed by that commit in a
different manner: it simply reversed the ordering of setting the model
state and invoking start(), so that if an event arrives before start()
returns, we would still consider it valid.

Fixes: 177795410
Test: Manual verification of STHAL operation.
      Sent patch to bug reporter to apply and test.
Change-Id: I5b08158eaed8e4bba9f77249b7d5e5b73c33a744
(cherry picked from commit 9efec8111bdd68ef8bc3ed4053ac1c4b69192a9b)
1 file changed