Fix race condition in SoundTriggerHw2Enforcer

Since HIDL doesn't guarantee message ordering between sync calls into
the HAL and async calls coming from the HAL, we have a rare
possibility of a race condition if a detection event callback arrives
before the startRecognition call returns. This change addresses that.
We do so by holding the lock during the calls into the HAL. We do NOT
hold the lock during the the "upward" calls to avoid deadlocks.

Fixes: 177795410
Test: Manual verification of STHAL operation.
      Sent patch to bug reporter to apply and test.
Change-Id: Ie042a92afa998d6d78786942146e3c533c401cd5
1 file changed