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

Commit a4229cc5 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Fix IME hidden nav bar bottom insets

In some apps, when the content would fill the screen, with the code path
exercised for hiding the IME navigation bar and with the IME in floating
mode, a larger bottom inset size would be sent to the app.

This is due to an older assumption in DisplayPolicy#getImeSourceFrameProvider
that is no longer applicable now that we have the IME navigation bar in
the IME process.

This also fixes DisplayPolicyTests testImeMinimalSourceFrame and
testImeInsetsGivenContentFrame which were setting values on displayInfo
but not using these consistently, which would sometimes conflict with
the real display height and cause the test to wrongly pass.

Test: install Gboard canary, open any app with a large scroll view
  (e.g. Chrome omnibox), launch Gboard in floating mode, observe how app
  content is displayed around the bottom of the screen (not cut off)
Bug: 298162496
Change-Id: Ibda9e18182cea0860d88b43fde4579810b89463b
parent 5d425594
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ final class NavigationBarController {
                mNavigationBarFrame.setOnApplyWindowInsetsListener((view, insets) -> {
                    if (mNavigationBarFrame != null) {
                        boolean visible = insets.isVisible(captionBar());
                        mNavigationBarFrame.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
                        mNavigationBarFrame.setVisibility(visible ? View.VISIBLE : View.GONE);
                    }
                    return view.onApplyWindowInsets(insets);
                });
+3 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;

import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.inputmethodservice.InputMethodService.ENABLE_HIDE_IME_CAPTION_BAR;
import static android.view.Display.TYPE_INTERNAL;
import static android.view.InsetsFrameProvider.SOURCE_ARBITRARY_RECTANGLE;
import static android.view.InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS;
@@ -1201,8 +1202,8 @@ public class DisplayPolicy {
                throw new IllegalArgumentException("IME insets must be provided by a window.");
            }

            if (mNavigationBar != null && navigationBarPosition(displayFrames.mRotation)
                    == NAV_BAR_BOTTOM) {
            if (!ENABLE_HIDE_IME_CAPTION_BAR && mNavigationBar != null
                    && navigationBarPosition(displayFrames.mRotation) == NAV_BAR_BOTTOM) {
                // In gesture navigation, nav bar frame is larger than frame to calculate insets.
                // IME should not provide frame which is smaller than the nav bar frame. Otherwise,
                // nav bar might be overlapped with the content of the client when IME is shown.
+5 −8
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.inputmethodservice.InputMethodService.ENABLE_HIDE_IME_CAPTION_BAR;
import static android.view.DisplayCutout.NO_CUTOUT;
import static android.view.InsetsSource.ID_IME;
import static android.view.RoundedCorners.NO_ROUNDED_CORNERS;
@@ -427,11 +428,11 @@ public class DisplayPolicyTests extends WindowTestsBase {
    @SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })
    @Test
    public void testImeMinimalSourceFrame() {
        Assume.assumeFalse("Behavior no longer needed with ENABLE_HIDE_IME_CAPTION_BAR",
                ENABLE_HIDE_IME_CAPTION_BAR);

        final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
        final DisplayInfo displayInfo = new DisplayInfo();
        displayInfo.logicalWidth = 1000;
        displayInfo.logicalHeight = 2000;
        displayInfo.rotation = ROTATION_0;
        final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();

        WindowManager.LayoutParams attrs = mNavBarWindow.mAttrs;
        displayPolicy.addWindowLw(mNavBarWindow, attrs);
@@ -466,10 +467,6 @@ public class DisplayPolicyTests extends WindowTestsBase {
    @Test
    public void testImeInsetsGivenContentFrame() {
        final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
        final DisplayInfo displayInfo = new DisplayInfo();
        displayInfo.logicalWidth = 1000;
        displayInfo.logicalHeight = 2000;
        displayInfo.rotation = ROTATION_0;

        mDisplayContent.setInputMethodWindowLocked(mImeWindow);
        mImeWindow.getControllableInsetProvider().setServerVisible(true);