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

Commit dd368733 authored by Vadim Caen's avatar Vadim Caen
Browse files

Do not reparent the SC when package is already realeased

If we pass a copy of the surface package, we can release the original,
but we need to check that in this case the surface control doesn't get
reparented to null since the SurfaceView using the copy might already
use the surface.

Test: atest CtsWindowManagerDeviceTestCases:SurfaceControlViewHostTests#testTransferSurfacePackage
Bug: 181757194
Change-Id: Ibf084aa70f3821e7dc82fe45b194c07f307ebe1e
parent cb81f171
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -571,7 +571,10 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        // recreate this Surface, so only release it when we are fully
        // detached.
        if (mSurfacePackage != null) {
            mTmpTransaction.reparent(mSurfacePackage.getSurfaceControl(), null).apply();
            final SurfaceControl sc = mSurfacePackage.getSurfaceControl();
            if (sc != null && sc.isValid()) {
                mTmpTransaction.reparent(sc, null).apply();
            }
            mSurfacePackage.release();
            mSurfacePackage = null;
        }
@@ -1839,8 +1842,11 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall

    private void reparentSurfacePackage(SurfaceControl.Transaction t,
            SurfaceControlViewHost.SurfacePackage p) {
        initEmbeddedHierarchyForAccessibility(p);
        final SurfaceControl sc = p.getSurfaceControl();
        if (sc == null || !sc.isValid()) {
            return;
        }
        initEmbeddedHierarchyForAccessibility(p);
        final SurfaceControl parent;
        if (mUseBlastAdapter) {
            parent = mBlastSurfaceControl;