Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1bf8122 authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi
Browse files

Fix deadlock between audio policy manager and sound trigger m/w

Audio policy manager and sound trigger middleware services both call
into each other and each has global locks, which may result in a
deadlock. We previously made sure that calls from sound trigger into
APM are done outside of the lock, but have missed a lock in one of
the decorators, namely SoundTriggerMiddlewareValidation.

Bug: 150843018
Test: Manual verification
Change-Id: I53dfd15e137a5137d664e75e5451c444ab848489
parent 5688bc3e
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -203,9 +203,13 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
        checkPreemptPermissions();
        // Input validation (always valid).

        synchronized (this) {
        // State validation (always valid).

        // Normally, we would acquire a lock here. However, we do not access any state here so it
        // is safe to not lock. This call is typically done from a different context than all the
        // other calls and may result in a deadlock if we lock here (between the audio server and
        // the system server).

        // From here on, every exception isn't client's fault.
        try {
            mDelegate.setExternalCaptureState(active);
@@ -213,7 +217,6 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
            throw handleException(e);
        }
    }
    }

    // Override toString() in order to have the delegate's ID in it.
    @Override