diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-07-14 16:27:40 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-07-15 00:25:26 +0000 |
commit | 56d82dd28a3c7dcca9c9dc37a73a1cf5fc44498e (patch) | |
tree | 9cd1b522a23ca2b82d550392a9b2d8d77c949dd1 /services/core/java | |
parent | d4c1861a536d022b00505c75c30529c50688f26a (diff) | |
download | frameworks_base-56d82dd28a3c7dcca9c9dc37a73a1cf5fc44498e.zip frameworks_base-56d82dd28a3c7dcca9c9dc37a73a1cf5fc44498e.tar.gz frameworks_base-56d82dd28a3c7dcca9c9dc37a73a1cf5fc44498e.tar.bz2 |
BatteryStats: Fix deadlock
Bug:22486756
Change-Id: I20e10cc344b128bfa156c5aada93d3fb2b0fcaa3
Diffstat (limited to 'services/core/java')
-rw-r--r-- | services/core/java/com/android/server/am/BatteryStatsService.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java index 070813b..13b75ab 100644 --- a/services/core/java/com/android/server/am/BatteryStatsService.java +++ b/services/core/java/com/android/server/am/BatteryStatsService.java @@ -101,8 +101,12 @@ public final class BatteryStatsService extends IBatteryStats.Stub mUpdateFlags = 0; } updateExternalStats((String)msg.obj, updateFlags); - synchronized (this) { - synchronized (mStats) { + + // other parts of the system could be calling into us + // from mStats in order to report of changes. We must grab the mStats + // lock before grabbing our own or we'll end up in a deadlock. + synchronized (mStats) { + synchronized (this) { final int numUidsToRemove = mUidsToRemove.size(); for (int i = 0; i < numUidsToRemove; i++) { mStats.removeIsolatedUidLocked(mUidsToRemove.get(i)); |