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

Commit 1b4736f7 authored by Winson Chung's avatar Winson Chung
Browse files

Release surfaces after they are unreferenced

- Explicitly release surfaces when they are unused in various callers

Bug: 337666906
Flag: EXEMPT bugfix
Test: WM Presubmit
Change-Id: Iaa7d07065b5c4aaba5d9d5bdb0ba7a0af0b60b9b
parent c3a2d64f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -324,6 +324,16 @@ public class RemoteAnimationTarget implements Parcelable {
        rotationChange = in.readInt();
    }

    /**
     * Releases any resources held by this animation target.
     * @hide
     */
    public void release() {
        if (leash != null) {
            leash.release();
        }
    }

    public void setShowBackdrop(boolean shouldShowBackdrop) {
        showBackdrop = shouldShowBackdrop;
    }
+11 −1
Original line number Diff line number Diff line
@@ -1415,7 +1415,7 @@ class BackNavigationController {
                }
            }
            if (mCloseAdaptor != null) {
                mCloseAdaptor.mTarget.cancelAnimation();
                mCloseAdaptor.cleanUp();
                mCloseAdaptor = null;
            }
            if (mOpenAnimAdaptor != null) {
@@ -1576,6 +1576,9 @@ class BackNavigationController {
                    mCloseTransaction.apply();
                    mCloseTransaction = null;
                }
                if (mRemoteAnimationTarget != null) {
                    mRemoteAnimationTarget.release();
                }

                mPreparedOpenTransition = null;
            }
@@ -1744,6 +1747,13 @@ class BackNavigationController {
                return null;
            }

            void cleanUp() {
                mTarget.cancelAnimation();
                if (mAnimationTarget != null) {
                    mAnimationTarget.release();
                }
            }

            @Override
            public boolean getShowWallpaper() {
                return false;
+4 −2
Original line number Diff line number Diff line
@@ -276,12 +276,14 @@ public class DisplayAreaOrganizerController extends IDisplayAreaOrganizerControl

    void onDisplayAreaAppeared(IDisplayAreaOrganizer organizer, DisplayArea da) {
        ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "DisplayArea appeared name=%s", da.getName());
        try {
            SurfaceControl outSurfaceControl = new SurfaceControl(da.getSurfaceControl(),
        final SurfaceControl outSurfaceControl = new SurfaceControl(da.getSurfaceControl(),
                "DisplayAreaOrganizerController.onDisplayAreaAppeared");
        try {
            organizer.onDisplayAreaAppeared(da.getDisplayAreaInfo(), outSurfaceControl);
        } catch (RemoteException e) {
            // Oh well...
        } finally {
            outSurfaceControl.release();
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -3494,6 +3494,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            mOverlayLayer.release();
            mInputOverlayLayer.release();
            mA11yOverlayLayer.release();
            mPointerEventDispatcherOverlayLayer.release();
            mInputMonitor.onDisplayRemoved();
            mWmService.mDisplayNotificationController.dispatchDisplayRemoved(this);
            mDisplayRotation.onDisplayRemoved();
+5 −2
Original line number Diff line number Diff line
@@ -115,11 +115,14 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
        void onTaskAppeared(Task task) {
            ProtoLog.v(WM_DEBUG_WINDOW_ORGANIZER, "Task appeared taskId=%d", task.mTaskId);
            final RunningTaskInfo taskInfo = task.getTaskInfo();
            final SurfaceControl leash = prepareLeash(task,
                    "TaskOrganizerController.onTaskAppeared");
            try {
                mTaskOrganizer.onTaskAppeared(taskInfo, prepareLeash(task,
                        "TaskOrganizerController.onTaskAppeared"));
                mTaskOrganizer.onTaskAppeared(taskInfo, leash);
            } catch (RemoteException e) {
                Slog.e(TAG, "Exception sending onTaskAppeared callback", e);
            } finally {
                leash.release();
            }
        }

Loading