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

Commit 2af23635 authored by Charles Chen's avatar Charles Chen
Browse files

Don't assocaite starting window to task for overlay TF

Before, we always associate starting window to task for embedded TF.
Now we don't do that for overlay TF because there must be a visible
activity in a task, and we just need to show splash screen on the
overlay TF.

Test: manual - demo app
Test: atest WmTests:ActivityRecordTests
Fixes: 321881164
Flag: EXEMPT bugfix
Change-Id: Ib361b45aa3ccd71f09394b19ab38939fbf9015b9
parent 1d1a9c34
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2896,6 +2896,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                || mStartingData.mAssociatedTask != null) {
            return;
        }
        if (task.isVisible() && !task.inTransition()) {
            // Don't associated with task if the task is visible especially when the activity is
            // embedded. We just need to show splash screen on the activity in case the first frame
            // is not ready.
            return;
        }
        associateStartingDataWithTask();
        attachStartingSurfaceToAssociatedTask();
    }
+24 −1
Original line number Diff line number Diff line
@@ -2955,7 +2955,8 @@ public class ActivityRecordTests extends WindowTestsBase {

    @Test
    public void testStartingWindowInTaskFragment() {
        final ActivityRecord activity1 = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final ActivityRecord activity1 = new ActivityBuilder(mAtm).setCreateTask(true)
                .setVisible(false).build();
        final WindowState startingWindow = createWindowState(
                new WindowManager.LayoutParams(TYPE_APPLICATION_STARTING), activity1);
        activity1.addWindow(startingWindow);
@@ -3010,6 +3011,28 @@ public class ActivityRecordTests extends WindowTestsBase {
        assertNull(task.mSharedStartingData);
    }

    @Test
    public void testStartingWindowInTaskFragmentWithVisibleTask() {
        final ActivityRecord activity1 = new ActivityBuilder(mAtm).setCreateTask(true).build();
        final Task task = activity1.getTask();
        final Rect taskBounds = task.getBounds();
        final Rect tfBounds = new Rect(taskBounds.left, taskBounds.top,
                taskBounds.left + taskBounds.width() / 2, taskBounds.bottom);
        final TaskFragment taskFragment = new TaskFragmentBuilder(mAtm).setParentTask(task)
                .setBounds(tfBounds).build();

        final ActivityRecord activity2 = new ActivityBuilder(mAtm).build();
        final WindowState startingWindow = createWindowState(
                new WindowManager.LayoutParams(TYPE_APPLICATION_STARTING), activity1);
        taskFragment.addChild(activity2);
        activity2.addWindow(startingWindow);
        activity2.mStartingData = mock(StartingData.class);
        activity2.attachStartingWindow(startingWindow);

        assertNull(activity2.mStartingData.mAssociatedTask);
        assertNull(task.mSharedStartingData);
    }

    @Test
    public void testTransitionAnimationBounds() {
        removeGlobalMinSizeRestriction();