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

Commit ca44df86 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Fix synchronization problem in PowerManagerService.dump()



Fixes a race condition that resulted in an IndexOutOfBoundsException
due to a wakelock being released while dump() was iterating through the
wakelock list.

BUG: 2469910

Change-Id: I10d7a65b9f397934942b290cb047c4ca81214297
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 2ec30697
Loading
Loading
Loading
Loading
+89 −87
Original line number Diff line number Diff line
@@ -154,8 +154,8 @@ class PowerManagerService extends IPowerManager.Stub
    private boolean mDoneBooting = false;
    private boolean mBootCompleted = false;
    private int mStayOnConditions = 0;
    private int[] mBroadcastQueue = new int[] { -1, -1, -1 };
    private int[] mBroadcastWhy = new int[3];
    private final int[] mBroadcastQueue = new int[] { -1, -1, -1 };
    private final int[] mBroadcastWhy = new int[3];
    private int mPartialCount = 0;
    private int mPowerState;
    // mScreenOffReason can be WindowManagerPolicy.OFF_BECAUSE_OF_USER,
@@ -194,8 +194,8 @@ class PowerManagerService extends IPowerManager.Stub
    private UnsynchronizedWakeLock mProximityPartialLock;
    private HandlerThread mHandlerThread;
    private Handler mHandler;
    private TimeoutTask mTimeoutTask = new TimeoutTask();
    private LightAnimator mLightAnimator = new LightAnimator();
    private final TimeoutTask mTimeoutTask = new TimeoutTask();
    private final LightAnimator mLightAnimator = new LightAnimator();
    private final BrightnessState mScreenBrightness
            = new BrightnessState(SCREEN_BRIGHT_BIT);
    private final BrightnessState mKeyboardBrightness
@@ -223,7 +223,7 @@ class PowerManagerService extends IPowerManager.Stub
    private volatile int mPokey = 0;
    private volatile boolean mPokeAwakeOnSet = false;
    private volatile boolean mInitComplete = false;
    private HashMap<IBinder,PokeLock> mPokeLocks = new HashMap<IBinder,PokeLock>();
    private final HashMap<IBinder,PokeLock> mPokeLocks = new HashMap<IBinder,PokeLock>();
    // mLastScreenOnTime is the time the screen was last turned on
    private long mLastScreenOnTime;
    private boolean mPreventScreenOn;
@@ -932,6 +932,7 @@ class PowerManagerService extends IPowerManager.Stub

        long now = SystemClock.uptimeMillis();

        synchronized (mLocks) {
            pw.println("Power Manager State:");
            pw.println("  mIsPowered=" + mIsPowered
                    + " mPowerState=" + mPowerState
@@ -1019,6 +1020,7 @@ class PowerManagerService extends IPowerManager.Stub

            pw.println();
        }
    }

    private void setTimeoutLocked(long now, int nextState)
    {