From fb7fd8ed90340c73be40c53f84ac645378cb26b8 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 31 May 2022 17:17:09 +0000 Subject: [PATCH] Separate fillsParent from deciding orientation This keep the behavior of commit a930e1e to avoid orientation from being affected by the change of mOccludesParent. But the animation style can still refer to the runtime change of translucent, e.g. AppTransitionController#findAnimLayoutParamsToken. Bug: 234328568 Test: ActivityRecordTests#testShouldStartWhenMakeClientActive Change-Id: If9019dfa6e4a69cd34607f24dfe2d06994fd6f10 --- .../com/android/server/wm/ActivityRecord.java | 15 ++++++++++----- .../android/server/wm/PinnedTaskController.java | 2 +- .../com/android/server/wm/WindowContainer.java | 11 +++++++---- .../android/server/wm/ActivityRecordTests.java | 4 ++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index d73746c077ca1..859b4df3baa6c 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -670,9 +670,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * from the style of activity. Because we don't want {@link WindowContainer#getOrientation()} * to be affected by the temporal state of {@link ActivityClientController#convertToTranslucent} * when running ANIM_SCENE_TRANSITION. - * @see WindowContainer#fillsParent() + * @see WindowContainer#providesOrientation() */ - private final boolean mFillsParent; + private final boolean mStyleFillsParent; // The input dispatching timeout for this application token in milliseconds. long mInputDispatchingTimeoutMillis = DEFAULT_DISPATCHING_TIMEOUT_MILLIS; @@ -1971,10 +1971,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // This style is propagated to the main window attributes with // FLAG_SHOW_WALLPAPER from PhoneWindow#generateLayout. || ent.array.getBoolean(R.styleable.Window_windowShowWallpaper, false); - mFillsParent = mOccludesParent; + mStyleFillsParent = mOccludesParent; noDisplay = ent.array.getBoolean(R.styleable.Window_windowNoDisplay, false); } else { - mFillsParent = mOccludesParent = true; + mStyleFillsParent = mOccludesParent = true; noDisplay = false; } @@ -2879,9 +2879,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return (TaskDisplayArea) super.getDisplayArea(); } + @Override + boolean providesOrientation() { + return mStyleFillsParent; + } + @Override boolean fillsParent() { - return mFillsParent; + return occludesParent(true /* includingFinishing */); } /** Returns true if this activity is not finishing, is opaque and fills the entire space of diff --git a/services/core/java/com/android/server/wm/PinnedTaskController.java b/services/core/java/com/android/server/wm/PinnedTaskController.java index 1ddeee9f46d9f..4378b4f17b5b5 100644 --- a/services/core/java/com/android/server/wm/PinnedTaskController.java +++ b/services/core/java/com/android/server/wm/PinnedTaskController.java @@ -172,7 +172,7 @@ class PinnedTaskController { */ void deferOrientationChangeForEnteringPipFromFullScreenIfNeeded() { final ActivityRecord topFullscreen = mDisplayContent.getActivity( - a -> a.fillsParent() && !a.getTask().inMultiWindowMode()); + a -> a.providesOrientation() && !a.getTask().inMultiWindowMode()); if (topFullscreen == null || topFullscreen.hasFixedRotationTransform()) { return; } diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index f9d19e22ddc7e..d7257180f01b8 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -1495,8 +1495,7 @@ class WindowContainer extends ConfigurationContainer< */ int getOrientation(int candidate) { mLastOrientationSource = null; - if (!fillsParent()) { - // Ignore containers that don't completely fill their parents. + if (!providesOrientation()) { return SCREEN_ORIENTATION_UNSET; } @@ -1530,8 +1529,8 @@ class WindowContainer extends ConfigurationContainer< continue; } - if (wc.fillsParent() || orientation != SCREEN_ORIENTATION_UNSPECIFIED) { - // Use the orientation if the container fills its parent or requested an explicit + if (wc.providesOrientation() || orientation != SCREEN_ORIENTATION_UNSPECIFIED) { + // Use the orientation if the container can provide or requested an explicit // orientation that isn't SCREEN_ORIENTATION_UNSPECIFIED. ProtoLog.v(WM_DEBUG_ORIENTATION, "%s is requesting orientation %d (%s)", wc.toString(), orientation, @@ -1560,6 +1559,10 @@ class WindowContainer extends ConfigurationContainer< return source; } + boolean providesOrientation() { + return fillsParent(); + } + /** * Returns true if this container is opaque and fills all the space made available by its parent * container. diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 12e5653949262..8c4a4c9ea2840 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -756,8 +756,8 @@ public class ActivityRecordTests extends WindowTestsBase { final ActivityRecord activity = createActivityWithTask(); ActivityRecord topActivity = new ActivityBuilder(mAtm).setTask(activity.getTask()).build(); topActivity.setOccludesParent(false); - // The requested occluding state doesn't affect whether it fills parent. - assertTrue(topActivity.fillsParent()); + // The requested occluding state doesn't affect whether it can decide orientation. + assertTrue(topActivity.providesOrientation()); activity.setState(STOPPED, "Testing"); activity.setVisibility(true); activity.makeActiveIfNeeded(null /* activeActivity */);