From efd82554191c36ebe84aa5b21f6e8bda088c3ea6 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Fri, 13 May 2022 12:37:01 -0700 Subject: [PATCH] Apply PiP Params if there was a deferred info. If there was a deferred info, that means PiP params was saved but not applied earlier. Force apply it. Bug: 232104080 Test: Double tap on YouTube after exiting earlier Map PiP, aspect ratio is correct Change-Id: I52e9f38d4a923fdfee06e7ff37eb61a599caba04 --- .../com/android/wm/shell/pip/PipTaskOrganizer.java | 6 ++++-- .../shell/flicker/pip/ExpandPipOnDoubleClickTest.kt | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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 45c9a958a42a5..aa895aee5972e 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 @@ -1096,11 +1096,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, * Handles all changes to the PictureInPictureParams. */ protected void applyNewPictureInPictureParams(@NonNull PictureInPictureParams params) { - if (PipUtils.aspectRatioChanged(params.getAspectRatioFloat(), + if (mDeferredTaskInfo != null || PipUtils.aspectRatioChanged(params.getAspectRatioFloat(), mPictureInPictureParams.getAspectRatioFloat())) { mPipParamsChangedForwarder.notifyAspectRatioChanged(params.getAspectRatioFloat()); } - if (PipUtils.remoteActionsChanged(params.getActions(), mPictureInPictureParams.getActions()) + if (mDeferredTaskInfo != null + || PipUtils.remoteActionsChanged(params.getActions(), + mPictureInPictureParams.getActions()) || !PipUtils.remoteActionsMatch(params.getCloseAction(), mPictureInPictureParams.getCloseAction())) { mPipParamsChangedForwarder.notifyActionsChanged(params.getActions(), diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt index 9f3fcea241e4e..28b7fc9bd29e6 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt @@ -123,6 +123,18 @@ class ExpandPipOnDoubleClickTest(testSpec: FlickerTestParameter) : PipTransition } } + @Presubmit + @Test + fun pipSameAspectRatio() { + val layerName = pipApp.component.toLayerName() + testSpec.assertLayers { + val pipLayerList = this.layers { it.name.contains(layerName) && it.isVisible } + pipLayerList.zipWithNext { previous, current -> + current.visibleRegion.isSameAspectRatio(previous.visibleRegion) + } + } + } + /** * Checks [pipApp] window remains pinned throughout the animation */