From 937eff0e76a849f4320ae077982e8b9cdd84a02c Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Fri, 27 Aug 2021 18:10:41 +0000 Subject: [PATCH] Dispatch blur radius for BACKGROUND_APP state When entering BACKGROUND_APP, it's possible that the blur radius will be lost. We need to dispatch it on the first possible frame, otherwise Overview won't have blurs. Fixes: 196828055 Test: enter overview multiple times Test: pull up all apps Test: open app from home or all apps Change-Id: I5920e1b28e2d23421863ecd59845e902040d126c --- .../launcher3/statehandlers/DepthController.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 68159fafdd..8ae5b4356a 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -96,7 +96,11 @@ public class DepthController implements StateHandler, public void onDraw() { View view = mLauncher.getDragLayer(); ViewRootImpl viewRootImpl = view.getViewRootImpl(); - setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null); + boolean applied = setSurface( + viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null); + if (!applied) { + dispatchTransactionSurface(mDepth); + } view.post(() -> view.getViewTreeObserver().removeOnDrawListener(this)); } }; @@ -202,20 +206,22 @@ public class DepthController implements StateHandler, /** * Sets the specified app target surface to apply the blur to. + * @return true when surface was valid and transaction was dispatched. */ - public void setSurface(SurfaceControl surface) { + public boolean setSurface(SurfaceControl surface) { // Set launcher as the SurfaceControl when we don't need an external target anymore. if (surface == null) { ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl(); surface = viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null; } - if (mSurface != surface) { mSurface = surface; if (surface != null) { dispatchTransactionSurface(mDepth); + return true; } } + return false; } @Override @@ -229,6 +235,8 @@ public class DepthController implements StateHandler, setDepth(toDepth); } else if (toState == LauncherState.OVERVIEW) { dispatchTransactionSurface(mDepth); + } else if (toState == LauncherState.BACKGROUND_APP) { + mLauncher.getDragLayer().getViewTreeObserver().addOnDrawListener(mOnDrawListener); } }