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

Commit 89b9cd6e authored by d34d's avatar d34d
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: Id958b76a093431854661d147268ddbe260613017
CYNGNOS-1041
parent 475550be
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ public class LockscreenShortcutsHelper {
        }
    };

    public void cleanup() {
        mContext.getContentResolver().unregisterContentObserver(mObserver);
        mListener = null;
    }

    public static class TargetInfo {
        public Drawable icon;
        public ColorFilter colorFilter;
+0 −3
Original line number Diff line number Diff line
@@ -280,9 +280,6 @@ public class BatteryMeterView extends View implements DemoMode,

    public void setBatteryStateRegistar(BatteryStateRegistar batteryStateRegistar) {
        mBatteryStateRegistar = batteryStateRegistar;
        if (!mAttached) {
            mBatteryStateRegistar.addStateChangedCallback(this);
        }
    }

    public void setBatteryController(BatteryController batteryController) {
+9 −0
Original line number Diff line number Diff line
@@ -235,6 +235,15 @@ public class QSPanel extends ViewGroup {
        mFooter.onConfigurationChanged();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (mHost != null) {
            mHost.getKeyguardMonitor().removeCallback(mKeyguardListener);
        }
        mBrightnessController.unregisterCallbacks();
    }

    public void setExpanded(boolean expanded) {
        if (mExpanded == expanded) return;
        mExpanded = expanded;
+5 −0
Original line number Diff line number Diff line
@@ -179,6 +179,11 @@ public class KeyguardIndicationController {
        }
    };

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

    private final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
+8 −0
Original line number Diff line number Diff line
@@ -492,7 +492,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mAccessibilityController.removeStateChangedCallback(this);
        getContext().unregisterReceiver(mDevicePolicyReceiver);
        KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallback);
        mTrustDrawable.stop();
        mShortcutHelper.cleanup();
    }

    private void updateLockIcon() {
@@ -701,6 +705,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        return mShortcutHelper.isTargetCustom(shortcut);
    }

    public void cleanup() {
        mUnlockMethodCache.removeListener(this);
    }

    @Override
    public void onChange() {
        updateCustomShortcuts();
Loading