From a2e8e229719aa0d3ff0aa8bd50b56fd569628ca5 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Tue, 19 Apr 2022 17:13:22 +0900 Subject: [PATCH] [DO NOT MERGE] Force extra nav bar provide side gesture insets This is a patch to fix the missing gesture insets issue when there's a task bar and no navigation bar on the display. It will try to add the gesture navigation insets when a window providing navigation bar insets is added and there's no window with TYPE_NAVIGATION_BAR. The logic will only be applied when the insets is not flexible. Due to the removal of the old hard-coded logic in the later version, this patch should not be merged into the next version. The final fix will not be on tm-dev to keep tm-dev stable. Cherry-pick the hard-coded solution to avoid failures related to IME. Bug: 231959399 Bug: 229805460 Bug: 232044523 Test: android.widget.cts.SeekBarTest#testSetOnSeekBarChangeListener Change-Id: I080df3547361aef1aa259dd2b3dc9bdb860a0193 (cherry picked from commit 1921f8c1dc660851a499c5dac5a55cedf854f93e) --- .../com/android/server/wm/DisplayPolicy.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 442f70846118a..7e91989a9105b 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -1231,6 +1231,29 @@ public class DisplayPolicy { } inOutFrame.inset(win.mGivenContentInsets); } : null, imeFrameProvider); + if (mNavigationBar == null && (insetsType == ITYPE_NAVIGATION_BAR + || insetsType == ITYPE_EXTRA_NAVIGATION_BAR)) { + mDisplayContent.setInsetProvider(ITYPE_LEFT_GESTURES, win, + (displayFrames, windowState, inOutFrame) -> { + final int leftSafeInset = + Math.max(displayFrames.mDisplayCutoutSafe.left,0); + inOutFrame.left = 0; + inOutFrame.top = 0; + inOutFrame.bottom = displayFrames.mDisplayHeight; + inOutFrame.right = + leftSafeInset + mLeftGestureInset; + }); + mDisplayContent.setInsetProvider(ITYPE_RIGHT_GESTURES, win, + (displayFrames, windowState, inOutFrame) -> { + final int rightSafeInset = + Math.min(displayFrames.mDisplayCutoutSafe.right, + displayFrames.mUnrestricted.right); + inOutFrame.left = rightSafeInset - mRightGestureInset; + inOutFrame.top = 0; + inOutFrame.bottom = displayFrames.mDisplayHeight; + inOutFrame.right = displayFrames.mDisplayWidth; + }); + } mInsetsSourceWindowsExceptIme.add(win); } }