diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
commit | d24b8183b93e781080b2c16c487e60d51c12da31 (patch) | |
tree | fbb89154858984eb8e41556da7e9433040d55cd4 /services/java/com/android/server/PowerManagerService.java | |
parent | f1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff) |
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'services/java/com/android/server/PowerManagerService.java')
-rw-r--r-- | services/java/com/android/server/PowerManagerService.java | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index ca0ad1a15c82..7c111d3d8c8b 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -486,8 +486,13 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage public void acquireWakeLock(int flags, IBinder lock, String tag) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WAKE_LOCK, null); - synchronized (mLocks) { - acquireWakeLockLocked(flags, lock, tag); + long ident = Binder.clearCallingIdentity(); + try { + synchronized (mLocks) { + acquireWakeLockLocked(flags, lock, tag); + } + } finally { + Binder.restoreCallingIdentity(ident); } } @@ -572,12 +577,13 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage } if (acquireType >= 0) { + long origId = Binder.clearCallingIdentity(); try { - long origId = Binder.clearCallingIdentity(); mBatteryStats.noteStartWakelock(acquireUid, acquireName, acquireType); - Binder.restoreCallingIdentity(origId); } catch (RemoteException e) { // Ignore + } finally { + Binder.restoreCallingIdentity(origId); } } } @@ -627,12 +633,13 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage releaseType = wl.monitorType; if (releaseType >= 0) { + long origId = Binder.clearCallingIdentity(); try { - long origId = Binder.clearCallingIdentity(); mBatteryStats.noteStopWakelock(releaseUid, releaseName, releaseType); - Binder.restoreCallingIdentity(origId); } catch (RemoteException e) { // Ignore + } finally { + Binder.restoreCallingIdentity(origId); } } } @@ -757,7 +764,7 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - if (mContext.checkCallingPermission(android.Manifest.permission.DUMP) + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { pw.println("Permission Denial: can't dump PowerManager from from pid=" + Binder.getCallingPid() @@ -960,8 +967,10 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage Log.d(TAG, "mBroadcastWakeLock=" + mBroadcastWakeLock); } if (mContext != null) { - mContext.sendOrderedBroadcast(mScreenOnIntent, null, - mScreenOnBroadcastDone, mHandler, 0, null, null); + if (ActivityManagerNative.isSystemReady()) { + mContext.sendOrderedBroadcast(mScreenOnIntent, null, + mScreenOnBroadcastDone, mHandler, 0, null, null); + } } else { synchronized (mLocks) { EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 2, @@ -1232,6 +1241,14 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage } if (reallyTurnScreenOn) { err = Power.setScreenState(true); + long identity = Binder.clearCallingIdentity(); + try { + mBatteryStats.noteScreenOn(); + } catch (RemoteException e) { + Log.w(TAG, "RemoteException calling noteScreenOn on BatteryStatsService", e); + } finally { + Binder.restoreCallingIdentity(identity); + } } else { Power.setScreenState(false); // But continue as if we really did turn the screen on... @@ -1250,6 +1267,14 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage } } else { mScreenOffTime = SystemClock.elapsedRealtime(); + long identity = Binder.clearCallingIdentity(); + try { + mBatteryStats.noteScreenOff(); + } catch (RemoteException e) { + Log.w(TAG, "RemoteException calling noteScreenOff on BatteryStatsService", e); + } finally { + Binder.restoreCallingIdentity(identity); + } if (!mScreenBrightness.animating) { err = turnScreenOffLocked(becauseOfUser); } else { |