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

Commit 66b0e8ad authored by Liam, Lee Pong Lam's avatar Liam, Lee Pong Lam Committed by Android (Google) Code Review
Browse files

Merge "Fixes Smartspace jumps issue during unlock animation" into udc-dev

parents 671d962a 53ab4f46
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -637,7 +637,9 @@ class KeyguardUnlockAnimationController @Inject constructor(
     * Unlock to the launcher, using in-window animations, and the smartspace shared element
     * transition if possible.
     */
    private fun unlockToLauncherWithInWindowAnimations() {

    @VisibleForTesting
    fun unlockToLauncherWithInWindowAnimations() {
        setSurfaceBehindAppearAmount(1f, wallpapers = false)

        try {
@@ -662,7 +664,9 @@ class KeyguardUnlockAnimationController @Inject constructor(

        // Now that the Launcher surface (with its smartspace positioned identically to ours) is
        // visible, hide our smartspace.
        if (lockscreenSmartspace?.visibility == View.VISIBLE) {
            lockscreenSmartspace?.visibility = View.INVISIBLE
        }

        // Start an animation for the wallpaper, which will finish keyguard exit when it completes.
        fadeInWallpaper()
@@ -914,7 +918,9 @@ class KeyguardUnlockAnimationController @Inject constructor(
        willUnlockWithSmartspaceTransition = false

        // The lockscreen surface is gone, so it is now safe to re-show the smartspace.
        if (lockscreenSmartspace?.visibility == View.INVISIBLE) {
            lockscreenSmartspace?.visibility = View.VISIBLE
        }

        listeners.forEach { it.onUnlockAnimationFinished() }
    }
+79 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import android.testing.TestableLooper.RunWithLooper
import android.view.RemoteAnimationTarget
import android.view.SurfaceControl
import android.view.SyncRtSurfaceTransactionApplier
import android.view.View
import android.view.ViewRootImpl
import androidx.test.filters.SmallTest
import com.android.keyguard.KeyguardViewController
@@ -32,6 +33,7 @@ import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.atLeastOnce
import org.mockito.Mockito.mock
import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyNoMoreInteractions
@@ -374,6 +376,83 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() {
        verifyNoMoreInteractions(surfaceTransactionApplier)
    }

    @Test
    fun unlockToLauncherWithInWindowAnimations_ssViewIsVisible() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.VISIBLE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.unlockToLauncherWithInWindowAnimations()

        verify(mockLockscreenSmartspaceView).visibility = View.INVISIBLE
    }

    @Test
    fun unlockToLauncherWithInWindowAnimations_ssViewIsInvisible() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.INVISIBLE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.unlockToLauncherWithInWindowAnimations()

        verify(mockLockscreenSmartspaceView, never()).visibility = View.INVISIBLE
    }

    @Test
    fun unlockToLauncherWithInWindowAnimations_ssViewIsGone() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.GONE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.unlockToLauncherWithInWindowAnimations()

        verify(mockLockscreenSmartspaceView, never()).visibility = View.INVISIBLE
    }

    @Test
    fun notifyFinishedKeyguardExitAnimation_ssViewIsInvisibleAndCancelledIsTrue() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.INVISIBLE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.notifyFinishedKeyguardExitAnimation(true)

        verify(mockLockscreenSmartspaceView).visibility = View.VISIBLE
    }

    @Test
    fun notifyFinishedKeyguardExitAnimation_ssViewIsGoneAndCancelledIsTrue() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.GONE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.notifyFinishedKeyguardExitAnimation(true)

        verify(mockLockscreenSmartspaceView, never()).visibility = View.VISIBLE
    }

    @Test
    fun notifyFinishedKeyguardExitAnimation_ssViewIsInvisibleAndCancelledIsFalse() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.INVISIBLE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.notifyFinishedKeyguardExitAnimation(false)

        verify(mockLockscreenSmartspaceView).visibility = View.VISIBLE
    }

    @Test
    fun notifyFinishedKeyguardExitAnimation_ssViewIsGoneAndCancelledIsFalse() {
        val mockLockscreenSmartspaceView = mock(View::class.java)
        whenever(mockLockscreenSmartspaceView.visibility).thenReturn(View.GONE)
        keyguardUnlockAnimationController.lockscreenSmartspace = mockLockscreenSmartspaceView

        keyguardUnlockAnimationController.notifyFinishedKeyguardExitAnimation(false)

        verify(mockLockscreenSmartspaceView, never()).visibility = View.VISIBLE
    }

    private class ArgThatCaptor<T> {
        private var allArgs: MutableList<T> = mutableListOf()