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

Commit c9bb0443 authored by Jon Miranda's avatar Jon Miranda Committed by Android (Google) Code Review
Browse files

Merge "Crop by navigation-bar inset during animations" into main

parents 0e399f99 0638f968
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.shared;

import android.window.RemoteTransition;
import android.window.TransitionFilter;
import android.view.InsetsState;

/**
 * Listener interface that Launcher attaches to SystemUI to get home activity transition callbacks
@@ -29,5 +30,10 @@ oneway interface IHomeTransitionListener {
     * Called when a transition changes the visibility of the home activity on the default display.
     */
    void onHomeVisibilityChanged(in boolean isVisible);

    /**
     * Called when the insets at display-level change.
     */
    void onDisplayInsetsChanged(in InsetsState insets);
}
+9 −4
Original line number Diff line number Diff line
@@ -762,6 +762,7 @@ public abstract class WMShellBaseModule {
            ShellTaskOrganizer organizer,
            TransactionPool pool,
            DisplayController displayController,
            DisplayInsetsController displayInsetsController,
            @ShellMainThread ShellExecutor mainExecutor,
            @ShellMainThread Handler mainHandler,
            @ShellAnimationThread ShellExecutor animExecutor,
@@ -773,15 +774,19 @@ public abstract class WMShellBaseModule {
            shellInit = new ShellInit(mainExecutor);
        }
        return new Transitions(context, shellInit, shellCommandHandler, shellController, organizer,
                pool, displayController, mainExecutor, mainHandler, animExecutor,
                rootTaskDisplayAreaOrganizer, homeTransitionObserver, focusTransitionObserver);
                pool, displayController, displayInsetsController, mainExecutor, mainHandler,
                animExecutor, rootTaskDisplayAreaOrganizer, homeTransitionObserver,
                focusTransitionObserver);
    }

    @WMSingleton
    @Provides
    static HomeTransitionObserver provideHomeTransitionObserver(Context context,
            @ShellMainThread ShellExecutor mainExecutor) {
        return new HomeTransitionObserver(context, mainExecutor);
            @ShellMainThread ShellExecutor mainExecutor,
            DisplayInsetsController displayInsetsController,
            ShellInit shellInit) {
        return new HomeTransitionObserver(context, mainExecutor, displayInsetsController,
                shellInit);
    }

    @WMSingleton
+19 −3
Original line number Diff line number Diff line
@@ -42,9 +42,10 @@ public class DefaultSurfaceAnimator {
            @NonNull Animation anim, @NonNull SurfaceControl leash,
            @NonNull Runnable finishCallback, @NonNull TransactionPool pool,
            @NonNull ShellExecutor mainExecutor, @Nullable Point position, float cornerRadius,
            @Nullable Rect clipRect) {
            @Nullable Rect clipRect,
            @Nullable TransitionAnimationHelper.RoundedContentPerDisplay roundedBounds) {
        final DefaultAnimationAdapter adapter = new DefaultAnimationAdapter(anim, leash,
                position, clipRect, cornerRadius);
                position, clipRect, cornerRadius, roundedBounds);
        buildSurfaceAnimation(animations, anim, finishCallback, pool, mainExecutor, adapter);
    }

@@ -109,9 +110,17 @@ public class DefaultSurfaceAnimator {
        @Nullable final Rect mClipRect;
        @Nullable private final Rect mAnimClipRect;
        final float mCornerRadius;
        final int mWindowBottom;

        /**
         * Inset changes aren't synchronized with transitions, so use a "provider" to track the
         * bottom of the display content during the animation.
         */
        @Nullable final TransitionAnimationHelper.RoundedContentPerDisplay mRoundedContentBounds;

        DefaultAnimationAdapter(@NonNull Animation anim, @NonNull SurfaceControl leash,
                @Nullable Point position, @Nullable Rect clipRect, float cornerRadius) {
                @Nullable Point position, @Nullable Rect clipRect, float cornerRadius,
                TransitionAnimationHelper.RoundedContentPerDisplay roundedBounds) {
            super(leash);
            mAnim = anim;
            mPosition = (position != null && (position.x != 0 || position.y != 0))
@@ -119,6 +128,8 @@ public class DefaultSurfaceAnimator {
            mClipRect = (clipRect != null && !clipRect.isEmpty()) ? clipRect : null;
            mAnimClipRect = mClipRect != null ? new Rect() : null;
            mCornerRadius = cornerRadius;
            mWindowBottom = clipRect != null ? clipRect.bottom : 0;
            mRoundedContentBounds = roundedBounds;
        }

        @Override
@@ -136,6 +147,11 @@ public class DefaultSurfaceAnimator {

            if (mClipRect != null) {
                boolean needCrop = false;
                if (mRoundedContentBounds != null) {
                    mClipRect.bottom = Math.min(mRoundedContentBounds.mBounds.bottom,
                            mWindowBottom);
                }

                mAnimClipRect.set(mClipRect);
                if (transformation.hasClipRect()) {
                    mAnimClipRect.intersectUnchecked(transformation.getClipRect());
+30 −6
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITI
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_INTRA_OPEN;
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_NONE;
import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_OPEN;
import static com.android.wm.shell.Flags.enableDynamicInsetsForAppLaunch;
import static com.android.wm.shell.transition.DefaultSurfaceAnimator.buildSurfaceAnimation;
import static com.android.wm.shell.transition.TransitionAnimationHelper.getTransitionBackgroundColorIfSet;
import static com.android.wm.shell.transition.TransitionAnimationHelper.getTransitionTypeFromInfo;
@@ -110,6 +111,7 @@ import com.android.window.flags.Flags;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.animation.SizeChangeAnimation;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
@@ -135,6 +137,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
    private final ShellExecutor mAnimExecutor;
    private final TransitionAnimation mTransitionAnimation;
    private final DevicePolicyManager mDevicePolicyManager;
    private final TransitionAnimationHelper.RoundedContentTracker mRoundedContentBounds;

    /** Keeps track of the currently-running animations associated with each transition. */
    private final ArrayMap<IBinder, ArrayList<Animator>> mAnimations = new ArrayMap<>();
@@ -164,6 +167,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
    DefaultTransitionHandler(@NonNull Context context,
            @NonNull ShellInit shellInit,
            @NonNull DisplayController displayController,
            @NonNull DisplayInsetsController displayInsetsController,
            @NonNull TransactionPool transactionPool,
            @NonNull ShellExecutor mainExecutor, @NonNull Handler mainHandler,
            @NonNull ShellExecutor animExecutor,
@@ -180,6 +184,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
        shellInit.addInitCallback(this::onInit, this);
        mRootTDAOrganizer = rootTDAOrganizer;
        mRoundedContentBounds = new TransitionAnimationHelper.RoundedContentTracker(
                displayController, displayInsetsController);
        mInteractionJankMonitor = interactionJankMonitor;
    }

@@ -192,6 +198,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                mMainHandler);

        TransitionAnimation.initAttributeCache(mContext, mMainHandler);
        mRoundedContentBounds.init();
    }

    private void updateEnterpriseThumbnailDrawable() {
@@ -298,6 +305,18 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        return ROTATION_ANIMATION_SEAMLESS;
    }

    @Nullable
    final TransitionAnimationHelper.RoundedContentPerDisplay getRoundedContentBounds(
            TransitionInfo.Change change) {
        if (!enableDynamicInsetsForAppLaunch()) {
            return null;
        }
        if (change.getTaskInfo() == null && change.getActivityComponent() == null) {
            return null;
        }
        return mRoundedContentBounds.forDisplay(change.getEndDisplayId());
    }

    @Override
    public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction startTransaction,
@@ -557,7 +576,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                        change.getEndAbsBounds().left - animRoot.getOffset().x,
                        change.getEndAbsBounds().top - animRoot.getOffset().y);

                if (change.getActivityComponent() != null) {
                final boolean isActivity = change.getActivityComponent() != null;
                if (isActivity) {
                    // For appcompat letterbox: we intentionally report the task-bounds so that we
                    // can animate as-if letterboxes are "part of" the activity. This means we can't
                    // always rely solely on endAbsBounds and need to also max with endRelOffset.
@@ -565,7 +585,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                    animRelOffset.y = Math.max(animRelOffset.y, change.getEndRelOffset().y);
                }

                if (change.getActivityComponent() != null && !isActivityLevel
                if (isActivity && !isActivityLevel
                        && !mRotator.isRotated(change)) {
                    // At this point, this is an independent activity change in a non-activity
                    // transition. This means that an activity transition got erroneously combined
@@ -590,8 +610,10 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                }

                buildSurfaceAnimation(animations, a, change.getLeash(), onAnimFinish,
                        mTransactionPool, mMainExecutor, animRelOffset, cornerRadius,
                        clipRect);
                        mTransactionPool, mMainExecutor, animRelOffset, cornerRadius, clipRect,
                        isTask || isActivity
                                ? mRoundedContentBounds.forDisplay(change.getEndDisplayId())
                                : null);

                final TransitionInfo.AnimationOptions options = change.getAnimationOptions();
                if (options != null) {
@@ -934,7 +956,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        a.restrictDuration(MAX_ANIMATION_DURATION);
        a.scaleCurrentDuration(mTransitionAnimationScaleSetting);
        buildSurfaceAnimation(animations, a, wt.getSurface(), finisher, mTransactionPool,
                mMainExecutor, change.getEndRelOffset(), cornerRadius, change.getEndAbsBounds());
                mMainExecutor, change.getEndRelOffset(), cornerRadius, change.getEndAbsBounds(),
                getRoundedContentBounds(change));
    }

    private void attachThumbnailAnimation(@NonNull ArrayList<Animator> animations,
@@ -958,7 +981,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        a.restrictDuration(MAX_ANIMATION_DURATION);
        a.scaleCurrentDuration(mTransitionAnimationScaleSetting);
        buildSurfaceAnimation(animations, a, wt.getSurface(), finisher, mTransactionPool,
                mMainExecutor, change.getEndRelOffset(), cornerRadius, change.getEndAbsBounds());
                mMainExecutor, change.getEndRelOffset(), cornerRadius, change.getEndAbsBounds(),
                getRoundedContentBounds(change));
    }

    private static int getWallpaperTransitType(TransitionInfo info) {
+21 −1
Original line number Diff line number Diff line
@@ -29,15 +29,18 @@ import android.annotation.NonNull;
import android.app.ActivityManager;
import android.content.Context;
import android.os.IBinder;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.window.TransitionInfo;

import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SingleInstanceRemoteListener;
import com.android.wm.shell.shared.IHomeTransitionListener;
import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.shared.bubbles.BubbleAnythingFlagHelper;
import com.android.wm.shell.sysui.ShellInit;

/**
 * The {@link TransitionObserver} that observes for transitions involving the home
@@ -51,13 +54,30 @@ public class HomeTransitionObserver implements TransitionObserver,

    private @NonNull final Context mContext;
    private @NonNull final ShellExecutor mMainExecutor;
    private @NonNull final DisplayInsetsController mDisplayInsetsController;
    private IBinder mPendingStartDragTransition;
    private Boolean mPendingHomeVisibilityUpdate;

    public HomeTransitionObserver(@NonNull Context context,
            @NonNull ShellExecutor mainExecutor) {
            @NonNull ShellExecutor mainExecutor,
            @NonNull DisplayInsetsController displayInsetsController,
            @NonNull ShellInit shellInit) {
        mContext = context;
        mMainExecutor = mainExecutor;
        mDisplayInsetsController = displayInsetsController;

        shellInit.addInitCallback(this::onInit, this);
    }

    private void onInit() {
        mDisplayInsetsController.addInsetsChangedListener(DEFAULT_DISPLAY,
                new DisplayInsetsController.OnInsetsChangedListener() {
                    @Override
                    public void insetsChanged(InsetsState insetsState) {
                        if (mListener == null) return;
                        mListener.call(l -> l.onDisplayInsetsChanged(insetsState));
                    }
                });
    }

    @Override
Loading