Loading services/core/java/com/android/server/wm/TaskFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -2435,7 +2435,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { inOutConfig.smallestScreenWidthDp = (int) (0.5f + Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); } else if (windowingMode == WINDOWING_MODE_MULTI_WINDOW && mIsEmbedded && insideParentBounds && !resolvedBounds.equals(parentBounds)) { && !resolvedBounds.equals(parentBounds)) { // For embedded TFs, the smallest width should be updated. Otherwise, inherit // from the parent task would result in applications loaded wrong resource. inOutConfig.smallestScreenWidthDp = Loading services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -1049,6 +1049,28 @@ public class TaskFragmentTest extends WindowTestsBase { assertFalse(taskFragment.shouldBeVisible(null)); } @Test public void testTaskFragmentSmallestScreenWidthDp() { // Create an embedded TaskFragment in a Task. final Task task = createTask(mDisplayContent); final TaskFragment taskFragment = new TaskFragmentBuilder(mAtm) .setParentTask(task) .createActivityCount(1) .build(); final Rect taskBounds = task.getBounds(); // Making the bounds of the embedded TaskFragment smaller than the parent Task. taskFragment.setBounds(taskBounds.left, taskBounds.top, taskBounds.right / 2, taskBounds.bottom); // The swdp should be calculated via the TF bounds when it is a multi-window TF. final Configuration outConfig = new Configuration(); outConfig.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); taskFragment.computeConfigResourceOverrides(outConfig, task.getConfiguration()); assertEquals(outConfig.smallestScreenWidthDp, Math.min(outConfig.screenWidthDp, outConfig.screenHeightDp)); } private WindowState createAppWindow(ActivityRecord app, String name) { final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, app, name, 0 /* ownerId */, false /* ownerCanAddInternalSystemWindow */, new TestIWindow()); Loading Loading
services/core/java/com/android/server/wm/TaskFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -2435,7 +2435,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { inOutConfig.smallestScreenWidthDp = (int) (0.5f + Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); } else if (windowingMode == WINDOWING_MODE_MULTI_WINDOW && mIsEmbedded && insideParentBounds && !resolvedBounds.equals(parentBounds)) { && !resolvedBounds.equals(parentBounds)) { // For embedded TFs, the smallest width should be updated. Otherwise, inherit // from the parent task would result in applications loaded wrong resource. inOutConfig.smallestScreenWidthDp = Loading
services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -1049,6 +1049,28 @@ public class TaskFragmentTest extends WindowTestsBase { assertFalse(taskFragment.shouldBeVisible(null)); } @Test public void testTaskFragmentSmallestScreenWidthDp() { // Create an embedded TaskFragment in a Task. final Task task = createTask(mDisplayContent); final TaskFragment taskFragment = new TaskFragmentBuilder(mAtm) .setParentTask(task) .createActivityCount(1) .build(); final Rect taskBounds = task.getBounds(); // Making the bounds of the embedded TaskFragment smaller than the parent Task. taskFragment.setBounds(taskBounds.left, taskBounds.top, taskBounds.right / 2, taskBounds.bottom); // The swdp should be calculated via the TF bounds when it is a multi-window TF. final Configuration outConfig = new Configuration(); outConfig.windowConfiguration.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW); taskFragment.computeConfigResourceOverrides(outConfig, task.getConfiguration()); assertEquals(outConfig.smallestScreenWidthDp, Math.min(outConfig.screenWidthDp, outConfig.screenHeightDp)); } private WindowState createAppWindow(ActivityRecord app, String name) { final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, app, name, 0 /* ownerId */, false /* ownerCanAddInternalSystemWindow */, new TestIWindow()); Loading