Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef83c50e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

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
parent 7ad12f9f
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -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,