Fix synchronization for BlurController.mBlurEnabled

Bug: 177523043
Test: atest BlurTests
Change-Id: Ia730c29aa94e7fcbe09c640e891d6e03bda224d6
This commit is contained in:
Galia Peycheva
2021-04-19 13:50:14 +02:00
parent 85bb3e4da0
commit 460ce763eb
4 changed files with 10 additions and 10 deletions

View File

@@ -30,8 +30,6 @@ import android.os.RemoteException;
import android.provider.Settings;
import android.view.ICrossWindowBlurEnabledListener;
import com.android.internal.annotations.GuardedBy;
/**
* Keeps track of the different factors that determine whether cross-window blur is enabled
* or disabled. Also keeps a list of all interested listeners and notifies them when the
@@ -44,8 +42,7 @@ final class BlurController {
// We don't use the WM global lock, because the BlurController is not involved in window
// drawing and only receives binder calls that don't need synchronization with the rest of WM
private final Object mLock = new Object();
@GuardedBy("mLock")
boolean mBlurEnabled;
private volatile boolean mBlurEnabled;
private boolean mInPowerSaveMode;
private boolean mBlurDisabledSetting;
@@ -87,9 +84,7 @@ final class BlurController {
boolean registerCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener) {
if (listener == null) return false;
mBlurEnabledListeners.register(listener);
synchronized (mLock) {
return mBlurEnabled;
}
return getBlurEnabled();
}
void unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener) {
@@ -97,6 +92,10 @@ final class BlurController {
mBlurEnabledListeners.unregister(listener);
}
boolean getBlurEnabled() {
return mBlurEnabled;
}
private void updateBlurEnabled() {
synchronized (mLock) {
final boolean newEnabled = CROSS_WINDOW_BLUR_SUPPORTED && !mBlurDisabledSetting

View File

@@ -6280,7 +6280,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
});
pw.print(" mInTouchMode="); pw.println(mInTouchMode);
pw.print(" mBlurEnabled="); pw.println(mBlurController.mBlurEnabled);
pw.print(" mBlurEnabled="); pw.println(mBlurController.getBlurEnabled());
pw.print(" mLastDisplayFreezeDuration=");
TimeUtils.formatDuration(mLastDisplayFreezeDuration, pw);
if ( mLastFinishedFreezeSource != null) {

View File

@@ -217,7 +217,7 @@ public class WindowManagerShellCommand extends ShellCommand {
String arg = getNextArg();
if (arg == null) {
pw.println("Blur supported on device: " + CROSS_WINDOW_BLUR_SUPPORTED);
pw.println("Blur enabled: " + mInternal.mBlurController.mBlurEnabled);
pw.println("Blur enabled: " + mInternal.mBlurController.getBlurEnabled());
return 0;
}

View File

@@ -5344,7 +5344,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
private boolean shouldDrawBlurBehind() {
return (mAttrs.flags & FLAG_BLUR_BEHIND) != 0 && mWmService.mBlurController.mBlurEnabled;
return (mAttrs.flags & FLAG_BLUR_BEHIND) != 0
&& mWmService.mBlurController.getBlurEnabled();
}
/**