From 63c9e5fa4a6afa00ef531ab2d022f16326257c0e Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 19 Oct 2021 16:48:19 +0100 Subject: [PATCH] Display's transition phase checked before DPC init. DisplayPowerController checks to see if a display is in a transition as part of it's display state calculation. However, this was happening only after the initialization call in DPC on the first loop of updatePowerState. This meant that a display added in a TRANSITION phase would get incorrectly initialized to ON instead of OFF. Test: Manually verify in logs that new displays are not initialized to ON during the fold action of a foldable device. Bug: 199123716 Change-Id: I8a2b3154cf4c36bc5fe924e787a3db1d11933f79 --- .../android/server/display/DisplayPowerController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 63d32c8da2b2e..768587a6a2b80 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -1052,11 +1052,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } assert(state != Display.STATE_UNKNOWN); - // Initialize things the first time the power state is changed. - if (mustInitialize) { - initialize(state); - } - // Apply the proximity sensor. if (mProximitySensor != null) { if (mPowerRequest.useProximitySensor && state != Display.STATE_OFF) { @@ -1107,6 +1102,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call state = Display.STATE_OFF; } + // Initialize things the first time the power state is changed. + if (mustInitialize) { + initialize(state); + } + // Animate the screen state change unless already animating. // The transition may be deferred, so after this point we will use the // actual state instead of the desired one.