Avoid deadlock between recognition events and SoundTriggerHwService.

If an event is generated from the HAL on a separate thread, it is
possible to enter a deadlocked state. This is due to the HAL typically
holding a lock when it starts the callback, which then needed to grab
the SoundTriggerHwService's main lock. However, if there was another
call coming down from somewhere else in the framework, it typically
tries to grab the service's main lock, then enter the HAL (which also
will likely try to grab a lock).

By removing the need to grab the mServiceLock on any of the paths that
respond to events generated by the HAL, this deadlock can be avoided.

Test: Manually on device.
Change-Id: Iac5f96ea67f618ce70e7f75300165f3588613947
2 files changed