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

Commit e74e5e92 authored by Steve Elliott's avatar Steve Elliott
Browse files

[flexiglass] fix leaky KeyguardStatusBarViewController

Flag: com.android.systemui.scene_container
Fixes: 415119794
Test: manual - verify in heapdump
Change-Id: I9648c4216ba82772ffa0f56dd39a86dd1d10b5ab
parent 8fbbf6f9
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -277,6 +277,16 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    private boolean mCommunalShowing;

    private final Consumer<Boolean> mCommunalConsumer = this::updateCommunalShowing;
    private final KeyguardStateController.Callback mKeyguardStateControllerCallback =
            new KeyguardStateController.Callback() {
                @Override
                public void onKeyguardFadingAwayChanged() {
                    if (!mKeyguardStateController.isKeyguardFadingAway()) {
                        mFirstBypassAttempt = false;
                        mDelayShowingKeyguardStatusBar = false;
                    }
                }
            };

    @VisibleForTesting
    void updateCommunalShowing(boolean communalShowing) {
@@ -407,17 +417,9 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
        mKeyguardInteractor = keyguardInteractor;

        mFirstBypassAttempt = mKeyguardBypassController.getBypassEnabled();
        mKeyguardStateController.addCallback(
                new KeyguardStateController.Callback() {
                    @Override
                    public void onKeyguardFadingAwayChanged() {
                        if (!mKeyguardStateController.isKeyguardFadingAway()) {
                            mFirstBypassAttempt = false;
                            mDelayShowingKeyguardStatusBar = false;
        if (!SceneContainerFlag.isEnabled()) {
            mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
        }
                    }
                }
        );

        Resources r = getResources();
        updateBlockedIcons();
@@ -454,6 +456,10 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat

    @Override
    protected void onViewAttached() {
        if (SceneContainerFlag.isEnabled()) {
            mKeyguardStateControllerCallback.onKeyguardFadingAwayChanged();
            mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
        }
        mView.init(mStatusBarUserChipViewModel);
        mConfigurationController.addCallback(mConfigurationListener);
        mAnimationScheduler.addCallback(mAnimationCallback);
@@ -547,6 +553,9 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
        if (mTintedIconManager != null) {
            mStatusBarIconController.removeIconGroup(mTintedIconManager);
        }
        if (SceneContainerFlag.isEnabled()) {
            mKeyguardStateController.removeCallback(mKeyguardStateControllerCallback);
        }
    }

    /** Should be called when the theme changes. */