From c785962ce5a8c887fc65818b5f7d204746f1d45b Mon Sep 17 00:00:00 2001 From: Rupesh Bansal Date: Wed, 3 Aug 2022 12:56:01 +0000 Subject: [PATCH] Make brightness transition to ON immediate if the screen was OFF because of close proxiity Currently, we ramp the brightness change from the start to end value at a configurable speed. If this configuration is set to a small value, users can have a deteriorated experience for the cases when they are on a phone call with phone on their ear, and then immediately want to check the phone display. This CL is to fix this experience, and make the transition immediate for such scenarios Bug: 238573816 Test: Manual Change-Id: I08a441641d836fcca746be549d7327e29cf2fb59 --- .../com/android/server/display/DisplayPowerController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 95c8fef12976a..a85824f085820 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -1204,6 +1204,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } assert(state != Display.STATE_UNKNOWN); + boolean skipRampBecauseOfProximityChangeToNegative = false; // Apply the proximity sensor. if (mProximitySensor != null) { if (mPowerRequest.useProximitySensor && state != Display.STATE_OFF) { @@ -1241,6 +1242,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // the screen back on. Also turn it back on if we've been asked to ignore the // prox sensor temporarily. mScreenOffBecauseOfProximity = false; + skipRampBecauseOfProximityChangeToNegative = true; sendOnProximityNegativeWithWakelock(); } } else { @@ -1521,8 +1523,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call final boolean wasOrWillBeInVr = (state == Display.STATE_VR || oldState == Display.STATE_VR); - final boolean initialRampSkip = - state == Display.STATE_ON && mSkipRampState != RAMP_STATE_SKIP_NONE; + final boolean initialRampSkip = (state == Display.STATE_ON && mSkipRampState + != RAMP_STATE_SKIP_NONE) || skipRampBecauseOfProximityChangeToNegative; // While dozing, sometimes the brightness is split into buckets. Rather than animating // through the buckets, which is unlikely to be smooth in the first place, just jump // right to the suggested brightness.