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

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

Fix a couple leaks in SystemUI

Changing the navigation mode causes an overlay broadcast which causes all
the fragments in systemui to be recreated.  This could result in leaks
in the status bar icons (lots of bitmaps) and also the sampling callbacks
from SurfaceFlinger.

- Always stop the sampling listener when the mode changes
- Always unregister from device config changes in the QS header

Bug: 141637942
Test: Switch navigation modes a couple times, take hprof dump and verify
      there aren't leaking classes or bitmaps

Change-Id: Id3a28031e2eeef1dc45ed0f4b028771d89e24610
parent a886cd3f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -257,10 +257,6 @@ public class QuickStatusBarHeader extends RelativeLayout implements
        mNextAlarmTextView.setSelected(true);

        mPermissionsHubEnabled = PrivacyItemControllerKt.isPermissionsHubEnabled();
        // Change the ignored slots when DeviceConfig flag changes
        DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_PRIVACY,
                mContext.getMainExecutor(), mPropertiesListener);

    }

    private List<String> getIgnoredIconSlots() {
@@ -489,6 +485,9 @@ public class QuickStatusBarHeader extends RelativeLayout implements
        super.onAttachedToWindow();
        mStatusBarIconController.addIconGroup(mIconManager);
        requestApplyInsets();
        // Change the ignored slots when DeviceConfig flag changes
        DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_PRIVACY,
                mContext.getMainExecutor(), mPropertiesListener);
    }

    @Override
@@ -527,6 +526,7 @@ public class QuickStatusBarHeader extends RelativeLayout implements
    public void onDetachedFromWindow() {
        setListening(false);
        mStatusBarIconController.removeIconGroup(mIconManager);
        DeviceConfig.removeOnPropertiesChangedListener(mPropertiesListener);
        super.onDetachedFromWindow();
    }

+5 −1
Original line number Diff line number Diff line
@@ -829,7 +829,11 @@ public class NavigationBarView extends FrameLayout implements
        mRecentsOnboarding.onNavigationModeChanged(mNavBarMode);
        getRotateSuggestionButton().onNavigationModeChanged(mNavBarMode);

        if (isGesturalMode(mNavBarMode)) {
            mRegionSamplingHelper.start(mSamplingBounds);
        } else {
            mRegionSamplingHelper.stop();
        }
    }

    public void setAccessibilityButtonState(final boolean visible, final boolean longClickable) {