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

Commit ae0c8b03 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Fixes regression on preserving PiP position"

parents 330203fa e75e191b
Loading
Loading
Loading
Loading
+24 −32
Original line number Diff line number Diff line
@@ -42,9 +42,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.activityTypeToString;
import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.CATEGORY_HOME;
@@ -6529,7 +6527,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            updateSurfacePosition();
        }

        adjustPinnedStackAndInitChangeTransitionIfNeeded(prevWinMode, getWindowingMode());
        final int newWinMode = getWindowingMode();
        if ((prevWinMode != newWinMode) && (mDisplayContent != null)
                && shouldStartChangeTransition(prevWinMode, newWinMode)) {
            initializeChangeTransition(mTmpPrevBounds);
        }

        // Configuration's equality doesn't consider seq so if only seq number changes in resolved
        // override configuration. Therefore ConfigurationContainer doesn't change merged override
@@ -6563,17 +6565,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
    }

    private void adjustPinnedStackAndInitChangeTransitionIfNeeded(int prevWinMode, int winMode) {
        if (prevWinMode == winMode || mDisplayContent == null) {
            return;
        }

        if (prevWinMode == WINDOWING_MODE_PINNED && winMode != WINDOWING_MODE_UNDEFINED
                && !isHidden()) {
    void savePinnedStackBounds() {
        // Leaving PiP to fullscreen, save the snap fraction based on the pre-animation bounds
        // for the next re-entry into PiP (assuming the activity is not hidden or destroyed)
        final TaskStack pinnedStack = mDisplayContent.getPinnedStack();
            if (pinnedStack != null) {
        if (pinnedStack == null) return;
        final Rect stackBounds;
        if (pinnedStack.lastAnimatingBoundsWasToFullscreen()) {
            // We are animating the bounds, use the pre-animation bounds to save the snap
@@ -6589,10 +6585,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mDisplayContent.mPinnedStackControllerLocked.saveReentrySnapFraction(
                mActivityComponent, stackBounds);
    }
        } else if (shouldStartChangeTransition(prevWinMode, winMode)) {
            initializeChangeTransition(mTmpPrevBounds);
        }
    }

    /** Returns true if the configuration is compatible with this activity. */
    boolean isConfigurationCompatible(Configuration config) {
+7 −0
Original line number Diff line number Diff line
@@ -588,6 +588,13 @@ class TaskRecord extends Task {
        boolean kept = true;
        try {
            final ActivityRecord r = topRunningActivityLocked();
            // give pinned stack a chance to save current bounds, this needs to be before the
            // actual reparent.
            if (inPinnedWindowingMode()
                    && !(toStackWindowingMode == WINDOWING_MODE_UNDEFINED)
                    && !r.isHidden()) {
                r.savePinnedStackBounds();
            }
            final boolean wasFocused = r != null && root.isTopDisplayFocusedStack(sourceStack)
                    && (topRunningActivityLocked() == r);
            final boolean wasResumed = r != null && sourceStack.getResumedActivity() == r;