Merge "Fix issue where window would be marked as opaque" into sc-dev

This commit is contained in:
Lucas Dupin
2021-06-25 20:52:29 +00:00
committed by Android (Google) Code Review
6 changed files with 32 additions and 39 deletions

View File

@@ -159,7 +159,6 @@ class ActivityLaunchAnimator(
// If we expect an animation, post a timeout to cancel it in case the remote animation is // If we expect an animation, post a timeout to cancel it in case the remote animation is
// never started. // never started.
if (willAnimate) { if (willAnimate) {
keyguardHandler.disableKeyguardBlurs()
runner.postTimeout() runner.postTimeout()
// Hide the keyguard using the launch animation instead of the default unlock animation. // Hide the keyguard using the launch animation instead of the default unlock animation.
@@ -220,8 +219,8 @@ class ActivityLaunchAnimator(
/** Hide the keyguard and animate using [runner]. */ /** Hide the keyguard and animate using [runner]. */
fun hideKeyguardWithAnimation(runner: IRemoteAnimationRunner) fun hideKeyguardWithAnimation(runner: IRemoteAnimationRunner)
/** Disable window blur so they don't overlap with the window launch animation **/ /** Enable/disable window blur so they don't overlap with the window launch animation **/
fun disableKeyguardBlurs() fun setBlursDisabledForAppLaunch(disabled: Boolean)
} }
/** /**
@@ -491,6 +490,7 @@ class ActivityLaunchAnimator(
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?, isReverse: Boolean) { override fun onAnimationStart(animation: Animator?, isReverse: Boolean) {
Log.d(TAG, "Animation started") Log.d(TAG, "Animation started")
keyguardHandler.setBlursDisabledForAppLaunch(true)
controller.onLaunchAnimationStart(isExpandingFullyAbove) controller.onLaunchAnimationStart(isExpandingFullyAbove)
// Add the drawable to the launch container overlay. Overlays always draw // Add the drawable to the launch container overlay. Overlays always draw
@@ -501,6 +501,7 @@ class ActivityLaunchAnimator(
override fun onAnimationEnd(animation: Animator?) { override fun onAnimationEnd(animation: Animator?) {
Log.d(TAG, "Animation ended") Log.d(TAG, "Animation ended")
keyguardHandler.setBlursDisabledForAppLaunch(false)
iCallback?.invoke() iCallback?.invoke()
controller.onLaunchAnimationEnd(isExpandingFullyAbove) controller.onLaunchAnimationEnd(isExpandingFullyAbove)
launchContainerOverlay.remove(windowBackgroundLayer) launchContainerOverlay.remove(windowBackgroundLayer)

View File

@@ -1677,8 +1677,8 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
* Disable notification shade background blurs until the keyguard is dismissed. * Disable notification shade background blurs until the keyguard is dismissed.
* (Used during app launch animations) * (Used during app launch animations)
*/ */
public void disableBlursUntilHidden() { public void setBlursDisabledForAppLaunch(boolean disabled) {
mNotificationShadeDepthController.get().setIgnoreShadeBlurUntilHidden(true); mNotificationShadeDepthController.get().setBlursDisabledForAppLaunch(disabled);
} }
public boolean isSecure() { public boolean isSecure() {

View File

@@ -122,7 +122,7 @@ class NotificationShadeDepthController @Inject constructor(
* When launching an app from the shade, the animations progress should affect how blurry the * When launching an app from the shade, the animations progress should affect how blurry the
* shade is, overriding the expansion amount. * shade is, overriding the expansion amount.
*/ */
var ignoreShadeBlurUntilHidden: Boolean = false var blursDisabledForAppLaunch: Boolean = false
set(value) { set(value) {
if (field == value) { if (field == value) {
return return
@@ -133,6 +133,10 @@ class NotificationShadeDepthController @Inject constructor(
if (shadeSpring.radius == 0 && shadeAnimation.radius == 0) { if (shadeSpring.radius == 0 && shadeAnimation.radius == 0) {
return return
} }
// Do not remove blurs when we're re-enabling them
if (!value) {
return
}
shadeSpring.animateTo(0) shadeSpring.animateTo(0)
shadeSpring.finishIfRunning() shadeSpring.finishIfRunning()
@@ -174,13 +178,9 @@ class NotificationShadeDepthController @Inject constructor(
combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(transitionToFullShadeProgress)) combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(transitionToFullShadeProgress))
var shadeRadius = max(combinedBlur, wakeAndUnlockBlurRadius).toFloat() var shadeRadius = max(combinedBlur, wakeAndUnlockBlurRadius).toFloat()
if (ignoreShadeBlurUntilHidden) { if (blursDisabledForAppLaunch) {
if (shadeRadius == 0f) {
ignoreShadeBlurUntilHidden = false
} else {
shadeRadius = 0f shadeRadius = 0f
} }
}
var blur = shadeRadius.toInt() var blur = shadeRadius.toInt()
@@ -193,7 +193,7 @@ class NotificationShadeDepthController @Inject constructor(
// Brightness slider removes blur, but doesn't affect zooms // Brightness slider removes blur, but doesn't affect zooms
blur = (blur * (1f - brightnessMirrorSpring.ratio)).toInt() blur = (blur * (1f - brightnessMirrorSpring.ratio)).toInt()
val opaque = scrimsVisible && !ignoreShadeBlurUntilHidden val opaque = scrimsVisible && !blursDisabledForAppLaunch
blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, opaque) blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, opaque)
try { try {
if (root.isAttachedToWindow && root.windowToken != null) { if (root.isAttachedToWindow && root.windowToken != null) {
@@ -424,7 +424,7 @@ class NotificationShadeDepthController @Inject constructor(
it.println("shadeAnimation: ${shadeAnimation.radius}") it.println("shadeAnimation: ${shadeAnimation.radius}")
it.println("brightnessMirrorRadius: ${brightnessMirrorSpring.radius}") it.println("brightnessMirrorRadius: ${brightnessMirrorSpring.radius}")
it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius") it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius")
it.println("ignoreShadeBlurUntilHidden: $ignoreShadeBlurUntilHidden") it.println("blursDisabledForAppLaunch: $blursDisabledForAppLaunch")
} }
} }

View File

@@ -2112,8 +2112,8 @@ public class StatusBar extends SystemUI implements DemoMode,
} }
@Override @Override
public void disableKeyguardBlurs() { public void setBlursDisabledForAppLaunch(boolean disabled) {
mMainThreadHandler.post(mKeyguardViewMediator::disableBlursUntilHidden); mKeyguardViewMediator.setBlursDisabledForAppLaunch(disabled);
} }
public boolean isDeviceInVrMode() { public boolean isDeviceInVrMode() {

View File

@@ -11,7 +11,6 @@ import android.os.Looper
import android.testing.AndroidTestingRunner import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper import android.testing.TestableLooper.RunWithLooper
import android.view.IRemoteAnimationFinishedCallback import android.view.IRemoteAnimationFinishedCallback
import android.view.IRemoteAnimationRunner
import android.view.RemoteAnimationAdapter import android.view.RemoteAnimationAdapter
import android.view.RemoteAnimationTarget import android.view.RemoteAnimationTarget
import android.view.SurfaceControl import android.view.SurfaceControl
@@ -20,19 +19,21 @@ import android.widget.LinearLayout
import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import junit.framework.Assert.assertFalse import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertNotNull import junit.framework.Assert.assertNotNull
import junit.framework.Assert.assertNull import junit.framework.Assert.assertNull
import junit.framework.Assert.assertTrue import junit.framework.Assert.assertTrue
import junit.framework.AssertionFailedError import junit.framework.AssertionFailedError
import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.never import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify import org.mockito.Mockito.verify
import org.mockito.Spy import org.mockito.Spy
import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoJUnit
@@ -43,13 +44,18 @@ import kotlin.concurrent.thread
@RunWithLooper @RunWithLooper
class ActivityLaunchAnimatorTest : SysuiTestCase() { class ActivityLaunchAnimatorTest : SysuiTestCase() {
private val launchContainer = LinearLayout(mContext) private val launchContainer = LinearLayout(mContext)
private val keyguardHandler = TestLaunchAnimatorKeyguardHandler(isOnKeyguard = false) @Mock lateinit var keyguardHandler: ActivityLaunchAnimator.KeyguardHandler
@Spy private val controller = TestLaunchAnimatorController(launchContainer) @Spy private val controller = TestLaunchAnimatorController(launchContainer)
@Mock lateinit var iCallback: IRemoteAnimationFinishedCallback @Mock lateinit var iCallback: IRemoteAnimationFinishedCallback
private val activityLaunchAnimator = ActivityLaunchAnimator(keyguardHandler, mContext)
private lateinit var activityLaunchAnimator: ActivityLaunchAnimator
@get:Rule val rule = MockitoJUnit.rule() @get:Rule val rule = MockitoJUnit.rule()
@Before
fun setup() {
activityLaunchAnimator = ActivityLaunchAnimator(keyguardHandler, mContext)
}
private fun startIntentWithAnimation( private fun startIntentWithAnimation(
animator: ActivityLaunchAnimator = this.activityLaunchAnimator, animator: ActivityLaunchAnimator = this.activityLaunchAnimator,
controller: ActivityLaunchAnimator.Controller? = this.controller, controller: ActivityLaunchAnimator.Controller? = this.controller,
@@ -110,7 +116,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
@Test @Test
fun animatesIfActivityIsAlreadyOpenAndIsOnKeyguard() { fun animatesIfActivityIsAlreadyOpenAndIsOnKeyguard() {
val keyguardHandler = spy(TestLaunchAnimatorKeyguardHandler(isOnKeyguard = true)) `when`(keyguardHandler.isOnKeyguard()).thenReturn(true)
val animator = ActivityLaunchAnimator(keyguardHandler, context) val animator = ActivityLaunchAnimator(keyguardHandler, context)
val willAnimateCaptor = ArgumentCaptor.forClass(Boolean::class.java) val willAnimateCaptor = ArgumentCaptor.forClass(Boolean::class.java)
@@ -123,7 +129,6 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
waitForIdleSync() waitForIdleSync()
verify(controller).onIntentStarted(willAnimateCaptor.capture()) verify(controller).onIntentStarted(willAnimateCaptor.capture())
verify(keyguardHandler).disableKeyguardBlurs()
verify(keyguardHandler).hideKeyguardWithAnimation(any()) verify(keyguardHandler).hideKeyguardWithAnimation(any())
assertTrue(willAnimateCaptor.value) assertTrue(willAnimateCaptor.value)
@@ -166,6 +171,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
val runner = activityLaunchAnimator.createRunner(controller) val runner = activityLaunchAnimator.createRunner(controller)
runner.onAnimationStart(0, arrayOf(fakeWindow()), emptyArray(), emptyArray(), iCallback) runner.onAnimationStart(0, arrayOf(fakeWindow()), emptyArray(), emptyArray(), iCallback)
waitForIdleSync() waitForIdleSync()
verify(keyguardHandler).setBlursDisabledForAppLaunch(eq(true))
verify(controller).onLaunchAnimationStart(anyBoolean()) verify(controller).onLaunchAnimationStart(anyBoolean())
} }
@@ -185,20 +191,6 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
} }
} }
private class TestLaunchAnimatorKeyguardHandler(
private val isOnKeyguard: Boolean
) : ActivityLaunchAnimator.KeyguardHandler {
override fun isOnKeyguard(): Boolean = isOnKeyguard
override fun disableKeyguardBlurs() {
// Do nothing
}
override fun hideKeyguardWithAnimation(runner: IRemoteAnimationRunner) {
// Do nothing.
}
}
/** /**
* A simple implementation of [ActivityLaunchAnimator.Controller] which throws if it is called * A simple implementation of [ActivityLaunchAnimator.Controller] which throws if it is called
* outside of the main thread. * outside of the main thread.

View File

@@ -231,7 +231,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
fun updateBlurCallback_ignoreShadeBlurUntilHidden_overridesZoom() { fun updateBlurCallback_ignoreShadeBlurUntilHidden_overridesZoom() {
`when`(shadeSpring.radius).thenReturn(maxBlur) `when`(shadeSpring.radius).thenReturn(maxBlur)
`when`(shadeAnimation.radius).thenReturn(maxBlur) `when`(shadeAnimation.radius).thenReturn(maxBlur)
notificationShadeDepthController.ignoreShadeBlurUntilHidden = true notificationShadeDepthController.blursDisabledForAppLaunch = true
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(blurUtils).applyBlur(any(), eq(0), eq(false)) verify(blurUtils).applyBlur(any(), eq(0), eq(false))
} }
@@ -253,7 +253,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test @Test
fun ignoreShadeBlurUntilHidden_schedulesFrame() { fun ignoreShadeBlurUntilHidden_schedulesFrame() {
notificationShadeDepthController.ignoreShadeBlurUntilHidden = true notificationShadeDepthController.blursDisabledForAppLaunch = true
verify(choreographer).postFrameCallback( verify(choreographer).postFrameCallback(
eq(notificationShadeDepthController.updateBlurCallback)) eq(notificationShadeDepthController.updateBlurCallback))
} }
@@ -288,7 +288,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
fun ignoreShadeBlurUntilHidden_whennNull_ignoresIfShadeHasNoBlur() { fun ignoreShadeBlurUntilHidden_whennNull_ignoresIfShadeHasNoBlur() {
`when`(shadeSpring.radius).thenReturn(0) `when`(shadeSpring.radius).thenReturn(0)
`when`(shadeAnimation.radius).thenReturn(0) `when`(shadeAnimation.radius).thenReturn(0)
notificationShadeDepthController.ignoreShadeBlurUntilHidden = true notificationShadeDepthController.blursDisabledForAppLaunch = true
verify(shadeSpring, never()).animateTo(anyInt(), any()) verify(shadeSpring, never()).animateTo(anyInt(), any())
verify(shadeAnimation, never()).animateTo(anyInt(), any()) verify(shadeAnimation, never()).animateTo(anyInt(), any())
} }