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

Commit ad07aef2 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Prevents embedded activity relaunched twice when display rotates" into main

parents 3388ef83 7001a8aa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 =
+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());