diff options
| author | 2024-10-20 22:42:30 -0700 | |
|---|---|---|
| committer | 2024-10-20 22:50:21 -0700 | |
| commit | 1d48c4478695ff964dcda9a7121f624e02586be4 (patch) | |
| tree | e89a3f5f5c811a8fdc85e175aa529e2c60ee1229 | |
| parent | f6002bc0c0e5df8302fd695fc4c65f84434b3551 (diff) | |
Make soundtrigger onResourcesAvailable async
This callback is a synchronous call from the STHAL. To prevent a triple
deadlock between the audioserver, system_server, and the hal, this
call should be async instead of sync.
Going async doesn't impact correctness, since this call is informative
rather than state-mutating, and the HAL is not sequencing on this call.
Receiving this callback delayed will be dropped in cases where it is
not relevant, since the response to the callback is to retry falliable
operations.
Fixes: 360057457
Test: Hotword
Flag: EXEMPT safe
Change-Id: I417effd9abe396429b80941d944e07289986996d
| -rw-r--r-- | services/voiceinteraction/java/com/android/server/soundtrigger_middleware/SoundTriggerHw3Compat.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/SoundTriggerHw3Compat.java b/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/SoundTriggerHw3Compat.java index b1165bb57628..dfd80a00544d 100644 --- a/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/SoundTriggerHw3Compat.java +++ b/services/voiceinteraction/java/com/android/server/soundtrigger_middleware/SoundTriggerHw3Compat.java @@ -36,6 +36,8 @@ import android.os.RemoteException; import android.os.ServiceSpecificException; import android.os.SystemClock; +import com.android.server.FgThread; + public class SoundTriggerHw3Compat implements ISoundTriggerHal { private final @NonNull ISoundTriggerHw mDriver; private final @NonNull Runnable mRebootRunnable; @@ -217,7 +219,12 @@ public class SoundTriggerHw3Compat implements ISoundTriggerHal { @Override public void onResourcesAvailable() { - mDelegate.onResourcesAvailable(); + // This call does not need to be sequenced relative to sessions on the upper levels. + // That is, if a new session gets this callback or if a already detached session gets + // this callback, because it is delayed, it doesn't matter, since this callback is + // purely informative and does not mutate any state -- it merely causes an already legal + // operation to be possibly re-attempted. + FgThread.getExecutor().execute(mDelegate::onResourcesAvailable); } @Override |