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
This commit is contained in:
Winson Chung
2019-09-25 14:44:05 -07:00
parent a886cd3fd9
commit efaacc3f9b
2 changed files with 9 additions and 5 deletions

View File

@@ -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();
}

View File

@@ -829,7 +829,11 @@ public class NavigationBarView extends FrameLayout implements
mRecentsOnboarding.onNavigationModeChanged(mNavBarMode);
getRotateSuggestionButton().onNavigationModeChanged(mNavBarMode);
mRegionSamplingHelper.start(mSamplingBounds);
if (isGesturalMode(mNavBarMode)) {
mRegionSamplingHelper.start(mSamplingBounds);
} else {
mRegionSamplingHelper.stop();
}
}
public void setAccessibilityButtonState(final boolean visible, final boolean longClickable) {