Keep window expanded when blurring it

We now have a spring animation, and the window must be expanded
until the animation is over.

Bug: 149792636
Test: manual
Test: atest NotificationShadeWindowControllerTest
Change-Id: I621813a04136c7bcb01b76f74a7e20d854434258
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
index eb8526d..3a33c4b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
@@ -31,6 +31,7 @@
 import com.android.systemui.dump.DumpManager
 import com.android.systemui.statusbar.phone.BiometricUnlockController
 import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK
+import com.android.systemui.statusbar.phone.NotificationShadeWindowController
 import com.android.systemui.statusbar.phone.PanelExpansionListener
 import com.android.systemui.statusbar.policy.KeyguardStateController
 import java.io.FileDescriptor
@@ -50,6 +51,7 @@
     private val keyguardStateController: KeyguardStateController,
     private val choreographer: Choreographer,
     private val wallpaperManager: WallpaperManager,
+    private val notificationShadeWindowController: NotificationShadeWindowController,
     dumpManager: DumpManager
 ) : PanelExpansionListener, Dumpable {
     companion object {
@@ -62,7 +64,6 @@
     private var keyguardAnimator: Animator? = null
     private var notificationAnimator: Animator? = null
     private var updateScheduled: Boolean = false
-    private var shadeExpansion = 1.0f
     private val shadeSpring = SpringAnimation(this, object :
             FloatPropertyCompat<NotificationShadeDepthController>("shadeBlurRadius") {
         override fun setValue(rect: NotificationShadeDepthController?, value: Float) {
@@ -100,6 +101,7 @@
         val rawZoom = max(blurUtils.ratioOfBlurRadius(blur), globalDialogVisibility)
         wallpaperManager.setWallpaperZoomOut(root.windowToken,
                 zoomInterpolator.getInterpolation(rawZoom))
+        notificationShadeWindowController.setBackgroundBlurRadius(blur)
     }
 
     /**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java
index 75f5023..e1e679f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java
@@ -309,7 +309,8 @@
         return !state.mForceCollapsed && (state.isKeyguardShowingAndNotOccluded()
                 || state.mPanelVisible || state.mKeyguardFadingAway || state.mBouncerShowing
                 || state.mHeadsUpShowing || state.mBubblesShowing
-                || state.mScrimsVisibility != ScrimController.TRANSPARENT);
+                || state.mScrimsVisibility != ScrimController.TRANSPARENT)
+                || state.mBackgroundBlurRadius > 0;
     }
 
     private void applyFitsSystemWindows(State state) {
@@ -478,6 +479,19 @@
         apply(mCurrentState);
     }
 
+    /**
+     * Current blur level, controller by
+     * {@link com.android.systemui.statusbar.NotificationShadeDepthController}.
+     * @param backgroundBlurRadius Radius in pixels.
+     */
+    public void setBackgroundBlurRadius(int backgroundBlurRadius) {
+        if (mCurrentState.mBackgroundBlurRadius == backgroundBlurRadius) {
+            return;
+        }
+        mCurrentState.mBackgroundBlurRadius = backgroundBlurRadius;
+        apply(mCurrentState);
+    }
+
     public void setHeadsUpShowing(boolean showing) {
         mCurrentState.mHeadsUpShowing = showing;
         apply(mCurrentState);
@@ -665,6 +679,7 @@
         boolean mForcePluginOpen;
         boolean mDozing;
         int mScrimsVisibility;
+        int mBackgroundBlurRadius;
 
         private boolean isKeyguardShowingAndNotOccluded() {
             return mKeyguardShowing && !mKeyguardOccluded;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java
index 83e89bd..5320ecd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java
@@ -20,6 +20,7 @@
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -27,6 +28,7 @@
 import android.app.IActivityManager;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper.RunWithLooper;
+import android.view.View;
 import android.view.WindowManager;
 
 import androidx.test.filters.SmallTest;
@@ -110,4 +112,13 @@
     public void testSetForcePluginOpen_beforeStatusBarInitialization() {
         mNotificationShadeWindowController.setForcePluginOpen(true);
     }
+
+    @Test
+    public void setBackgroundBlurRadius_expandedWithBlurs() {
+        mNotificationShadeWindowController.setBackgroundBlurRadius(10);
+        verify(mNotificationShadeWindowView).setVisibility(eq(View.VISIBLE));
+
+        mNotificationShadeWindowController.setBackgroundBlurRadius(0);
+        verify(mNotificationShadeWindowView).setVisibility(eq(View.INVISIBLE));
+    }
 }