Handle task visibility change to show the surface

- When a new task organizer is registered, while a task is invisible,
  onTaskAppeared() may get called with isVisible=false.
- Later on when visibility becomes true, onTaskAppeared() is not called
  and hence that surface would still remain hidden.
- Handle this scenario in onTaskInfoChanged to make sure surface is
  shown correctly.

Fix: 272296051
Test: Tested manually by triggering this case on gcar_ui_portrait
Change-Id: Ie61be170ae92dac1c4eab102e76629f989afa64c
This commit is contained in:
Gaurav Bhola
2023-03-10 15:40:05 -08:00
parent 3d1b8b9a3f
commit 7e21e56840

View File

@@ -129,6 +129,7 @@ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener {
public void onTaskInfoChanged(RunningTaskInfo taskInfo) {
final State state = mTasks.get(taskInfo.taskId);
final Point oldPositionInParent = state.mTaskInfo.positionInParent;
boolean oldVisible = state.mTaskInfo.isVisible;
if (mWindowDecorViewModelOptional.isPresent()) {
mWindowDecorViewModelOptional.get().onTaskInfoChanged(taskInfo);
@@ -138,12 +139,18 @@ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener {
updateRecentsForVisibleFullscreenTask(taskInfo);
final Point positionInParent = state.mTaskInfo.positionInParent;
if (!oldPositionInParent.equals(state.mTaskInfo.positionInParent)) {
boolean positionInParentChanged = !oldPositionInParent.equals(positionInParent);
boolean becameVisible = !oldVisible && state.mTaskInfo.isVisible;
if (becameVisible || positionInParentChanged) {
mSyncQueue.runInSync(t -> {
if (!state.mLeash.isValid()) {
// Task vanished before sync completion
return;
}
if (becameVisible) {
t.show(state.mLeash);
}
t.setPosition(state.mLeash, positionInParent.x, positionInParent.y);
});
}