Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7001a8aa authored by Louis Chang's avatar Louis Chang
Browse files

Prevents embedded activity relaunched twice when display rotates

The activity was relaunched when the display rotated because the
TF bounds were not inside the parent Task bounds at the moment,
so the swdp was changed (inherited from the parent Task).

And then the activity relaunched again due to the embedded TF bounds
were updated by the TFOrganizer afterward.

Note that the insets may still change while the display rotates,
and making the pre-V activities bounds changed and relaunched,
with another activity relaunch followed due to embedded TF bounds
change.

Bug: 294389608
Flag: EXEMPT bugfix
Test: atest WmTests:TaskFragmentTest

Change-Id: I26934398a8d41ba9fe791e485cf6983f47863f9f
parent 2bebdf21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2436,7 +2436,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 =
+22 −0
Original line number Diff line number Diff line
@@ -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());