From 0463e0e17014d95e024dd33af1700ce96ce1e38d Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 10 Nov 2021 20:32:27 +0800 Subject: [PATCH] Choose opaque activity for fixed rotation with entering pip The case is like: (A,B,C are activities from top to bottom) A orientation=unspecified, dialog style(!fillsParent) B orientation=landscape, entering pip mode C orientation=portrait, the activity that decides screen orientation The non-opaque activity won't decide screen orientation, that causes to miss the proper timing to trigger fixed rotation when the previous top is switching from fullscreen to pip with screen orientation change. This makes the callback order of PipTaskOrganizer still follows first onFixedRotationStarted and then onTaskAppeared. So the PiP won't stay in a stale state with wrong bounds or alpha. Bug: 204844178 Test: 1. Launch Chrome and play video in fullscreen landscape. 2. Enable auto-rotation, put device in landscape. 3. adb shell am start -a android.intent.action.VIEW Chrome should enter PiP correctly. Change-Id: I34250bb879898059568bc3b3b6b4da88fea75f57 --- .../java/com/android/server/wm/PinnedTaskController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/PinnedTaskController.java b/services/core/java/com/android/server/wm/PinnedTaskController.java index b4963c5b9f1c3..b54208d11974d 100644 --- a/services/core/java/com/android/server/wm/PinnedTaskController.java +++ b/services/core/java/com/android/server/wm/PinnedTaskController.java @@ -17,7 +17,6 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ROTATION_UNDEFINED; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; @@ -173,10 +172,8 @@ class PinnedTaskController { * to avoid flickering when running PiP animation across different orientations. */ void deferOrientationChangeForEnteringPipFromFullScreenIfNeeded() { - final Task topFullscreenTask = mDisplayContent.getDefaultTaskDisplayArea() - .getTopRootTaskInWindowingMode(WINDOWING_MODE_FULLSCREEN); - final ActivityRecord topFullscreen = topFullscreenTask != null - ? topFullscreenTask.topRunningActivity() : null; + final ActivityRecord topFullscreen = mDisplayContent.getActivity( + a -> a.fillsParent() && !a.getTask().inMultiWindowMode()); if (topFullscreen == null || topFullscreen.hasFixedRotationTransform()) { return; }