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

Commit 473cd952 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Force report resizing after window token is reparented

Without this, VRI was updating back the context display id to the previous one before receiving the onDisplayMoved callback (that was sent one frame later).
This caused one configuration change to be received with correct resources and configuration, but while the windowContext had wrong display ID.
During the configuration change, some SysUI classes were also using the context display id to have different layouts, and they were broken.
With this, the VRI receives the new resize callback earlier, and we never update the context display id from VRI to the old one.

The API is essentially only called when com.android.systemui.shade_window_goes_around flag is enabled.

Bug: 362719719
Bug: 388886443
Bug: 403570017
Bug: 405216230
Test: from shade collapsed, expand in a different display. Observe only one config change happens, and the context doesn't change display id more than once.
Flag: com.android.window.flags.reparent_window_token_api
Flag: com.android.systemui.shade_window_goes_around
Change-Id: Id6e1b872daa6f7b00b833644b82438d436cf04d9
parent 3d4dbbea
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -3147,6 +3147,11 @@ public class WindowManagerService extends IWindowManager.Stub
                    // Reparent the window created for this window context.
                    dc.reParentWindowToken(token);
                    hideUntilNextDraw(token);
                    // Prevent a race condition where VRI temporarily reverts the context display ID
                    // before the onDisplayMoved callback arrives. This caused incorrect display IDs
                    // during configuration changes, breaking SysUI layouts dependent on it.
                    // Forcing a resize report ensures VRI has the correct ID before the update.
                    forceReportResizing(token);
                    // This makes sure there is a traversal scheduled that will eventually report
                    // the window resize to the client.
                    dc.setLayoutNeeded();
@@ -3168,6 +3173,14 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private void forceReportResizing(@NonNull WindowContainer<?> wc) {
        wc.forAllWindows(w -> {
            if (!mResizingWindows.contains(w)) {
                mResizingWindows.add(w);
            }
        }, true /* traverseTopToBottom */);
    }

    private void hideUntilNextDraw(@NonNull WindowToken token) {
        final WindowState topChild = token.getTopChild();
        if (topChild != null) {