Use IFP only for non-IME window insets providers
With the flexible insets change, it is now not possible the window is providng insets but without a InsetsFrameProvider. The calculation of the givenContentInsets is already included in the InsetsFrameProvider and it is not longer necessary to calculate it in updateSourceFrame any more. For IME cases, the IME is provider its own frame provider to calculate insets size with considering of the givenContentInsets. No extra calculation needed in the general InsetsSourceProvider as well. Tests are modified. The tests were using navigation bar to test the mGivenContentInsets related logic. Since it will not really happen in the production environment, modified the test to use IME window to verify the logic, and cover the ImeSourceProvider related code. Because the given content insets only in effect with the process of DisplayPolicy, and is covered by the modified test is DisplayPolicyTests, removing the other out-dated tests. Test: DisplayPolicyTests Test: DisplayPolicyInsetsTests Bug: 274723551 Change-Id: I2a6828255a336fdf0d5b6c1281daff1cec02a7eb
This commit is contained in:
@@ -1122,7 +1122,6 @@ public class DisplayPolicy {
|
||||
inOutFrame.set(windowContainer.getBounds());
|
||||
break;
|
||||
case SOURCE_FRAME:
|
||||
inOutFrame.inset(win.mGivenContentInsets);
|
||||
extendByCutout =
|
||||
(lp.privateFlags & PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT) != 0;
|
||||
break;
|
||||
|
||||
@@ -218,8 +218,6 @@ class InsetsSourceProvider {
|
||||
if (mFrameProvider != null) {
|
||||
mFrameProvider.accept(mWindowContainer.getDisplayContent().mDisplayFrames,
|
||||
mWindowContainer, mSourceFrame);
|
||||
} else {
|
||||
mSourceFrame.inset(win.mGivenContentInsets);
|
||||
}
|
||||
updateSourceFrameForServerVisibility();
|
||||
|
||||
|
||||
@@ -428,8 +428,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
boolean mGivenInsetsPending;
|
||||
|
||||
/**
|
||||
* These are the content insets that were given during layout for
|
||||
* this window, to be applied to windows behind it.
|
||||
* These are the content insets that were given during layout for this window, to be applied to
|
||||
* windows behind it.
|
||||
* This is only applied to IME windows when corresponding process in DisplayPolicy executed.
|
||||
*/
|
||||
final Rect mGivenContentInsets = new Rect();
|
||||
|
||||
|
||||
@@ -352,27 +352,28 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
||||
assertTrue(imeSource.getFrame().contains(navBarSource.getFrame()));
|
||||
}
|
||||
|
||||
@SetupWindows(addWindows = W_NAVIGATION_BAR)
|
||||
@SetupWindows(addWindows = W_INPUT_METHOD)
|
||||
@Test
|
||||
public void testInsetsGivenContentFrame() {
|
||||
public void testImeInsetsGivenContentFrame() {
|
||||
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||
final DisplayInfo displayInfo = new DisplayInfo();
|
||||
displayInfo.logicalWidth = 1000;
|
||||
displayInfo.logicalHeight = 2000;
|
||||
displayInfo.rotation = ROTATION_0;
|
||||
|
||||
WindowManager.LayoutParams attrs = mNavBarWindow.mAttrs;
|
||||
displayPolicy.addWindowLw(mNavBarWindow, attrs);
|
||||
mNavBarWindow.setRequestedSize(attrs.width, attrs.height);
|
||||
mNavBarWindow.getControllableInsetProvider().setServerVisible(true);
|
||||
mDisplayContent.setInputMethodWindowLocked(mImeWindow);
|
||||
mImeWindow.getControllableInsetProvider().setServerVisible(true);
|
||||
|
||||
mNavBarWindow.mGivenContentInsets.set(0, 10, 0, 0);
|
||||
mImeWindow.mGivenContentInsets.set(0, 10, 0, 0);
|
||||
|
||||
displayPolicy.layoutWindowLw(mNavBarWindow, null, mDisplayContent.mDisplayFrames);
|
||||
displayPolicy.layoutWindowLw(mImeWindow, null, mDisplayContent.mDisplayFrames);
|
||||
final InsetsState state = mDisplayContent.getInsetsStateController().getRawInsetsState();
|
||||
final InsetsSource navBarSource = state.peekSource(
|
||||
mNavBarWindow.getControllableInsetProvider().getSource().getId());
|
||||
assertEquals(attrs.height - 10, navBarSource.getFrame().height());
|
||||
final InsetsSource imeSource = state.peekSource(ID_IME);
|
||||
|
||||
assertNotNull(imeSource);
|
||||
assertFalse(imeSource.getFrame().isEmpty());
|
||||
assertEquals(mImeWindow.getWindowFrames().mFrame.height() - 10,
|
||||
imeSource.getFrame().height());
|
||||
}
|
||||
|
||||
@SetupWindows(addWindows = { W_ACTIVITY, W_NAVIGATION_BAR })
|
||||
|
||||
@@ -75,25 +75,6 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
mProvider.getSource().calculateVisibleInsets(new Rect(0, 0, 500, 500)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostLayout_givenInsets() {
|
||||
final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime");
|
||||
ime.getFrame().set(0, 0, 500, 100);
|
||||
ime.mGivenContentInsets.set(0, 0, 0, 60);
|
||||
ime.mGivenVisibleInsets.set(0, 0, 0, 75);
|
||||
ime.mHasSurface = true;
|
||||
mProvider.setWindowContainer(ime, null, null);
|
||||
mProvider.updateSourceFrame(ime.getFrame());
|
||||
mProvider.onPostLayout();
|
||||
assertEquals(new Rect(0, 0, 500, 40), mProvider.getSource().getFrame());
|
||||
assertEquals(new Rect(0, 0, 500, 25), mProvider.getSource().getVisibleFrame());
|
||||
assertEquals(Insets.of(0, 40, 0, 0),
|
||||
mProvider.getSource().calculateInsets(new Rect(0, 0, 500, 500),
|
||||
false /* ignoreVisibility */));
|
||||
assertEquals(Insets.of(0, 25, 0, 0),
|
||||
mProvider.getSource().calculateVisibleInsets(new Rect(0, 0, 500, 500)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostLayout_invisible() {
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
|
||||
Reference in New Issue
Block a user