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

Commit 4880a30f authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Remove divider view when exiting splitscreen

Remove and re add divider view as needed so we do not allocate memory
while split screen is not active. Also release surface reference from
server when we are done with the SurfaceControl so we don't have to rely
on GC to remove the last reference.

Fixes: 150190730
Test: test split screen manually, check for offscreen or onscreen
divider layers in winscope

Change-Id: I1a6a1c1d4346aafeae85aaf61ec4df23722e75ab
parent 0b17a067
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -275,12 +275,4 @@ public class SurfaceControlViewHost {
        // ViewRoot will release mSurfaceControl for us.
        mViewRoot.die(false /* immediate */);
    }

    /**
     * Tell this viewroot to clean itself up.
     * @hide
     */
    public void die() {
        mViewRoot.die(false /* immediate */);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public class SurfaceViewRequestReceiver {
     */
    public void onReceive(Context context, Bundle bundle, View view, Size viewSize) {
        if (mSurfaceControlViewHost != null) {
            mSurfaceControlViewHost.die();
            mSurfaceControlViewHost.release();
        }

        SurfaceControl surfaceControl = SurfaceViewRequestUtils.getSurfaceControl(bundle);
+8 −7
Original line number Diff line number Diff line
@@ -592,14 +592,12 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
        removeDivider();
        addDivider(configuration);

        if (mView != null) {
        if (mMinimized) {
            mView.setMinimizedDockStack(true, mHomeStackResizable);
            updateTouchable();
        }
        mView.setHidden(isDividerHidden);
    }
    }

    void onTaskVanished() {
        mHandler.post(this::removeDivider);
@@ -610,7 +608,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
                mContext.getDisplayId()).getResources().getConfiguration()));
    }

    void updateVisibility(final boolean visible) {
    private void updateVisibility(final boolean visible) {
        if (DEBUG) Slog.d(TAG, "Updating visibility " + mVisible + "->" + visible);
        if (mVisible != visible) {
            mVisible = visible;
@@ -639,6 +637,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
    void onSplitDismissed() {
        mMinimized = false;
        updateVisibility(false /* visible */);
        removeDivider();
    }

    /** Switch to minimized state if appropriate */
@@ -788,6 +787,8 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
    }

    void startEnterSplit() {
        update(mDisplayController.getDisplayContext(
                mContext.getDisplayId()).getResources().getConfiguration());
        // Set resizable directly here because applyEnterSplit already resizes home stack.
        mHomeStackResizable = WindowManagerProxy.applyEnterSplit(mSplits, mSplitLayout);
    }
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ public class SystemWindows {
     */
    public void removeView(View view) {
        SurfaceControlViewHost root = mViewRoots.remove(view);
        root.die();
        root.release();
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -8082,6 +8082,7 @@ public class WindowManagerService extends IWindowManager.Stub
        t.setInputWindowInfo(surface, h);
        t.apply();
        t.close();
        surface.release();
    }

    /**