Merge "Check visibility for TransitionInfo.Change FLAG_FILLS_TASK" into tm-qpr-dev

This commit is contained in:
Chris Li
2022-09-22 00:42:51 +00:00
committed by Android (Google) Code Review
2 changed files with 80 additions and 9 deletions

View File

@@ -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;
}
}
/**

View File

@@ -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;
@@ -1164,6 +1164,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);