Ignore the light sensor if the screen is turning off.
Fixes bug b/2202165. The light sensor was interfering with the screen off animation.
Change-Id: I1bc566a164af689b60b066e6cb3dcbf7959bc50a
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 af93d36..596325c 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1440,6 +1440,8 @@
sendNotificationLocked(true, -1);
}
} else {
+ // cancel light sensor task
+ mHandler.removeCallbacks(mAutoBrightnessTask);
mScreenOffTime = SystemClock.elapsedRealtime();
long identity = Binder.clearCallingIdentity();
try {
@@ -1803,6 +1805,10 @@
}
}
+ private boolean isScreenTurningOffLocked() {
+ return (mScreenBrightness.animating && mScreenBrightness.targetValue == 0);
+ }
+
private void forceUserActivityLocked() {
// cancel animation so userActivity will succeed
mScreenBrightness.animating = false;
@@ -1863,7 +1869,7 @@
+ " force=" + force);
}
// ignore user activity if we are in the process of turning off the screen
- if (mScreenBrightness.animating && mScreenBrightness.targetValue == 0) {
+ if (isScreenTurningOffLocked()) {
Log.d(TAG, "ignoring user activity while turning off screen");
return;
}
@@ -2441,6 +2447,11 @@
SensorEventListener mLightListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
synchronized (mLocks) {
+ // ignore light sensor while screen is turning off
+ if (isScreenTurningOffLocked()) {
+ return;
+ }
+
int value = (int)event.values[0];
long milliseconds = event.timestamp / 1000000;
if (mDebugLightSensor) {