Fix leakage of DisplayContent referenced from TransitionController
Unlike AppTransition which is associated DisplayContent, the
TransitionController is a global instance. So it needs to unregister
the listener when the display is removed.
Bug: 214991741
Test: Start/stop screen recording multiple times (create virtual
display). The heap dump of system server should not contain
many DisplayContent instances.
Change-Id: I44e2a794981fc114ada0ce98cd2471adf623d856
This commit is contained in:
@@ -1067,8 +1067,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
|
||||
mAppTransition = new AppTransition(mWmService.mContext, mWmService, this);
|
||||
mAppTransition.registerListenerLocked(mWmService.mActivityManagerAppTransitionNotifier);
|
||||
mTransitionController.registerLegacyListener(
|
||||
mWmService.mActivityManagerAppTransitionNotifier);
|
||||
mAppTransition.registerListenerLocked(mFixedRotationTransitionListener);
|
||||
mAppTransitionController = new AppTransitionController(mWmService, this);
|
||||
mUnknownAppVisibilityController = new UnknownAppVisibilityController(mWmService, this);
|
||||
|
||||
@@ -3311,6 +3311,7 @@ public class DisplayPolicy {
|
||||
}
|
||||
|
||||
void release() {
|
||||
mDisplayContent.mTransitionController.unregisterLegacyListener(mAppTransitionListener);
|
||||
mHandler.post(mGestureNavigationSettingsObserver::unregister);
|
||||
}
|
||||
|
||||
|
||||
@@ -430,6 +430,10 @@ class TransitionController {
|
||||
mLegacyListeners.add(listener);
|
||||
}
|
||||
|
||||
void unregisterLegacyListener(WindowManagerInternal.AppTransitionListener listener) {
|
||||
mLegacyListeners.remove(listener);
|
||||
}
|
||||
|
||||
void dispatchLegacyAppTransitionPending() {
|
||||
for (int i = 0; i < mLegacyListeners.size(); ++i) {
|
||||
mLegacyListeners.get(i).onAppTransitionPendingLocked();
|
||||
|
||||
@@ -137,6 +137,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
|
||||
|
||||
void setWindowManager(WindowManagerService wms) {
|
||||
mTransitionController = new TransitionController(mService, wms.mTaskSnapshotController);
|
||||
mTransitionController.registerLegacyListener(wms.mActivityManagerAppTransitionNotifier);
|
||||
}
|
||||
|
||||
TransitionController getTransitionController() {
|
||||
|
||||
Reference in New Issue
Block a user