From b9c1bc336ccebb1c2d1a35447397fc4d2b292d7c Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 27 Dec 2021 13:37:17 +0800 Subject: [PATCH] Fix NPE when entering PIP from different orientation 1. handleRequest for TRANSIT_PIP will happen before the Task appeared, so setting ENTRY_SCHEDULED in handleRequest will cause the rotation to access the leash before Task appeared, which causes NPE. 2. We don't want to do fixed rotation launch in Core when Shell transition is enabled. Otherwise it will stuck at waiting for continue rotation. TODO: handle PIP to Fullscreen rotation in Shell transition Bug: 210965919 Test: manual test entering PIP from different orientation without NPE Change-Id: Ie5e61a5cf05eff7a0c1adb731d5f3d8677e0f091 --- .../Shell/src/com/android/wm/shell/pip/PipTransition.java | 1 - services/core/java/com/android/server/wm/DisplayContent.java | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) 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 0fcfced2dcfc6..c909652fd6616 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 @@ -219,7 +219,6 @@ public class PipTransition extends PipTransitionController { @NonNull TransitionRequestInfo request) { if (request.getType() == TRANSIT_PIP) { WindowContainerTransaction wct = new WindowContainerTransaction(); - mPipTransitionState.setTransitionState(PipTransitionState.ENTRY_SCHEDULED); if (mOneShotAnimationType == ANIM_TYPE_ALPHA) { wct.setActivityWindowingMode(request.getTriggerTask().token, WINDOWING_MODE_UNDEFINED); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 8ede0160cdce1..5e8056b28ad57 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1598,6 +1598,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp */ @Rotation int rotationForActivityInDifferentOrientation(@NonNull ActivityRecord r) { + if (mTransitionController.isShellTransitionsEnabled()) { + return ROTATION_UNDEFINED; + } if (!WindowManagerService.ENABLE_FIXED_ROTATION_TRANSFORM) { return ROTATION_UNDEFINED; }