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

Commit 3acb0152 authored by Ytai Ben-tsvi's avatar Ytai Ben-tsvi Committed by Automerger Merge Worker
Browse files

Merge "Fix deadlock between APS and sound trigger middleware" into rvc-dev am: bb2f50e7

Change-Id: Ia5f294b3ed86421f8ae4ac07c2c9b0f28dd2a206
parents 3bf75714 bb2f50e7
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;

/**
 * This is a decorator of an {@link ISoundTriggerMiddlewareService}, which enforces permissions and
@@ -123,7 +124,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
        }
    }

    private Boolean mCaptureState;
    private AtomicReference<Boolean> mCaptureState = new AtomicReference<>();

    private final @NonNull ISoundTriggerMiddlewareInternal mDelegate;
    private final @NonNull Context mContext;
@@ -230,10 +231,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
        } catch (Exception e) {
            throw handleException(e);
        } finally {
            // It is safe to lock here - local operation.
            synchronized (this) {
                mCaptureState = active;
            }
            mCaptureState.set(active);
        }
    }

@@ -286,8 +284,9 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
    @Override
    public void dump(PrintWriter pw) {
        synchronized (this) {
            pw.printf("Capture state is %s\n\n", mCaptureState == null ? "uninitialized"
                    : (mCaptureState ? "active" : "inactive"));
            Boolean captureState = mCaptureState.get();
            pw.printf("Capture state is %s\n\n", captureState == null ? "uninitialized"
                    : (captureState ? "active" : "inactive"));
            if (mModules != null) {
                for (int handle : mModules.keySet()) {
                    final ModuleState module = mModules.get(handle);