Merge "Fix deadlock between APS and sound trigger middleware" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bb2f50e768
@@ -47,6 +47,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a decorator of an {@link ISoundTriggerMiddlewareService}, which enforces permissions and
|
* 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 ISoundTriggerMiddlewareInternal mDelegate;
|
||||||
private final @NonNull Context mContext;
|
private final @NonNull Context mContext;
|
||||||
@@ -230,10 +231,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
} finally {
|
} finally {
|
||||||
// It is safe to lock here - local operation.
|
mCaptureState.set(active);
|
||||||
synchronized (this) {
|
|
||||||
mCaptureState = active;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,8 +284,9 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
|||||||
@Override
|
@Override
|
||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
pw.printf("Capture state is %s\n\n", mCaptureState == null ? "uninitialized"
|
Boolean captureState = mCaptureState.get();
|
||||||
: (mCaptureState ? "active" : "inactive"));
|
pw.printf("Capture state is %s\n\n", captureState == null ? "uninitialized"
|
||||||
|
: (captureState ? "active" : "inactive"));
|
||||||
if (mModules != null) {
|
if (mModules != null) {
|
||||||
for (int handle : mModules.keySet()) {
|
for (int handle : mModules.keySet()) {
|
||||||
final ModuleState module = mModules.get(handle);
|
final ModuleState module = mModules.get(handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user