diff options
| author | 2023-06-08 07:15:07 +0000 | |
|---|---|---|
| committer | 2023-06-08 07:15:07 +0000 | |
| commit | 9a93f5df20bf02c18ba188bf7fc8988e3b4da7b9 (patch) | |
| tree | 2583fce71009a7035db67970471800cba3f7d967 | |
| parent | 0d295f9da03911e8fc128c12932a6790d514db7e (diff) | |
| parent | 98f7b6ea3acdb05476a46b69c7e090df25fd1196 (diff) | |
Merge "Animate PiP with considering next rotation" into udc-dev
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java | 24 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/Transition.java | 62 |
2 files changed, 63 insertions, 23 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java index 5086e2c4b05d..bf75132dde54 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java @@ -816,6 +816,12 @@ public class PipTransition extends PipTransitionController { final ActivityManager.RunningTaskInfo taskInfo = pipChange.getTaskInfo(); final SurfaceControl leash = pipChange.getLeash(); final int startRotation = pipChange.getStartRotation(); + // Check again in case some callers use startEnterAnimation directly so the flag was not + // set in startAnimation, e.g. from DefaultMixedHandler. + if (!mInFixedRotation) { + mEndFixedRotation = pipChange.getEndFixedRotation(); + mInFixedRotation = mEndFixedRotation != ROTATION_UNDEFINED; + } final int endRotation = mInFixedRotation ? mEndFixedRotation : pipChange.getEndRotation(); setBoundsStateForEntry(taskInfo.topActivity, taskInfo.pictureInPictureParams, @@ -844,7 +850,7 @@ public class PipTransition extends PipTransitionController { && taskInfo.pictureInPictureParams.isAutoEnterEnabled() && mPipTransitionState.getInSwipePipToHomeTransition()) { handleSwipePipToHomeTransition(startTransaction, finishTransaction, leash, - sourceHintRect, destinationBounds, rotationDelta, taskInfo); + sourceHintRect, destinationBounds, taskInfo); return; } @@ -935,8 +941,15 @@ public class PipTransition extends PipTransitionController { @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull SurfaceControl leash, @Nullable Rect sourceHintRect, - @NonNull Rect destinationBounds, int rotationDelta, + @NonNull Rect destinationBounds, @NonNull ActivityManager.RunningTaskInfo pipTaskInfo) { + if (mInFixedRotation) { + // If rotation changes when returning to home, the transition should contain both the + // entering PiP and the display change (PipController#startSwipePipToHome has updated + // the display layout to new rotation). So it is not expected to see fixed rotation. + ProtoLog.w(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, + "%s: SwipePipToHome should not use fixed rotation %d", TAG, mEndFixedRotation); + } final SurfaceControl swipePipToHomeOverlay = mPipOrganizer.mSwipePipToHomeOverlay; if (swipePipToHomeOverlay != null) { // Launcher fade in the overlay on top of the fullscreen Task. It is possible we @@ -947,12 +960,7 @@ public class PipTransition extends PipTransitionController { mPipOrganizer.mSwipePipToHomeOverlay = null; } - Rect sourceBounds = pipTaskInfo.configuration.windowConfiguration.getBounds(); - if (!Transitions.SHELL_TRANSITIONS_ROTATION && rotationDelta % 2 == 1) { - // PipController#startSwipePipToHome has updated the display layout to new rotation, - // so flip the source bounds to match the same orientation. - sourceBounds = new Rect(0, 0, sourceBounds.height(), sourceBounds.width()); - } + final Rect sourceBounds = pipTaskInfo.configuration.windowConfiguration.getBounds(); final PipAnimationController.PipTransitionAnimator animator = mPipAnimationController.getAnimator(pipTaskInfo, leash, sourceBounds, sourceBounds, destinationBounds, sourceHintRect, TRANSITION_DIRECTION_TO_PIP, diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 82b00866502b..f7550ca2fa8e 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -2317,23 +2317,13 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { task.fillTaskInfo(tinfo); change.setTaskInfo(tinfo); change.setRotationAnimation(getTaskRotationAnimation(task)); - final ActivityRecord topMostActivity = task.getTopMostActivity(); - change.setAllowEnterPip(topMostActivity != null - && topMostActivity.checkEnterPictureInPictureAppOpsState()); final ActivityRecord topRunningActivity = task.topRunningActivity(); - if (topRunningActivity != null && task.mDisplayContent != null - // Display won't be rotated for multi window Task, so the fixed rotation - // won't be applied. This can happen when the windowing mode is changed - // before the previous fixed rotation is applied. - && (!task.inMultiWindowMode() || !topRunningActivity.inMultiWindowMode())) { - // If Activity is in fixed rotation, its will be applied with the next rotation, - // when the Task is still in the previous rotation. - final int taskRotation = task.getWindowConfiguration().getDisplayRotation(); - final int activityRotation = topRunningActivity.getWindowConfiguration() - .getDisplayRotation(); - if (taskRotation != activityRotation) { - change.setEndFixedRotation(activityRotation); + if (topRunningActivity != null) { + if (topRunningActivity.info.supportsPictureInPicture()) { + change.setAllowEnterPip( + topRunningActivity.checkEnterPictureInPictureAppOpsState()); } + setEndFixedRotationIfNeeded(change, task, topRunningActivity); } } else if ((info.mFlags & ChangeInfo.FLAG_SEAMLESS_ROTATION) != 0) { change.setRotationAnimation(ROTATION_ANIMATION_SEAMLESS); @@ -2441,6 +2431,48 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } return animOptions; } + + private static void setEndFixedRotationIfNeeded(@NonNull TransitionInfo.Change change, + @NonNull Task task, @NonNull ActivityRecord taskTopRunning) { + if (!taskTopRunning.isVisibleRequested()) { + // Fixed rotation only applies to opening or changing activity. + return; + } + if (task.inMultiWindowMode() && taskTopRunning.inMultiWindowMode()) { + // Display won't be rotated for multi window Task, so the fixed rotation won't be + // applied. This can happen when the windowing mode is changed before the previous + // fixed rotation is applied. Check both task and activity because the activity keeps + // fullscreen mode when the task is entering PiP. + return; + } + final int taskRotation = task.getWindowConfiguration().getDisplayRotation(); + final int activityRotation = taskTopRunning.getWindowConfiguration() + .getDisplayRotation(); + // If the Activity uses fixed rotation, its rotation will be applied to display after + // the current transition is done, while the Task is still in the previous rotation. + if (taskRotation != activityRotation) { + change.setEndFixedRotation(activityRotation); + return; + } + + // For example, the task is entering PiP so it no longer decides orientation. If the next + // orientation source (it could be an activity which was behind the PiP or launching to top) + // will change display rotation, then set the fixed rotation hint as well so the animation + // can consider the rotated position. + if (!task.inPinnedWindowingMode() || taskTopRunning.mDisplayContent.inTransition()) { + return; + } + final WindowContainer<?> orientationSource = + taskTopRunning.mDisplayContent.getLastOrientationSource(); + if (orientationSource == null) { + return; + } + final int nextRotation = orientationSource.getWindowConfiguration().getDisplayRotation(); + if (taskRotation != nextRotation) { + change.setEndFixedRotation(nextRotation); + } + } + /** * Finds the top-most common ancestor of app targets. * |