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

Commit 460ce763 authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Fix synchronization for BlurController.mBlurEnabled

Bug: 177523043
Test: atest BlurTests
Change-Id: Ia730c29aa94e7fcbe09c640e891d6e03bda224d6
parent 85bb3e4d
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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;
        }

+2 −1
Original line number Diff line number Diff line
@@ -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();
    }

    /**