blob: e6345523bd1499664d34b1687ec1d262f2747c0e [file] [log] [blame]
Filip Gruszczynski84fa3352016-01-25 16:28:49 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.wm;
18
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080019import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
20import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
21import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
22
23import android.animation.Animator;
24import android.animation.ValueAnimator;
Winson Chung8bca9e42017-04-16 15:59:43 -070025import android.annotation.IntDef;
Winson Chungbaa7b722017-03-03 21:33:44 -080026import android.content.Context;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080027import android.graphics.Rect;
Wale Ogunwale2ba71292016-05-05 09:16:47 -070028import android.os.Handler;
Robert Carrf9aa2a92016-04-26 14:22:19 -070029import android.os.IBinder;
Wale Ogunwale5658e4b2016-02-12 12:22:19 -080030import android.os.Debug;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080031import android.util.ArrayMap;
32import android.util.Slog;
Winson Chungbaa7b722017-03-03 21:33:44 -080033import android.view.animation.AnimationUtils;
34import android.view.animation.Interpolator;
Robert Carrf9aa2a92016-04-26 14:22:19 -070035import android.view.WindowManagerInternal;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080036
Winson Chung19953ca2017-04-11 11:19:23 -070037import com.android.internal.annotations.VisibleForTesting;
38
Winson Chung8bca9e42017-04-16 15:59:43 -070039import java.lang.annotation.Retention;
40import java.lang.annotation.RetentionPolicy;
41
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080042/**
43 * Enables animating bounds of objects.
44 *
45 * In multi-window world bounds of both stack and tasks can change. When we need these bounds to
46 * change smoothly and not require the app to relaunch (e.g. because it handles resizes and
47 * relaunching it would cause poorer experience), these class provides a way to directly animate
48 * the bounds of the resized object.
49 *
Winson Chung8bca9e42017-04-16 15:59:43 -070050 * The object that is resized needs to implement {@link BoundsAnimationTarget} interface.
Wale Ogunwale2ba71292016-05-05 09:16:47 -070051 *
52 * NOTE: All calls to methods in this class should be done on the UI thread
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080053 */
54public class BoundsAnimationController {
Wale Ogunwale5658e4b2016-02-12 12:22:19 -080055 private static final boolean DEBUG_LOCAL = false;
56 private static final boolean DEBUG = DEBUG_LOCAL || DEBUG_ANIM;
57 private static final String TAG = TAG_WITH_CLASS_NAME || DEBUG_LOCAL
58 ? "BoundsAnimationController" : TAG_WM;
Wale Ogunwalece144522016-02-05 22:51:01 -080059 private static final int DEBUG_ANIMATION_SLOW_DOWN_FACTOR = 1;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080060
Winson Chungbaa7b722017-03-03 21:33:44 -080061 private static final int DEFAULT_TRANSITION_DURATION = 425;
62
Winson Chung8bca9e42017-04-16 15:59:43 -070063 @Retention(RetentionPolicy.SOURCE)
64 @IntDef({NO_PIP_MODE_CHANGED_CALLBACKS, SCHEDULE_PIP_MODE_CHANGED_ON_START,
65 SCHEDULE_PIP_MODE_CHANGED_ON_END})
66 public @interface SchedulePipModeChangedState {}
67 /** Do not schedule any PiP mode changed callbacks as a part of this animation. */
68 public static final int NO_PIP_MODE_CHANGED_CALLBACKS = 0;
69 /** Schedule a PiP mode changed callback when this animation starts. */
70 public static final int SCHEDULE_PIP_MODE_CHANGED_ON_START = 1;
71 /** Schedule a PiP mode changed callback when this animation ends. */
72 public static final int SCHEDULE_PIP_MODE_CHANGED_ON_END = 2;
73
Wale Ogunwalece144522016-02-05 22:51:01 -080074 // Only accessed on UI thread.
Winson Chung8bca9e42017-04-16 15:59:43 -070075 private ArrayMap<BoundsAnimationTarget, BoundsAnimator> mRunningAnimations = new ArrayMap<>();
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080076
Wale Ogunwale2ba71292016-05-05 09:16:47 -070077 private final class AppTransitionNotifier
78 extends WindowManagerInternal.AppTransitionListener implements Runnable {
Robert Carrf9aa2a92016-04-26 14:22:19 -070079
Wale Ogunwale2ba71292016-05-05 09:16:47 -070080 public void onAppTransitionCancelledLocked() {
Winson Chung87e5d552017-04-05 11:49:38 -070081 if (DEBUG) Slog.d(TAG, "onAppTransitionCancelledLocked:"
82 + " mFinishAnimationAfterTransition=" + mFinishAnimationAfterTransition);
Wale Ogunwale2ba71292016-05-05 09:16:47 -070083 animationFinished();
84 }
85 public void onAppTransitionFinishedLocked(IBinder token) {
Winson Chung87e5d552017-04-05 11:49:38 -070086 if (DEBUG) Slog.d(TAG, "onAppTransitionFinishedLocked:"
87 + " mFinishAnimationAfterTransition=" + mFinishAnimationAfterTransition);
Wale Ogunwale2ba71292016-05-05 09:16:47 -070088 animationFinished();
89 }
90 private void animationFinished() {
91 if (mFinishAnimationAfterTransition) {
92 mHandler.removeCallbacks(this);
Winson Chung87e5d552017-04-05 11:49:38 -070093 // This might end up calling into activity manager which will be bad since we have
94 // the window manager lock held at this point. Post a message to take care of the
95 // processing so we don't deadlock.
Wale Ogunwale2ba71292016-05-05 09:16:47 -070096 mHandler.post(this);
97 }
98 }
99
100 @Override
101 public void run() {
102 for (int i = 0; i < mRunningAnimations.size(); i++) {
103 final BoundsAnimator b = mRunningAnimations.valueAt(i);
104 b.onAnimationEnd(null);
105 }
106 }
107 }
108
109 private final Handler mHandler;
Robert Carrf9aa2a92016-04-26 14:22:19 -0700110 private final AppTransition mAppTransition;
Wale Ogunwale2ba71292016-05-05 09:16:47 -0700111 private final AppTransitionNotifier mAppTransitionNotifier = new AppTransitionNotifier();
Winson Chungbaa7b722017-03-03 21:33:44 -0800112 private final Interpolator mFastOutSlowInInterpolator;
Robert Carrf9aa2a92016-04-26 14:22:19 -0700113 private boolean mFinishAnimationAfterTransition = false;
114
Winson Chungbaa7b722017-03-03 21:33:44 -0800115 BoundsAnimationController(Context context, AppTransition transition, Handler handler) {
Wale Ogunwale2ba71292016-05-05 09:16:47 -0700116 mHandler = handler;
Robert Carrf9aa2a92016-04-26 14:22:19 -0700117 mAppTransition = transition;
118 mAppTransition.registerListenerLocked(mAppTransitionNotifier);
Winson Chungbaa7b722017-03-03 21:33:44 -0800119 mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
120 com.android.internal.R.interpolator.fast_out_slow_in);
Robert Carrf9aa2a92016-04-26 14:22:19 -0700121 }
122
Winson Chung19953ca2017-04-11 11:19:23 -0700123 @VisibleForTesting
124 final class BoundsAnimator extends ValueAnimator
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800125 implements ValueAnimator.AnimatorUpdateListener, ValueAnimator.AnimatorListener {
Winson Chung8bca9e42017-04-16 15:59:43 -0700126 private final BoundsAnimationTarget mTarget;
Winson Chung84a38342016-11-08 16:15:10 -0800127 private final Rect mFrom = new Rect();
128 private final Rect mTo = new Rect();
Robert Carr0d00c2e2016-02-29 17:45:02 -0800129 private final Rect mTmpRect = new Rect();
130 private final Rect mTmpTaskBounds = new Rect();
Winson Chung8bca9e42017-04-16 15:59:43 -0700131
132 // True if this this animation was canceled and will be replaced the another animation from
133 // the same {@link #BoundsAnimationTarget} target.
Winson Chung19953ca2017-04-11 11:19:23 -0700134 private boolean mSkipFinalResize;
Winson Chung5af42fc2017-03-24 17:11:33 -0700135 // True if this animation replaced a previous animation of the same
Winson Chung8bca9e42017-04-16 15:59:43 -0700136 // {@link #BoundsAnimationTarget} target.
Winson Chung5af42fc2017-03-24 17:11:33 -0700137 private final boolean mSkipAnimationStart;
Winson Chung8bca9e42017-04-16 15:59:43 -0700138 // True if this animation was canceled by the user, not as a part of a replacing animation
Winson Chung19953ca2017-04-11 11:19:23 -0700139 private boolean mSkipAnimationEnd;
Winson Chung8bca9e42017-04-16 15:59:43 -0700140 // True if the animation target should be moved to the fullscreen stack at the end of this
141 // animation
142 private boolean mMoveToFullscreen;
143
144 // Whether to schedule PiP mode changes on animation start/end
145 private @SchedulePipModeChangedState int mSchedulePipModeChangedState;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800146
Robert Carr0d00c2e2016-02-29 17:45:02 -0800147 // Depending on whether we are animating from
148 // a smaller to a larger size
149 private final int mFrozenTaskWidth;
150 private final int mFrozenTaskHeight;
151
Winson Chung8bca9e42017-04-16 15:59:43 -0700152 BoundsAnimator(BoundsAnimationTarget target, Rect from, Rect to,
153 @SchedulePipModeChangedState int schedulePipModeChangedState,
154 boolean moveToFullscreen, boolean replacingExistingAnimation) {
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800155 super();
156 mTarget = target;
Winson Chung84a38342016-11-08 16:15:10 -0800157 mFrom.set(from);
158 mTo.set(to);
Winson Chung5af42fc2017-03-24 17:11:33 -0700159 mSkipAnimationStart = replacingExistingAnimation;
Winson Chung8bca9e42017-04-16 15:59:43 -0700160 mSchedulePipModeChangedState = schedulePipModeChangedState;
161 mMoveToFullscreen = moveToFullscreen;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800162 addUpdateListener(this);
163 addListener(this);
Robert Carr0d00c2e2016-02-29 17:45:02 -0800164
165 // If we are animating from smaller to larger, we want to change the task bounds
166 // to their final size immediately so we can use scaling to make the window
167 // larger. Likewise if we are going from bigger to smaller, we want to wait until
168 // the end so we don't have to upscale from the smaller finished size.
169 if (animatingToLargerSize()) {
170 mFrozenTaskWidth = mTo.width();
171 mFrozenTaskHeight = mTo.height();
172 } else {
173 mFrozenTaskWidth = mFrom.width();
174 mFrozenTaskHeight = mFrom.height();
175 }
176 }
177
Winson Chung5af42fc2017-03-24 17:11:33 -0700178 @Override
179 public void onAnimationStart(Animator animation) {
180 if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget
Winson Chung8bca9e42017-04-16 15:59:43 -0700181 + " mSkipAnimationStart=" + mSkipAnimationStart
182 + " mSchedulePipModeChangedState=" + mSchedulePipModeChangedState);
Winson Chung5af42fc2017-03-24 17:11:33 -0700183 mFinishAnimationAfterTransition = false;
184 mTmpRect.set(mFrom.left, mFrom.top, mFrom.left + mFrozenTaskWidth,
185 mFrom.top + mFrozenTaskHeight);
186
187 // Ensure that we have prepared the target for animation before
188 // we trigger any size changes, so it can swap surfaces
189 // in to appropriate modes, or do as it wishes otherwise.
190 if (!mSkipAnimationStart) {
Winson Chung8bca9e42017-04-16 15:59:43 -0700191 mTarget.onAnimationStart(mSchedulePipModeChangedState ==
192 SCHEDULE_PIP_MODE_CHANGED_ON_START);
Winson Chung5af42fc2017-03-24 17:11:33 -0700193 }
194
195 // Immediately update the task bounds if they have to become larger, but preserve
196 // the starting position so we don't jump at the beginning of the animation.
197 if (animatingToLargerSize()) {
198 mTarget.setPinnedStackSize(mFrom, mTmpRect);
199 }
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800200 }
201
202 @Override
203 public void onAnimationUpdate(ValueAnimator animation) {
204 final float value = (Float) animation.getAnimatedValue();
205 final float remains = 1 - value;
Wale Ogunwalece144522016-02-05 22:51:01 -0800206 mTmpRect.left = (int) (mFrom.left * remains + mTo.left * value + 0.5f);
207 mTmpRect.top = (int) (mFrom.top * remains + mTo.top * value + 0.5f);
208 mTmpRect.right = (int) (mFrom.right * remains + mTo.right * value + 0.5f);
209 mTmpRect.bottom = (int) (mFrom.bottom * remains + mTo.bottom * value + 0.5f);
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800210 if (DEBUG) Slog.d(TAG, "animateUpdate: mTarget=" + mTarget + " mBounds="
211 + mTmpRect + " from=" + mFrom + " mTo=" + mTo + " value=" + value
212 + " remains=" + remains);
Robert Carr0d00c2e2016-02-29 17:45:02 -0800213
Robert Carrc7294602016-05-13 11:32:05 -0700214 mTmpTaskBounds.set(mTmpRect.left, mTmpRect.top,
215 mTmpRect.left + mFrozenTaskWidth, mTmpRect.top + mFrozenTaskHeight);
Robert Carr0d00c2e2016-02-29 17:45:02 -0800216
Robert Carrc7294602016-05-13 11:32:05 -0700217 if (!mTarget.setPinnedStackSize(mTmpRect, mTmpTaskBounds)) {
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800218 // Whoops, the target doesn't feel like animating anymore. Let's immediately finish
219 // any further animation.
Winson Chung87e5d552017-04-05 11:49:38 -0700220 if (DEBUG) Slog.d(TAG, "animateUpdate: cancelled");
Winson Chung19953ca2017-04-11 11:19:23 -0700221
Winson Chung8bca9e42017-04-16 15:59:43 -0700222 // If we have already scheduled a PiP mode changed at the start of the animation,
223 // then we need to clean up and schedule one at the end, since we have canceled the
224 // animation to the final state.
225 if (mSchedulePipModeChangedState == SCHEDULE_PIP_MODE_CHANGED_ON_START) {
226 mSchedulePipModeChangedState = SCHEDULE_PIP_MODE_CHANGED_ON_END;
227 }
228
Winson Chung19953ca2017-04-11 11:19:23 -0700229 // Since we are cancelling immediately without a replacement animation, send the
230 // animation end to maintain callback parity, but also skip any further resizes
Winson Chung8bca9e42017-04-16 15:59:43 -0700231 cancelAndCallAnimationEnd();
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800232 }
233 }
234
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800235 @Override
236 public void onAnimationEnd(Animator animation) {
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800237 if (DEBUG) Slog.d(TAG, "onAnimationEnd: mTarget=" + mTarget
Winson Chung19953ca2017-04-11 11:19:23 -0700238 + " mSkipFinalResize=" + mSkipFinalResize
Winson Chung87e5d552017-04-05 11:49:38 -0700239 + " mFinishAnimationAfterTransition=" + mFinishAnimationAfterTransition
Winson Chung8bca9e42017-04-16 15:59:43 -0700240 + " mAppTransitionIsRunning=" + mAppTransition.isRunning()
241 + " callers=" + Debug.getCallers(2));
Jaewan Kimb0033642016-04-22 18:41:37 +0900242
Robert Carrf9aa2a92016-04-26 14:22:19 -0700243 // There could be another animation running. For example in the
244 // move to fullscreen case, recents will also be closing while the
245 // previous task will be taking its place in the fullscreen stack.
246 // we have to ensure this is completed before we finish the animation
247 // and take our place in the fullscreen stack.
248 if (mAppTransition.isRunning() && !mFinishAnimationAfterTransition) {
249 mFinishAnimationAfterTransition = true;
250 return;
251 }
252
Winson Chung8bca9e42017-04-16 15:59:43 -0700253 if (!mSkipAnimationEnd) {
254 // If this animation has already scheduled the picture-in-picture mode on start, and
255 // we are not skipping the final resize due to being canceled, then move the PiP to
256 // fullscreen once the animation ends
257 if (DEBUG) Slog.d(TAG, "onAnimationEnd: mTarget=" + mTarget
258 + " moveToFullscreen=" + mMoveToFullscreen);
259 mTarget.onAnimationEnd(mSchedulePipModeChangedState ==
260 SCHEDULE_PIP_MODE_CHANGED_ON_END, !mSkipFinalResize ? mTo : null,
261 mMoveToFullscreen);
Winson Chung19953ca2017-04-11 11:19:23 -0700262 }
263
Winson Chung8bca9e42017-04-16 15:59:43 -0700264 // Clean up this animation
265 removeListener(this);
266 removeUpdateListener(this);
267 mRunningAnimations.remove(mTarget);
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800268 }
269
270 @Override
271 public void onAnimationCancel(Animator animation) {
Winson Chung8bca9e42017-04-16 15:59:43 -0700272 // Always skip the final resize when the animation is canceled
273 mSkipFinalResize = true;
274 mMoveToFullscreen = false;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800275 }
276
Winson Chung8bca9e42017-04-16 15:59:43 -0700277 private void cancelAndCallAnimationEnd() {
278 if (DEBUG) Slog.d(TAG, "cancelAndCallAnimationEnd: mTarget=" + mTarget);
279 mSkipAnimationEnd = false;
280 super.cancel();
Winson Chung19953ca2017-04-11 11:19:23 -0700281 }
282
Wale Ogunwalece144522016-02-05 22:51:01 -0800283 @Override
284 public void cancel() {
Winson Chung19953ca2017-04-11 11:19:23 -0700285 if (DEBUG) Slog.d(TAG, "cancel: mTarget=" + mTarget);
Winson Chung8bca9e42017-04-16 15:59:43 -0700286 mSkipAnimationEnd = true;
Wale Ogunwalece144522016-02-05 22:51:01 -0800287 super.cancel();
288 }
289
Winson Chung8bca9e42017-04-16 15:59:43 -0700290 /**
291 * @return true if the animation target is the same as the input bounds.
292 */
Winson Chung5af42fc2017-03-24 17:11:33 -0700293 boolean isAnimatingTo(Rect bounds) {
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800294 return mTo.equals(bounds);
295 }
296
Winson Chung8bca9e42017-04-16 15:59:43 -0700297 /**
298 * @return true if we are animating to a larger surface size
299 */
300 @VisibleForTesting
301 boolean animatingToLargerSize() {
302 // TODO: Fix this check for aspect ratio changes
303 return (mFrom.width() * mFrom.height() <= mTo.width() * mTo.height());
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800304 }
305
306 @Override
307 public void onAnimationRepeat(Animator animation) {
Winson Chung5af42fc2017-03-24 17:11:33 -0700308 // Do nothing
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800309 }
310 }
311
Winson Chung8bca9e42017-04-16 15:59:43 -0700312 public void animateBounds(final BoundsAnimationTarget target, Rect from, Rect to,
313 int animationDuration, @SchedulePipModeChangedState int schedulePipModeChangedState,
314 boolean moveToFullscreen) {
315 animateBoundsImpl(target, from, to, animationDuration, schedulePipModeChangedState,
316 moveToFullscreen);
Winson Chung19953ca2017-04-11 11:19:23 -0700317 }
318
319 @VisibleForTesting
Winson Chung8bca9e42017-04-16 15:59:43 -0700320 BoundsAnimator animateBoundsImpl(final BoundsAnimationTarget target, Rect from, Rect to,
321 int animationDuration, @SchedulePipModeChangedState int schedulePipModeChangedState,
322 boolean moveToFullscreen) {
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800323 final BoundsAnimator existing = mRunningAnimations.get(target);
Wale Ogunwalece144522016-02-05 22:51:01 -0800324 final boolean replacing = existing != null;
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800325
326 if (DEBUG) Slog.d(TAG, "animateBounds: target=" + target + " from=" + from + " to=" + to
Winson Chung8bca9e42017-04-16 15:59:43 -0700327 + " schedulePipModeChangedState=" + schedulePipModeChangedState
328 + " replacing=" + replacing);
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800329
Wale Ogunwalece144522016-02-05 22:51:01 -0800330 if (replacing) {
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800331 if (existing.isAnimatingTo(to)) {
Winson Chung19953ca2017-04-11 11:19:23 -0700332 // Just let the current animation complete if it has the same destination as the
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800333 // one we are trying to start.
334 if (DEBUG) Slog.d(TAG, "animateBounds: same destination as existing=" + existing
335 + " ignoring...");
Winson Chung8bca9e42017-04-16 15:59:43 -0700336
Winson Chung19953ca2017-04-11 11:19:23 -0700337 return existing;
Wale Ogunwale5658e4b2016-02-12 12:22:19 -0800338 }
Winson Chung8bca9e42017-04-16 15:59:43 -0700339
340 // Update the PiP callback states if we are replacing the animation
341 if (existing.mSchedulePipModeChangedState == SCHEDULE_PIP_MODE_CHANGED_ON_START) {
342 if (schedulePipModeChangedState == SCHEDULE_PIP_MODE_CHANGED_ON_START) {
343 if (DEBUG) Slog.d(TAG, "animateBounds: still animating to fullscreen, keep"
344 + " existing deferred state");
345 } else {
346 if (DEBUG) Slog.d(TAG, "animateBounds: fullscreen animation canceled, callback"
347 + " on start already processed, schedule deferred update on end");
348 schedulePipModeChangedState = SCHEDULE_PIP_MODE_CHANGED_ON_END;
349 }
350 } else if (existing.mSchedulePipModeChangedState == SCHEDULE_PIP_MODE_CHANGED_ON_END) {
351 if (schedulePipModeChangedState == SCHEDULE_PIP_MODE_CHANGED_ON_START) {
352 if (DEBUG) Slog.d(TAG, "animateBounds: non-fullscreen animation canceled,"
353 + " callback on start will be processed");
354 } else {
355 if (DEBUG) Slog.d(TAG, "animateBounds: still animating from fullscreen, keep"
356 + " existing deferred state");
357 schedulePipModeChangedState = SCHEDULE_PIP_MODE_CHANGED_ON_END;
358 }
359 }
360
361 // Since we are replacing, we skip both animation start and end callbacks
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800362 existing.cancel();
363 }
Winson Chung8bca9e42017-04-16 15:59:43 -0700364 final BoundsAnimator animator = new BoundsAnimator(target, from, to,
365 schedulePipModeChangedState, moveToFullscreen, replacing);
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800366 mRunningAnimations.put(target, animator);
367 animator.setFloatValues(0f, 1f);
Wale Ogunwalee75a9ad2016-03-18 20:43:49 -0700368 animator.setDuration((animationDuration != -1 ? animationDuration
Winson Chungbaa7b722017-03-03 21:33:44 -0800369 : DEFAULT_TRANSITION_DURATION) * DEBUG_ANIMATION_SLOW_DOWN_FACTOR);
370 animator.setInterpolator(mFastOutSlowInInterpolator);
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800371 animator.start();
Winson Chung19953ca2017-04-11 11:19:23 -0700372 return animator;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800373 }
374}