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

Commit 71200f2c authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceControl: Provide Transaction#remove() method.

When we switched from destroy() to reparent(..., null) we introduced
a regression where the CloseGuard was not released. reparent(..., null) can
not release the CloseGuard because the caller may want to retain the control.
It seems a frustrating burden to require users to write: "reparent(null), release()"
where previously we provided destroy so we provide a helper #remove method.

Test: Existing tests pass
Bug: 123923589
Bug: 122728663
Change-Id: I60b529573f8868624c70b78c7a71a4d7c7827ff7
parent 5ea304db
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -2459,5 +2459,23 @@ public final class SurfaceControl implements Parcelable {
            nativeMergeTransaction(mNativeObject, other.mNativeObject);
            return this;
        }

        /**
         * Equivalent to reparent with a null parent, in that it removes
         * the SurfaceControl from the scene, but it also releases
         * the local resources (by calling {@link SurfaceControl#release})
         * after this method returns, {@link SurfaceControl#isValid} will return
         * false for the argument.
         *
         * @param sc The surface to remove and release.
         * @return This transaction
         * @hide
         */
        @NonNull
        public Transaction remove(@NonNull SurfaceControl sc) {
            reparent(sc, null);
            sc.release();
            return this;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -2504,7 +2504,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    public void onAnimationLeashDestroyed(Transaction t) {
        super.onAnimationLeashDestroyed(t);
        if (mAnimationBoundsLayer != null) {
            t.reparent(mAnimationBoundsLayer, null);
            t.remove(mAnimationBoundsLayer);
            mAnimationBoundsLayer = null;
        }

+2 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class Dimmer {
            final DimAnimatable dimAnimatable = new DimAnimatable(dimLayer);
            mSurfaceAnimator = new SurfaceAnimator(dimAnimatable, () -> {
                if (!mDimming) {
                    dimAnimatable.getPendingTransaction().reparent(mDimLayer, null);
                    dimAnimatable.getPendingTransaction().remove(mDimLayer);
                }
            }, mHost.mWmService);
        }
@@ -300,7 +300,7 @@ class Dimmer {

        if (!mDimState.mDimming) {
            if (!mDimState.mAnimateExit) {
                t.reparent(mDimState.mDimLayer, null);
                t.remove(mDimState.mDimLayer);
            } else {
                startDimExit(mLastRequestedDimContainer, mDimState.mSurfaceAnimator, t);
            }
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ class SurfaceAnimator {
        }
        mService.mAnimationTransferMap.remove(mAnimation);
        if (mLeash != null && destroyLeash) {
            t.reparent(mLeash, null);
            t.remove(mLeash);
            scheduleAnim = true;
        }
        mLeash = null;
+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        }

        if (mSurfaceControl != null) {
            mPendingTransaction.reparent(mSurfaceControl, null);
            mPendingTransaction.remove(mSurfaceControl);

            // Merge to parent transaction to ensure the transactions on this WindowContainer are
            // applied in native even if WindowContainer is removed.
Loading