From 316b1f5028faa4a5775249d23f163269d15b3afc Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Tue, 4 Jun 2019 16:05:19 -0700 Subject: [PATCH] Make PiP window visible when user launches PiP in landscape mode Two PiP animations are triggered when launching PiP in landscape mode (one when first swiping up (FADE_IN), the other moves the PiP window to portrait position (BOUNDS)). When screen rotation happens after the first animation is started, it cancels it while leaving the window alpha to close to 0. In order to make sure the window after rotation has the correct alpha, we should set the alpha of the window when mCancelCurrentBoundsAnimation is true to 1. Fixes: 133711307 Test: Play a YouTube video in landscape mode, and then swipe up. Make sure that PiP window shows up after screen rotation forced by launcher Test: atest PinnedStackTests Change-Id: I3ec186b0e1e3f50dc91cfb03fc3847ddd7b5faef --- .../core/java/com/android/server/wm/TaskStack.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index d83869109ff38..481c3ba24fcad 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -1640,6 +1640,7 @@ public class TaskStack extends WindowContainer implements if (mAnimationType == BoundsAnimationController.FADE_IN) { setPinnedStackAlpha(1f); mActivityStack.mService.notifyPinnedStackAnimationEnded(); + return; } if (finalStackSize != null && !mCancelCurrentBoundsAnimation) { @@ -1935,14 +1936,11 @@ public class TaskStack extends WindowContainer implements public boolean setPinnedStackAlpha(float alpha) { // Hold the lock since this is called from the BoundsAnimator running on the UiThread synchronized (mWmService.mGlobalLock) { - if (mCancelCurrentBoundsAnimation) { - return false; - } - getPendingTransaction().setAlpha(getSurfaceControl(), alpha); + getPendingTransaction().setAlpha(getSurfaceControl(), + mCancelCurrentBoundsAnimation ? 1 : alpha); scheduleAnimation(); + return !mCancelCurrentBoundsAnimation; } - - return true; } public DisplayInfo getDisplayInfo() {