diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt index bb66f7bbc01fe..fe19df88f98fb 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt @@ -56,13 +56,6 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) { .sendBroadcast(createIntentWithAction(broadcastAction)) } - fun requestOrientationForPip(orientation: Int) { - instrumentation.context.sendBroadcast( - createIntentWithAction(Components.PipActivity.ACTION_SET_REQUESTED_ORIENTATION) - .putExtra(Components.PipActivity.EXTRA_PIP_ORIENTATION, orientation.toString()) - ) - } - companion object { // Corresponds to ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt index d65388bd8cc57..159caee506f09 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt @@ -28,8 +28,8 @@ import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import com.android.wm.shell.flicker.pip.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_LANDSCAPE +import com.android.wm.shell.flicker.testapp.Components import com.android.wm.shell.flicker.testapp.Components.FixedActivity.EXTRA_FIXED_ORIENTATION -import com.android.wm.shell.flicker.testapp.Components.PipActivity.EXTRA_ENTER_PIP import org.junit.Assume import org.junit.Before import org.junit.FixMethodOrder @@ -39,7 +39,7 @@ import org.junit.runners.MethodSorters import org.junit.runners.Parameterized /** - * Test Pip with orientation changes. + * Test exiting Pip with orientation changes. * To run this test: `atest WMShellFlickerTests:SetRequestedOrientationWhilePinnedTest` */ @RequiresDevice @@ -65,10 +65,16 @@ open class SetRequestedOrientationWhilePinnedTest( setup { eachRun { - // Launch the PiP activity fixed as landscape + // Launch the PiP activity fixed as landscape. pipApp.launchViaIntent(wmHelper, stringExtras = mapOf( - EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString(), - EXTRA_ENTER_PIP to "true")) + EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())) + // Enter PiP. + broadcastActionTrigger.doAction(Components.PipActivity.ACTION_ENTER_PIP) + wmHelper.waitPipShown() + wmHelper.waitForRotation(Surface.ROTATION_0) + wmHelper.waitForAppTransitionIdle() + // System bar may fade out during fixed rotation. + wmHelper.waitForNavBarStatusBarVisible() } } teardown { @@ -77,14 +83,13 @@ open class SetRequestedOrientationWhilePinnedTest( } } transitions { - // Request that the orientation is set to landscape - broadcastActionTrigger.requestOrientationForPip(ORIENTATION_LANDSCAPE) - - // Launch the activity back into fullscreen and - // ensure that it is now in landscape + // Launch the activity back into fullscreen and ensure that it is now in landscape pipApp.launchViaIntent(wmHelper) wmHelper.waitForFullScreenApp(pipApp.component) wmHelper.waitForRotation(Surface.ROTATION_90) + wmHelper.waitForAppTransitionIdle() + // System bar may fade out during fixed rotation. + wmHelper.waitForNavBarStatusBarVisible() } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTestShellTransit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTestShellTransit.kt index 36e28049864f9..8d764a8d0e692 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTestShellTransit.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTestShellTransit.kt @@ -29,6 +29,10 @@ import org.junit.runner.RunWith import org.junit.runners.MethodSorters import org.junit.runners.Parameterized +/** + * Test exiting Pip with orientation changes. + * To run this test: `atest WMShellFlickerTests:SetRequestedOrientationWhilePinnedTestShellTransit` + */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 3a3103e752ad2..bf33f86ac672d 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1262,7 +1262,11 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe change.setAllowEnterPip(topMostActivity != null && topMostActivity.checkEnterPictureInPictureAppOpsState()); final ActivityRecord topRunningActivity = task.topRunningActivity(); - if (topRunningActivity != null && task.mDisplayContent != null) { + 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()) { // 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();