From ec57d42427ac1cd5dc1c73e3747df16c3e016edf Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 16 Jun 2021 18:08:47 +0800 Subject: [PATCH] Generalize the condition to take task snapshot when entering AOD There is no guarantee that AOD or keyguard will show together or individually (depends on SystemUI). So this change allows to take snapshot for both cases. Bug: 182571838 Test: 1. Enable "Always show time and info". 2. Open any app and go to home. 3. Launch the app again and make some changes to its content. 4. Press power key to enter dozing. 5. Unlock and check if the animation has the latest content. Change-Id: Ib60b00e96632d38fac308b8851cd59b71142f321 --- .../android/server/wm/KeyguardController.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index 0112f797d9379..f8238c1d154ad 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -48,6 +48,7 @@ import android.os.Trace; import android.util.Slog; import android.util.SparseArray; import android.util.proto.ProtoOutputStream; +import android.view.Display; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.server.inputmethod.InputMethodManagerInternal; @@ -163,16 +164,27 @@ class KeyguardController { aodShowing ? 1 : 0, mKeyguardGoingAway ? 1 : 0, "setKeyguardShown"); + + // Update the task snapshot if the screen will not be turned off. To make sure that the + // unlocking animation can animate consistent content. The conditions are: + // - Either AOD or keyguard changes to be showing. So if the states change individually, + // the later one can be skipped to avoid taking snapshot again. While it still accepts + // if both of them change to show at the same time. + // - Keyguard was not going away. Because if it was, the closing transition is able to + // handle the snapshot. + // - The display state is ON. Because if AOD is not on or pulsing, the display state will + // be OFF or DOZE (the path of screen off may have handled it). + if (((aodShowing ^ keyguardShowing) || (aodShowing && aodChanged && keyguardChanged)) + && !mKeyguardGoingAway && Display.isOnState( + mRootWindowContainer.getDefaultDisplay().getDisplayInfo().state)) { + mWindowManager.mTaskSnapshotController.snapshotForSleeping(DEFAULT_DISPLAY); + } + mKeyguardShowing = keyguardShowing; mAodShowing = aodShowing; if (aodChanged) { // Ensure the new state takes effect. mWindowManager.mWindowPlacerLocked.performSurfacePlacement(); - // If the device can enter AOD and keyguard at the same time, the screen will not be - // turned off, so the snapshot needs to be refreshed when these states are changed. - if (aodShowing && keyguardShowing && keyguardChanged) { - mWindowManager.mTaskSnapshotController.snapshotForSleeping(DEFAULT_DISPLAY); - } } if (keyguardChanged) {