diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 4658a745b6800..094b1927480db 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -100,6 +100,7 @@ import com.android.keyguard.KeyguardViewController; import com.android.keyguard.ViewMediatorCallback; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.CoreStartable; +import com.android.systemui.DejankUtils; import com.android.systemui.Dumpable; import com.android.systemui.animation.Interpolators; import com.android.systemui.broadcast.BroadcastDispatcher; @@ -2345,16 +2346,20 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, // Block the panel from expanding, in case we were doing a swipe to dismiss gesture. mKeyguardViewControllerLazy.get().blockPanelExpansionFromCurrentTouch(); final boolean wasShowing = mShowing; - onKeyguardExitFinished(); - - if (mKeyguardStateController.isDismissingFromSwipe() || wasShowing) { - mKeyguardUnlockAnimationControllerLazy.get().hideKeyguardViewAfterRemoteAnimation(); - } - - finishSurfaceBehindRemoteAnimation(cancelled); - mSurfaceBehindRemoteAnimationRequested = false; - mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation(); InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); + + // Post layout changes to the next frame, so we don't hang at the end of the animation. + DejankUtils.postAfterTraversal(() -> { + onKeyguardExitFinished(); + + if (mKeyguardStateController.isDismissingFromSwipe() || wasShowing) { + mKeyguardUnlockAnimationControllerLazy.get().hideKeyguardViewAfterRemoteAnimation(); + } + + finishSurfaceBehindRemoteAnimation(cancelled); + mSurfaceBehindRemoteAnimationRequested = false; + mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation(); + }); } /**