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

This commit is contained in:
Liam, Lee Pong Lam
2023-05-24 22:29:07 +00:00
committed by Android (Google) Code Review
2 changed files with 88 additions and 3 deletions

View File

@@ -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.
lockscreenSmartspace?.visibility = View.INVISIBLE
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.
lockscreenSmartspace?.visibility = View.VISIBLE
if (lockscreenSmartspace?.visibility == View.INVISIBLE) {
lockscreenSmartspace?.visibility = View.VISIBLE
}
listeners.forEach { it.onUnlockAnimationFinished() }
}

View File

@@ -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()