Fixed screen decor layout frames

am: 0d83376433

Change-Id: Idd8f66c0b783add12affb0147983375ceab39e6f
This commit is contained in:
chaviw
2019-06-25 15:38:43 -07:00
committed by android-build-merger
2 changed files with 66 additions and 7 deletions

View File

@@ -1494,8 +1494,6 @@ public class DisplayPolicy {
}
sTmpRect.setEmpty();
sTmpDockedFrame.set(displayFrames.mDock);
final int displayId = displayFrames.mDisplayId;
final Rect dockFrame = displayFrames.mDock;
final int displayHeight = displayFrames.mDisplayHeight;
@@ -1508,11 +1506,13 @@ public class DisplayPolicy {
continue;
}
w.getWindowFrames().setFrames(sTmpDockedFrame /* parentFrame */,
sTmpDockedFrame /* displayFrame */, sTmpDockedFrame /* overscanFrame */,
sTmpDockedFrame /* contentFrame */, sTmpDockedFrame /* visibleFrame */,
sTmpRect /* decorFrame */, sTmpDockedFrame /* stableFrame */,
sTmpDockedFrame /* outsetFrame */);
w.getWindowFrames().setFrames(displayFrames.mUnrestricted /* parentFrame */,
displayFrames.mUnrestricted /* displayFrame */,
displayFrames.mUnrestricted /* overscanFrame */,
displayFrames.mUnrestricted /* contentFrame */,
displayFrames.mUnrestricted /* visibleFrame */, sTmpRect /* decorFrame */,
displayFrames.mUnrestricted /* stableFrame */,
displayFrames.mUnrestricted /* outsetFrame */);
w.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
w.computeFrameLw();
final Rect frame = w.getFrameLw();

View File

@@ -16,6 +16,10 @@
package com.android.server.wm;
import static android.view.Gravity.BOTTOM;
import static android.view.Gravity.LEFT;
import static android.view.Gravity.RIGHT;
import static android.view.Gravity.TOP;
import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
@@ -26,9 +30,11 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -66,6 +72,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
private WindowState mWindow;
private int mRotation = ROTATION_0;
private boolean mHasDisplayCutout;
private static final int DECOR_WINDOW_INSET = 50;
@Before
public void setUp() throws Exception {
@@ -520,6 +527,58 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
}
}
@Test
public void testScreenDecorWindows() {
synchronized (mWm.mGlobalLock) {
final WindowState decorWindow = createWindow(null, TYPE_APPLICATION_OVERLAY,
"decorWindow");
decorWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
decorWindow.mAttrs.privateFlags |= PRIVATE_FLAG_IS_SCREEN_DECOR;
addWindow(decorWindow);
addWindow(mWindow);
// Decor on top
updateDecorWindow(decorWindow, MATCH_PARENT, DECOR_WINDOW_INSET, TOP);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
assertInsetByTopBottom(mWindow.getContentFrameLw(), DECOR_WINDOW_INSET, NAV_BAR_HEIGHT);
// Decor on bottom
updateDecorWindow(decorWindow, MATCH_PARENT, DECOR_WINDOW_INSET, BOTTOM);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT,
DECOR_WINDOW_INSET);
// Decor on the left
updateDecorWindow(decorWindow, DECOR_WINDOW_INSET, MATCH_PARENT, LEFT);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
assertInsetBy(mWindow.getContentFrameLw(), DECOR_WINDOW_INSET, STATUS_BAR_HEIGHT, 0,
NAV_BAR_HEIGHT);
// Decor on the right
updateDecorWindow(decorWindow, DECOR_WINDOW_INSET, MATCH_PARENT, RIGHT);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
assertInsetBy(mWindow.getContentFrameLw(), 0, STATUS_BAR_HEIGHT, DECOR_WINDOW_INSET,
NAV_BAR_HEIGHT);
// Decor not allowed as inset
updateDecorWindow(decorWindow, DECOR_WINDOW_INSET, DECOR_WINDOW_INSET, TOP);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
}
}
private void updateDecorWindow(WindowState decorWindow, int width, int height, int gravity) {
decorWindow.mAttrs.width = width;
decorWindow.mAttrs.height = height;
decorWindow.mAttrs.gravity = gravity;
decorWindow.setRequestedSize(width, height);
}
/**
* Asserts that {@code actual} is inset by the given amounts from the full display rect.
*