From a60654e05c2e5e785dbd473fe0ef205a2329f218 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 17 Feb 2021 13:24:17 +0000 Subject: [PATCH] Send display-OFF event if that is initial state. Local Displays have always sent an initial state of something other than OFF. With foldables, thats not the case any more so don't ignore state_off events if the device's state was previously UNKNOWN. Bug: 178713651 Test: manual, atest com.android.server.display Change-Id: Icc426c289e59aad43dc5d6fb0033fbbc887b0270 --- .../com/android/server/display/LocalDisplayAdapter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/display/LocalDisplayAdapter.java b/services/core/java/com/android/server/display/LocalDisplayAdapter.java index 4bbf227f70332..5b2b3366b1175 100644 --- a/services/core/java/com/android/server/display/LocalDisplayAdapter.java +++ b/services/core/java/com/android/server/display/LocalDisplayAdapter.java @@ -718,7 +718,12 @@ final class LocalDisplayAdapter extends DisplayAdapter { setDisplayState(Display.STATE_ON); currentState = Display.STATE_ON; } else { - return; // old state and new state is off + if (oldState == Display.STATE_UNKNOWN) { + // There's no guarantee about what the initial state is + // at startup, so we have to set it if previous was UNKNOWN. + setDisplayState(state); + } + return; } }