From 81de8b99f599aaa163a7c9b2067e649e101f94b0 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 28 Nov 2011 16:54:31 -0800 Subject: Fix issue #5642121: Proximity sensor didn't turn the screen on in call Turning animations back on exposed this. The problem is that when the screen brightness changes, it initiates a brightness animation. When we force the screen to black as we wait for it to be ready to display, it sees that an animation is running so stops it and thinks this means it should now turn the display off. To fix this, don't modify the screen brightness while we are waiting to show the screen. This is good anyway because the whole point is to avoid showing the screen until ready, and modifying the brightness at that point would turn it on prematurely. Change-Id: I84b296f8ca5705c2d237ea7741cdeb95c5521df9 --- .../com/android/server/PowerManagerService.java | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'services') diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index 6b23b33..2a0d2a0 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -1689,6 +1689,11 @@ public class PowerManagerService extends IPowerManager.Stub // before showing it to the user. We want the light off // until it is ready to be shown to the user, not it using // whatever the last value it had. + if (DEBUG_SCREEN_ON) { + Slog.i(TAG, "Forcing brightness 0: mPowerState=0x" + + Integer.toHexString(mPowerState) + + " mSkippedScreenOn=" + mSkippedScreenOn); + } mScreenBrightness.forceValueLocked(Power.BRIGHTNESS_OFF); } } @@ -2038,12 +2043,14 @@ public class PowerManagerService extends IPowerManager.Stub } finally { Binder.restoreCallingIdentity(identity); } - mScreenBrightness.setTargetLocked(brightness, steps, - INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue); - if (DEBUG_SCREEN_ON) { - RuntimeException e = new RuntimeException("here"); - e.fillInStackTrace(); - Slog.i(TAG, "Setting screen brightness: " + brightness, e); + if (!mSkippedScreenOn) { + mScreenBrightness.setTargetLocked(brightness, steps, + INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue); + if (DEBUG_SCREEN_ON) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Slog.i(TAG, "Setting screen brightness: " + brightness, e); + } } } @@ -2086,6 +2093,11 @@ public class PowerManagerService extends IPowerManager.Stub ? LightsService.BRIGHTNESS_MODE_SENSOR : LightsService.BRIGHTNESS_MODE_USER); if ((mask & SCREEN_BRIGHT_BIT) != 0) { + if (DEBUG_SCREEN_ON) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Slog.i(TAG, "Set LCD brightness: " + value, e); + } mLcdLight.setBrightness(value, brightnessMode); } if ((mask & BUTTON_BRIGHT_BIT) != 0) { @@ -2137,7 +2149,7 @@ public class PowerManagerService extends IPowerManager.Stub delta = (targetValue - (nominalCurrentValue >= 0 ? nominalCurrentValue : curValue)) / stepsToTarget; - if (mSpew) { + if (mSpew || DEBUG_SCREEN_ON) { String noticeMe = nominalCurrentValue == curValue ? "" : " ******************"; Slog.i(TAG, "setTargetLocked mask=" + mask + " curValue=" + curValue + " target=" + target + " targetValue=" + targetValue + " delta=" + delta @@ -2527,8 +2539,10 @@ public class PowerManagerService extends IPowerManager.Stub } if (mAutoBrightessEnabled && mScreenBrightnessOverride < 0) { - mScreenBrightness.setTargetLocked(lcdValue, AUTOBRIGHTNESS_ANIM_STEPS, - INITIAL_SCREEN_BRIGHTNESS, (int)mScreenBrightness.curValue); + if (!mSkippedScreenOn) { + mScreenBrightness.setTargetLocked(lcdValue, AUTOBRIGHTNESS_ANIM_STEPS, + INITIAL_SCREEN_BRIGHTNESS, (int)mScreenBrightness.curValue); + } } if (mButtonBrightnessOverride < 0) { mButtonLight.setBrightness(buttonValue); -- cgit v1.1