Associate starting window with task once a TF is added
Because the host activity of starting window may not be moved into TaskFragment, and the order change from WCT is outside the scope of transferring starting window. Bug: 243120073 Test: atest ActivityRecordTests#testStartingWindowInTaskFragment Change-Id: I8a052af72bf4c307e9d72e10ed47a7f8ffbdf847
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2868,6 +2868,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 */);
|
||||
@@ -2889,7 +2890,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());
|
||||
@@ -2897,7 +2897,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user