Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74afbddb authored by Lucas Dupin's avatar Lucas Dupin Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15100552

Change-Id: I442300320291b12d2b1288e80d0d63b079333336
parents 1e1358d7 be01e4e8
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@ class ActivityLaunchAnimator(
        // If we expect an animation, post a timeout to cancel it in case the remote animation is
        // never started.
        if (willAnimate) {
            keyguardHandler.disableKeyguardBlurs()
            runner.postTimeout()

            // 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]. */
        fun hideKeyguardWithAnimation(runner: IRemoteAnimationRunner)

        /** Disable window blur so they don't overlap with the window launch animation **/
        fun disableKeyguardBlurs()
        /** Enable/disable window blur so they don't overlap with the window launch animation **/
        fun setBlursDisabledForAppLaunch(disabled: Boolean)
    }

    /**
@@ -491,6 +490,7 @@ class ActivityLaunchAnimator(
            animator.addListener(object : AnimatorListenerAdapter() {
                override fun onAnimationStart(animation: Animator?, isReverse: Boolean) {
                    Log.d(TAG, "Animation started")
                    keyguardHandler.setBlursDisabledForAppLaunch(true)
                    controller.onLaunchAnimationStart(isExpandingFullyAbove)

                    // Add the drawable to the launch container overlay. Overlays always draw
@@ -501,6 +501,7 @@ class ActivityLaunchAnimator(

                override fun onAnimationEnd(animation: Animator?) {
                    Log.d(TAG, "Animation ended")
                    keyguardHandler.setBlursDisabledForAppLaunch(false)
                    iCallback?.invoke()
                    controller.onLaunchAnimationEnd(isExpandingFullyAbove)
                    launchContainerOverlay.remove(windowBackgroundLayer)
+2 −2
Original line number Diff line number Diff line
@@ -1677,8 +1677,8 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
     * Disable notification shade background blurs until the keyguard is dismissed.
     * (Used during app launch animations)
     */
    public void disableBlursUntilHidden() {
        mNotificationShadeDepthController.get().setIgnoreShadeBlurUntilHidden(true);
    public void setBlursDisabledForAppLaunch(boolean disabled) {
        mNotificationShadeDepthController.get().setBlursDisabledForAppLaunch(disabled);
    }

    public boolean isSecure() {
+9 −9
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ class NotificationShadeDepthController @Inject constructor(
     * When launching an app from the shade, the animations progress should affect how blurry the
     * shade is, overriding the expansion amount.
     */
    var ignoreShadeBlurUntilHidden: Boolean = false
    var blursDisabledForAppLaunch: Boolean = false
        set(value) {
            if (field == value) {
                return
@@ -133,6 +133,10 @@ class NotificationShadeDepthController @Inject constructor(
            if (shadeSpring.radius == 0 && shadeAnimation.radius == 0) {
                return
            }
            // Do not remove blurs when we're re-enabling them
            if (!value) {
                return
            }
            shadeSpring.animateTo(0)
            shadeSpring.finishIfRunning()

@@ -174,13 +178,9 @@ class NotificationShadeDepthController @Inject constructor(
        combinedBlur = max(combinedBlur, blurUtils.blurRadiusOfRatio(transitionToFullShadeProgress))
        var shadeRadius = max(combinedBlur, wakeAndUnlockBlurRadius).toFloat()

        if (ignoreShadeBlurUntilHidden) {
            if (shadeRadius == 0f) {
                ignoreShadeBlurUntilHidden = false
            } else {
        if (blursDisabledForAppLaunch) {
            shadeRadius = 0f
        }
        }

        var blur = shadeRadius.toInt()

@@ -193,7 +193,7 @@ class NotificationShadeDepthController @Inject constructor(
        // Brightness slider removes blur, but doesn't affect zooms
        blur = (blur * (1f - brightnessMirrorSpring.ratio)).toInt()

        val opaque = scrimsVisible && !ignoreShadeBlurUntilHidden
        val opaque = scrimsVisible && !blursDisabledForAppLaunch
        blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur, opaque)
        try {
            if (root.isAttachedToWindow && root.windowToken != null) {
@@ -424,7 +424,7 @@ class NotificationShadeDepthController @Inject constructor(
            it.println("shadeAnimation: ${shadeAnimation.radius}")
            it.println("brightnessMirrorRadius: ${brightnessMirrorSpring.radius}")
            it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius")
            it.println("ignoreShadeBlurUntilHidden: $ignoreShadeBlurUntilHidden")
            it.println("blursDisabledForAppLaunch: $blursDisabledForAppLaunch")
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -2112,8 +2112,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    }

    @Override
    public void disableKeyguardBlurs() {
        mMainThreadHandler.post(mKeyguardViewMediator::disableBlursUntilHidden);
    public void setBlursDisabledForAppLaunch(boolean disabled) {
        mKeyguardViewMediator.setBlursDisabledForAppLaunch(disabled);
    }

    public boolean isDeviceInVrMode() {
+12 −20
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ import android.os.Looper
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import android.view.IRemoteAnimationFinishedCallback
import android.view.IRemoteAnimationRunner
import android.view.RemoteAnimationAdapter
import android.view.RemoteAnimationTarget
import android.view.SurfaceControl
@@ -20,19 +19,21 @@ import android.widget.LinearLayout
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertNotNull
import junit.framework.Assert.assertNull
import junit.framework.Assert.assertTrue
import junit.framework.AssertionFailedError
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.Spy
import org.mockito.junit.MockitoJUnit
@@ -43,13 +44,18 @@ import kotlin.concurrent.thread
@RunWithLooper
class ActivityLaunchAnimatorTest : SysuiTestCase() {
    private val launchContainer = LinearLayout(mContext)
    private val keyguardHandler = TestLaunchAnimatorKeyguardHandler(isOnKeyguard = false)
    @Mock lateinit var keyguardHandler: ActivityLaunchAnimator.KeyguardHandler
    @Spy private val controller = TestLaunchAnimatorController(launchContainer)
    @Mock lateinit var iCallback: IRemoteAnimationFinishedCallback
    private val activityLaunchAnimator = ActivityLaunchAnimator(keyguardHandler, mContext)

    private lateinit var activityLaunchAnimator: ActivityLaunchAnimator
    @get:Rule val rule = MockitoJUnit.rule()

    @Before
    fun setup() {
        activityLaunchAnimator = ActivityLaunchAnimator(keyguardHandler, mContext)
    }

    private fun startIntentWithAnimation(
        animator: ActivityLaunchAnimator = this.activityLaunchAnimator,
        controller: ActivityLaunchAnimator.Controller? = this.controller,
@@ -110,7 +116,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {

    @Test
    fun animatesIfActivityIsAlreadyOpenAndIsOnKeyguard() {
        val keyguardHandler = spy(TestLaunchAnimatorKeyguardHandler(isOnKeyguard = true))
        `when`(keyguardHandler.isOnKeyguard()).thenReturn(true)
        val animator = ActivityLaunchAnimator(keyguardHandler, context)

        val willAnimateCaptor = ArgumentCaptor.forClass(Boolean::class.java)
@@ -123,7 +129,6 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {

        waitForIdleSync()
        verify(controller).onIntentStarted(willAnimateCaptor.capture())
        verify(keyguardHandler).disableKeyguardBlurs()
        verify(keyguardHandler).hideKeyguardWithAnimation(any())

        assertTrue(willAnimateCaptor.value)
@@ -166,6 +171,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
        val runner = activityLaunchAnimator.createRunner(controller)
        runner.onAnimationStart(0, arrayOf(fakeWindow()), emptyArray(), emptyArray(), iCallback)
        waitForIdleSync()
        verify(keyguardHandler).setBlursDisabledForAppLaunch(eq(true))
        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
 * outside of the main thread.
Loading