diff options
| author | 2024-12-09 13:24:42 +0800 | |
|---|---|---|
| committer | 2024-12-09 13:24:42 +0800 | |
| commit | ef83c50efd9e5a62f3374be1b8efd3ec668d4a10 (patch) | |
| tree | b62dabc441d3b533145654a33b32081a0957b9b7 | |
| parent | 7ad12f9f1b013c4e651500b3d78299329776070f (diff) | |
Do not transfer pending snapshot starting data to different orientation
Otherwise the snapshot will be squeezed to the unmatched size, and the
content shows in a different orientation.
Bug: 379593519
Flag: EXEMPT bugfix
Test: Launch an opaque portrait activity X.
Launch a translucent landscape activity Y with
android:resumeWhilePausing="true" (easier to transfer)
on the same task of X.
Return to home and launch X's task.
Y calls finish() in its onResume.
The landscape starting window should not reparent to X.
Change-Id: I8bff6f358cfdb3208f3ffa9eca5eceabaa0e6475
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityRecord.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 3467f947ece4..48cf78f1e713 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4585,6 +4585,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } } + /** + * Returns {@code true} if the requested orientation of this activity is the same as the + * resolved orientation of the from activity. + */ + private boolean isStartingOrientationCompatible(@NonNull ActivityRecord fromActivity) { + final int fromOrientation = fromActivity.getConfiguration().orientation; + final int requestedOrientation = getRequestedConfigurationOrientation(); + if (requestedOrientation == ORIENTATION_UNDEFINED) { + return fromOrientation == getConfiguration().orientation; + } + return fromOrientation == requestedOrientation; + } + private boolean transferStartingWindow(@NonNull ActivityRecord fromActivity) { final WindowState tStartingWindow = fromActivity.mStartingWindow; if (tStartingWindow != null && fromActivity.mStartingSurface != null) { @@ -4604,13 +4617,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } // Do not transfer if the orientation doesn't match, redraw starting window while it is // on top will cause flicker. - final int fromOrientation = fromActivity.getConfiguration().orientation; - final int requestedOrientation = getRequestedConfigurationOrientation(); - if (requestedOrientation == ORIENTATION_UNDEFINED) { - if (fromOrientation != getConfiguration().orientation) { - return false; - } - } else if (fromOrientation != requestedOrientation) { + if (!isStartingOrientationCompatible(fromActivity)) { return false; } @@ -4708,6 +4715,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } return true; } else if (fromActivity.mStartingData != null) { + if (fromActivity.mStartingData instanceof SnapshotStartingData + && !isStartingOrientationCompatible(fromActivity)) { + // Do not transfer because the snapshot will be distorted in different orientation. + return false; + } // The previous app was getting ready to show a // starting window, but hasn't yet done so. Steal it! ProtoLog.v(WM_DEBUG_STARTING_WINDOW, |