Mark shade as opaque when scrims are visible
Fixes: 188940598 Test: atest NotificationShadeDepthControllerTest Test: atest BlurUtilsTest Change-Id: I06559a9f6d2919868f30d4747ba423043cdb8db8
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Consumer<Int>>
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user