diff options
| author | 2023-03-22 16:07:37 -0700 | |
|---|---|---|
| committer | 2023-03-23 21:06:18 -0700 | |
| commit | 89b36b32b79c3559bc5c7a50dc430c9e5745223c (patch) | |
| tree | 6acc901c35b2ade5dd02242414403f668b67ecc9 | |
| parent | b7fff582dc77755f2c72db5c1aced634b87c8f3e (diff) | |
Allow PipTouchHandler to re-enable the touches
This is to fix the regression from ag/21471704 that
PipTouchHandler#setTouchEnabled(true) is not called due to
PipAnimationController#quietCancel when receives display changed
callback, which happens on folding the display.
Bug: 272825196
Test: manual, follow the reproduces in b/272825196
Test: manual, make sure no regression following b/263211281
Change-Id: I3f18680856bd3705af8ca374bf1592ae97499071
3 files changed, 9 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java index 1187126f5bf1..4c53f607a5f8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java @@ -210,7 +210,7 @@ public class PipAnimationController { /** * Quietly cancel the animator by removing the listeners first. */ - public static void quietCancel(@NonNull ValueAnimator animator) { + static void quietCancel(@NonNull ValueAnimator animator) { animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 1dd2ef94a959..7e9f2c53d04b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -147,10 +147,12 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, // These callbacks are called on the update thread private final PipAnimationController.PipAnimationCallback mPipAnimationCallback = new PipAnimationController.PipAnimationCallback() { + private boolean mIsCancelled; @Override public void onPipAnimationStart(TaskInfo taskInfo, PipAnimationController.PipTransitionAnimator animator) { final int direction = animator.getTransitionDirection(); + mIsCancelled = false; sendOnPipTransitionStarted(direction); } @@ -158,6 +160,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, public void onPipAnimationEnd(TaskInfo taskInfo, SurfaceControl.Transaction tx, PipAnimationController.PipTransitionAnimator animator) { final int direction = animator.getTransitionDirection(); + if (mIsCancelled) { + sendOnPipTransitionFinished(direction); + return; + } final int animationType = animator.getAnimationType(); final Rect destinationBounds = animator.getDestinationBounds(); if (isInPipDirection(direction) && animator.getContentOverlayLeash() != null) { @@ -196,6 +202,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, public void onPipAnimationCancel(TaskInfo taskInfo, PipAnimationController.PipTransitionAnimator animator) { final int direction = animator.getTransitionDirection(); + mIsCancelled = true; if (isInPipDirection(direction) && animator.getContentOverlayLeash() != null) { fadeOutAndRemoveOverlay(animator.getContentOverlayLeash(), animator::clearContentOverlay, true /* withStartDelay */); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 9807320afb03..2bd5f1c5817c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -779,7 +779,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb mPipAnimationController.getCurrentAnimator(); if (animator != null && animator.isRunning()) { // cancel any running animator, as it is using stale display layout information - PipAnimationController.quietCancel(animator); + animator.cancel(); } onDisplayChangedUncheck(layout, saveRestoreSnapFraction); } |