diff options
| author | 2023-09-01 17:44:03 +0200 | |
|---|---|---|
| committer | 2023-09-05 12:49:33 +0200 | |
| commit | a4229cc58c6ef8d8dd9cd64c3aba73209edf7196 (patch) | |
| tree | 1d8e399fe0be488c1bec00ac723f39d8e335e4df | |
| parent | 5d425594bbe4f68bb866936b4d95e3445b1eef70 (diff) | |
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
3 files changed, 9 insertions, 11 deletions
diff --git a/core/java/android/inputmethodservice/NavigationBarController.java b/core/java/android/inputmethodservice/NavigationBarController.java index c01664e55744..8be4c5858694 100644 --- a/core/java/android/inputmethodservice/NavigationBarController.java +++ b/core/java/android/inputmethodservice/NavigationBarController.java @@ -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); }); diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 354b0db77382..0e63cd3ab0f1 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -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. diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java index dd90e0450280..bf86563e3d86 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java @@ -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); |