From 6ef225e9a2e069e3b828ce11a1df69d3920cf353 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Tue, 23 Jun 2020 11:16:05 -0700 Subject: [PATCH] Reparent PiP to split screen on exit When exiting PiP from a different orientation, reparent the PiP task to split screen as we do in finishResize and orientation does not change. Video: http://rcll/aaaaaabFQoRHlzixHdtY/dBQuk6juYvCIiO4zc9aHFP Bug: 159617346 Test: manual, see video Change-Id: Iafe1abb61d35cabdc46c172ae80f7e0886307ab7 --- .../systemui/pip/PipTaskOrganizer.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java index d924346783578..e2feb71735fff 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java +++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java @@ -273,8 +273,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements sendOnPipTransitionStarted(direction); // Don't bother doing an animation if the display rotation differs or if it's in // a non-supported windowing mode - wct.setWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); - wct.setActivityWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); + applyWindowingModeChangeOnExit(wct, direction); WindowOrganizer.applyTransaction(wct); // Send finished callback though animation is ignored. sendOnPipTransitionFinished(direction); @@ -303,6 +302,16 @@ public class PipTaskOrganizer extends TaskOrganizer implements mExitingPip = true; } + private void applyWindowingModeChangeOnExit(WindowContainerTransaction wct, int direction) { + // Reset the final windowing mode. + wct.setWindowingMode(mToken, getOutPipWindowingMode()); + // Simply reset the activity mode set prior to the animation running. + wct.setActivityWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); + if (mSplitDivider != null && direction == TRANSITION_DIRECTION_TO_SPLIT_SCREEN) { + wct.reparent(mToken, mSplitDivider.getSecondaryRoot(), true /* onTop */); + } + } + /** * Removes PiP immediately. */ @@ -745,13 +754,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements // on the task to ensure that the task "matches" the parent's bounds. taskBounds = (direction == TRANSITION_DIRECTION_TO_FULLSCREEN) ? null : destinationBounds; - // Reset the final windowing mode. - wct.setWindowingMode(mToken, getOutPipWindowingMode()); - // Simply reset the activity mode set prior to the animation running. - wct.setActivityWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); - if (mSplitDivider != null && direction == TRANSITION_DIRECTION_TO_SPLIT_SCREEN) { - wct.reparent(mToken, mSplitDivider.getSecondaryRoot(), true /* onTop */); - } + applyWindowingModeChangeOnExit(wct, direction); } else { // Just a resize in PIP taskBounds = destinationBounds;