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

Commit 9dfbde45 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

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

Merge "Include TaskFragment bounds change in app transition" into sc-v2-dev am: c7e316e4 am: d771105c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15559306

Change-Id: I8c55150dd674f8a5322e239b256c81af8945733f
parents 46adda46 d771105c
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -332,6 +332,12 @@ public interface WindowManager extends ViewManager {
     */
     */
    int TRANSIT_OLD_TASK_FRAGMENT_CLOSE = 29;
    int TRANSIT_OLD_TASK_FRAGMENT_CLOSE = 29;


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

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


    static boolean isChangeTransitOld(@TransitionOldType int transit) {
    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) {
    static boolean isClosingTransitOld(@TransitionOldType int transit) {
+18 −6
Original line number Original line 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_NONE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
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_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_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
@@ -204,8 +205,8 @@ public class AppTransitionController {
                mDisplayContent.mOpeningApps);
                mDisplayContent.mOpeningApps);


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


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


        // Special transitions
        // Special transitions
        // TODO(new-app-transitions): Revisit if those can be rewritten by using flags.
        // 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;
                    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) {
        if ((flags & TRANSIT_FLAG_APP_CRASHED) != 0) {
            return TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE;
            return TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE;
+0 −10
Original line number Original line Diff line number Diff line
@@ -2166,16 +2166,6 @@ class Task extends TaskFragment {
        bounds.offset(horizontalDiff, verticalDiff);
        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) {
    private boolean shouldStartChangeTransition(int prevWinMode, int newWinMode) {
        if (mWmService.mDisableTransitionAnimation
        if (mWmService.mDisableTransitionAnimation
                || !isVisible()
                || !isVisible()
+44 −0
Original line number Original line 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.content.res.Configuration.ORIENTATION_UNDEFINED;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_NULL;
import static android.view.Display.INVALID_DISPLAY;
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_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_OPEN_BEHIND;
import static android.view.WindowManager.TRANSIT_FLAG_OPEN_BEHIND;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_NONE;
@@ -1987,10 +1988,48 @@ class TaskFragment extends WindowContainer<WindowContainer> {


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

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


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

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