From 86571395a4f9b7474262cc21767ec5c9d1429bcd Mon Sep 17 00:00:00 2001 From: Jacqueline Bronger Date: Tue, 3 Jan 2023 12:23:50 +0100 Subject: 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 --- .../wm/shell/pip/tv/TvPipBoundsController.java | 6 ++++-- .../android/wm/shell/pip/tv/TvPipController.java | 25 ++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsController.java index b189163a354a..8d4a38442ce5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipBoundsController.java @@ -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(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java index fd4fcff54f01..442642348b07 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipController.java @@ -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); } -- cgit v1.2.3-59-g8ed1b