From 7277eab6884c621d394fa957ead35bd380ef203d Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 23 Feb 2022 23:20:26 +0800 Subject: [PATCH] Update orientation before executing transition by starting window The issue case only happens with splash starting window (new task), and the activity is going to start in a different orientation. Because usually updateOrientation() in this case is called from activityPaused() of previous activity or attachApplication for cold launch (both route to ensureVisibilityAndConfig). But the starting window may be drawn before that, then the transition still runs in old orientation and then runs another rotation animation. Also use isReportedDrawn() to replace isVisible(). Because the original usage is to handle the case back from a non-occluding activity to an existing visible activity. Since the condition doesn't depend on transition, it can work both for legacy and shell transition. Bug: 218659058 Test: atest com.android.server.wm.flicker.launch.OpenAppColdTest Change-Id: I4ecf64a496cffb628deaded6fe8ab031d42005cb --- .../com/android/server/wm/ActivityRecord.java | 4 ++++ .../com/android/server/wm/DisplayContent.java | 8 +------- .../android/server/wm/TransitionController.java | 15 --------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index b0efa5b283bba..28df0532e26b7 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -6186,6 +6186,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // The pending transition state will be cleared after the transition is started, so // save the state for launching the client later (used by LaunchActivityItem). mStartingData.mIsTransitionForward = true; + // Ensure that the transition can run with the latest orientation. + if (this != mDisplayContent.getLastOrientationSource()) { + mDisplayContent.updateOrientation(); + } mDisplayContent.executeAppTransition(); } } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index fd24565798fbd..166740a526b4e 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1642,18 +1642,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // It has been set and not yet finished. return true; } - if (!r.occludesParent()) { + if (!r.occludesParent() || r.isReportedDrawn()) { // While entering or leaving a translucent or floating activity (e.g. dialog style), // there is a visible activity in the background. Then it still needs rotation animation // to cover the activity configuration change. return false; } - if (mTransitionController.isShellTransitionsEnabled() - ? mTransitionController.wasVisibleAtStart(r) : r.isVisible()) { - // If activity is already visible, then it's not "launching". However, shell-transitions - // will make it visible immediately. - return false; - } if (checkOpening) { if (mTransitionController.isShellTransitionsEnabled()) { if (!mTransitionController.isCollecting(r)) { diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java index c13ae95217b56..caad76b0aedb7 100644 --- a/services/core/java/com/android/server/wm/TransitionController.java +++ b/services/core/java/com/android/server/wm/TransitionController.java @@ -282,21 +282,6 @@ class TransitionController { return false; } - /** - * Temporary work-around to deal with integration of legacy fixed-rotation. Returns whether - * the activity was visible before the collecting transition. - * TODO: at-least replace the polling mechanism. - */ - boolean wasVisibleAtStart(@NonNull ActivityRecord ar) { - if (mCollectingTransition == null) return ar.isVisible(); - final Transition.ChangeInfo ci = mCollectingTransition.mChanges.get(ar); - if (ci == null) { - // not part of transition, so use current state. - return ar.isVisible(); - } - return ci.mVisible; - } - @WindowConfiguration.WindowingMode int getWindowingModeAtStart(@NonNull WindowContainer wc) { if (mCollectingTransition == null) return wc.getWindowingMode();