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

Commit 1f37e676 authored by Shawn Lin's avatar Shawn Lin Committed by Automerger Merge Worker
Browse files

Merge "Add nav bar case to RemoteAnimationTarget of non-app window" into sc-dev am: 9aa51c5c

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia47dabdce103d4bb21d009a4e573eca0bba2a57a
parents 8445d04a 9aa51c5c
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import static android.view.RemoteAnimationTargetProto.START_BOUNDS;
import static android.view.RemoteAnimationTargetProto.START_LEASH;
import static android.view.RemoteAnimationTargetProto.START_LEASH;
import static android.view.RemoteAnimationTargetProto.TASK_ID;
import static android.view.RemoteAnimationTargetProto.TASK_ID;
import static android.view.RemoteAnimationTargetProto.WINDOW_CONFIGURATION;
import static android.view.RemoteAnimationTargetProto.WINDOW_CONFIGURATION;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;


import android.annotation.IntDef;
import android.annotation.IntDef;
import android.app.PictureInPictureParams;
import android.app.PictureInPictureParams;
@@ -195,12 +196,30 @@ public class RemoteAnimationTarget implements Parcelable {
     */
     */
    public PictureInPictureParams pictureInPictureParams;
    public PictureInPictureParams pictureInPictureParams;


    /**
     * The {@link android.view.WindowManager.LayoutParams.WindowType} of this window. It's only used
     * for non-app window.
     */
    public final @WindowManager.LayoutParams.WindowType int windowType;

    public RemoteAnimationTarget(int taskId, int mode, SurfaceControl leash, boolean isTranslucent,
    public RemoteAnimationTarget(int taskId, int mode, SurfaceControl leash, boolean isTranslucent,
            Rect clipRect, Rect contentInsets, int prefixOrderIndex, Point position,
            Rect clipRect, Rect contentInsets, int prefixOrderIndex, Point position,
            Rect localBounds, Rect screenSpaceBounds,
            Rect localBounds, Rect screenSpaceBounds,
            WindowConfiguration windowConfig, boolean isNotInRecents,
            WindowConfiguration windowConfig, boolean isNotInRecents,
            SurfaceControl startLeash, Rect startBounds,
            SurfaceControl startLeash, Rect startBounds,
            PictureInPictureParams pictureInPictureParams) {
            PictureInPictureParams pictureInPictureParams) {
        this(taskId, mode, leash, isTranslucent, clipRect, contentInsets, prefixOrderIndex,
                position, localBounds, screenSpaceBounds, windowConfig, isNotInRecents, startLeash,
                startBounds, pictureInPictureParams, INVALID_WINDOW_TYPE);
    }

    public RemoteAnimationTarget(int taskId, int mode, SurfaceControl leash, boolean isTranslucent,
            Rect clipRect, Rect contentInsets, int prefixOrderIndex, Point position,
            Rect localBounds, Rect screenSpaceBounds,
            WindowConfiguration windowConfig, boolean isNotInRecents,
            SurfaceControl startLeash, Rect startBounds,
            PictureInPictureParams pictureInPictureParams,
            @WindowManager.LayoutParams.WindowType int windowType) {
        this.mode = mode;
        this.mode = mode;
        this.taskId = taskId;
        this.taskId = taskId;
        this.leash = leash;
        this.leash = leash;
@@ -217,6 +236,7 @@ public class RemoteAnimationTarget implements Parcelable {
        this.startLeash = startLeash;
        this.startLeash = startLeash;
        this.startBounds = startBounds == null ? null : new Rect(startBounds);
        this.startBounds = startBounds == null ? null : new Rect(startBounds);
        this.pictureInPictureParams = pictureInPictureParams;
        this.pictureInPictureParams = pictureInPictureParams;
        this.windowType = windowType;
    }
    }


    public RemoteAnimationTarget(Parcel in) {
    public RemoteAnimationTarget(Parcel in) {
@@ -236,6 +256,7 @@ public class RemoteAnimationTarget implements Parcelable {
        startLeash = in.readTypedObject(SurfaceControl.CREATOR);
        startLeash = in.readTypedObject(SurfaceControl.CREATOR);
        startBounds = in.readTypedObject(Rect.CREATOR);
        startBounds = in.readTypedObject(Rect.CREATOR);
        pictureInPictureParams = in.readTypedObject(PictureInPictureParams.CREATOR);
        pictureInPictureParams = in.readTypedObject(PictureInPictureParams.CREATOR);
        windowType = in.readInt();
    }
    }


    @Override
    @Override
@@ -261,6 +282,7 @@ public class RemoteAnimationTarget implements Parcelable {
        dest.writeTypedObject(startLeash, 0 /* flags */);
        dest.writeTypedObject(startLeash, 0 /* flags */);
        dest.writeTypedObject(startBounds, 0 /* flags */);
        dest.writeTypedObject(startBounds, 0 /* flags */);
        dest.writeTypedObject(pictureInPictureParams, 0 /* flags */);
        dest.writeTypedObject(pictureInPictureParams, 0 /* flags */);
        dest.writeInt(windowType);
    }
    }


    public void dump(PrintWriter pw, String prefix) {
    public void dump(PrintWriter pw, String prefix) {
@@ -274,6 +296,7 @@ public class RemoteAnimationTarget implements Parcelable {
        pw.print(" sourceContainerBounds="); sourceContainerBounds.printShortString(pw);
        pw.print(" sourceContainerBounds="); sourceContainerBounds.printShortString(pw);
        pw.print(" screenSpaceBounds="); screenSpaceBounds.printShortString(pw);
        pw.print(" screenSpaceBounds="); screenSpaceBounds.printShortString(pw);
        pw.print(" localBounds="); localBounds.printShortString(pw);
        pw.print(" localBounds="); localBounds.printShortString(pw);
        pw.print(" windowType="); pw.print(windowType);
        pw.println();
        pw.println();
        pw.print(prefix); pw.print("windowConfiguration="); pw.println(windowConfiguration);
        pw.print(prefix); pw.print("windowConfiguration="); pw.println(windowConfiguration);
        pw.print(prefix); pw.print("leash="); pw.println(leash);
        pw.print(prefix); pw.print("leash="); pw.println(leash);
+7 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.systemui.shared.system;
package com.android.systemui.shared.system;


import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;

import android.app.PictureInPictureParams;
import android.app.PictureInPictureParams;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration;
import android.graphics.Point;
import android.graphics.Point;
@@ -44,6 +46,9 @@ public class RemoteAnimationTargetCompat {
    public static final int ACTIVITY_TYPE_ASSISTANT = WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
    public static final int ACTIVITY_TYPE_ASSISTANT = WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
    public final int activityType;
    public final int activityType;


    public static final int TYPE_NAVIGATION_BAR = WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
    public final int windowType;

    public final int taskId;
    public final int taskId;
    public final SurfaceControlCompat leash;
    public final SurfaceControlCompat leash;
    public final boolean isTranslucent;
    public final boolean isTranslucent;
@@ -74,6 +79,7 @@ public class RemoteAnimationTargetCompat {
        contentInsets = app.contentInsets;
        contentInsets = app.contentInsets;
        activityType = app.windowConfiguration.getActivityType();
        activityType = app.windowConfiguration.getActivityType();
        pictureInPictureParams = app.pictureInPictureParams;
        pictureInPictureParams = app.pictureInPictureParams;
        windowType = app.windowType;


        mStartLeash = app.startLeash;
        mStartLeash = app.startLeash;
    }
    }
@@ -114,6 +120,7 @@ public class RemoteAnimationTargetCompat {
            activityType = ACTIVITY_TYPE_UNDEFINED;
            activityType = ACTIVITY_TYPE_UNDEFINED;
        }
        }
        pictureInPictureParams = null;
        pictureInPictureParams = null;
        windowType = INVALID_WINDOW_TYPE;
        mStartLeash = null;
        mStartLeash = null;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -1305,7 +1305,7 @@ public class AppTransition implements Dump {
        if (isTransitionSet()) {
        if (isTransitionSet()) {
            clear();
            clear();
            mNextAppTransitionType = NEXT_TRANSIT_TYPE_REMOTE;
            mNextAppTransitionType = NEXT_TRANSIT_TYPE_REMOTE;
            mRemoteAnimationController = new RemoteAnimationController(mService,
            mRemoteAnimationController = new RemoteAnimationController(mService, mDisplayContent,
                    remoteAnimationAdapter, mHandler);
                    remoteAnimationAdapter, mHandler);
        }
        }
    }
    }
+54 −11
Original line number Original line Diff line number Diff line
@@ -16,6 +16,12 @@


package com.android.server.wm;
package com.android.server.wm;


import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_TO_FRONT;
import static android.view.WindowManager.TRANSIT_OLD_WALLPAPER_CLOSE;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
@@ -26,6 +32,7 @@ import android.os.SystemClock;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.RemoteAnimationTarget;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
import android.view.WindowManager;


import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.protolog.common.ProtoLog;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.policy.WindowManagerPolicy;
@@ -35,7 +42,7 @@ import java.util.ArrayList;


class NonAppWindowAnimationAdapter implements AnimationAdapter {
class NonAppWindowAnimationAdapter implements AnimationAdapter {


    private final WindowState mWindow;
    private final WindowContainer mWindow;
    private RemoteAnimationTarget mTarget;
    private RemoteAnimationTarget mTarget;
    private SurfaceControl mCapturedLeash;
    private SurfaceControl mCapturedLeash;


@@ -47,22 +54,43 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
        return false;
        return false;
    }
    }


    NonAppWindowAnimationAdapter(WindowState w,
    NonAppWindowAnimationAdapter(WindowContainer w, long durationHint,
            long durationHint, long statusBarTransitionDelay) {
            long statusBarTransitionDelay) {
        mWindow = w;
        mWindow = w;
        mDurationHint = durationHint;
        mDurationHint = durationHint;
        mStatusBarTransitionDelay = statusBarTransitionDelay;
        mStatusBarTransitionDelay = statusBarTransitionDelay;
    }
    }


    static RemoteAnimationTarget[] startNonAppWindowAnimations(WindowManagerService service,
            DisplayContent displayContent, @WindowManager.TransitionOldType int transit,
            long durationHint, long statusBarTransitionDelay) {
        final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>();
        if (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
                || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER) {
            startNonAppWindowAnimationsForKeyguardExit(
                    service, durationHint, statusBarTransitionDelay, targets);
        } else if (transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT
                || transit == TRANSIT_OLD_WALLPAPER_CLOSE) {
            final boolean shouldAttachNavBarToApp =
                    displayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition()
                            && service.getRecentsAnimationController() == null
                            && displayContent.getFixedRotationAnimationController() == null;
            if (shouldAttachNavBarToApp) {
                startNavigationBarWindowAnimation(
                        displayContent, durationHint, statusBarTransitionDelay, targets);
            }
        }
        return targets.toArray(new RemoteAnimationTarget[targets.size()]);
    }

    /**
    /**
     * Creates and starts remote animations for all the visible non app windows.
     * Creates and starts remote animations for all the visible non app windows.
     *
     *
     * @return RemoteAnimationTarget[] targets for all the visible non app windows
     * @return RemoteAnimationTarget[] targets for all the visible non app windows
     */
     */
    public static RemoteAnimationTarget[] startNonAppWindowAnimationsForKeyguardExit(
    private static void startNonAppWindowAnimationsForKeyguardExit(WindowManagerService service,
            WindowManagerService service, long durationHint, long statusBarTransitionDelay) {
            long durationHint, long statusBarTransitionDelay,
        final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>();
            ArrayList<RemoteAnimationTarget> targets) {

        final WindowManagerPolicy policy = service.mPolicy;
        final WindowManagerPolicy policy = service.mPolicy;
        service.mRoot.forAllWindows(nonAppWindow -> {
        service.mRoot.forAllWindows(nonAppWindow -> {
            if (nonAppWindow.mActivityRecord == null && policy.canBeHiddenByKeyguardLw(nonAppWindow)
            if (nonAppWindow.mActivityRecord == null && policy.canBeHiddenByKeyguardLw(nonAppWindow)
@@ -74,7 +102,22 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
                targets.add(nonAppAdapter.createRemoteAnimationTarget());
                targets.add(nonAppAdapter.createRemoteAnimationTarget());
            }
            }
        }, true /* traverseTopToBottom */);
        }, true /* traverseTopToBottom */);
        return targets.toArray(new RemoteAnimationTarget[targets.size()]);
    }

    /**
     * Creates and starts remote animation for the navigation bar windows.
     *
     * @return RemoteAnimationTarget[] targets for all the visible non app windows
     */
    private static void startNavigationBarWindowAnimation(DisplayContent displayContent,
            long durationHint, long statusBarTransitionDelay,
            ArrayList<RemoteAnimationTarget> targets) {
        final WindowState navWindow = displayContent.getDisplayPolicy().getNavigationBar();
        final NonAppWindowAnimationAdapter nonAppAdapter = new NonAppWindowAnimationAdapter(
                navWindow.mToken, durationHint, statusBarTransitionDelay);
        navWindow.mToken.startAnimation(navWindow.mToken.getPendingTransaction(),
                nonAppAdapter, false /* hidden */, ANIMATION_TYPE_WINDOW_ANIMATION);
        targets.add(nonAppAdapter.createRemoteAnimationTarget());
    }
    }


    /**
    /**
@@ -84,7 +127,7 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
        mTarget = new RemoteAnimationTarget(-1, -1, getLeash(), false,
        mTarget = new RemoteAnimationTarget(-1, -1, getLeash(), false,
                new Rect(), null, mWindow.getPrefixOrderIndex(), mWindow.getLastSurfacePosition(),
                new Rect(), null, mWindow.getPrefixOrderIndex(), mWindow.getLastSurfacePosition(),
                mWindow.getBounds(), null, mWindow.getWindowConfiguration(), true, null, null,
                mWindow.getBounds(), null, mWindow.getWindowConfiguration(), true, null, null,
                null);
                null, mWindow.getWindowType());
        return mTarget;
        return mTarget;
    }
    }


@@ -120,8 +163,8 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
    @Override
    @Override
    public void dump(PrintWriter pw, String prefix) {
    public void dump(PrintWriter pw, String prefix) {
        pw.print(prefix);
        pw.print(prefix);
        pw.print("token=");
        pw.print("window=");
        pw.println(mWindow.mToken);
        pw.println(mWindow);
        if (mTarget != null) {
        if (mTarget != null) {
            pw.print(prefix);
            pw.print(prefix);
            pw.println("Target:");
            pw.println("Target:");
+7 −9
Original line number Original line Diff line number Diff line
@@ -16,9 +16,6 @@


package com.android.server.wm;
package com.android.server.wm;


import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_REMOTE_ANIMATIONS;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
import static com.android.server.wm.AnimationAdapterProto.REMOTE;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
@@ -60,6 +57,7 @@ class RemoteAnimationController implements DeathRecipient {
    private static final long TIMEOUT_MS = 2000;
    private static final long TIMEOUT_MS = 2000;


    private final WindowManagerService mService;
    private final WindowManagerService mService;
    private final DisplayContent mDisplayContent;
    private final RemoteAnimationAdapter mRemoteAnimationAdapter;
    private final RemoteAnimationAdapter mRemoteAnimationAdapter;
    private final ArrayList<RemoteAnimationRecord> mPendingAnimations = new ArrayList<>();
    private final ArrayList<RemoteAnimationRecord> mPendingAnimations = new ArrayList<>();
    private final ArrayList<WallpaperAnimationAdapter> mPendingWallpaperAnimations =
    private final ArrayList<WallpaperAnimationAdapter> mPendingWallpaperAnimations =
@@ -72,9 +70,10 @@ class RemoteAnimationController implements DeathRecipient {
    private boolean mCanceled;
    private boolean mCanceled;
    private boolean mLinkedToDeathOfRunner;
    private boolean mLinkedToDeathOfRunner;


    RemoteAnimationController(WindowManagerService service,
    RemoteAnimationController(WindowManagerService service, DisplayContent displayContent,
            RemoteAnimationAdapter remoteAnimationAdapter, Handler handler) {
            RemoteAnimationAdapter remoteAnimationAdapter, Handler handler) {
        mService = service;
        mService = service;
        mDisplayContent = displayContent;
        mRemoteAnimationAdapter = remoteAnimationAdapter;
        mRemoteAnimationAdapter = remoteAnimationAdapter;
        mHandler = handler;
        mHandler = handler;
    }
    }
@@ -221,12 +220,11 @@ class RemoteAnimationController implements DeathRecipient {
    private RemoteAnimationTarget[] createNonAppWindowAnimations(
    private RemoteAnimationTarget[] createNonAppWindowAnimations(
            @WindowManager.TransitionOldType int transit) {
            @WindowManager.TransitionOldType int transit) {
        ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createNonAppWindowAnimations()");
        ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createNonAppWindowAnimations()");
        return (transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY
        return NonAppWindowAnimationAdapter.startNonAppWindowAnimations(mService,
                || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER)
                    mDisplayContent,
                ? NonAppWindowAnimationAdapter.startNonAppWindowAnimationsForKeyguardExit(mService,
                    transit,
                    mRemoteAnimationAdapter.getDuration(),
                    mRemoteAnimationAdapter.getDuration(),
                    mRemoteAnimationAdapter.getStatusBarTransitionDelay())
                    mRemoteAnimationAdapter.getStatusBarTransitionDelay());
                : new RemoteAnimationTarget[0];
    }
    }


    private void onAnimationFinished() {
    private void onAnimationFinished() {
Loading