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

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

Merge "Update the server visibility before layout" into main

parents c7eefff9 017b6b94
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ public class ImePerfTest extends ImePerfTestBase
            "IMMS.applyImeVisibility",
            "applyPostLayoutPolicy",
            "applyWindowSurfaceChanges",
            "ISC.onPreLayout",
            "ISC.onPostLayout"
    };

+2 −0
Original line number Diff line number Diff line
@@ -5082,6 +5082,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            setLayoutNeeded();
        }

        mInsetsStateController.onPreLayout();

        // Perform a layout, if needed.
        performLayout(true /* initial */, false /* updateInputWindows */);
        pendingLayoutChanges = 0;
+21 −6
Original line number Diff line number Diff line
@@ -70,6 +70,12 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
     */
    private boolean mServerVisible;

    /**
     * The server visibility of the source provider's window before the latest
     * {@link #onPreLayout} call.
     */
    private boolean mServerVisiblePreLayout;

    /**
     * When the IME is not ready, it has givenInsetsPending. However, this could happen again,
     * after it became serverVisible. This flag indicates is used to determine if it is
@@ -91,12 +97,17 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    }

    @Override
    void onPostLayout() {
        boolean wasServerVisible = mServerVisible;
        super.onPostLayout();
    void onPreLayout() {
        mServerVisiblePreLayout = mServerVisible;
        super.onPreLayout();

        final boolean givenInsetsPending = mWin != null && mWin.mGivenInsetsPending;
        mLastDrawn = mWin != null && mWin.isDrawn();
    }

    @Override
    boolean onPostLayout() {
        final boolean controlDispatched = super.onPostLayout();
        final boolean givenInsetsPending = mWin != null && mWin.mGivenInsetsPending;

        // isLeashReadyForDispatching (used to dispatch the leash of the control) is
        // depending on mGivenInsetsReady. Therefore, triggering notifyControlChanged here
@@ -109,9 +120,12 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
            mGivenInsetsReady = true;
            ImeTracker.forLogging().onProgress(mStatsToken,
                    ImeTracker.PHASE_WM_POST_LAYOUT_NOTIFY_CONTROLS_CHANGED);
            if (!controlDispatched) {
                mStateController.notifyControlChanged(mControlTarget, this);
            }
            setImeShowing(true);
        } else if (wasServerVisible && isServerVisible() && mGivenInsetsReady
            return true;
        } else if (mServerVisiblePreLayout && isServerVisible() && mGivenInsetsReady
                && givenInsetsPending) {
            // If the server visibility didn't change (still visible), and mGivenInsetsReady
            // is set, we won't call into notifyControlChanged. Therefore, we can reset the
@@ -127,6 +141,7 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
                    mControlTarget);
            setImeShowing(false);
        }
        return controlDispatched;
    }

    @Nullable
+22 −9
Original line number Diff line number Diff line
@@ -366,28 +366,41 @@ class InsetsSourceProvider {
    }

    /**
     * Called when a layout pass has occurred.
     * Called before a layout pass will occur.
     */
    void onPostLayout() {
    void onPreLayout() {
        if (mWin == null) {
            return;
        }
        final boolean isServerVisible = isSurfaceVisible();
        setServerVisible(isSurfaceVisible());
    }

        final boolean serverVisibleChanged = mServerVisible != isServerVisible;
        setServerVisible(isServerVisible);
    /**
     * Called after a layout pass has occurred.
     *
     * @return {@code true} if {@link InsetsStateController#notifyControlChanged} was called or
     * was scheduled to be called within this method, else {@code false}.
     */
    boolean onPostLayout() {
        if (mWin == null) {
            return false;
        }
        if (mControl != null && mControlTarget != null) {
            final boolean positionChanged = updateInsetsControlPosition(mWin);
            if (!(positionChanged || mHasPendingPosition)
            if (positionChanged || mHasPendingPosition) {
                return true;
            }
            // The insets hint would be updated while changing the position. Here updates it
                    // for the possible change of the bounds or the server visibility.
                    && (updateInsetsHint(mControl) || serverVisibleChanged)) {
            // for the possible change of the bounds.
            if (updateInsetsHint(mControl)) {
                // Only call notifyControlChanged here when the position hasn't been or won't be
                // changed. Otherwise, it has been called or scheduled to be called during
                // updateInsetsControlPosition.
                mStateController.notifyControlChanged(mControlTarget, this);
                return true;
            }
        }
        return false;
    }

    /**
+12 −1
Original line number Diff line number Diff line
@@ -188,7 +188,18 @@ class InsetsStateController {
    }

    /**
     * Called when a layout pass has occurred.
     * Called before a layout pass will occur.
     */
    void onPreLayout() {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "ISC.onPreLayout");
        for (int i = mProviders.size() - 1; i >= 0; i--) {
            mProviders.valueAt(i).onPreLayout();
        }
        Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
    }

    /**
     * Called after a layout pass has occurred.
     */
    void onPostLayout() {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "ISC.onPostLayout");
Loading