summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/PowerManagerService.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-20 07:38:31 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-20 07:38:31 -0800
commit15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (patch)
treed03d027a7ed97af616904e02a7b420babf40d44f /services/java/com/android/server/PowerManagerService.java
parent3001a035439d8134a7d70d796376d1dfbff3cdcd (diff)
auto import from //branches/cupcake/...@132569
Diffstat (limited to 'services/java/com/android/server/PowerManagerService.java')
-rw-r--r--services/java/com/android/server/PowerManagerService.java54
1 files changed, 26 insertions, 28 deletions
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 16b581903873..f41d21f7a6ba 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -246,8 +246,13 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
public void acquire() {
if (!mRefCounted || mCount++ == 0) {
- PowerManagerService.this.acquireWakeLockLocked(mFlags, mToken,
- MY_UID, mTag);
+ long ident = Binder.clearCallingIdentity();
+ try {
+ PowerManagerService.this.acquireWakeLockLocked(mFlags, mToken,
+ MY_UID, mTag);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
}
}
@@ -1285,8 +1290,9 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
} finally {
Binder.restoreCallingIdentity(identity);
}
+ mPowerState &= ~SCREEN_ON_BIT;
if (!mScreenBrightness.animating) {
- err = turnScreenOffLocked(becauseOfUser);
+ err = screenOffFinishedAnimating(becauseOfUser);
} else {
mOffBecauseOfUser = becauseOfUser;
err = 0;
@@ -1297,33 +1303,25 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
}
}
- private int turnScreenOffLocked(boolean becauseOfUser) {
- if ((mPowerState&SCREEN_ON_BIT) != 0) {
- EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 0, becauseOfUser ? 1 : 0,
- mTotalTouchDownTime, mTouchCycles);
- mLastTouchDown = 0;
- int err = Power.setScreenState(false);
+ private int screenOffFinishedAnimating(boolean becauseOfUser) {
+ // I don't think we need to check the current state here because all of these
+ // Power.setScreenState and sendNotificationLocked can both handle being
+ // called multiple times in the same state. -joeo
+ EventLog.writeEvent(LOG_POWER_SCREEN_STATE, 0, becauseOfUser ? 1 : 0,
+ mTotalTouchDownTime, mTouchCycles);
+ mLastTouchDown = 0;
+ int err = Power.setScreenState(false);
+ if (mScreenOnStartTime != 0) {
mScreenOnTime += SystemClock.elapsedRealtime() - mScreenOnStartTime;
mScreenOnStartTime = 0;
- if (err == 0) {
- //
- // FIXME(joeo)
- //
- // The problem that causes the screen not to come on is that this isn't
- // called until after the animation is done. It needs to be set right
- // away, and the anmiation's state needs to be recorded separately.
- //
- //
-
- mPowerState &= ~SCREEN_ON_BIT;
- int why = becauseOfUser
- ? WindowManagerPolicy.OFF_BECAUSE_OF_USER
- : WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT;
- sendNotificationLocked(false, why);
- }
- return err;
}
- return 0;
+ if (err == 0) {
+ int why = becauseOfUser
+ ? WindowManagerPolicy.OFF_BECAUSE_OF_USER
+ : WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT;
+ sendNotificationLocked(false, why);
+ }
+ return err;
}
private boolean batteryIsLow() {
@@ -1538,7 +1536,7 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
animating = more;
if (!more) {
if (mask == Power.SCREEN_LIGHT && curIntValue == Power.BRIGHTNESS_OFF) {
- turnScreenOffLocked(mOffBecauseOfUser);
+ screenOffFinishedAnimating(mOffBecauseOfUser);
}
}
return more;