summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2013-07-16 15:18:19 -0700
committerJeff Brown <jeffbrown@google.com>2013-07-16 22:29:57 +0000
commitba8a54136d184d48fbed4f7b27734f645e4e8ad0 (patch)
tree7cc0e3b91a4e3695ca51374cb6d2a53a97966e8e /services
parent7c6be10d314413bb7afbed41017343320319915d (diff)
downloadframeworks_base-ba8a54136d184d48fbed4f7b27734f645e4e8ad0.zip
frameworks_base-ba8a54136d184d48fbed4f7b27734f645e4e8ad0.tar.gz
frameworks_base-ba8a54136d184d48fbed4f7b27734f645e4e8ad0.tar.bz2
Fix missing lock in power manager.
The display wake lock and other internal state could become out of sync if we happened to execute the power manager's update function concurrently due to the missing lock. This bug can be trigged due to display state changes or proximity sensor updated. Although it would be extremely rare, we have some evidence of this happening on at least a few devices resulting in rapid power drain with the screen off or a crash. Bug: 9880044 Change-Id: I3c674ce429621a50cbb36c3a01883d5f388205b2 (cherry picked from commit d91e417b06388694db213257b4df6b4dd78e0d49)
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/power/PowerManagerService.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index 1203e02..6f70712 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -1702,24 +1702,30 @@ public final class PowerManagerService extends IPowerManager.Stub
new DisplayPowerController.Callbacks() {
@Override
public void onStateChanged() {
- mDirty |= DIRTY_ACTUAL_DISPLAY_POWER_STATE_UPDATED;
- updatePowerStateLocked();
+ synchronized (mLock) {
+ mDirty |= DIRTY_ACTUAL_DISPLAY_POWER_STATE_UPDATED;
+ updatePowerStateLocked();
+ }
}
@Override
public void onProximityPositive() {
- mProximityPositive = true;
- mDirty |= DIRTY_PROXIMITY_POSITIVE;
- updatePowerStateLocked();
+ synchronized (mLock) {
+ mProximityPositive = true;
+ mDirty |= DIRTY_PROXIMITY_POSITIVE;
+ updatePowerStateLocked();
+ }
}
@Override
public void onProximityNegative() {
- mProximityPositive = false;
- mDirty |= DIRTY_PROXIMITY_POSITIVE;
- userActivityNoUpdateLocked(SystemClock.uptimeMillis(),
- PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
- updatePowerStateLocked();
+ synchronized (mLock) {
+ mProximityPositive = false;
+ mDirty |= DIRTY_PROXIMITY_POSITIVE;
+ userActivityNoUpdateLocked(SystemClock.uptimeMillis(),
+ PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
+ updatePowerStateLocked();
+ }
}
};