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

Commit 14cc7776 authored by Gaurav Bhola's avatar Gaurav Bhola
Browse files

Add getParentingSurfaceControl() in DisplayContent

- After the DisplayAreas are created from the policy, DisplayContent
  adds a RootWrapper in the parent hierarhcy and then mSurfaceControl
  starts pointing to the RootWrapper instead of the original
  DisplayContent surface which now becomes mWindowingLayer.
- Later when DisplayAreaOrganizers are reset because of a client crash,
  all the leashes of the DisplayAreas move under RootWrapper causing
  inconsistency in z-order.
- To avoid this, getParentingSurfaceControl() method should be used at
  all the places that are reparenting the directly children of
  DisplayContent.
- This method can be used at other places as a future work. For now only
  use it for 2 obvious scenarios.

Fix: 326975721
Test: atest DisplayContentTests
Change-Id: I21d580b4fead8e9b0b19a36e3282c923880a9dc9
parent da0bc475
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1319,7 +1319,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        for (int i = 0; i < mChildren.size(); i++)  {
            SurfaceControl sc = mChildren.get(i).getSurfaceControl();
            if (sc != null) {
                t.reparent(sc, mSurfaceControl);
                t.reparent(sc, getParentingSurfaceControl());
            }
        }

@@ -5808,6 +5808,21 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                || supportsSystemDecorations();
    }

    /**
     * Returns the {@link SurfaceControl} where all the children should be parented on.
     *
     * <p> {@link DisplayContent} inserts a RootWrapper leash in the hierarchy above its original
     * {@link #mSurfaceControl} and then overrides the {@link #mSurfaceControl} to point to the
     * RootWrapper.
     * <p> To prevent inconsistent state later where the DAs might get re-parented to the
     * RootWrapper, this method should be used which returns the correct surface where the
     * re-parenting should happen.
     */
    @Override
    SurfaceControl getParentingSurfaceControl() {
        return mWindowingLayer;
    }

    SurfaceControl getWindowingLayer() {
        return mWindowingLayer;
    }
+12 −1
Original line number Diff line number Diff line
@@ -716,7 +716,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<

        // If parent is null, the layer should be placed offscreen so reparent to null. Otherwise,
        // set to the available parent.
        t.reparent(mSurfaceControl, mParent == null ? null : mParent.getSurfaceControl());
        t.reparent(mSurfaceControl, mParent == null ? null : mParent.getParentingSurfaceControl());

        if (mLastRelativeToLayer != null) {
            t.setRelativeLayer(mSurfaceControl, mLastRelativeToLayer, mLastLayer);
@@ -2906,6 +2906,17 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return mSurfaceControl;
    }

    /**
     * Returns the {@link SurfaceControl} where all the children should be parented on.
     *
     * A {@link WindowContainer} might insert intermediate leashes in the hierarchy and hence
     * {@link #getSurfaceControl} won't return the correct surface where the children should be
     * re-parented on.
     */
    SurfaceControl getParentingSurfaceControl() {
        return getSurfaceControl();
    }

    /**
     * Use this method instead of {@link #getPendingTransaction()} if the Transaction should be
     * synchronized with the client.