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

Commit 2952f2cf authored by Garfield Tan's avatar Garfield Tan
Browse files

Only save launch params for leaf tasks.

It doesn't happen in R because back then ActivityStack inherits from
Task and we pass ActivityInfo to it when it's created so setIntent() is
called and Task#realActivity isn't null.

Bug: 178789502
Test: System won't crash when setting display windowing mode.
Test: atest TaskRecordTests with no new failures.
Change-Id: I29adf18700a85593a80d08cf5be998542a97fc51
parent 40517bbf
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -921,10 +921,8 @@ class Task extends WindowContainer<WindowContainer> {
            return;
        }

        if (isLeafTask()) {
        // This task is going away, so save the last state if necessary.
        saveLaunchingStateIfNeeded(((WindowContainer) oldParent).getDisplayContent());
        }

        // TODO: VI what about activity?
        final boolean isVoiceSession = voiceSession != null;
@@ -2474,14 +2472,16 @@ class Task extends WindowContainer<WindowContainer> {

    /**
     * Saves launching state if necessary so that we can launch the activity to its latest state.
     * It only saves state if this task has been shown to user and it's in fullscreen or freeform
     * mode on freeform displays.
     */
    private void saveLaunchingStateIfNeeded() {
        saveLaunchingStateIfNeeded(getDisplayContent());
    }

    private void saveLaunchingStateIfNeeded(DisplayContent display) {
        if (!isLeafTask()) {
            return;
        }

        if (!getHasBeenVisible()) {
            // Not ever visible to user.
            return;
+20 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,26 @@ public class TaskRecordTests extends WindowTestsBase {
        verify(persister, never()).saveTask(same(task), any());
    }

    @Test
    public void testNotSaveLaunchingStateForNonLeafTask() {
        LaunchParamsPersister persister = mAtm.mTaskSupervisor.mLaunchParamsPersister;
        spyOn(persister);

        final Task task = getTestTask();
        task.setHasBeenVisible(false);
        task.getDisplayContent().setDisplayWindowingMode(WINDOWING_MODE_FREEFORM);
        task.getRootTask().setWindowingMode(WINDOWING_MODE_FULLSCREEN);

        final Task leafTask = createTaskInStack(task, 0 /* userId */);

        leafTask.setHasBeenVisible(true);
        task.setHasBeenVisible(true);
        task.onConfigurationChanged(task.getParent().getConfiguration());

        verify(persister, never()).saveTask(same(task), any());
        verify(persister).saveTask(same(leafTask), any());
    }

    @Test
    public void testNotSpecifyOrientationByFloatingTask() {
        final Task task = new TaskBuilder(mSupervisor)