Fix incorrect animation direction for closing TaskFragment

Before, we only recorded the organizer override bounds when there is a
bounds change WCT, but missed the initial bounds set when creating the
TaskFragment. Now, we also record the initial bounds.

Also add a log for case when the organizer is removed before the
animation is played.

Fix: 264980267
Test: atest WmTests:TaskFragmentOrganizerControllerTest
Change-Id: I3585747a009b9a655b3a8bed7d62edea3ec90041
This commit is contained in:
Chris Li
2023-01-12 15:16:42 +08:00
parent c5978eaf77
commit 1a9ba51731
3 changed files with 40 additions and 3 deletions

View File

@@ -540,9 +540,12 @@ public class TaskFragmentOrganizerController extends ITaskFragmentOrganizerContr
synchronized (mGlobalLock) {
final TaskFragmentOrganizerState organizerState =
mTaskFragmentOrganizerState.get(organizer.asBinder());
return organizerState != null
? organizerState.mRemoteAnimationDefinition
: null;
if (organizerState == null) {
Slog.e(TAG, "TaskFragmentOrganizer has been unregistered or died when trying"
+ " to play animation on its organized windows.");
return null;
}
return organizerState.mRemoteAnimationDefinition;
}
}

View File

@@ -1962,6 +1962,8 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
ownerTask.addChild(taskFragment, position);
taskFragment.setWindowingMode(creationParams.getWindowingMode());
taskFragment.setBounds(creationParams.getInitialBounds());
// Record the initial relative embedded bounds.
taskFragment.updateRelativeEmbeddedBounds();
mLaunchTaskFragments.put(creationParams.getFragmentToken(), taskFragment);
if (transition != null) transition.collectExistenceChange(taskFragment);

View File

@@ -795,6 +795,38 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
task.mChildren.indexOf(activityOnTop));
}
@Test
public void testApplyTransaction_createTaskFragment_overrideBounds() {
final Task task = createTask(mDisplayContent);
final ActivityRecord activityAtBottom = createActivityRecord(task);
final int uid = Binder.getCallingUid();
activityAtBottom.info.applicationInfo.uid = uid;
activityAtBottom.getTask().effectiveUid = uid;
mTaskFragment = new TaskFragmentBuilder(mAtm)
.setParentTask(task)
.setFragmentToken(mFragmentToken)
.createActivityCount(1)
.build();
mWindowOrganizerController.mLaunchTaskFragments.put(mFragmentToken, mTaskFragment);
final IBinder fragmentToken1 = new Binder();
final Rect bounds = new Rect(100, 100, 500, 1000);
final TaskFragmentCreationParams params = new TaskFragmentCreationParams.Builder(
mOrganizerToken, fragmentToken1, activityAtBottom.token)
.setPairedActivityToken(activityAtBottom.token)
.setInitialBounds(bounds)
.build();
mTransaction.setTaskFragmentOrganizer(mIOrganizer);
mTransaction.createTaskFragment(params);
assertApplyTransactionAllowed(mTransaction);
// Successfully created a TaskFragment.
final TaskFragment taskFragment = mWindowOrganizerController.getTaskFragment(
fragmentToken1);
assertNotNull(taskFragment);
// The relative embedded bounds is updated to the initial requested bounds.
assertEquals(bounds, taskFragment.getRelativeEmbeddedBounds());
}
@Test
public void testApplyTransaction_createTaskFragment_withPairedActivityToken() {
final Task task = createTask(mDisplayContent);