diff options
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskFragment.java | 2 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index e07b54b1e8ae..29e82f7fe88f 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -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 = diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java index 47d34a6e5f2b..3c247a03d744 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java @@ -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()); |