diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java index 411e0f07f2be0..178a74cecc2ec 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java @@ -95,9 +95,10 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks d.setOnShowListener(dialog -> { if (mBlurUtils.supportsBlursOnWindows()) { - background.setAlpha((int) (ScrimController.BUSY_SCRIM_ALPHA * 255)); + int backgroundAlpha = (int) (ScrimController.BUSY_SCRIM_ALPHA * 255); + background.setAlpha(backgroundAlpha); mBlurUtils.applyBlur(d.getWindow().getDecorView().getViewRootImpl(), - mBlurUtils.blurRadiusOfRatio(1)); + mBlurUtils.blurRadiusOfRatio(1), backgroundAlpha == 255); } else { float backgroundAlpha = mContext.getResources().getFloat( com.android.systemui.R.dimen.shutdown_scrim_behind_alpha); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BlurUtils.kt b/packages/SystemUI/src/com/android/systemui/statusbar/BlurUtils.kt index 9d52fe50a7d62..969877d5349cd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BlurUtils.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BlurUtils.kt @@ -76,13 +76,14 @@ open class BlurUtils @Inject constructor( * @param viewRootImpl The window root. * @param radius blur radius in pixels. */ - fun applyBlur(viewRootImpl: ViewRootImpl?, radius: Int) { + fun applyBlur(viewRootImpl: ViewRootImpl?, radius: Int, opaqueBackground: Boolean) { if (viewRootImpl == null || !viewRootImpl.surfaceControl.isValid || !supportsBlursOnWindows()) { return } createTransaction().use { it.setBackgroundBlurRadius(viewRootImpl.surfaceControl, radius) + it.setOpaque(viewRootImpl.surfaceControl, opaqueBackground) it.apply() } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt index e8ce5f952b3bd..b7e8bfb3f2d1b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt @@ -184,7 +184,7 @@ class NotificationShadeDepthController @Inject constructor( blur = 0 } - blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur) + blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, scrimsVisible) val zoomOut = blurUtils.ratioOfBlurRadius(blur) try { if (root.isAttachedToWindow && root.windowToken != null) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/BlurUtilsTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/BlurUtilsTest.kt index f48d693e3bb1c..7c7d2dc16c03e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/BlurUtilsTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/BlurUtilsTest.kt @@ -47,7 +47,7 @@ class BlurUtilsTest : SysuiTestCase() { @Test fun testApplyBlur_noViewRoot_doesntCrash() { - blurUtils.applyBlur(null /* viewRootImple */, 10 /* radius */) + blurUtils.applyBlur(null /* viewRootImple */, 10 /* radius */, false /* opaque */) } @Test @@ -55,7 +55,7 @@ class BlurUtilsTest : SysuiTestCase() { val surfaceControl = mock(SurfaceControl::class.java) val viewRootImpl = mock(ViewRootImpl::class.java) `when`(viewRootImpl.surfaceControl).thenReturn(surfaceControl) - blurUtils.applyBlur(viewRootImpl, 10 /* radius */) + blurUtils.applyBlur(viewRootImpl, 10 /* radius */, false /* opaque */) } @Test @@ -65,8 +65,9 @@ class BlurUtilsTest : SysuiTestCase() { val viewRootImpl = mock(ViewRootImpl::class.java) `when`(viewRootImpl.surfaceControl).thenReturn(surfaceControl) `when`(surfaceControl.isValid).thenReturn(true) - blurUtils.applyBlur(viewRootImpl, radius) + blurUtils.applyBlur(viewRootImpl, radius, true /* opaque */) verify(transaction).setBackgroundBlurRadius(eq(surfaceControl), eq(radius)) + verify(transaction).setOpaque(eq(surfaceControl), eq(true)) verify(transaction).apply() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt index a0c3ed9921151..4169cdd9eb126 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt @@ -30,6 +30,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.notification.ExpandAnimationParameters import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.DozeParameters +import com.android.systemui.statusbar.phone.ScrimController import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.util.mockito.eq import org.junit.Before @@ -38,6 +39,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.any @@ -49,6 +51,7 @@ import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit +import java.util.function.Consumer @RunWith(AndroidTestingRunner::class) @RunWithLooper @@ -71,6 +74,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { @Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation @Mock private lateinit var listener: NotificationShadeDepthController.DepthListener @Mock private lateinit var dozeParameters: DozeParameters + @Captor private lateinit var scrimVisibilityCaptor: ArgumentCaptor> @JvmField @Rule val mockitoRule = MockitoJUnit.rule() private lateinit var statusBarStateListener: StatusBarStateController.StateListener @@ -102,6 +106,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { val captor = ArgumentCaptor.forClass(StatusBarStateController.StateListener::class.java) verify(statusBarStateController).addCallback(captor.capture()) statusBarStateListener = captor.value + verify(notificationShadeWindowController) + .setScrimsVisibilityListener(scrimVisibilityCaptor.capture()) } @Test @@ -175,7 +181,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun setQsPanelExpansion_appliesBlur() { notificationShadeDepthController.qsPanelExpansion = 1f notificationShadeDepthController.updateBlurCallback.doFrame(0) - verify(blurUtils).applyBlur(any(), eq(maxBlur)) + verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) } @Test @@ -188,7 +194,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun updateGlobalDialogVisibility_appliesBlur_withoutHomeControls() { `when`(globalActionsSpring.radius).thenReturn(maxBlur) notificationShadeDepthController.updateBlurCallback.doFrame(0) - verify(blurUtils).applyBlur(any(), eq(maxBlur)) + verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) } @Test @@ -196,7 +202,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.showingHomeControls = true `when`(globalActionsSpring.radius).thenReturn(maxBlur) notificationShadeDepthController.updateBlurCallback.doFrame(0) - verify(blurUtils).applyBlur(any(), eq(0)) + verify(blurUtils).applyBlur(any(), eq(0), eq(false)) } @Test @@ -205,7 +211,14 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(wallpaperManager).setWallpaperZoomOut(any(), anyFloat()) verify(listener).onWallpaperZoomOutChanged(anyFloat()) - verify(blurUtils).applyBlur(any(), anyInt()) + verify(blurUtils).applyBlur(any(), anyInt(), eq(false)) + } + + @Test + fun updateBlurCallback_setsOpaque_whenScrim() { + scrimVisibilityCaptor.value.accept(ScrimController.OPAQUE) + notificationShadeDepthController.updateBlurCallback.doFrame(0) + verify(blurUtils).applyBlur(any(), anyInt(), eq(true)) } @Test @@ -213,7 +226,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { `when`(shadeSpring.radius).thenReturn(maxBlur) `when`(shadeAnimation.radius).thenReturn(maxBlur) notificationShadeDepthController.updateBlurCallback.doFrame(0) - verify(blurUtils).applyBlur(any(), eq(maxBlur)) + verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) } @Test @@ -224,7 +237,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { animProgress.linearProgress = 1f notificationShadeDepthController.notificationLaunchAnimationParams = animProgress notificationShadeDepthController.updateBlurCallback.doFrame(0) - verify(blurUtils).applyBlur(any(), eq(0)) + verify(blurUtils).applyBlur(any(), eq(0), eq(false)) } @Test