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

Commit 18b5c901 authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

SysUI: Clean up objects when recreating statusbar

Recreating the status bar for theme changes causes several views
and objects to not get GCed.  By analyzing hprof dumps of
com.android.systemui we can identify these issues and get things
properly cleaned up, and that's what this patch is doing.

Change-Id: Ieaec759e4378a9a7701e6fba46ed33464caaee0a
TICKET: CYNGNOS-1041
parent eff6b9cc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -153,6 +153,11 @@ public class KeyguardIndicationController {
        }
    }

    public void cleanup() {
        KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitor);
        mContext.unregisterReceiver(mReceiver);
    }

    private void updateIndication() {
        if (mVisible) {
            mTextView.switchIndication(computeIndication());
+7 −2
Original line number Diff line number Diff line
@@ -136,10 +136,15 @@ public class SignalClusterView

    public void setSecurityController(SecurityController sc) {
        if (DEBUG) Log.d(TAG, "SecurityController=" + sc);
        if (sc == null && mSC != null) {
            mSC.removeCallback(this);
        }
        mSC = sc;
        if (mSC != null) {
            mSC.addCallback(this);
            mVpnVisible = mSC.isVpnEnabled();
        }
    }

    @Override
    protected void onFinishInflate() {
+4 −0
Original line number Diff line number Diff line
@@ -142,4 +142,8 @@ public class ClockController {
            FontSizeUtils.updateFontSize(mActiveClock, R.dimen.status_bar_clock_size);
        }
    }

    public void cleanup() {
        mSettingsObserver.unobserve();
    }
}
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -809,4 +809,13 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    public void onChange() {
        updateCustomShortcuts();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mAccessibilityController.removeStateChangedCallback(this);
        mContext.unregisterReceiver(mDevicePolicyReceiver);
        mShortcutHelper.cleanup();
        mUnlockMethodCache.removeListener(this);
    }
}
+20 −6
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ public class KeyguardStatusBarView extends RelativeLayout {
    private int mSystemIconsSwitcherHiddenExpandedMargin;
    private Interpolator mFastOutSlowInInterpolator;

    private UserInfoController mUserInfoController;

    public KeyguardStatusBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
@@ -85,6 +87,14 @@ public class KeyguardStatusBarView extends RelativeLayout {
                        com.android.internal.R.dimen.text_size_small_material));
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (mUserInfoController != null) {
            mUserInfoController.removeListener(mUserInfoChangedListener);
        }
    }

    private void loadDimens() {
        mSystemIconsSwitcherHiddenExpandedMargin = getResources().getDimensionPixelSize(
                R.dimen.system_icons_switcher_hidden_expanded_margin);
@@ -129,13 +139,17 @@ public class KeyguardStatusBarView extends RelativeLayout {
        mMultiUserSwitch.setUserSwitcherController(controller);
    }

    public void setUserInfoController(UserInfoController userInfoController) {
        userInfoController.addListener(new UserInfoController.OnUserInfoChangedListener() {
    private UserInfoController.OnUserInfoChangedListener mUserInfoChangedListener =
            new UserInfoController.OnUserInfoChangedListener() {
        @Override
        public void onUserInfoChanged(String name, Drawable picture) {
            mMultiUserAvatar.setImageDrawable(picture);
        }
        });
    };

    public void setUserInfoController(UserInfoController userInfoController) {
        mUserInfoController = userInfoController;
        userInfoController.addListener(mUserInfoChangedListener);
    }

    public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) {
Loading