diff options
| author | 2022-09-22 00:42:51 +0000 | |
|---|---|---|
| committer | 2022-09-22 00:42:51 +0000 | |
| commit | 284e5152e45defcd8a69a8819c77858a4b74fc66 (patch) | |
| tree | 3dda6652b55b8cc2df84fba1c6006d4e71beaf6c | |
| parent | a9f12bada8911428a0de71fa3b58327baf201379 (diff) | |
| parent | d789273731fb5a83a1a13abd37a2ee731bd043f2 (diff) | |
Merge "Check visibility for TransitionInfo.Change FLAG_FILLS_TASK" into tm-qpr-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/Transition.java | 26 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/TransitionTests.java | 63 |
2 files changed, 80 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 488fe676d265..ec7a755b5d1f 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1894,14 +1894,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; } } @@ -1923,6 +1917,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; + } } /** diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index 8cf32baa49eb..210edae62b56 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -1120,7 +1120,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; @@ -1165,6 +1165,67 @@ public class TransitionTests extends WindowTestsBase { } @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); final Task task = createTask(mDisplayContent); |