diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index 404e5311961b8..6dfc5e192abb1 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -44,6 +44,7 @@ import com.android.systemui.shared.system.QuickStepContract import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController import com.android.systemui.shared.system.smartspace.SmartspaceState +import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.SysuiStatusBarStateController import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.policy.KeyguardStateController @@ -142,7 +143,8 @@ class KeyguardUnlockAnimationController @Inject constructor( private val keyguardViewController: KeyguardViewController, private val featureFlags: FeatureFlags, private val biometricUnlockControllerLazy: Lazy, - private val statusBarStateController: SysuiStatusBarStateController + private val statusBarStateController: SysuiStatusBarStateController, + private val notificationShadeWindowController: NotificationShadeWindowController ) : KeyguardStateController.Callback, ISysuiUnlockAnimationController.Stub() { interface KeyguardUnlockAnimationListener { @@ -362,6 +364,9 @@ class KeyguardUnlockAnimationController @Inject constructor( */ fun canPerformInWindowLauncherAnimations(): Boolean { return isNexusLauncherUnderneath() && + // If the launcher is underneath, but we're about to launch an activity, don't do + // the animations since they won't be visible. + !notificationShadeWindowController.isLaunchingActivity && launcherUnlockController != null && !keyguardStateController.isDismissingFromSwipe && // Temporarily disable for foldables since foldable launcher has two first pages, @@ -413,7 +418,6 @@ class KeyguardUnlockAnimationController @Inject constructor( (lockscreenSmartspace as BcSmartspaceDataPlugin.SmartspaceView?)?.selectedPage ?: -1 try { - // Let the launcher know to prepare for this animation. launcherUnlockController?.prepareForUnlock( willUnlockWithSmartspaceTransition, /* willAnimateSmartspace */ diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt index 2abc666e87fbe..a4d223853b128 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt @@ -14,6 +14,8 @@ import androidx.test.filters.SmallTest import com.android.keyguard.KeyguardViewController import com.android.systemui.SysuiTestCase import com.android.systemui.flags.FeatureFlags +import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController +import com.android.systemui.statusbar.NotificationShadeWindowController import com.android.systemui.statusbar.SysuiStatusBarStateController import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.policy.KeyguardStateController @@ -52,6 +54,11 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { private lateinit var surfaceTransactionApplier: SyncRtSurfaceTransactionApplier @Mock private lateinit var statusBarStateController: SysuiStatusBarStateController + @Mock + private lateinit var notificationShadeWindowController: NotificationShadeWindowController + + @Mock + private lateinit var launcherUnlockAnimationController: ILauncherUnlockAnimationController.Stub private lateinit var remoteAnimationTarget: RemoteAnimationTarget @@ -60,8 +67,11 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) keyguardUnlockAnimationController = KeyguardUnlockAnimationController( context, keyguardStateController, { keyguardViewMediator }, keyguardViewController, - featureFlags, { biometricUnlockController }, statusBarStateController + featureFlags, { biometricUnlockController }, statusBarStateController, + notificationShadeWindowController ) + keyguardUnlockAnimationController.setLauncherUnlockController( + launcherUnlockAnimationController) `when`(keyguardViewController.viewRootImpl).thenReturn(mock(ViewRootImpl::class.java)) @@ -194,4 +204,18 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) assertFalse(keyguardUnlockAnimationController.surfaceBehindAlphaAnimator.isRunning) } + + @Test + fun doNotPlayCannedUnlockAnimation_ifLaunchingApp() { + `when`(notificationShadeWindowController.isLaunchingActivity).thenReturn(true) + + keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( + remoteAnimationTarget, + 0 /* startTime */, + true /* requestedShowSurfaceBehindKeyguard */ + ) + + assertFalse(keyguardUnlockAnimationController.canPerformInWindowLauncherAnimations()) + assertFalse(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) + } } \ No newline at end of file