Fix some legacy-transition timing issues in split-screen
This does 2 things: 1. Leash-setup was originally made asymmetric to handle tasks switching between organized and non-organized; however, now the tasks don't do that so we can symmetrize this again. 2. TaskInfoChanged reporting was added to ensureActivityVisibility. This causes noise as it can repeatedly send unchanged TaskInfos to shell. The result is that the legacy split organizer will reposition its surface while it is on an animation leash. To avoid this, keep track of the last positions and only update it if it changes. This maintains a contract that as long as the task's actual position doesn't change (ie. during an animation), the shell won't clobber changes made by legacy-transition's leashing. This can be cleaned up once we move to shell transitions where ownership is better defined. Bug: 172840531 Test: open 2 apps in split and observe no offset in launcher Change-Id: I262e3a53b7497192e234d4a8ba215e10ed73a145
This commit is contained in:
@@ -52,6 +52,9 @@ class LegacySplitScreenTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
private final SyncTransactionQueue mSyncQueue;
|
||||
private final SparseArray<SurfaceControl> mLeashByTaskId = new SparseArray<>();
|
||||
|
||||
// TODO(shell-transitions): Remove when switched to shell-transitions.
|
||||
private final SparseArray<Point> mPositionByTaskId = new SparseArray<>();
|
||||
|
||||
RunningTaskInfo mPrimary;
|
||||
RunningTaskInfo mSecondary;
|
||||
SurfaceControl mPrimarySurface;
|
||||
@@ -167,6 +170,7 @@ class LegacySplitScreenTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
@Override
|
||||
public void onTaskVanished(RunningTaskInfo taskInfo) {
|
||||
synchronized (this) {
|
||||
mPositionByTaskId.remove(taskInfo.taskId);
|
||||
if (taskInfo.hasParentTask()) {
|
||||
mLeashByTaskId.remove(taskInfo.taskId);
|
||||
return;
|
||||
@@ -200,16 +204,24 @@ class LegacySplitScreenTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
}
|
||||
synchronized (this) {
|
||||
if (taskInfo.hasParentTask()) {
|
||||
// changed messages are noisy since it reports on every ensureVisibility. This
|
||||
// conflicts with legacy app-transitions which "swaps" the position to a
|
||||
// leash. For now, only update when position actually changes to avoid
|
||||
// poorly-timed duplicate calls.
|
||||
if (taskInfo.positionInParent.equals(mPositionByTaskId.get(taskInfo.taskId))) {
|
||||
return;
|
||||
}
|
||||
handleChildTaskChanged(taskInfo);
|
||||
return;
|
||||
} else {
|
||||
handleTaskInfoChanged(taskInfo);
|
||||
}
|
||||
|
||||
handleTaskInfoChanged(taskInfo);
|
||||
mPositionByTaskId.put(taskInfo.taskId, new Point(taskInfo.positionInParent));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChildTaskAppeared(RunningTaskInfo taskInfo, SurfaceControl leash) {
|
||||
mLeashByTaskId.put(taskInfo.taskId, leash);
|
||||
mPositionByTaskId.put(taskInfo.taskId, new Point(taskInfo.positionInParent));
|
||||
if (Transitions.ENABLE_SHELL_TRANSITIONS) return;
|
||||
updateChildTaskSurface(taskInfo, leash, true /* firstAppeared */);
|
||||
}
|
||||
|
||||
@@ -3625,7 +3625,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
|
||||
@Override
|
||||
void resetSurfacePositionForAnimationLeash(SurfaceControl.Transaction t) {
|
||||
if (isOrganized()) return;
|
||||
super.resetSurfacePositionForAnimationLeash(t);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user