diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-09-14 11:13:03 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2010-09-14 11:13:03 -0700 |
commit | 70be1673abf6334d2caf60fdc0504088b0e0859c (patch) | |
tree | 9add2a9aadf5a58d872c0e81ed9c370fd5c9fe59 /services/java | |
parent | a224f70b1efc29d9698da5b5c143251a43838f2b (diff) | |
download | frameworks_base-70be1673abf6334d2caf60fdc0504088b0e0859c.zip frameworks_base-70be1673abf6334d2caf60fdc0504088b0e0859c.tar.gz frameworks_base-70be1673abf6334d2caf60fdc0504088b0e0859c.tar.bz2 |
Fix problem where power manager was calling battery stats with bad wl type.
Also fiddle code to reduce duplication.
Change-Id: I3f1b086e53ef88dac1ec1896fe711b3cfe7fdd58
Diffstat (limited to 'services/java')
-rw-r--r-- | services/java/com/android/server/PowerManagerService.java | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index af8d7d4..8ab1bb8 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -660,28 +660,38 @@ class PowerManagerService extends IPowerManager.Stub } void noteStartWakeLocked(WakeLock wl, WorkSource ws) { - try { - if (ws != null) { - mBatteryStats.noteStartWakelockFromSource(ws, wl.pid, wl.tag, - wl.monitorType); - } else { - mBatteryStats.noteStartWakelock(wl.uid, wl.pid, wl.tag, wl.monitorType); + if (wl.monitorType >= 0) { + long origId = Binder.clearCallingIdentity(); + try { + if (ws != null) { + mBatteryStats.noteStartWakelockFromSource(ws, wl.pid, wl.tag, + wl.monitorType); + } else { + mBatteryStats.noteStartWakelock(wl.uid, wl.pid, wl.tag, wl.monitorType); + } + } catch (RemoteException e) { + // Ignore + } finally { + Binder.restoreCallingIdentity(origId); } - } catch (RemoteException e) { - // Ignore } } void noteStopWakeLocked(WakeLock wl, WorkSource ws) { - try { - if (ws != null) { - mBatteryStats.noteStopWakelockFromSource(ws, wl.pid, wl.tag, - wl.monitorType); - } else { - mBatteryStats.noteStopWakelock(wl.uid, wl.pid, wl.tag, wl.monitorType); + if (wl.monitorType >= 0) { + long origId = Binder.clearCallingIdentity(); + try { + if (ws != null) { + mBatteryStats.noteStopWakelockFromSource(ws, wl.pid, wl.tag, + wl.monitorType); + } else { + mBatteryStats.noteStopWakelock(wl.uid, wl.pid, wl.tag, wl.monitorType); + } + } catch (RemoteException e) { + // Ignore + } finally { + Binder.restoreCallingIdentity(origId); } - } catch (RemoteException e) { - // Ignore } } @@ -813,21 +823,16 @@ class PowerManagerService extends IPowerManager.Stub if (ws != null) { enforceWakeSourcePermission(uid, pid); } - long ident = Binder.clearCallingIdentity(); - try { - synchronized (mLocks) { - int index = mLocks.getIndex(lock); - if (index < 0) { - throw new IllegalArgumentException("Wake lock not active"); - } - WakeLock wl = mLocks.get(index); - WorkSource oldsource = wl.ws; - wl.ws = ws != null ? new WorkSource(ws) : null; - noteStopWakeLocked(wl, oldsource); - noteStartWakeLocked(wl, ws); + synchronized (mLocks) { + int index = mLocks.getIndex(lock); + if (index < 0) { + throw new IllegalArgumentException("Wake lock not active"); } - } finally { - Binder.restoreCallingIdentity(ident); + WakeLock wl = mLocks.get(index); + WorkSource oldsource = wl.ws; + wl.ws = ws != null ? new WorkSource(ws) : null; + noteStopWakeLocked(wl, oldsource); + noteStartWakeLocked(wl, ws); } } @@ -884,14 +889,7 @@ class PowerManagerService extends IPowerManager.Stub // Unlink the lock from the binder. wl.binder.unlinkToDeath(wl, 0); - if (wl.monitorType >= 0) { - long origId = Binder.clearCallingIdentity(); - try { - noteStopWakeLocked(wl, wl.ws); - } finally { - Binder.restoreCallingIdentity(origId); - } - } + noteStopWakeLocked(wl, wl.ws); } private class PokeLock implements IBinder.DeathRecipient |