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

Commit 20466969 authored by Fengjiang Li's avatar Fengjiang Li
Browse files

Let DecorView call addCrossWindowBlurEnabledListener() with HandlerExecutor if...

Let DecorView call addCrossWindowBlurEnabledListener() with HandlerExecutor if DecorView is rendered on separate UI thread

Follow up of ag/13603505

Note that the thread on which the DecorView is added to the WindowManager determines the actual UI thread for this window and DecorView.

Fix: 362982490
Flag: NONE - not gated
Test: presubmit
Change-Id: I2ba27e9e081deb0a4e63967ec9cebe160e9666e9
parent d84495f8
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair;
@@ -114,6 +117,7 @@ import com.android.internal.widget.floatingtoolbar.FloatingToolbar;
import com.android.window.flags.Flags;

import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/** @hide */
@@ -1348,8 +1352,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                    mCrossWindowBlurEnabled = enabled;
                    updateBackgroundBlurRadius();
                };
                // The executor to receive callback {@link mCrossWindowBlurEnabledListener}. It
                // should be the executor for this {@link DecorView}'s ui thread (not necessarily
                // the main thread).
                final Executor executor = Looper.myLooper() == Looper.getMainLooper()
                        ? getContext().getMainExecutor()
                        : new HandlerExecutor(new Handler(Looper.myLooper()));
                getContext().getSystemService(WindowManager.class)
                        .addCrossWindowBlurEnabledListener(mCrossWindowBlurEnabledListener);
                        .addCrossWindowBlurEnabledListener(
                                executor, mCrossWindowBlurEnabledListener);
                getViewTreeObserver().addOnPreDrawListener(mBackgroundBlurOnPreDrawListener);
            } else {
                updateBackgroundBlurRadius();