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

Commit 6e581904 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Associate starting window with task once a TF is added" into tm-qpr-dev am: e99311a4

parents 6dc609bd e99311a4
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -1582,13 +1582,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        if (newParent != null && isState(RESUMED)) {
            newParent.setResumedActivity(this, "onParentChanged");
            if (mStartingWindow != null && mStartingData != null
                    && mStartingData.mAssociatedTask == null && newParent.isEmbedded()) {
                // The starting window should keep covering its task when the activity is
                // reparented to a task fragment that may not fill the task bounds.
                associateStartingDataWithTask();
                attachStartingSurfaceToAssociatedTask();
            }
            mImeInsetsFrozenUntilStartInput = false;
        }

@@ -2679,14 +2672,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
    }

    /** Called when the starting window is added to this activity. */
    void attachStartingWindow(@NonNull WindowState startingWindow) {
        startingWindow.mStartingData = mStartingData;
        mStartingWindow = startingWindow;
        // The snapshot type may have called associateStartingDataWithTask().
        if (mStartingData != null && mStartingData.mAssociatedTask != null) {
            attachStartingSurfaceToAssociatedTask();
        }
    }

    /** Makes starting window always fill the associated task. */
    private void attachStartingSurfaceToAssociatedTask() {
        // Associate the configuration of starting window with the task.
        overrideConfigurationPropagation(mStartingWindow, mStartingData.mAssociatedTask);
@@ -2694,6 +2690,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mStartingData.mAssociatedTask.mSurfaceControl);
    }

    /** Called when the starting window is not added yet but its data is known to fill the task. */
    private void associateStartingDataWithTask() {
        mStartingData.mAssociatedTask = task;
        task.forAllActivities(r -> {
@@ -2703,6 +2700,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        });
    }

    /** Associates and attaches an added starting window to the current task. */
    void associateStartingWindowWithTaskIfNeeded() {
        if (mStartingWindow == null || mStartingData == null
                || mStartingData.mAssociatedTask != null) {
            return;
        }
        associateStartingDataWithTask();
        attachStartingSurfaceToAssociatedTask();
    }

    void removeStartingWindow() {
        boolean prevEligibleForLetterboxEducation = isEligibleForLetterboxEducation();

+7 −0
Original line number Diff line number Diff line
@@ -1433,6 +1433,13 @@ class Task extends TaskFragment {
        final TaskFragment childTaskFrag = child.asTaskFragment();
        if (childTaskFrag != null && childTaskFrag.asTask() == null) {
            childTaskFrag.setMinDimensions(mMinWidth, mMinHeight);

            // The starting window should keep covering its task when a pure TaskFragment is added
            // because its bounds may not fill the task.
            final ActivityRecord top = getTopMostActivity();
            if (top != null) {
                top.associateStartingWindowWithTaskIfNeeded();
            }
        }
    }

+1 −2
Original line number Diff line number Diff line
@@ -2871,6 +2871,7 @@ public class ActivityRecordTests extends WindowTestsBase {
                mAtm, null /* fragmentToken */, false /* createdByOrganizer */);
        fragmentSetup.accept(taskFragment1, new Rect(0, 0, width / 2, height));
        task.addChild(taskFragment1, POSITION_TOP);
        assertEquals(task, activity1.mStartingData.mAssociatedTask);

        final TaskFragment taskFragment2 = new TaskFragment(
                mAtm, null /* fragmentToken */, false /* createdByOrganizer */);
@@ -2892,7 +2893,6 @@ public class ActivityRecordTests extends WindowTestsBase {
                eq(task.mSurfaceControl));
        assertEquals(activity1.mStartingData, startingWindow.mStartingData);
        assertEquals(task.mSurfaceControl, startingWindow.getAnimationLeashParent());
        assertEquals(task, activity1.mStartingData.mAssociatedTask);
        assertEquals(taskFragment1.getBounds(), activity1.getBounds());
        // The activity was resized by task fragment, but starting window must still cover the task.
        assertEquals(taskBounds, activity1.mStartingWindow.getBounds());
@@ -2900,7 +2900,6 @@ public class ActivityRecordTests extends WindowTestsBase {
        // The starting window is only removed when all embedded activities are drawn.
        final WindowState activityWindow = mock(WindowState.class);
        activity1.onFirstWindowDrawn(activityWindow);
        assertNotNull(activity1.mStartingWindow);
        activity2.onFirstWindowDrawn(activityWindow);
        assertNull(activity1.mStartingWindow);
    }