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
This commit is contained in:
Riddle Hsu
2021-11-10 20:32:27 +08:00
parent db38b7faf4
commit 0463e0e170

View File

@@ -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;
}