OSDN Git Service

Fix a race condition that could result in the screen being forced off indefinitely...
authorMike Lockwood <lockwood@android.com>
Fri, 6 Nov 2009 01:53:00 +0000 (20:53 -0500)
committerMike Lockwood <lockwood@android.com>
Fri, 6 Nov 2009 13:28:19 +0000 (08:28 -0500)
This should fix a "black screen" bug that Motorola identified.
mProximitySensorActive was being set to true due to a proximity sensor change being posted
just after we disabled the proximity sensor.
Now we ignore proximity changes after the phone app releases the proximity lock after the call is done.

Change-Id: I417d423de3d43515389b1b7b008cdcb795cd10f6
Signed-off-by: Mike Lockwood <lockwood@android.com>
services/java/com/android/server/PowerManagerService.java

index a03ac6c..611a86e 100644 (file)
@@ -2349,11 +2349,9 @@ class PowerManagerService extends IPowerManager.Stub
         } finally {
             Binder.restoreCallingIdentity(identity);
         }
-        synchronized (mLocks) {
-            if (mProximitySensorActive) {
-                mProximitySensorActive = false;
-                forceUserActivityLocked();
-            }
+        if (mProximitySensorActive) {
+            mProximitySensorActive = false;
+            forceUserActivityLocked();
         }
     }
 
@@ -2361,6 +2359,10 @@ class PowerManagerService extends IPowerManager.Stub
         if (mSpew) {
             Log.d(TAG, "proximityChangedLocked, active: " + active);
         }
+        if (mProximityCount <= 0) {
+            Log.d(TAG, "Ignoring proximity change after last proximity lock is released");
+            return;
+        }
         if (active) {
             goToSleepLocked(SystemClock.uptimeMillis());
             mProximitySensorActive = true;