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

Commit b63a512b authored by Patrick Williams's avatar Patrick Williams
Browse files

Release SurfaceControls created by SCVH

Bug: 407989942
Flag: com.android.window.flags.scvh_surface_control_lifetime_fix
Test: manual verification of SurfaceControl lifetime
Change-Id: If2717dab8fe8e7c298fdf0cb3b43a4287c5cf2d4
parent c0d3ffdd
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -61,6 +61,11 @@ public class SurfaceControlViewHost {
    private final WindowlessWindowManager mWm;

    private SurfaceControl mSurfaceControl;

    // True if this SurfaceControlViewHost created mSurfaceControl and is responsible for releasing
    // it.
    private final boolean mOwnsSurfaceControl;

    private IAccessibilityEmbeddedConnection mAccessibilityEmbeddedConnection;
    private boolean mReleased = false;

@@ -325,6 +330,7 @@ public class SurfaceControlViewHost {
    public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d,
            @NonNull WindowlessWindowManager wwm, @NonNull String callsite) {
        mSurfaceControl = wwm.mRootSurface;
        mOwnsSurfaceControl = false;
        mWm = wwm;
        mViewRoot = new ViewRootImpl(c, d, mWm, new WindowlessWindowLayout());
        mCloseGuard.openWithCallSite("release", callsite);
@@ -393,6 +399,7 @@ public class SurfaceControlViewHost {
                .setName("SurfaceControlViewHost")
                .setCallsite("SurfaceControlViewHost[" + callsite + "]")
                .build();
        mOwnsSurfaceControl = true;
        mWm = new WindowlessWindowManager(context.getResources().getConfiguration(),
                mSurfaceControl, hostToken);

@@ -545,7 +552,6 @@ public class SurfaceControlViewHost {
     * and render the object unusable.
     */
    public void release() {
        // ViewRoot will release mSurfaceControl for us.
        doRelease(true /* immediate */);
    }

@@ -557,6 +563,9 @@ public class SurfaceControlViewHost {

        mViewRoot.die(immediate);
        WindowManagerGlobal.getInstance().removeWindowlessRoot(mViewRoot);
        if (Flags.scvhSurfaceControlLifetimeFix() && mOwnsSurfaceControl) {
            mSurfaceControl.release();
        }
        mReleased = true;
        mCloseGuard.close();
    }
+11 −0
Original line number Diff line number Diff line
@@ -134,3 +134,14 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "scvh_surface_control_lifetime_fix"
    namespace: "window_surfaces"
    description: "Fix lifetime issue with SurfaceControl's created by SCVH"
    is_fixed_read_only: true
    bug: "407989942"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}