Fix TV PiP back and forth animation after switch

When switching from one PiP to another, the new PiP was briefly starting
to animate to the size of the previous PiP before going back to the new
size.

Bug: 264362433
Test: manual - launch a vertical PiP and then start a horizontal PiP on
top of it (orientation change only to make issue more visible if it
happens)

Change-Id: Ic954444756b245cfd44c1f2b97ada668fc6ace83
This commit is contained in:
Jacqueline Bronger
2023-01-03 12:23:50 +01:00
parent 3ad4f200c2
commit 86571395a4
2 changed files with 15 additions and 16 deletions

View File

@@ -125,7 +125,9 @@ public class TvPipBoundsController {
cancelScheduledPlacement();
applyPlacement(placement, shouldStash, animationDuration);
} else {
applyPlacementBounds(mCurrentPlacementBounds, animationDuration);
if (mCurrentPlacementBounds != null) {
applyPlacementBounds(mCurrentPlacementBounds, animationDuration);
}
schedulePinnedStackPlacement(placement, animationDuration);
}
}
@@ -188,7 +190,7 @@ public class TvPipBoundsController {
applyPlacementBounds(bounds, animationDuration);
}
void onPipDismissed() {
void reset() {
mCurrentPlacementBounds = null;
mPipTargetBounds = null;
cancelScheduledPlacement();

View File

@@ -450,18 +450,6 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
mPipMediaController.registerSessionListenerForCurrentUser();
}
private void checkIfPinnedTaskAppeared() {
final TaskInfo pinnedTask = getPinnedTaskInfo();
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: checkIfPinnedTaskAppeared(), task=%s", TAG, pinnedTask);
if (pinnedTask == null || pinnedTask.topActivity == null) return;
mPinnedTaskId = pinnedTask.taskId;
mPipMediaController.onActivityPinned();
mActionBroadcastReceiver.register();
mPipNotificationController.show(pinnedTask.topActivity.getPackageName());
}
private void checkIfPinnedTaskIsGone() {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: onTaskStackChanged()", TAG);
@@ -482,7 +470,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
mTvPipMenuController.closeMenu();
mTvPipBoundsState.resetTvPipState();
mTvPipBoundsController.onPipDismissed();
mTvPipBoundsController.reset();
setState(STATE_NO_PIP);
mPinnedTaskId = NONEXISTENT_TASK_ID;
}
@@ -537,7 +525,16 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
taskStackListener.addListener(new TaskStackListenerCallback() {
@Override
public void onActivityPinned(String packageName, int userId, int taskId, int stackId) {
checkIfPinnedTaskAppeared();
final TaskInfo pinnedTask = getPinnedTaskInfo();
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"%s: onActivityPinned(), task=%s", TAG, pinnedTask);
if (pinnedTask == null || pinnedTask.topActivity == null) return;
mPinnedTaskId = pinnedTask.taskId;
mPipMediaController.onActivityPinned();
mActionBroadcastReceiver.register();
mPipNotificationController.show(pinnedTask.topActivity.getPackageName());
mTvPipBoundsController.reset();
mAppOpsListener.onActivityPinned(packageName);
}