From 86db01e137af481e24721667980efa949114b3bb Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 16 May 2023 17:09:24 -0700 Subject: [PATCH] Move doze animation until finished waking up Move the start of the LOCKSCREEN_TRANSITION_FROM_AOD animation from onStartedWakingUp() to onFinishedWakingUp(). This mitigates against dropped frames in sysui due to the animation running while HWC is chaniging the power mode (see: IComposerClient.setPowerMode). Test: wake up with/without power button, with/without touch to unlock anytime enabled Bug: 193615254 Change-Id: Iea0ee65b2e20b092914d997e948568e5a37c2e0b --- .../statusbar/phone/CentralSurfacesImpl.java | 24 +++++++++++++------ .../phone/CentralSurfacesImplTest.java | 6 ++++- 2 files changed, 22 insertions(+), 8 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 a0cb1181165c8..f92a74c6a0f65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -2837,7 +2837,11 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } private void updateDozingState() { - Trace.traceCounter(Trace.TRACE_TAG_APP, "dozing", mDozing ? 1 : 0); + if (Trace.isTagEnabled(Trace.TRACE_TAG_APP)) { + Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_APP, "Dozing", 0); + Trace.asyncTraceForTrackBegin(Trace.TRACE_TAG_APP, "Dozing", String.valueOf(mDozing), + 0); + } Trace.beginSection("CentralSurfaces#updateDozingState"); boolean keyguardVisible = mKeyguardStateController.isVisible(); @@ -3191,6 +3195,10 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public void onStartedWakingUp() { + // Between onStartedWakingUp() and onFinishedWakingUp(), the system is changing the + // display power mode. To avoid jank, animations should NOT run during these power + // mode transitions, which means that whenever possible, animations should + // start running during the onFinishedWakingUp() callback instead of this callback. String tag = "CentralSurfaces#onStartedWakingUp"; DejankUtils.startDetectingBlockingIpcs(tag); mNotificationShadeWindowController.batchApplyWindowLayoutParams(()-> { @@ -3235,6 +3243,14 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { updateVisibleToUser(); updateIsKeyguard(); + }); + DejankUtils.stopDetectingBlockingIpcs(tag); + } + + @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 @@ -3248,13 +3264,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { if (mScreenOffAnimationController.shouldHideLightRevealScrimOnWakeUp()) { mShadeController.makeExpandedInvisible(); } - }); - DejankUtils.stopDetectingBlockingIpcs(tag); - } - - @Override - public void onFinishedWakingUp() { 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 fd9f6a73aee4b..7512d757057fa 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 @@ -1103,8 +1103,10 @@ public class CentralSurfacesImplTest extends SysuiTestCase { clearInvocations(mNotificationPanelViewController); mCentralSurfaces.mWakefulnessObserver.onStartedWakingUp(); - verify(mDozeServiceHost).stopDozing(); + verify(mDozeServiceHost, never()).stopDozing(); verify(mNotificationPanelViewController).expand(eq(false)); + mCentralSurfaces.mWakefulnessObserver.onFinishedWakingUp(); + verify(mDozeServiceHost).stopDozing(); } @Test @@ -1118,6 +1120,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mCentralSurfaces.setBouncerShowing(true); mCentralSurfaces.mWakefulnessObserver.onStartedWakingUp(); verify(mNotificationPanelViewController, never()).expand(anyBoolean()); + mCentralSurfaces.mWakefulnessObserver.onFinishedWakingUp(); + verify(mDozeServiceHost).stopDozing(); } @Test