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

Commit 8fe006d9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Release SurfaceControls created by SCVH" into main

parents ee456a9a b63a512b
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
    }
}