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

Commit c7e316e4 authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Include TaskFragment bounds change in app transition" into sc-v2-dev

parents a7dbf474 118428b6
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -332,6 +332,12 @@ public interface WindowManager extends ViewManager {
     */
    int TRANSIT_OLD_TASK_FRAGMENT_CLOSE = 29;

    /**
     * A window of task fragment is changing bounds.
     * @hide
     */
    int TRANSIT_OLD_TASK_FRAGMENT_CHANGE = 30;

    /**
     * @hide
     */
@@ -359,7 +365,8 @@ public interface WindowManager extends ViewManager {
            TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE,
            TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE,
            TRANSIT_OLD_TASK_FRAGMENT_OPEN,
            TRANSIT_OLD_TASK_FRAGMENT_CLOSE
            TRANSIT_OLD_TASK_FRAGMENT_CLOSE,
            TRANSIT_OLD_TASK_FRAGMENT_CHANGE
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface TransitionOldType {}
+7 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_OLD_NONE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
@@ -941,7 +942,7 @@ public class AppTransition implements Dump {
                    "applyAnimation NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS: "
                            + "anim=%s transit=%s isEntrance=true Callers=%s",
                    a, appTransitionOldToString(transit), Debug.getCallers(3));
        } else if (transit == TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE) {
        } else if (isChangeTransitOld(transit)) {
            // In the absence of a specific adapter, we just want to keep everything stationary.
            a = new AlphaAnimation(1.f, 1.f);
            a.setDuration(WindowChangeAnimationSpec.ANIMATION_DURATION);
@@ -1338,6 +1339,9 @@ public class AppTransition implements Dump {
            case TRANSIT_OLD_TASK_FRAGMENT_CLOSE: {
                return "TRANSIT_OLD_TASK_FRAGMENT_CLOSE";
            }
            case TRANSIT_OLD_TASK_FRAGMENT_CHANGE: {
                return "TRANSIT_OLD_TASK_FRAGMENT_CHANGE";
            }
            default: {
                return "<UNKNOWN: " + transition + ">";
            }
@@ -1595,7 +1599,8 @@ public class AppTransition implements Dump {
    }

    static boolean isChangeTransitOld(@TransitionOldType int transit) {
        return transit == TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
        return transit == TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE
                || transit == TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
    }

    static boolean isClosingTransitOld(@TransitionOldType int transit) {
+18 −6
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_OLD_NONE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
@@ -204,8 +205,8 @@ public class AppTransitionController {
                mDisplayContent.mOpeningApps);

        final @TransitionOldType int transit = getTransitCompatType(
                mDisplayContent.mAppTransition,
                mDisplayContent.mOpeningApps, mDisplayContent.mClosingApps,
                mDisplayContent.mAppTransition, mDisplayContent.mOpeningApps,
                mDisplayContent.mClosingApps, mDisplayContent.mChangingContainers,
                mWallpaperControllerLocked.getWallpaperTarget(), getOldWallpaper(),
                mDisplayContent.mSkipAppTransitionAnimation);
        mDisplayContent.mSkipAppTransitionAnimation = false;
@@ -286,6 +287,7 @@ public class AppTransitionController {
     * @param appTransition {@link AppTransition} for managing app transition state.
     * @param openingApps {@link ActivityRecord}s which are becoming visible.
     * @param closingApps {@link ActivityRecord}s which are becoming invisible.
     * @param changingContainers {@link WindowContainer}s which are changed in configuration.
     * @param wallpaperTarget If non-null, this is the currently visible window that is associated
     *                        with the wallpaper.
     * @param oldWallpaper The currently visible window that is associated with the wallpaper in
@@ -294,8 +296,8 @@ public class AppTransitionController {
     */
    static @TransitionOldType int getTransitCompatType(AppTransition appTransition,
            ArraySet<ActivityRecord> openingApps, ArraySet<ActivityRecord> closingApps,
            @Nullable WindowState wallpaperTarget, @Nullable WindowState oldWallpaper,
            boolean skipAppTransitionAnimation) {
            ArraySet<WindowContainer> changingContainers, @Nullable WindowState wallpaperTarget,
            @Nullable WindowState oldWallpaper, boolean skipAppTransitionAnimation) {

        // Determine if closing and opening app token sets are wallpaper targets, in which case
        // special animations are needed.
@@ -328,8 +330,18 @@ public class AppTransitionController {

        // Special transitions
        // TODO(new-app-transitions): Revisit if those can be rewritten by using flags.
        if (appTransition.containsTransitRequest(TRANSIT_CHANGE)) {
        if (appTransition.containsTransitRequest(TRANSIT_CHANGE) && !changingContainers.isEmpty()) {
            @TransitContainerType int changingType =
                    getTransitContainerType(changingContainers.valueAt(0));
            switch (changingType) {
                case TYPE_TASK:
                    return TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
                case TYPE_TASK_FRAGMENT:
                    return TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
                default:
                    throw new IllegalStateException(
                            "TRANSIT_CHANGE with unrecognized changing type=" + changingType);
            }
        }
        if ((flags & TRANSIT_FLAG_APP_CRASHED) != 0) {
            return TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE;
+0 −10
Original line number Diff line number Diff line
@@ -2166,16 +2166,6 @@ class Task extends TaskFragment {
        bounds.offset(horizontalDiff, verticalDiff);
    }

    /**
     * Initializes a change transition. See {@link SurfaceFreezer} for more information.
     */
    private void initializeChangeTransition(Rect startBounds) {
        mDisplayContent.prepareAppTransition(TRANSIT_CHANGE);
        mDisplayContent.mChangingContainers.add(this);

        mSurfaceFreezer.freeze(getPendingTransaction(), startBounds);
    }

    private boolean shouldStartChangeTransition(int prevWinMode, int newWinMode) {
        if (mWmService.mDisableTransitionAnimation
                || !isVisible()
+44 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
import static android.os.UserHandle.USER_NULL;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_OPEN_BEHIND;
import static android.view.WindowManager.TRANSIT_NONE;
@@ -1987,10 +1988,48 @@ class TaskFragment extends WindowContainer<WindowContainer> {

    @Override
    public void onConfigurationChanged(Configuration newParentConfig) {
        // Task will animate differently.
        if (mTaskFragmentOrganizer != null) {
            mTmpPrevBounds.set(getBounds());
        }

        super.onConfigurationChanged(newParentConfig);

        if (shouldStartChangeTransition(mTmpPrevBounds)) {
            initializeChangeTransition(mTmpPrevBounds);
        }

        if (mTaskFragmentOrganizer != null) {
            // Update the surface position here instead of in the organizer so that we can make sure
            // it can be synced with the surface freezer.
            updateSurfacePosition(getSyncTransaction());
        }

        sendTaskFragmentInfoChanged();
    }

    /** Whether we should prepare a transition for this {@link TaskFragment} bounds change. */
    private boolean shouldStartChangeTransition(Rect startBounds) {
        if (mWmService.mDisableTransitionAnimation
                || mDisplayContent == null
                || mTaskFragmentOrganizer == null
                || getSurfaceControl() == null
                || !isVisible()) {
            return false;
        }

        return !startBounds.equals(getBounds());
    }

    /**
     * Initializes a change transition. See {@link SurfaceFreezer} for more information.
     */
    void initializeChangeTransition(Rect startBounds) {
        mDisplayContent.prepareAppTransition(TRANSIT_CHANGE);
        mDisplayContent.mChangingContainers.add(this);
        mSurfaceFreezer.freeze(getSyncTransaction(), startBounds);
    }

    @Override
    void setSurfaceControl(SurfaceControl sc) {
        super.setSurfaceControl(sc);
@@ -2061,6 +2100,11 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        return mTaskFragmentOrganizer;
    }

    @Override
    boolean isOrganized() {
        return mTaskFragmentOrganizer != null;
    }

    /** Clear {@link #mLastPausedActivity} for all {@link TaskFragment} children */
    void clearLastPausedActivity() {
        forAllTaskFragments(taskFragment -> taskFragment.mLastPausedActivity = null);
Loading