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

Commit 7bbdb187 authored by Candice's avatar Candice
Browse files

Correctly release the surface control to avoid leak

The surface control need to be reparented to null, otherwise, its parent will keep it alive.

Bug: 407989942
Test: Manually verify the layer removed when magnification disabled
Flag: EXEMPT bugfix
Change-Id: I140243f00baa0ec96d1bec5d81227fb27a928dd6
parent 91fc447f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@ public class FullscreenMagnificationController implements ComponentCallbacks {
    private final IWindowManager mIWindowManager;
    private Supplier<SurfaceControlViewHost> mScvhSupplier;
    private SurfaceControlViewHost mSurfaceControlViewHost = null;
    /**
     * The SurfaceControl provided by SurfaceControlViewHost.
     */
    private SurfaceControl mBorderSurfaceControl = null;
    private Rect mWindowBounds;
    private SurfaceControl.Transaction mTransaction;
@@ -286,6 +289,12 @@ public class FullscreenMagnificationController implements ComponentCallbacks {
            mSurfaceControlViewHost = null;
        }

        if (mBorderSurfaceControl != null) {
            mTransaction.reparent(mBorderSurfaceControl, null).apply();
            mBorderSurfaceControl.release();
            mBorderSurfaceControl = null;
        }

        if (mFullscreenBorder != null) {
            if (mHandler.hasCallbacks(mHideBorderImmediatelyRunnable)) {
                mHandler.removeCallbacks(mHideBorderImmediatelyRunnable);