diff options
| -rw-r--r-- | core/java/android/view/InsetsSource.java | 6 | ||||
| -rw-r--r-- | core/tests/coretests/src/android/view/InsetsSourceTest.java | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/core/java/android/view/InsetsSource.java b/core/java/android/view/InsetsSource.java index 2f40bdbff05f..5f2bccc8b857 100644 --- a/core/java/android/view/InsetsSource.java +++ b/core/java/android/view/InsetsSource.java @@ -140,7 +140,11 @@ public class InsetsSource implements Parcelable { if (getType() == ITYPE_CAPTION_BAR) { return Insets.of(0, frame.height(), 0, 0); } - if (!getIntersection(frame, relativeFrame, mTmpFrame)) { + // Checks for whether there is shared edge with insets for 0-width/height window. + final boolean hasIntersection = relativeFrame.isEmpty() + ? getIntersection(frame, relativeFrame, mTmpFrame) + : mTmpFrame.setIntersect(frame, relativeFrame); + if (!hasIntersection) { return Insets.NONE; } diff --git a/core/tests/coretests/src/android/view/InsetsSourceTest.java b/core/tests/coretests/src/android/view/InsetsSourceTest.java index c61f33e15b18..2106b4bc5be9 100644 --- a/core/tests/coretests/src/android/view/InsetsSourceTest.java +++ b/core/tests/coretests/src/android/view/InsetsSourceTest.java @@ -169,6 +169,13 @@ public class InsetsSourceTest { } @Test + public void testCalculateInsetsForIme_noIntersection_horizontal() { + mImeSource.setFrame(new Rect(0, 0, 100, 500)); + Insets insets = mImeSource.calculateInsets(new Rect(100, 0, 500, 500), false); + assertEquals(Insets.NONE, insets); + } + + @Test public void testCalculateInsets_zeroWidthIntersection_horizontal_start() { mSource.setFrame(new Rect(0, 0, 100, 500)); Insets insets = mSource.calculateInsets(new Rect(0, 0, 500, 0), false); |