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

Commit 39c4f9d8 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce unnecessary invocation of shouldImeAttachedToApp

Is is more common that IME is invisible. And the visibility check
can be 10 times faster than shouldImeAttachedToApp.

The method needsRelativeLayeringToIme may be called hundreds of times
for assigning layer during launching an app.

Bug: 297502610
Flag: EXEMPT optimization without logic change
Test: ZOrderingTests# \
      testAssignWindowLayers_ForImeWithAppTargetWithChildWindows
Change-Id: I1ddcd07c7d5e7651580bfe76c487a4a6f56b5e76
parent 15cce63c
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -5351,7 +5351,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        outPos.y = (int) (surfaceInsets.top * mGlobalScale + 0.5f);
    }

    /**
     * Whether the layer of this window should be relatively above IME.
     * @see DisplayContent#assignRelativeLayerForImeLayeringTargetChild
     */
    boolean needsRelativeLayeringToIme() {
        if (!mDisplayContent.getImeContainer().isVisible()) {
            return false;
        }
        // We use the relative layering when IME isn't attached to the app. Such as part of
        // elevating the IME and windows above it's target above the docked divider in
        // split-screen, or make the popupMenu to be above the IME when the parent window is the
@@ -5360,13 +5367,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            return false;
        }

        // We don't need to set the window to be relatively above IME if the IME is not visible.
        // In case seeing the window is animating above the app transition layer because its
        // relative layer is above the IME container on the display area but actually not necessary.
        if (!getDisplayContent().getImeContainer().isVisible()) {
            return false;
        }

        if (isChildWindow()) {
            // If we are a child of the IME layering target we need this promotion.
            if (getParentWindow().isImeLayeringTarget()) {