Fix non-zero window inset

We support 0-width/height window to get shared edge with inset for
b/150696052, but we should limit that to only 0-width/height window.

This will fix the issue that in a dual-display device, when the ime is
only shown on one display, the app on the other display shouldn't get
the inset.

Bug: 175779509
Test: atest InsetsSourceTest
Change-Id: I3c73278a082b084e36be8241c20fa89fb00e405a
This commit is contained in:
Chris Li
2021-02-17 10:59:52 -08:00
parent e3ca0e420c
commit 418acc10ae
2 changed files with 12 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -168,6 +168,13 @@ public class InsetsSourceTest {
assertEquals(Insets.NONE, insets);
}
@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));