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

Commit edbfdb38 authored by Winson Chung's avatar Winson Chung
Browse files

Prevent adding duplicate callbacks to the state controller

- KeyguardBottomAreaView can add itself multiple times as a callback,
  which can leak a bitmap via that view if the state controller keeps
  an extra ref to it.

Bug: 141555865
Bug: 140629244
Test: Change overlays multiple times, take heap dump and ensure no
      leaked bitmaps

Change-Id: I8169eac24d8801ae71e4bdc60a16c68eb3896cc4
parent 85ce7cb0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -101,7 +101,9 @@ public class KeyguardStateControllerImpl extends KeyguardUpdateMonitorCallback
    @Override
    public void addCallback(@NonNull Callback callback) {
        Preconditions.checkNotNull(callback, "Callback must not be null. b/128895449");
        if (!mCallbacks.contains(callback)) {
            mCallbacks.add(callback);
        }
        if (mCallbacks.size() != 0 && !mListening) {
            mListening = true;
            mKeyguardUpdateMonitor.registerCallback(this);