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

Commit c886a83e authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

Merge "Check visibility for TransitionInfo.Change FLAG_FILLS_TASK" into...

Merge "Check visibility for TransitionInfo.Change FLAG_FILLS_TASK" into tm-qpr-dev am: 284e5152 am: f74753cc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19992908



Change-Id: I7b762deb7c4b990bfb1f8b6dca170378ca7a80ce
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4c3efb78 f74753cc
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -1860,14 +1860,8 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
                    // Whether this is in a Task with embedded activity.
                    flags |= FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
                }
                final Rect taskBounds = parentTask.getBounds();
                final Rect startBounds = mAbsoluteBounds;
                final Rect endBounds = wc.getBounds();
                if (taskBounds.width() == startBounds.width()
                        && taskBounds.height() == startBounds.height()
                        && taskBounds.width() == endBounds.width()
                        && taskBounds.height() == endBounds.height()) {
                    // Whether the container fills the Task bounds before and after the transition.
                if (isWindowFillingTask(wc, parentTask)) {
                    // Whether the container fills its parent Task bounds.
                    flags |= FLAG_FILLS_TASK;
                }
            }
@@ -1889,6 +1883,22 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
            }
            return flags;
        }

        /** Whether the container fills its parent Task bounds before and after the transition. */
        private boolean isWindowFillingTask(@NonNull WindowContainer wc, @NonNull Task parentTask) {
            final Rect taskBounds = parentTask.getBounds();
            final int taskWidth = taskBounds.width();
            final int taskHeight = taskBounds.height();
            final Rect startBounds = mAbsoluteBounds;
            final Rect endBounds = wc.getBounds();
            // Treat it as filling the task if it is not visible.
            final boolean isInvisibleOrFillingTaskBeforeTransition = !mVisible
                    || (taskWidth == startBounds.width() && taskHeight == startBounds.height());
            final boolean isInVisibleOrFillingTaskAfterTransition = !wc.isVisibleRequested()
                    || (taskWidth == endBounds.width() && taskHeight == endBounds.height());
            return isInvisibleOrFillingTaskBeforeTransition
                    && isInVisibleOrFillingTaskAfterTransition;
        }
    }

    /**
+62 −1
Original line number Diff line number Diff line
@@ -1123,7 +1123,7 @@ public class TransitionTests extends WindowTestsBase {
    }

    @Test
    public void testFlagFillsTask() {
    public void testFlagFillsTask_embeddingNotFillingTask() {
        final Transition transition = createTestTransition(TRANSIT_OPEN);
        final ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
        final ArraySet<WindowContainer> participants = transition.mParticipants;
@@ -1167,6 +1167,67 @@ public class TransitionTests extends WindowTestsBase {
        assertFalse(info.getChanges().get(1).hasFlags(FLAG_FILLS_TASK));
    }

    @Test
    public void testFlagFillsTask_openActivityFillingTask() {
        final Transition transition = createTestTransition(TRANSIT_OPEN);
        final ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
        final ArraySet<WindowContainer> participants = transition.mParticipants;

        final Task task = createTask(mDisplayContent);
        // Set to multi-windowing mode in order to set bounds.
        task.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
        final Rect taskBounds = new Rect(0, 0, 500, 1000);
        task.setBounds(taskBounds);
        final ActivityRecord activity = createActivityRecord(task);
        // Start states: set bounds to make sure the start bounds is ignored if it is not visible.
        activity.getConfiguration().windowConfiguration.setBounds(new Rect(0, 0, 250, 500));
        activity.mVisibleRequested = false;
        changes.put(activity, new Transition.ChangeInfo(activity));
        // End states: reset bounds to fill Task.
        activity.getConfiguration().windowConfiguration.setBounds(taskBounds);
        activity.mVisibleRequested = true;

        participants.add(activity);
        final ArrayList<WindowContainer> targets = Transition.calculateTargets(
                participants, changes);
        final TransitionInfo info = Transition.calculateTransitionInfo(
                transition.mType, 0 /* flags */, targets, changes, mMockT);

        // Opening activity that is filling Task after transition should have the flag.
        assertEquals(1, info.getChanges().size());
        assertTrue(info.getChanges().get(0).hasFlags(FLAG_FILLS_TASK));
    }

    @Test
    public void testFlagFillsTask_closeActivityFillingTask() {
        final Transition transition = createTestTransition(TRANSIT_CLOSE);
        final ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
        final ArraySet<WindowContainer> participants = transition.mParticipants;

        final Task task = createTask(mDisplayContent);
        // Set to multi-windowing mode in order to set bounds.
        task.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
        final Rect taskBounds = new Rect(0, 0, 500, 1000);
        task.setBounds(taskBounds);
        final ActivityRecord activity = createActivityRecord(task);
        // Start states: fills Task without override.
        activity.mVisibleRequested = true;
        changes.put(activity, new Transition.ChangeInfo(activity));
        // End states: set bounds to make sure the start bounds is ignored if it is not visible.
        activity.getConfiguration().windowConfiguration.setBounds(new Rect(0, 0, 250, 500));
        activity.mVisibleRequested = false;

        participants.add(activity);
        final ArrayList<WindowContainer> targets = Transition.calculateTargets(
                participants, changes);
        final TransitionInfo info = Transition.calculateTransitionInfo(
                transition.mType, 0 /* flags */, targets, changes, mMockT);

        // Closing activity that is filling Task before transition should have the flag.
        assertEquals(1, info.getChanges().size());
        assertTrue(info.getChanges().get(0).hasFlags(FLAG_FILLS_TASK));
    }

    @Test
    public void testIncludeEmbeddedActivityReparent() {
        final Transition transition = createTestTransition(TRANSIT_OPEN);