Merge "Update config according to insets of status bar" into udc-dev am: 99491ef5a2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22842018 Change-Id: I5a6e5a7661dd001ed6b01ec2bd76a2782d369084 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1882,6 +1882,12 @@ public class DisplayPolicy {
|
|||||||
|
|
||||||
static final int DECOR_TYPES = Type.displayCutout() | Type.navigationBars();
|
static final int DECOR_TYPES = Type.displayCutout() | Type.navigationBars();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The types that may affect display configuration. This excludes cutout because it is
|
||||||
|
* known from display info.
|
||||||
|
*/
|
||||||
|
static final int CONFIG_TYPES = Type.statusBars() | Type.navigationBars();
|
||||||
|
|
||||||
private final DisplayContent mDisplayContent;
|
private final DisplayContent mDisplayContent;
|
||||||
private final Info[] mInfoForRotation = new Info[4];
|
private final Info[] mInfoForRotation = new Info[4];
|
||||||
final Info mTmpInfo = new Info();
|
final Info mTmpInfo = new Info();
|
||||||
@@ -1921,7 +1927,7 @@ public class DisplayPolicy {
|
|||||||
final DecorInsets.Info newInfo = mDecorInsets.mTmpInfo;
|
final DecorInsets.Info newInfo = mDecorInsets.mTmpInfo;
|
||||||
newInfo.update(mDisplayContent, rotation, dw, dh);
|
newInfo.update(mDisplayContent, rotation, dw, dh);
|
||||||
final DecorInsets.Info currentInfo = getDecorInsetsInfo(rotation, dw, dh);
|
final DecorInsets.Info currentInfo = getDecorInsetsInfo(rotation, dw, dh);
|
||||||
if (newInfo.mNonDecorFrame.equals(currentInfo.mNonDecorFrame)) {
|
if (newInfo.mConfigFrame.equals(currentInfo.mConfigFrame)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mDecorInsets.invalidate();
|
mDecorInsets.invalidate();
|
||||||
|
|||||||
@@ -1831,7 +1831,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
boolean needToSendNewConfiguration =
|
boolean needToSendNewConfiguration =
|
||||||
win.isVisibleRequestedOrAdding() && displayContent.updateOrientation();
|
win.isVisibleRequestedOrAdding() && displayContent.updateOrientation();
|
||||||
if (win.providesNonDecorInsets()) {
|
if (win.providesDisplayDecorInsets()) {
|
||||||
needToSendNewConfiguration |= displayPolicy.updateDecorInsetsInfo();
|
needToSendNewConfiguration |= displayPolicy.updateDecorInsetsInfo();
|
||||||
}
|
}
|
||||||
if (needToSendNewConfiguration) {
|
if (needToSendNewConfiguration) {
|
||||||
@@ -2274,7 +2274,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
& WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED) != 0) {
|
& WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED) != 0) {
|
||||||
win.mLayoutNeeded = true;
|
win.mLayoutNeeded = true;
|
||||||
}
|
}
|
||||||
if (layoutChanged && win.providesNonDecorInsets()) {
|
if (layoutChanged && win.providesDisplayDecorInsets()) {
|
||||||
configChanged = displayPolicy.updateDecorInsetsInfo();
|
configChanged = displayPolicy.updateDecorInsetsInfo();
|
||||||
}
|
}
|
||||||
if (win.mActivityRecord != null && ((flagChanges & FLAG_SHOW_WHEN_LOCKED) != 0
|
if (win.mActivityRecord != null && ((flagChanges & FLAG_SHOW_WHEN_LOCKED) != 0
|
||||||
|
|||||||
@@ -1834,13 +1834,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
return (mPolicyVisibility & POLICY_VISIBILITY_ALL) == POLICY_VISIBILITY_ALL;
|
return (mPolicyVisibility & POLICY_VISIBILITY_ALL) == POLICY_VISIBILITY_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean providesNonDecorInsets() {
|
boolean providesDisplayDecorInsets() {
|
||||||
if (mInsetsSourceProviders == null) {
|
if (mInsetsSourceProviders == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = mInsetsSourceProviders.size() - 1; i >= 0; i--) {
|
for (int i = mInsetsSourceProviders.size() - 1; i >= 0; i--) {
|
||||||
final InsetsSource source = mInsetsSourceProviders.valueAt(i).getSource();
|
final InsetsSource source = mInsetsSourceProviders.valueAt(i).getSource();
|
||||||
if (source.getType() == WindowInsets.Type.navigationBars()) {
|
if ((source.getType() & DisplayPolicy.DecorInsets.CONFIG_TYPES) != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2507,13 +2507,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if window provides non decor insets before clearing its provided insets.
|
// Check if window provides non decor insets before clearing its provided insets.
|
||||||
final boolean windowProvidesNonDecorInsets = providesNonDecorInsets();
|
final boolean windowProvidesDisplayDecorInsets = providesDisplayDecorInsets();
|
||||||
|
|
||||||
removeImmediately();
|
removeImmediately();
|
||||||
// Removing a visible window may affect the display orientation so just update it if
|
// Removing a visible window may affect the display orientation so just update it if
|
||||||
// needed. Also recompute configuration if it provides screen decor insets.
|
// needed. Also recompute configuration if it provides screen decor insets.
|
||||||
boolean needToSendNewConfiguration = wasVisible && displayContent.updateOrientation();
|
boolean needToSendNewConfiguration = wasVisible && displayContent.updateOrientation();
|
||||||
if (windowProvidesNonDecorInsets) {
|
if (windowProvidesDisplayDecorInsets) {
|
||||||
needToSendNewConfiguration |=
|
needToSendNewConfiguration |=
|
||||||
displayContent.getDisplayPolicy().updateDecorInsetsInfo();
|
displayContent.getDisplayPolicy().updateDecorInsetsInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3124,7 +3124,7 @@ public class ActivityRecordTests extends WindowTestsBase {
|
|||||||
.setSystemDecorations(true).build();
|
.setSystemDecorations(true).build();
|
||||||
// Add a decor insets provider window.
|
// Add a decor insets provider window.
|
||||||
final WindowState navbar = createNavBarWithProvidedInsets(squareDisplay);
|
final WindowState navbar = createNavBarWithProvidedInsets(squareDisplay);
|
||||||
assertTrue(navbar.providesNonDecorInsets()
|
assertTrue(navbar.providesDisplayDecorInsets()
|
||||||
&& squareDisplay.getDisplayPolicy().updateDecorInsetsInfo());
|
&& squareDisplay.getDisplayPolicy().updateDecorInsetsInfo());
|
||||||
squareDisplay.sendNewConfiguration();
|
squareDisplay.sendNewConfiguration();
|
||||||
final Task task = new TaskBuilder(mSupervisor).setDisplay(squareDisplay).build();
|
final Task task = new TaskBuilder(mSupervisor).setDisplay(squareDisplay).build();
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ import static org.junit.Assert.assertNotEquals;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -298,20 +300,27 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDisplayConfigurationByDecor() {
|
public void testUpdateDisplayConfigurationByDecor() {
|
||||||
|
doReturn(NO_CUTOUT).when(mDisplayContent).calculateDisplayCutoutForRotation(anyInt());
|
||||||
final WindowState navbar = createNavBarWithProvidedInsets(mDisplayContent);
|
final WindowState navbar = createNavBarWithProvidedInsets(mDisplayContent);
|
||||||
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
|
||||||
final DisplayInfo di = mDisplayContent.getDisplayInfo();
|
final DisplayInfo di = mDisplayContent.getDisplayInfo();
|
||||||
final int prevScreenHeightDp = mDisplayContent.getConfiguration().screenHeightDp;
|
final int prevScreenHeightDp = mDisplayContent.getConfiguration().screenHeightDp;
|
||||||
assertTrue(navbar.providesNonDecorInsets() && displayPolicy.updateDecorInsetsInfo());
|
assertTrue(navbar.providesDisplayDecorInsets() && displayPolicy.updateDecorInsetsInfo());
|
||||||
assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
|
assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
|
||||||
di.logicalWidth, di.logicalHeight).mConfigInsets.bottom);
|
di.logicalWidth, di.logicalHeight).mConfigInsets.bottom);
|
||||||
mDisplayContent.sendNewConfiguration();
|
mDisplayContent.sendNewConfiguration();
|
||||||
assertNotEquals(prevScreenHeightDp, mDisplayContent.getConfiguration().screenHeightDp);
|
assertNotEquals(prevScreenHeightDp, mDisplayContent.getConfiguration().screenHeightDp);
|
||||||
assertFalse(navbar.providesNonDecorInsets() && displayPolicy.updateDecorInsetsInfo());
|
assertFalse(navbar.providesDisplayDecorInsets() && displayPolicy.updateDecorInsetsInfo());
|
||||||
|
|
||||||
navbar.removeIfPossible();
|
navbar.removeIfPossible();
|
||||||
assertEquals(0, displayPolicy.getDecorInsetsInfo(di.rotation, di.logicalWidth,
|
assertEquals(0, displayPolicy.getDecorInsetsInfo(di.rotation, di.logicalWidth,
|
||||||
di.logicalHeight).mNonDecorInsets.bottom);
|
di.logicalHeight).mNonDecorInsets.bottom);
|
||||||
|
|
||||||
|
final WindowState statusBar = createStatusBarWithProvidedInsets(mDisplayContent);
|
||||||
|
assertTrue(statusBar.providesDisplayDecorInsets()
|
||||||
|
&& displayPolicy.updateDecorInsetsInfo());
|
||||||
|
assertEquals(STATUS_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
|
||||||
|
di.logicalWidth, di.logicalHeight).mConfigInsets.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })
|
@SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })
|
||||||
|
|||||||
@@ -471,6 +471,17 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
return navbar;
|
return navbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WindowState createStatusBarWithProvidedInsets(DisplayContent dc) {
|
||||||
|
final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, dc, "statusBar");
|
||||||
|
final Binder owner = new Binder();
|
||||||
|
statusBar.mAttrs.providedInsets = new InsetsFrameProvider[] {
|
||||||
|
new InsetsFrameProvider(owner, 0, WindowInsets.Type.statusBars())
|
||||||
|
.setInsetsSize(Insets.of(0, STATUS_BAR_HEIGHT, 0, 0))
|
||||||
|
};
|
||||||
|
dc.getDisplayPolicy().addWindowLw(statusBar, statusBar.mAttrs);
|
||||||
|
return statusBar;
|
||||||
|
}
|
||||||
|
|
||||||
WindowState createAppWindow(Task task, int type, String name) {
|
WindowState createAppWindow(Task task, int type, String name) {
|
||||||
final ActivityRecord activity = createNonAttachedActivityRecord(task.getDisplayContent());
|
final ActivityRecord activity = createNonAttachedActivityRecord(task.getDisplayContent());
|
||||||
task.addChild(activity, 0);
|
task.addChild(activity, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user