From 7734c763ed8ba6d39e533c930ca2adb0c9fb4ddc Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 16 May 2023 17:09:24 -0700 Subject: [PATCH] Only delay wake-up animation if AOD is enabled Also, use ZJ_285570694_LOCKSCREEN_TRANSITION_FROM_AOD flag for LOCKSCREEN_TRANSITION_FROM_AOD zero jank fixes. Bug: 286880921 Bug: 285623104 Bug: 285570694 Bug: 193615254 Test: Disable AOD, use analog clock, turn screen off then on. Ensure that analog AOD clock does not briefly flicker on display. Change-Id: I36707ca64cab8c7c719a9665ae3e494fb3307ee8 --- .../statusbar/phone/CentralSurfacesImpl.java | 54 +++++++++++++------ .../phone/CentralSurfacesImplTest.java | 3 ++ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 1396d8efc7af7..17ccee6942eba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -456,6 +456,13 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { */ private boolean mShouldDelayWakeUpAnimation = false; + /** + * Whether we should delay the AOD->Lockscreen animation. + * If false, the animation will start in onStartedWakingUp(). + * If true, the animation will start in onFinishedWakingUp(). + */ + private boolean mShouldDelayLockscreenTransitionFromAod = false; + private final Object mQueueLock = new Object(); private final PulseExpansionHandler mPulseExpansionHandler; @@ -3077,28 +3084,43 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { updateVisibleToUser(); updateIsKeyguard(); + mShouldDelayLockscreenTransitionFromAod = mDozeParameters.getAlwaysOn() + && mFeatureFlags.isEnabled( + Flags.ZJ_285570694_LOCKSCREEN_TRANSITION_FROM_AOD); + if (!mShouldDelayLockscreenTransitionFromAod) { + startLockscreenTransitionFromAod(); + } }); DejankUtils.stopDetectingBlockingIpcs(tag); } + /** + * Private helper for starting the LOCKSCREEN_TRANSITION_FROM_AOD animation - only necessary + * so we can start it from either onFinishedWakingUp() or onFinishedWakingUp(). + */ + private void startLockscreenTransitionFromAod() { + // stopDozing() starts the LOCKSCREEN_TRANSITION_FROM_AOD animation. + mDozeServiceHost.stopDozing(); + // This is intentionally below the stopDozing call above, since it avoids that we're + // unnecessarily animating the wakeUp transition. Animations should only be enabled + // once we fully woke up. + updateRevealEffect(true /* wakingUp */); + updateNotificationPanelTouchState(); + mStatusBarTouchableRegionManager.updateTouchableRegion(); + + // If we are waking up during the screen off animation, we should undo making the + // expanded visible (we did that so the LightRevealScrim would be visible). + if (mScreenOffAnimationController.shouldHideLightRevealScrimOnWakeUp()) { + mShadeController.makeExpandedInvisible(); + } + } + @Override public void onFinishedWakingUp() { - mNotificationShadeWindowController.batchApplyWindowLayoutParams(()-> { - // stopDozing() starts the LOCKSCREEN_TRANSITION_FROM_AOD animation. - mDozeServiceHost.stopDozing(); - // This is intentionally below the stopDozing call above, since it avoids that we're - // unnecessarily animating the wakeUp transition. Animations should only be enabled - // once we fully woke up. - updateRevealEffect(true /* wakingUp */); - updateNotificationPanelTouchState(); - mStatusBarTouchableRegionManager.updateTouchableRegion(); - - // If we are waking up during the screen off animation, we should undo making the - // expanded visible (we did that so the LightRevealScrim would be visible). - if (mScreenOffAnimationController.shouldHideLightRevealScrimOnWakeUp()) { - mShadeController.makeExpandedInvisible(); - } - }); + if (mShouldDelayLockscreenTransitionFromAod) { + mNotificationShadeWindowController.batchApplyWindowLayoutParams( + this::startLockscreenTransitionFromAod); + } mWakeUpCoordinator.setFullyAwake(true); mWakeUpCoordinator.setWakingUp(false, false); if (mKeyguardStateController.isOccluded() diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index 4762e57fa5777..afb89a88b79b7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -353,6 +353,9 @@ public class CentralSurfacesImplTest extends SysuiTestCase { // For the Shade to animate during the Back gesture, we must enable the animation flag. mFeatureFlags.set(Flags.WM_SHADE_ANIMATE_BACK_GESTURE, true); mFeatureFlags.set(Flags.LIGHT_REVEAL_MIGRATION, true); + // Turn AOD on and toggle feature flag for jank fixes + mFeatureFlags.set(Flags.ZJ_285570694_LOCKSCREEN_TRANSITION_FROM_AOD, true); + when(mDozeParameters.getAlwaysOn()).thenReturn(true); IThermalService thermalService = mock(IThermalService.class); mPowerManager = new PowerManager(mContext, mPowerManagerService, thermalService,