Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56d82dd2 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

BatteryStats: Fix deadlock

Bug:22486756
Change-Id: I20e10cc344b128bfa156c5aada93d3fb2b0fcaa3
parent d4c1861a
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -101,8 +101,12 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        mUpdateFlags = 0;
                    }
                    updateExternalStats((String)msg.obj, updateFlags);
                    synchronized (this) {

                    // 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));