Fix a race condition that resulted in the screen coming on without the brightness set to the correct value.
Do not cancel screen brightness animation in forceUserActivityLocked unless screen is turning off.
Also not turn the screen on if PowerManager.preventScreenOn(false) is called while proximity sensor is active.
Fixes b/2254818 (dim display) where due to a race condition the screen is stuck in a dim state.
Change-Id: If6f805609c8d463631b9e22805e5242714ce34c0
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 73527b7..bde03f3 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1266,7 +1266,7 @@
// Forcibly turn on the screen if it's supposed to be on. (This
// handles the case where the screen is currently off because of
// a prior preventScreenOn(true) call.)
- if ((mPowerState & SCREEN_ON_BIT) != 0) {
+ if (!mProximitySensorActive && (mPowerState & SCREEN_ON_BIT) != 0) {
if (mSpew) {
Log.d(TAG,
"preventScreenOn: turning on after a prior preventScreenOn(true)!");
@@ -1847,8 +1847,10 @@
}
private void forceUserActivityLocked() {
- // cancel animation so userActivity will succeed
- mScreenBrightness.animating = false;
+ if (isScreenTurningOffLocked()) {
+ // cancel animation so userActivity will succeed
+ mScreenBrightness.animating = false;
+ }
boolean savedActivityAllowed = mUserActivityAllowed;
mUserActivityAllowed = true;
userActivity(SystemClock.uptimeMillis(), false);