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

Commit 46ca92cc authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Do not copy local insets to IME during insets traversal

WindowState traversal will be including the IME window because of the
idea that the IME was attached to a window, and something applied to a
window state should also applied to the insets.

However, this is no longer true, also the IME doesn't rely on the target
window to calculate the insets correctly. Skip copy of local insets
sources to IME window to avoid accidental inheritance of insets from the
IME target window.

Bug: 421000153
Bug: 441434842
Test: InsetsPolicyTests
Test: Check the bug report and verify with bubble test apps
Flag: com.android.window.flags.relative_insets
Change-Id: I2a7f02573c9c313fa970594814e591666f89029e
parent 2a22330b
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -4597,9 +4597,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        final SparseArray<InsetsSource> mergedLocalInsetsSources =
                createMergedSparseArray(localInsetsSourcesFromParent, mLocalInsetsSources);

        // Insets provided by the IME window can effect all the windows below it and hence it needs
        // to be visited in the correct order. Because of which updateAboveInsetsState() can't be
        // used here and instead forAllWindows() is used.
        // ForAllWindows is the reliable way to visit the IME window and the windows within this
        // WindowState in the correct order. updateAboveInsetsState doesn't take the real order of
        // IME into account.
        forAllWindows(w -> {
            if (!w.mAboveInsetsState.equals(aboveInsetsState)) {
                w.mAboveInsetsState.set(aboveInsetsState);
@@ -4607,9 +4607,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            }

            if (!mergedLocalInsetsSources.contentEquals(w.mMergedLocalInsetsSources)) {
                // The traversal will reach IME if this window is an IME target window. However, we
                // should not copy the local insets to the IME window. The forAllWindow will reach
                // all IME containers by the logic in {@link #applyImeWindowsIfNeeded}.
                if (!w.mIsImWindow) {
                    w.mMergedLocalInsetsSources = mergedLocalInsetsSources;
                    insetsChangedWindows.add(w);
                }
            }

            final SparseArray<InsetsSourceProvider> providers = w.mInsetsSourceProviders;
            if (providers != null) {