blob: d1145d030654620a06669adbb16f53c61a767a6b [file] [log] [blame]
Craig Mautner164d4bb2012-11-26 13:51:23 -08001/*
2 * Copyright (C) 2011 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 Gruszczynski71b0d2d2015-08-12 18:52:26 -070019import android.annotation.Nullable;
Craig Mautner164d4bb2012-11-26 13:51:23 -080020import android.content.Context;
Winson Chung2820c452014-04-15 15:34:44 -070021import android.content.res.Configuration;
Craig Mautner164d4bb2012-11-26 13:51:23 -080022import android.graphics.Bitmap;
Winson Chung399f6202014-03-19 10:47:20 -070023import android.graphics.Rect;
Craig Mautner164d4bb2012-11-26 13:51:23 -080024import android.os.Debug;
25import android.os.Handler;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010026import android.os.IBinder;
Craig Mautner164d4bb2012-11-26 13:51:23 -080027import android.os.IRemoteCallback;
28import android.util.Slog;
Filip Gruszczynski170192a2015-08-16 17:46:34 -070029import android.util.SparseArray;
30import android.view.AppTransitionAnimationSpec;
Craig Mautner164d4bb2012-11-26 13:51:23 -080031import android.view.WindowManager;
Craig Mautner164d4bb2012-11-26 13:51:23 -080032import android.view.animation.AlphaAnimation;
33import android.view.animation.Animation;
34import android.view.animation.AnimationSet;
35import android.view.animation.AnimationUtils;
Winson Chung399f6202014-03-19 10:47:20 -070036import android.view.animation.ClipRectAnimation;
Chet Haase10e23ab2015-02-11 15:08:38 -080037import android.view.animation.ClipRectLRAnimation;
38import android.view.animation.ClipRectTBAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080039import android.view.animation.Interpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070040import android.view.animation.PathInterpolator;
Craig Mautner164d4bb2012-11-26 13:51:23 -080041import android.view.animation.ScaleAnimation;
Winson Chung399f6202014-03-19 10:47:20 -070042import android.view.animation.TranslateAnimation;
Chet Haase10e23ab2015-02-11 15:08:38 -080043import android.view.animation.TranslateYAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070044
Craig Mautner164d4bb2012-11-26 13:51:23 -080045import com.android.internal.util.DumpUtils.Dump;
46import com.android.server.AttributeCache;
47import com.android.server.wm.WindowManagerService.H;
48
49import java.io.PrintWriter;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010050import java.util.ArrayList;
Craig Mautner164d4bb2012-11-26 13:51:23 -080051
Jorim Jaggi77ba4802015-02-18 13:57:50 +010052import static android.view.WindowManagerInternal.AppTransitionListener;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080053import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation;
54import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070055import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation;
56import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -070057import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070058import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080059import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation;
60import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070061import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation;
62import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080063import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation;
64import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070065import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation;
66import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080067import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation;
68import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080069import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation;
70import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070071import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation;
72import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
73import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation;
74import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080075
Craig Mautner164d4bb2012-11-26 13:51:23 -080076// State management of app transitions. When we are preparing for a
77// transition, mNextAppTransition will be the kind of transition to
78// perform or TRANSIT_NONE if we are not waiting. If we are waiting,
79// mOpeningApps and mClosingApps are the lists of tokens that will be
80// made visible or hidden at the next transition.
81public class AppTransition implements Dump {
82 private static final String TAG = "AppTransition";
Craig Mautner321bdf52012-12-18 09:53:24 -080083 private static final boolean DEBUG_APP_TRANSITIONS =
84 WindowManagerService.DEBUG_APP_TRANSITIONS;
85 private static final boolean DEBUG_ANIM = WindowManagerService.DEBUG_ANIM;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070086 private static final int CLIP_REVEAL_TRANSLATION_Y_DP = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080087
Craig Mautner4b71aa12012-12-27 17:20:01 -080088 /** Not set up for a transition. */
89 public static final int TRANSIT_UNSET = -1;
90 /** No animation for transition. */
91 public static final int TRANSIT_NONE = 0;
92 /** A window in a new activity is being opened on top of an existing one in the same task. */
Craig Mautnerbb742462014-07-07 15:28:55 -070093 public static final int TRANSIT_ACTIVITY_OPEN = 6;
Craig Mautner4b71aa12012-12-27 17:20:01 -080094 /** The window in the top-most activity is being closed to reveal the
95 * previous activity in the same task. */
Craig Mautnerbb742462014-07-07 15:28:55 -070096 public static final int TRANSIT_ACTIVITY_CLOSE = 7;
Craig Mautner4b71aa12012-12-27 17:20:01 -080097 /** A window in a new task is being opened on top of an existing one
98 * in another activity's task. */
Craig Mautnerbb742462014-07-07 15:28:55 -070099 public static final int TRANSIT_TASK_OPEN = 8;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800100 /** A window in the top-most activity is being closed to reveal the
101 * previous activity in a different task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700102 public static final int TRANSIT_TASK_CLOSE = 9;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800103 /** A window in an existing task is being displayed on top of an existing one
104 * in another activity's task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700105 public static final int TRANSIT_TASK_TO_FRONT = 10;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800106 /** A window in an existing task is being put below all other tasks. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700107 public static final int TRANSIT_TASK_TO_BACK = 11;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800108 /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that
109 * does, effectively closing the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700110 public static final int TRANSIT_WALLPAPER_CLOSE = 12;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800111 /** A window in a new activity that does have a wallpaper is being opened on one that didn't,
112 * effectively opening the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700113 public static final int TRANSIT_WALLPAPER_OPEN = 13;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800114 /** A window in a new activity is being opened on top of an existing one, and both are on top
115 * of the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700116 public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800117 /** The window in the top-most activity is being closed to reveal the previous activity, and
118 * both are on top of the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700119 public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
120 /** A window in a new task is being opened behind an existing one in another activity's task.
121 * The new window will show briefly and then be gone. */
122 public static final int TRANSIT_TASK_OPEN_BEHIND = 16;
Winson Chung044d5292014-11-06 11:05:19 -0800123 /** A window in a task is being animated in-place. */
124 public static final int TRANSIT_TASK_IN_PLACE = 17;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800125
Winson Chunga4ccb862014-08-22 15:26:27 -0700126 /** Fraction of animation at which the recents thumbnail stays completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700127 private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800128 /** Fraction of animation at which the recents thumbnail becomes completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700129 private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800130
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700131 private static final int DEFAULT_APP_TRANSITION_DURATION = 336;
132 private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336;
133 private static final int THUMBNAIL_APP_TRANSITION_ALPHA_DURATION = 336;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800134
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800135 private final Context mContext;
136 private final Handler mH;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800137
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800138 private int mNextAppTransition = TRANSIT_UNSET;
139
140 private static final int NEXT_TRANSIT_TYPE_NONE = 0;
141 private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1;
142 private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2;
143 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3;
144 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4;
Winson Chunga4ccb862014-08-22 15:26:27 -0700145 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5;
146 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6;
Winson Chung044d5292014-11-06 11:05:19 -0800147 private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7;
Chet Haase10e23ab2015-02-11 15:08:38 -0800148 private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800149 private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
150
Winson Chung399f6202014-03-19 10:47:20 -0700151 // These are the possible states for the enter/exit activities during a thumbnail transition
152 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0;
153 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1;
154 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2;
155 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3;
156
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800157 private String mNextAppTransitionPackage;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800158 // Used for thumbnail transitions. True if we're scaling up, false if scaling down
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800159 private boolean mNextAppTransitionScaleUp;
160 private IRemoteCallback mNextAppTransitionCallback;
161 private int mNextAppTransitionEnter;
162 private int mNextAppTransitionExit;
Winson Chung044d5292014-11-06 11:05:19 -0800163 private int mNextAppTransitionInPlace;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700164
165 // Keyed by task id.
166 private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs
167 = new SparseArray<>();
168 private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec;
169
Winson Chunga4ccb862014-08-22 15:26:27 -0700170 private Rect mNextAppTransitionInsets = new Rect();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800171
Winson Chung2820c452014-04-15 15:34:44 -0700172 private Rect mTmpFromClipRect = new Rect();
173 private Rect mTmpToClipRect = new Rect();
174
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700175 private final Rect mTmpStartRect = new Rect();
176
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800177 private final static int APP_STATE_IDLE = 0;
178 private final static int APP_STATE_READY = 1;
179 private final static int APP_STATE_RUNNING = 2;
180 private final static int APP_STATE_TIMEOUT = 3;
181 private int mAppTransitionState = APP_STATE_IDLE;
182
183 private final int mConfigShortAnimTime;
Craig Mautner321bdf52012-12-18 09:53:24 -0800184 private final Interpolator mDecelerateInterpolator;
Winson Chunga4ccb862014-08-22 15:26:27 -0700185 private final Interpolator mThumbnailFadeInInterpolator;
186 private final Interpolator mThumbnailFadeOutInterpolator;
Chet Haase10e23ab2015-02-11 15:08:38 -0800187 private final Interpolator mLinearOutSlowInInterpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700188 private final Interpolator mFastOutLinearInInterpolator;
189 private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f);
190
191 /** Interpolator to be used for animations that respond directly to a touch */
192 private final Interpolator mTouchResponseInterpolator =
193 new PathInterpolator(0.3f, 0f, 0.1f, 1f);
194
195 private final int mClipRevealTranslationY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800196
Amith Yamasani4befbec2013-07-10 16:18:01 -0700197 private int mCurrentUserId = 0;
198
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100199 private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>();
200
Craig Mautner164d4bb2012-11-26 13:51:23 -0800201 AppTransition(Context context, Handler h) {
202 mContext = context;
203 mH = h;
Chet Haase10e23ab2015-02-11 15:08:38 -0800204 mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
205 com.android.internal.R.interpolator.linear_out_slow_in);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700206 mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
207 com.android.internal.R.interpolator.fast_out_linear_in);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800208 mConfigShortAnimTime = context.getResources().getInteger(
209 com.android.internal.R.integer.config_shortAnimTime);
Craig Mautner321bdf52012-12-18 09:53:24 -0800210 mDecelerateInterpolator = AnimationUtils.loadInterpolator(context,
211 com.android.internal.R.interpolator.decelerate_cubic);
Winson Chunga4ccb862014-08-22 15:26:27 -0700212 mThumbnailFadeInInterpolator = new Interpolator() {
213 @Override
214 public float getInterpolation(float input) {
215 // Linear response for first fraction, then complete after that.
216 if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) {
217 return 0f;
218 }
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700219 float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) /
Winson Chunga4ccb862014-08-22 15:26:27 -0700220 (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700221 return mFastOutLinearInInterpolator.getInterpolation(t);
Winson Chunga4ccb862014-08-22 15:26:27 -0700222 }
223 };
224 mThumbnailFadeOutInterpolator = new Interpolator() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800225 @Override
226 public float getInterpolation(float input) {
227 // Linear response for first fraction, then complete after that.
228 if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) {
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700229 float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION;
230 return mLinearOutSlowInInterpolator.getInterpolation(t);
Craig Mautner321bdf52012-12-18 09:53:24 -0800231 }
Winson Chunga4ccb862014-08-22 15:26:27 -0700232 return 1f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800233 }
234 };
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700235 mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP
236 * mContext.getResources().getDisplayMetrics().density);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800237 }
238
239 boolean isTransitionSet() {
240 return mNextAppTransition != TRANSIT_UNSET;
241 }
242
243 boolean isTransitionNone() {
244 return mNextAppTransition == TRANSIT_NONE;
245 }
246
247 boolean isTransitionEqual(int transit) {
248 return mNextAppTransition == transit;
249 }
250
251 int getAppTransition() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800252 return mNextAppTransition;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800253 }
254
255 void setAppTransition(int transit) {
256 mNextAppTransition = transit;
257 }
258
259 boolean isReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800260 return mAppTransitionState == APP_STATE_READY
261 || mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800262 }
263
Craig Mautnerae446592012-12-06 19:05:05 -0800264 void setReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800265 mAppTransitionState = APP_STATE_READY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800266 }
267
268 boolean isRunning() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800269 return mAppTransitionState == APP_STATE_RUNNING;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800270 }
271
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800272 void setIdle() {
273 mAppTransitionState = APP_STATE_IDLE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800274 }
275
276 boolean isTimeout() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800277 return mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800278 }
279
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800280 void setTimeout() {
281 mAppTransitionState = APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800282 }
283
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700284 Bitmap getAppTransitionThumbnailHeader(int taskId) {
285 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
286 return spec != null ? spec.bitmap : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800287 }
288
Winson Chunga4ccb862014-08-22 15:26:27 -0700289 /** Returns whether the next thumbnail transition is aspect scaled up. */
290 boolean isNextThumbnailTransitionAspectScaled() {
291 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
292 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
293 }
294
295 /** Returns whether the next thumbnail transition is scaling up. */
296 boolean isNextThumbnailTransitionScaleUp() {
297 return mNextAppTransitionScaleUp;
298 }
299
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700300 boolean prepare() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800301 if (!isRunning()) {
302 mAppTransitionState = APP_STATE_IDLE;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100303 notifyAppTransitionPendingLocked();
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700304 return true;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800305 }
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700306 return false;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800307 }
308
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100309 void goodToGo(AppWindowAnimator openingAppAnimator, AppWindowAnimator closingAppAnimator) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800310 mNextAppTransition = TRANSIT_UNSET;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800311 mAppTransitionState = APP_STATE_RUNNING;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100312 notifyAppTransitionStartingLocked(
313 openingAppAnimator != null ? openingAppAnimator.mAppToken.token : null,
314 closingAppAnimator != null ? closingAppAnimator.mAppToken.token : null,
315 openingAppAnimator != null ? openingAppAnimator.animation : null,
316 closingAppAnimator != null ? closingAppAnimator.animation : null);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800317 }
318
319 void clear() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800320 mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800321 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700322 mNextAppTransitionAnimationsSpecs.clear();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800323 }
324
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800325 void freeze() {
326 setAppTransition(AppTransition.TRANSIT_UNSET);
327 clear();
328 setReady();
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100329 notifyAppTransitionCancelledLocked();
330 }
331
332 void registerListenerLocked(AppTransitionListener listener) {
333 mListeners.add(listener);
334 }
335
Wale Ogunwalea48eadb2015-05-14 17:43:12 -0700336 public void notifyAppTransitionFinishedLocked(IBinder token) {
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100337 for (int i = 0; i < mListeners.size(); i++) {
338 mListeners.get(i).onAppTransitionFinishedLocked(token);
339 }
340 }
341
342 private void notifyAppTransitionPendingLocked() {
343 for (int i = 0; i < mListeners.size(); i++) {
344 mListeners.get(i).onAppTransitionPendingLocked();
345 }
346 }
347
348 private void notifyAppTransitionCancelledLocked() {
349 for (int i = 0; i < mListeners.size(); i++) {
350 mListeners.get(i).onAppTransitionCancelledLocked();
351 }
352 }
353
354 private void notifyAppTransitionStartingLocked(IBinder openToken,
355 IBinder closeToken, Animation openAnimation, Animation closeAnimation) {
356 for (int i = 0; i < mListeners.size(); i++) {
357 mListeners.get(i).onAppTransitionStartingLocked(openToken, closeToken, openAnimation,
358 closeAnimation);
359 }
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800360 }
361
Craig Mautner164d4bb2012-11-26 13:51:23 -0800362 private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
363 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
364 + (lp != null ? lp.packageName : null)
365 + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null));
366 if (lp != null && lp.windowAnimations != 0) {
367 // If this is a system resource, don't try to load it from the
368 // application resources. It is nice to avoid loading application
369 // resources if we can.
370 String packageName = lp.packageName != null ? lp.packageName : "android";
371 int resId = lp.windowAnimations;
372 if ((resId&0xFF000000) == 0x01000000) {
373 packageName = "android";
374 }
375 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
376 + packageName);
377 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700378 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800379 }
380 return null;
381 }
382
383 private AttributeCache.Entry getCachedAnimations(String packageName, int resId) {
384 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package="
385 + packageName + " resId=0x" + Integer.toHexString(resId));
386 if (packageName != null) {
387 if ((resId&0xFF000000) == 0x01000000) {
388 packageName = "android";
389 }
390 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
391 + packageName);
392 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700393 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800394 }
395 return null;
396 }
397
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700398 Animation loadAnimationAttr(WindowManager.LayoutParams lp, int animAttr) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800399 int anim = 0;
400 Context context = mContext;
401 if (animAttr >= 0) {
402 AttributeCache.Entry ent = getCachedAnimations(lp);
403 if (ent != null) {
404 context = ent.context;
405 anim = ent.array.getResourceId(animAttr, 0);
406 }
407 }
408 if (anim != 0) {
409 return AnimationUtils.loadAnimation(context, anim);
410 }
411 return null;
412 }
413
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700414 Animation loadAnimationRes(WindowManager.LayoutParams lp, int resId) {
415 Context context = mContext;
416 if (resId >= 0) {
417 AttributeCache.Entry ent = getCachedAnimations(lp);
418 if (ent != null) {
419 context = ent.context;
420 }
421 return AnimationUtils.loadAnimation(context, resId);
422 }
423 return null;
424 }
425
426 private Animation loadAnimationRes(String packageName, int resId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800427 int anim = 0;
428 Context context = mContext;
429 if (resId >= 0) {
430 AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
431 if (ent != null) {
432 context = ent.context;
433 anim = resId;
434 }
435 }
436 if (anim != 0) {
437 return AnimationUtils.loadAnimation(context, anim);
438 }
439 return null;
440 }
441
Craig Mautner164d4bb2012-11-26 13:51:23 -0800442 /**
443 * Compute the pivot point for an animation that is scaling from a small
444 * rect on screen to a larger rect. The pivot point varies depending on
445 * the distance between the inner and outer edges on both sides. This
446 * function computes the pivot point for one dimension.
447 * @param startPos Offset from left/top edge of outer rectangle to
448 * left/top edge of inner rectangle.
449 * @param finalScale The scaling factor between the size of the outer
450 * and inner rectangles.
451 */
452 private static float computePivot(int startPos, float finalScale) {
453 final float denom = finalScale-1;
454 if (Math.abs(denom) < .0001f) {
455 return startPos;
456 }
457 return -startPos / denom;
458 }
459
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700460 private Animation createScaleUpAnimationLocked(
461 int transit, boolean enter, int appWidth, int appHeight) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800462 Animation a = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700463 getDefaultNextAppTransitionStartRect(mTmpStartRect);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800464 if (enter) {
465 // Entering app zooms out from the center of the initial rect.
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700466 float scaleW = mTmpStartRect.width() / (float) appWidth;
467 float scaleH = mTmpStartRect.height() / (float) appHeight;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800468 Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700469 computePivot(mTmpStartRect.left, scaleW),
470 computePivot(mTmpStartRect.right, scaleH));
Craig Mautner321bdf52012-12-18 09:53:24 -0800471 scale.setInterpolator(mDecelerateInterpolator);
472
Craig Mautner164d4bb2012-11-26 13:51:23 -0800473 Animation alpha = new AlphaAnimation(0, 1);
Winson Chunga4ccb862014-08-22 15:26:27 -0700474 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
Craig Mautner321bdf52012-12-18 09:53:24 -0800475
476 AnimationSet set = new AnimationSet(false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800477 set.addAnimation(scale);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800478 set.addAnimation(alpha);
479 set.setDetachWallpaper(true);
480 a = set;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800481 } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
482 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800483 // If we are on top of the wallpaper, we need an animation that
484 // correctly handles the wallpaper staying static behind all of
485 // the animated elements. To do this, will just have the existing
486 // element fade out.
487 a = new AlphaAnimation(1, 0);
488 a.setDetachWallpaper(true);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800489 } else {
Craig Mautner321bdf52012-12-18 09:53:24 -0800490 // For normal animations, the exiting element just holds in place.
491 a = new AlphaAnimation(1, 1);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800492 }
Craig Mautner321bdf52012-12-18 09:53:24 -0800493
494 // Pick the desired duration. If this is an inter-activity transition,
495 // it is the standard duration for that. Otherwise we use the longer
496 // task transition duration.
497 final long duration;
498 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800499 case TRANSIT_ACTIVITY_OPEN:
500 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800501 duration = mConfigShortAnimTime;
502 break;
503 default:
504 duration = DEFAULT_APP_TRANSITION_DURATION;
505 break;
506 }
507 a.setDuration(duration);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800508 a.setFillAfter(true);
Craig Mautner321bdf52012-12-18 09:53:24 -0800509 a.setInterpolator(mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800510 a.initialize(appWidth, appHeight, appWidth, appHeight);
511 return a;
512 }
513
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700514 private void getDefaultNextAppTransitionStartRect(Rect rect) {
515 if (mDefaultNextAppTransitionAnimationSpec == null ||
516 mDefaultNextAppTransitionAnimationSpec.rect == null) {
517 Slog.wtf(TAG, "Starting rect for app requested, but none available", new Throwable());
518 rect.setEmpty();
519 } else {
520 rect.set(mDefaultNextAppTransitionAnimationSpec.rect);
521 }
522 }
523
524 void getNextAppTransitionStartRect(int taskId, Rect rect) {
525 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
526 if (spec == null || spec.rect == null) {
527 Slog.wtf(TAG, "Starting rect for task: " + taskId + " requested, but not available",
528 new Throwable());
529 rect.setEmpty();
530 } else {
531 rect.set(spec.rect);
532 }
533 }
534
535 private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height) {
536 mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */,
537 null /* bitmap */, new Rect(left, top, left + width, top + height));
538 }
539
Craig Mautner80b1f642015-04-22 10:59:09 -0700540 private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame) {
Chet Haase10e23ab2015-02-11 15:08:38 -0800541 final Animation anim;
542 if (enter) {
543 // Reveal will expand and move faster in horizontal direction
544
Craig Mautner80b1f642015-04-22 10:59:09 -0700545 final int appWidth = appFrame.width();
546 final int appHeight = appFrame.height();
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700547 getDefaultNextAppTransitionStartRect(mTmpStartRect);
Craig Mautner80b1f642015-04-22 10:59:09 -0700548
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700549 float t = 0f;
550 if (appHeight > 0) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700551 t = (float) mTmpStartRect.left / appHeight;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700552 }
553 int translationY = mClipRevealTranslationY
554 + (int)(appHeight / 7f * t);
555
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700556 int centerX = mTmpStartRect.centerX();
557 int centerY = mTmpStartRect.centerY();
558 int halfWidth = mTmpStartRect.width() / 2;
559 int halfHeight = mTmpStartRect.height() / 2;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700560
561 // Clip third of the from size of launch icon, expand to full width/height
Chet Haase10e23ab2015-02-11 15:08:38 -0800562 Animation clipAnimLR = new ClipRectLRAnimation(
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700563 centerX - halfWidth, centerX + halfWidth, 0, appWidth);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700564 clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
565 clipAnimLR.setDuration((long) (DEFAULT_APP_TRANSITION_DURATION / 2.5f));
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700566 Animation clipAnimTB = new ClipRectTBAnimation(centerY - halfHeight - translationY,
567 centerY + halfHeight/ 2 - translationY, 0, appHeight);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700568 clipAnimTB.setInterpolator(mTouchResponseInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800569 clipAnimTB.setDuration(DEFAULT_APP_TRANSITION_DURATION);
570
Chet Haase10e23ab2015-02-11 15:08:38 -0800571 TranslateYAnimation translateY = new TranslateYAnimation(
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700572 Animation.ABSOLUTE, translationY, Animation.ABSOLUTE, 0);
573 translateY.setInterpolator(mLinearOutSlowInInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800574 translateY.setDuration(DEFAULT_APP_TRANSITION_DURATION);
575
576 // Quick fade-in from icon to app window
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700577 final int alphaDuration = DEFAULT_APP_TRANSITION_DURATION / 4;
578 AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
Chet Haase10e23ab2015-02-11 15:08:38 -0800579 alpha.setDuration(alphaDuration);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700580 alpha.setInterpolator(mLinearOutSlowInInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800581
582 AnimationSet set = new AnimationSet(false);
583 set.addAnimation(clipAnimLR);
584 set.addAnimation(clipAnimTB);
Chet Haase10e23ab2015-02-11 15:08:38 -0800585 set.addAnimation(translateY);
586 set.addAnimation(alpha);
Filip Gruszczynski9e2cf5b2015-07-31 12:20:40 -0700587 set.setZAdjustment(Animation.ZORDER_TOP);
Chet Haase10e23ab2015-02-11 15:08:38 -0800588 set.initialize(appWidth, appHeight, appWidth, appHeight);
589 anim = set;
590 } else {
591 final long duration;
592 switch (transit) {
593 case TRANSIT_ACTIVITY_OPEN:
594 case TRANSIT_ACTIVITY_CLOSE:
595 duration = mConfigShortAnimTime;
596 break;
597 default:
598 duration = DEFAULT_APP_TRANSITION_DURATION;
599 break;
600 }
601 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
602 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
603 // If we are on top of the wallpaper, we need an animation that
604 // correctly handles the wallpaper staying static behind all of
605 // the animated elements. To do this, will just have the existing
606 // element fade out.
607 anim = new AlphaAnimation(1, 0);
608 anim.setDetachWallpaper(true);
609 } else {
610 // For normal animations, the exiting element just holds in place.
611 anim = new AlphaAnimation(1, 1);
612 }
613 anim.setInterpolator(mDecelerateInterpolator);
614 anim.setDuration(duration);
615 anim.setFillAfter(true);
616 }
617 return anim;
618 }
619
Winson Chung399f6202014-03-19 10:47:20 -0700620 /**
621 * Prepares the specified animation with a standard duration, interpolator, etc.
622 */
Winson Chung5393dff2014-05-08 14:25:43 -0700623 Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight,
624 int duration, Interpolator interpolator) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700625 if (duration > 0) {
626 a.setDuration(duration);
627 }
Winson Chung5393dff2014-05-08 14:25:43 -0700628 a.setFillAfter(true);
629 a.setInterpolator(interpolator);
630 a.initialize(appWidth, appHeight, appWidth, appHeight);
631 return a;
632 }
633
634 /**
635 * Prepares the specified animation with a standard duration, interpolator, etc.
636 */
Winson Chung399f6202014-03-19 10:47:20 -0700637 Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800638 // Pick the desired duration. If this is an inter-activity transition,
639 // it is the standard duration for that. Otherwise we use the longer
640 // task transition duration.
Winson Chung5393dff2014-05-08 14:25:43 -0700641 final int duration;
Craig Mautner321bdf52012-12-18 09:53:24 -0800642 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800643 case TRANSIT_ACTIVITY_OPEN:
644 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800645 duration = mConfigShortAnimTime;
646 break;
647 default:
648 duration = DEFAULT_APP_TRANSITION_DURATION;
649 break;
650 }
Winson Chung5393dff2014-05-08 14:25:43 -0700651 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration,
652 mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800653 }
654
Winson Chung399f6202014-03-19 10:47:20 -0700655 /**
656 * Return the current thumbnail transition state.
657 */
658 int getThumbnailTransitionState(boolean enter) {
659 if (enter) {
660 if (mNextAppTransitionScaleUp) {
661 return THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
662 } else {
663 return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN;
664 }
665 } else {
666 if (mNextAppTransitionScaleUp) {
667 return THUMBNAIL_TRANSITION_EXIT_SCALE_UP;
668 } else {
669 return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN;
670 }
671 }
672 }
673
674 /**
675 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700676 * when a thumbnail is specified with the pending animation override.
Winson Chung399f6202014-03-19 10:47:20 -0700677 */
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700678 Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, Bitmap thumbnailHeader,
679 final int taskId) {
Winson Chung399f6202014-03-19 10:47:20 -0700680 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700681 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chung399f6202014-03-19 10:47:20 -0700682 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700683 final int thumbHeightI = thumbnailHeader.getHeight();
Winson Chung399f6202014-03-19 10:47:20 -0700684 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700685 final int appWidth = appRect.width();
Winson Chung399f6202014-03-19 10:47:20 -0700686
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700687 float scaleW = appWidth / thumbWidth;
Winson Chunga4ccb862014-08-22 15:26:27 -0700688 float unscaledHeight = thumbHeight * scaleW;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700689 getNextAppTransitionStartRect(taskId, mTmpStartRect);
690 float unscaledStartY = mTmpStartRect.top - (unscaledHeight - thumbHeight) / 2f;
Winson Chung399f6202014-03-19 10:47:20 -0700691 if (mNextAppTransitionScaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700692 // Animation up from the thumbnail to the full screen
693 Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700694 mTmpStartRect.left + (thumbWidth / 2f), mTmpStartRect.top + (thumbHeight / 2f));
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700695 scale.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700696 scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
Winson Chung399f6202014-03-19 10:47:20 -0700697 Animation alpha = new AlphaAnimation(1, 0);
Winson Chunga4ccb862014-08-22 15:26:27 -0700698 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
699 alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION);
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700700 final float toX = appRect.left + appRect.width() / 2 -
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700701 (mTmpStartRect.left + thumbWidth / 2);
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700702 final float toY = appRect.top + mNextAppTransitionInsets.top + -unscaledStartY;
703 Animation translate = new TranslateAnimation(0, toX, 0, toY);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700704 translate.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700705 translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
Winson Chung399f6202014-03-19 10:47:20 -0700706
707 // This AnimationSet uses the Interpolators assigned above.
708 AnimationSet set = new AnimationSet(false);
709 set.addAnimation(scale);
710 set.addAnimation(alpha);
Winson Chunga4ccb862014-08-22 15:26:27 -0700711 set.addAnimation(translate);
Winson Chung399f6202014-03-19 10:47:20 -0700712 a = set;
713 } else {
Winson Chunga4ccb862014-08-22 15:26:27 -0700714 // Animation down from the full screen to the thumbnail
715 Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700716 mTmpStartRect.left + (thumbWidth / 2f), mTmpStartRect.top + (thumbHeight / 2f));
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700717 scale.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700718 scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
719 Animation alpha = new AlphaAnimation(0f, 1f);
720 alpha.setInterpolator(mThumbnailFadeInInterpolator);
721 alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION);
722 Animation translate = new TranslateAnimation(0, 0, -unscaledStartY +
723 mNextAppTransitionInsets.top, 0);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700724 translate.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700725 translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
Winson Chung399f6202014-03-19 10:47:20 -0700726
Winson Chunga4ccb862014-08-22 15:26:27 -0700727 // This AnimationSet uses the Interpolators assigned above.
728 AnimationSet set = new AnimationSet(false);
729 set.addAnimation(scale);
730 set.addAnimation(alpha);
731 set.addAnimation(translate);
732 a = set;
733
734 }
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700735 return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0,
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700736 mTouchResponseInterpolator);
Winson Chung399f6202014-03-19 10:47:20 -0700737 }
738
739 /**
740 * This alternate animation is created when we are doing a thumbnail transition, for the
741 * activity that is leaving, and the activity that is entering.
742 */
Winson Chunga4ccb862014-08-22 15:26:27 -0700743 Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState,
744 int appWidth, int appHeight, int orientation, int transit, Rect containingFrame,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700745 Rect contentInsets, @Nullable Rect surfaceInsets, boolean resizedWindow,
746 int taskId) {
Winson Chung399f6202014-03-19 10:47:20 -0700747 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700748 getDefaultNextAppTransitionStartRect(mTmpStartRect);
749 final int thumbWidthI = mTmpStartRect.width();
Winson Chung399f6202014-03-19 10:47:20 -0700750 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700751 final int thumbHeightI = mTmpStartRect.height();
Winson Chung399f6202014-03-19 10:47:20 -0700752 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
753
Winson Chung2820c452014-04-15 15:34:44 -0700754 // Used for the ENTER_SCALE_UP and EXIT_SCALE_DOWN transitions
755 float scale = 1f;
756 int scaledTopDecor = 0;
757
Winson Chung399f6202014-03-19 10:47:20 -0700758 switch (thumbTransitState) {
759 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700760 if (resizedWindow) {
761 a = createAspectScaledThumbnailEnterNonFullscreenAnimationLocked(
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700762 containingFrame, surfaceInsets, taskId);
Winson Chung2820c452014-04-15 15:34:44 -0700763 } else {
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700764 // App window scaling up to become full screen
765 if (orientation == Configuration.ORIENTATION_PORTRAIT) {
766 // In portrait, we scale the width and clip to the top/left square
767 scale = thumbWidth / appWidth;
768 scaledTopDecor = (int) (scale * contentInsets.top);
769 int unscaledThumbHeight = (int) (thumbHeight / scale);
770 mTmpFromClipRect.set(containingFrame);
771 mTmpFromClipRect.bottom = (mTmpFromClipRect.top + unscaledThumbHeight);
772 mTmpToClipRect.set(containingFrame);
773 } else {
774 // In landscape, we scale the height and clip to the top/left square
775 scale = thumbHeight / (appHeight - contentInsets.top);
776 scaledTopDecor = (int) (scale * contentInsets.top);
777 int unscaledThumbWidth = (int) (thumbWidth / scale);
778 mTmpFromClipRect.set(containingFrame);
779 mTmpFromClipRect.right = (mTmpFromClipRect.left + unscaledThumbWidth);
780 mTmpToClipRect.set(containingFrame);
781 }
782 // exclude top screen decor (status bar) region from the source clip.
783 mTmpFromClipRect.top = contentInsets.top;
784
785 mNextAppTransitionInsets.set(contentInsets);
786
787 Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700788 computePivot(mTmpStartRect.left, scale),
789 computePivot(mTmpStartRect.top, scale));
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700790 Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
791 Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0);
792
793 AnimationSet set = new AnimationSet(true);
794 set.addAnimation(clipAnim);
795 set.addAnimation(scaleAnim);
796 set.addAnimation(translateAnim);
797 a = set;
Winson Chung2820c452014-04-15 15:34:44 -0700798 }
Winson Chung399f6202014-03-19 10:47:20 -0700799 break;
800 }
801 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
Winson Chunga4ccb862014-08-22 15:26:27 -0700802 // Previous app window during the scale up
Winson Chung399f6202014-03-19 10:47:20 -0700803 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700804 // Fade out the source activity if we are animating to a wallpaper
Winson Chung399f6202014-03-19 10:47:20 -0700805 // activity.
806 a = new AlphaAnimation(1, 0);
807 } else {
Winson Chung399f6202014-03-19 10:47:20 -0700808 a = new AlphaAnimation(1, 1);
809 }
810 break;
811 }
812 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
Winson Chunga4ccb862014-08-22 15:26:27 -0700813 // Target app window during the scale down
814 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
815 // Fade in the destination activity if we are animating from a wallpaper
816 // activity.
817 a = new AlphaAnimation(0, 1);
818 } else {
819 a = new AlphaAnimation(1, 1);
820 }
Winson Chung399f6202014-03-19 10:47:20 -0700821 break;
822 }
823 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
Winson Chunga4ccb862014-08-22 15:26:27 -0700824 // App window scaling down from full screen
Winson Chung2820c452014-04-15 15:34:44 -0700825 if (orientation == Configuration.ORIENTATION_PORTRAIT) {
826 // In portrait, we scale the width and clip to the top/left square
827 scale = thumbWidth / appWidth;
828 scaledTopDecor = (int) (scale * contentInsets.top);
829 int unscaledThumbHeight = (int) (thumbHeight / scale);
830 mTmpFromClipRect.set(containingFrame);
831 mTmpToClipRect.set(containingFrame);
832 mTmpToClipRect.bottom = (mTmpToClipRect.top + unscaledThumbHeight);
833 } else {
834 // In landscape, we scale the height and clip to the top/left square
835 scale = thumbHeight / (appHeight - contentInsets.top);
836 scaledTopDecor = (int) (scale * contentInsets.top);
837 int unscaledThumbWidth = (int) (thumbWidth / scale);
838 mTmpFromClipRect.set(containingFrame);
839 mTmpToClipRect.set(containingFrame);
840 mTmpToClipRect.right = (mTmpToClipRect.left + unscaledThumbWidth);
841 }
Wale Ogunwale35a57f82015-07-01 15:07:36 -0700842 // exclude top screen decor (status bar) region from the destination clip.
843 mTmpToClipRect.top = contentInsets.top;
844
Winson Chunga4ccb862014-08-22 15:26:27 -0700845 mNextAppTransitionInsets.set(contentInsets);
Winson Chung399f6202014-03-19 10:47:20 -0700846
847 Animation scaleAnim = new ScaleAnimation(1, scale, 1, scale,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700848 computePivot(mTmpStartRect.left, scale),
849 computePivot(mTmpStartRect.top, scale));
Winson Chung2820c452014-04-15 15:34:44 -0700850 Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
Winson Chung399f6202014-03-19 10:47:20 -0700851 Animation translateAnim = new TranslateAnimation(0, 0, 0, -scaledTopDecor);
852
853 AnimationSet set = new AnimationSet(true);
Winson Chung399f6202014-03-19 10:47:20 -0700854 set.addAnimation(clipAnim);
855 set.addAnimation(scaleAnim);
856 set.addAnimation(translateAnim);
857
858 a = set;
859 a.setZAdjustment(Animation.ZORDER_TOP);
860 break;
861 }
862 default:
863 throw new RuntimeException("Invalid thumbnail transition state");
864 }
865
Winson Chungab79fce2014-11-04 16:15:22 -0800866 int duration = Math.max(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION,
867 THUMBNAIL_APP_TRANSITION_DURATION);
868 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration,
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700869 mTouchResponseInterpolator);
Winson Chung399f6202014-03-19 10:47:20 -0700870 }
871
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700872 private Animation createAspectScaledThumbnailEnterNonFullscreenAnimationLocked(
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700873 Rect containingFrame, @Nullable Rect surfaceInsets, int taskId) {
874 getNextAppTransitionStartRect(taskId, mTmpStartRect);
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700875 float width = containingFrame.width();
876 float height = containingFrame.height();
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700877 float scaleWidth = mTmpStartRect.width() / width;
878 float scaleHeight = mTmpStartRect.height() / height;
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700879 AnimationSet set = new AnimationSet(true);
880 int surfaceInsetsHorizontal = surfaceInsets == null
881 ? 0 : surfaceInsets.left + surfaceInsets.right;
882 int surfaceInsetsVertical = surfaceInsets == null
883 ? 0 : surfaceInsets.top + surfaceInsets.bottom;
884 // We want the scaling to happen from the center of the surface. In order to achieve that,
885 // we need to account for surface insets that will be used to enlarge the surface.
886 ScaleAnimation scale = new ScaleAnimation(scaleWidth, 1, scaleHeight, 1,
887 (width + surfaceInsetsHorizontal) / 2, (height + surfaceInsetsVertical) / 2);
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700888 int fromX = mTmpStartRect.left + mTmpStartRect.width() / 2
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700889 - (containingFrame.left + containingFrame.width() / 2);
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700890 int fromY = mTmpStartRect.top + mTmpStartRect.height() / 2
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700891 - (containingFrame.top + containingFrame.height() / 2);
892 TranslateAnimation translation = new TranslateAnimation(fromX, 0, fromY, 0);
893 set.addAnimation(scale);
894 set.addAnimation(translation);
895 return set;
896 }
897
Winson Chung399f6202014-03-19 10:47:20 -0700898 /**
Winson Chunga4ccb862014-08-22 15:26:27 -0700899 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700900 * when a thumbnail is specified with the pending animation override.
Winson Chunga4ccb862014-08-22 15:26:27 -0700901 */
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700902 Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit,
903 Bitmap thumbnailHeader) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700904 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700905 getDefaultNextAppTransitionStartRect(mTmpStartRect);
906 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chunga4ccb862014-08-22 15:26:27 -0700907 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700908 final int thumbHeightI = thumbnailHeader.getHeight();
Winson Chunga4ccb862014-08-22 15:26:27 -0700909 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
910
911 if (mNextAppTransitionScaleUp) {
912 // Animation for the thumbnail zooming from its initial size to the full screen
913 float scaleW = appWidth / thumbWidth;
914 float scaleH = appHeight / thumbHeight;
915 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700916 computePivot(mTmpStartRect.left, 1 / scaleW),
917 computePivot(mTmpStartRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -0700918 scale.setInterpolator(mDecelerateInterpolator);
919
920 Animation alpha = new AlphaAnimation(1, 0);
921 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
922
923 // This AnimationSet uses the Interpolators assigned above.
924 AnimationSet set = new AnimationSet(false);
925 set.addAnimation(scale);
926 set.addAnimation(alpha);
927 a = set;
928 } else {
929 // Animation for the thumbnail zooming down from the full screen to its final size
930 float scaleW = appWidth / thumbWidth;
931 float scaleH = appHeight / thumbHeight;
932 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700933 computePivot(mTmpStartRect.left, 1 / scaleW),
934 computePivot(mTmpStartRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -0700935 }
936
937 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
938 }
939
940 /**
Winson Chung399f6202014-03-19 10:47:20 -0700941 * This animation is created when we are doing a thumbnail transition, for the activity that is
942 * leaving, and the activity that is entering.
943 */
944 Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700945 int appHeight, int transit, int taskId) {
946 Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
Winson Chung399f6202014-03-19 10:47:20 -0700947 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700948 getDefaultNextAppTransitionStartRect(mTmpStartRect);
949 final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
Winson Chung399f6202014-03-19 10:47:20 -0700950 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700951 final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
Winson Chung399f6202014-03-19 10:47:20 -0700952 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
953
954 switch (thumbTransitState) {
955 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
956 // Entering app scales up with the thumbnail
957 float scaleW = thumbWidth / appWidth;
958 float scaleH = thumbHeight / appHeight;
959 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700960 computePivot(mTmpStartRect.left, scaleW),
961 computePivot(mTmpStartRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -0700962 break;
963 }
964 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
965 // Exiting app while the thumbnail is scaling up should fade or stay in place
966 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
967 // Fade out while bringing up selected activity. This keeps the
968 // current activity from showing through a launching wallpaper
969 // activity.
970 a = new AlphaAnimation(1, 0);
971 } else {
972 // noop animation
973 a = new AlphaAnimation(1, 1);
974 }
975 break;
976 }
977 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
978 // Entering the other app, it should just be visible while we scale the thumbnail
979 // down above it
980 a = new AlphaAnimation(1, 1);
981 break;
982 }
983 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
984 // Exiting the current app, the app should scale down with the thumbnail
985 float scaleW = thumbWidth / appWidth;
986 float scaleH = thumbHeight / appHeight;
987 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700988 computePivot(mTmpStartRect.left, scaleW),
989 computePivot(mTmpStartRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -0700990
991 Animation alpha = new AlphaAnimation(1, 0);
992
993 AnimationSet set = new AnimationSet(true);
994 set.addAnimation(scale);
995 set.addAnimation(alpha);
996 set.setZAdjustment(Animation.ZORDER_TOP);
997 a = set;
998 break;
999 }
1000 default:
1001 throw new RuntimeException("Invalid thumbnail transition state");
1002 }
1003
1004 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
1005 }
1006
Jorim Jaggic554b772015-06-04 16:07:57 -07001007 /**
1008 * @return true if and only if the first frame of the transition can be skipped, i.e. the first
1009 * frame of the transition doesn't change the visuals on screen, so we can start
1010 * directly with the second one
1011 */
1012 boolean canSkipFirstFrame() {
1013 return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM
1014 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE
1015 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL;
1016 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001017
1018 Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter,
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001019 int appWidth, int appHeight, int orientation, Rect containingFrame, Rect contentInsets,
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001020 @Nullable Rect surfaceInsets, Rect appFrame, boolean isVoiceInteraction,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001021 boolean resizedWindow, int taskId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001022 Animation a;
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001023 if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN
1024 || transit == TRANSIT_TASK_OPEN
1025 || transit == TRANSIT_TASK_TO_FRONT)) {
1026 a = loadAnimationRes(lp, enter
1027 ? com.android.internal.R.anim.voice_activity_open_enter
1028 : com.android.internal.R.anim.voice_activity_open_exit);
1029 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1030 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001031 + " anim=" + a + " transit=" + appTransitionToString(transit)
1032 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001033 } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE
1034 || transit == TRANSIT_TASK_CLOSE
1035 || transit == TRANSIT_TASK_TO_BACK)) {
1036 a = loadAnimationRes(lp, enter
1037 ? com.android.internal.R.anim.voice_activity_close_enter
1038 : com.android.internal.R.anim.voice_activity_close_exit);
1039 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1040 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001041 + " anim=" + a + " transit=" + appTransitionToString(transit)
1042 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001043 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
1044 a = loadAnimationRes(mNextAppTransitionPackage, enter ?
Craig Mautner164d4bb2012-11-26 13:51:23 -08001045 mNextAppTransitionEnter : mNextAppTransitionExit);
1046 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1047 "applyAnimation:"
1048 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001049 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001050 + " Callers=" + Debug.getCallers(3));
Winson Chung044d5292014-11-06 11:05:19 -08001051 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
1052 a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
1053 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1054 "applyAnimation:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001055 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE"
1056 + " transit=" + appTransitionToString(transit)
1057 + " Callers=" + Debug.getCallers(3));
Chet Haase10e23ab2015-02-11 15:08:38 -08001058 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) {
Craig Mautner80b1f642015-04-22 10:59:09 -07001059 a = createClipRevealAnimationLocked(transit, enter, appFrame);
Chet Haase10e23ab2015-02-11 15:08:38 -08001060 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1061 "applyAnimation:"
1062 + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL"
1063 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001064 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001065 a = createScaleUpAnimationLocked(transit, enter, appWidth, appHeight);
1066 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1067 "applyAnimation:"
1068 + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001069 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001070 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001071 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
1072 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001073 mNextAppTransitionScaleUp =
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001074 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
Winson Chunga4ccb862014-08-22 15:26:27 -07001075 a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter),
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001076 appWidth, appHeight, transit, taskId);
Winson Chunga4ccb862014-08-22 15:26:27 -07001077 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1078 String animName = mNextAppTransitionScaleUp ?
1079 "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
1080 Slog.v(TAG, "applyAnimation:"
1081 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001082 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Winson Chunga4ccb862014-08-22 15:26:27 -07001083 + " Callers=" + Debug.getCallers(3));
1084 }
1085 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
1086 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) {
1087 mNextAppTransitionScaleUp =
1088 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP);
1089 a = createAspectScaledThumbnailEnterExitAnimationLocked(
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001090 getThumbnailTransitionState(enter), appWidth, appHeight, orientation, transit,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001091 containingFrame, contentInsets, surfaceInsets, resizedWindow, taskId);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001092 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1093 String animName = mNextAppTransitionScaleUp ?
Winson Chunga4ccb862014-08-22 15:26:27 -07001094 "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner164d4bb2012-11-26 13:51:23 -08001095 Slog.v(TAG, "applyAnimation:"
1096 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001097 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001098 + " Callers=" + Debug.getCallers(3));
1099 }
1100 } else {
1101 int animAttr = 0;
1102 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -08001103 case TRANSIT_ACTIVITY_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001104 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001105 ? WindowAnimation_activityOpenEnterAnimation
1106 : WindowAnimation_activityOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001107 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001108 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001109 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001110 ? WindowAnimation_activityCloseEnterAnimation
1111 : WindowAnimation_activityCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001112 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001113 case TRANSIT_TASK_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001114 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001115 ? WindowAnimation_taskOpenEnterAnimation
1116 : WindowAnimation_taskOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001117 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001118 case TRANSIT_TASK_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001119 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001120 ? WindowAnimation_taskCloseEnterAnimation
1121 : WindowAnimation_taskCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001122 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001123 case TRANSIT_TASK_TO_FRONT:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001124 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001125 ? WindowAnimation_taskToFrontEnterAnimation
1126 : WindowAnimation_taskToFrontExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001127 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001128 case TRANSIT_TASK_TO_BACK:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001129 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001130 ? WindowAnimation_taskToBackEnterAnimation
1131 : WindowAnimation_taskToBackExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001132 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001133 case TRANSIT_WALLPAPER_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001134 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001135 ? WindowAnimation_wallpaperOpenEnterAnimation
1136 : WindowAnimation_wallpaperOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001137 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001138 case TRANSIT_WALLPAPER_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001139 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001140 ? WindowAnimation_wallpaperCloseEnterAnimation
1141 : WindowAnimation_wallpaperCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001142 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001143 case TRANSIT_WALLPAPER_INTRA_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001144 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001145 ? WindowAnimation_wallpaperIntraOpenEnterAnimation
1146 : WindowAnimation_wallpaperIntraOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001147 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001148 case TRANSIT_WALLPAPER_INTRA_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001149 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001150 ? WindowAnimation_wallpaperIntraCloseEnterAnimation
1151 : WindowAnimation_wallpaperIntraCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001152 break;
Craig Mautnerbb742462014-07-07 15:28:55 -07001153 case TRANSIT_TASK_OPEN_BEHIND:
1154 animAttr = enter
1155 ? WindowAnimation_launchTaskBehindSourceAnimation
Craig Mautner3b2cd1d2014-08-25 14:25:54 -07001156 : WindowAnimation_launchTaskBehindTargetAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001157 }
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001158 a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001159 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1160 "applyAnimation:"
1161 + " anim=" + a
1162 + " animAttr=0x" + Integer.toHexString(animAttr)
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001163 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001164 + " Callers=" + Debug.getCallers(3));
1165 }
1166 return a;
1167 }
1168
1169 void postAnimationCallback() {
1170 if (mNextAppTransitionCallback != null) {
1171 mH.sendMessage(mH.obtainMessage(H.DO_ANIMATION_CALLBACK, mNextAppTransitionCallback));
1172 mNextAppTransitionCallback = null;
1173 }
1174 }
1175
1176 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
1177 IRemoteCallback startedCallback) {
1178 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001179 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001180 mNextAppTransitionPackage = packageName;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001181 mNextAppTransitionAnimationsSpecs.clear();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001182 mNextAppTransitionEnter = enterAnim;
1183 mNextAppTransitionExit = exitAnim;
1184 postAnimationCallback();
1185 mNextAppTransitionCallback = startedCallback;
1186 } else {
1187 postAnimationCallback();
1188 }
1189 }
1190
1191 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001192 int startHeight) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001193 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001194 mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001195 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001196 mNextAppTransitionAnimationsSpecs.clear();
1197 putDefaultNextAppTransitionCoordinates(startX, startY, startX + startWidth,
1198 startY + startHeight);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001199 postAnimationCallback();
1200 mNextAppTransitionCallback = null;
1201 }
1202 }
1203
Chet Haase10e23ab2015-02-11 15:08:38 -08001204 void overridePendingAppTransitionClipReveal(int startX, int startY,
1205 int startWidth, int startHeight) {
1206 if (isTransitionSet()) {
1207 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001208 putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight);
Chet Haase10e23ab2015-02-11 15:08:38 -08001209 postAnimationCallback();
1210 mNextAppTransitionCallback = null;
1211 }
1212 }
1213
Craig Mautner164d4bb2012-11-26 13:51:23 -08001214 void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
1215 IRemoteCallback startedCallback, boolean scaleUp) {
1216 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001217 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP
1218 : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001219 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001220 mNextAppTransitionAnimationsSpecs.clear();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001221 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001222 putDefaultNextAppTransitionCoordinates(startX, startY, 0 ,0);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001223 postAnimationCallback();
1224 mNextAppTransitionCallback = startedCallback;
1225 } else {
1226 postAnimationCallback();
1227 }
1228 }
1229
Winson Chunga4ccb862014-08-22 15:26:27 -07001230 void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY,
Winson Chung2e7f3bd2014-09-05 13:17:22 +02001231 int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001232 if (isTransitionSet()) {
1233 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1234 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
1235 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001236 mNextAppTransitionAnimationsSpecs.clear();
Winson Chunga4ccb862014-08-22 15:26:27 -07001237 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001238 putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight);
Winson Chunga4ccb862014-08-22 15:26:27 -07001239 postAnimationCallback();
1240 mNextAppTransitionCallback = startedCallback;
1241 } else {
1242 postAnimationCallback();
1243 }
1244 }
1245
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001246 public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs,
1247 IRemoteCallback callback, boolean scaleUp) {
1248 if (isTransitionSet()) {
1249 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1250 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
1251 mNextAppTransitionPackage = null;
1252 mNextAppTransitionAnimationsSpecs.clear();
1253 mNextAppTransitionScaleUp = scaleUp;
1254 for (int i = 0; i < specs.length; i++) {
1255 AppTransitionAnimationSpec spec = specs[i];
1256 if (spec != null) {
1257 mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec);
1258 }
1259 }
1260 postAnimationCallback();
1261 mNextAppTransitionCallback = callback;
1262 } else {
1263 postAnimationCallback();
1264 }
1265 }
1266
Winson Chung044d5292014-11-06 11:05:19 -08001267 void overrideInPlaceAppTransition(String packageName, int anim) {
1268 if (isTransitionSet()) {
1269 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE;
1270 mNextAppTransitionPackage = packageName;
1271 mNextAppTransitionInPlace = anim;
1272 } else {
1273 postAnimationCallback();
1274 }
1275 }
1276
Craig Mautner164d4bb2012-11-26 13:51:23 -08001277 @Override
1278 public String toString() {
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001279 return "mNextAppTransition=" + appTransitionToString(mNextAppTransition);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001280 }
1281
Craig Mautner4b71aa12012-12-27 17:20:01 -08001282 /**
1283 * Returns the human readable name of a window transition.
1284 *
1285 * @param transition The window transition.
1286 * @return The transition symbolic name.
1287 */
1288 public static String appTransitionToString(int transition) {
1289 switch (transition) {
1290 case TRANSIT_UNSET: {
1291 return "TRANSIT_UNSET";
1292 }
1293 case TRANSIT_NONE: {
1294 return "TRANSIT_NONE";
1295 }
Craig Mautner4b71aa12012-12-27 17:20:01 -08001296 case TRANSIT_ACTIVITY_OPEN: {
1297 return "TRANSIT_ACTIVITY_OPEN";
1298 }
1299 case TRANSIT_ACTIVITY_CLOSE: {
1300 return "TRANSIT_ACTIVITY_CLOSE";
1301 }
1302 case TRANSIT_TASK_OPEN: {
1303 return "TRANSIT_TASK_OPEN";
1304 }
1305 case TRANSIT_TASK_CLOSE: {
1306 return "TRANSIT_TASK_CLOSE";
1307 }
1308 case TRANSIT_TASK_TO_FRONT: {
1309 return "TRANSIT_TASK_TO_FRONT";
1310 }
1311 case TRANSIT_TASK_TO_BACK: {
1312 return "TRANSIT_TASK_TO_BACK";
1313 }
1314 case TRANSIT_WALLPAPER_CLOSE: {
1315 return "TRANSIT_WALLPAPER_CLOSE";
1316 }
1317 case TRANSIT_WALLPAPER_OPEN: {
1318 return "TRANSIT_WALLPAPER_OPEN";
1319 }
1320 case TRANSIT_WALLPAPER_INTRA_OPEN: {
1321 return "TRANSIT_WALLPAPER_INTRA_OPEN";
1322 }
1323 case TRANSIT_WALLPAPER_INTRA_CLOSE: {
1324 return "TRANSIT_WALLPAPER_INTRA_CLOSE";
1325 }
Craig Mautnerbb742462014-07-07 15:28:55 -07001326 case TRANSIT_TASK_OPEN_BEHIND: {
1327 return "TRANSIT_TASK_OPEN_BEHIND";
1328 }
Craig Mautner4b71aa12012-12-27 17:20:01 -08001329 default: {
1330 return "<UNKNOWN>";
1331 }
1332 }
1333 }
1334
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001335 private String appStateToString() {
1336 switch (mAppTransitionState) {
1337 case APP_STATE_IDLE:
1338 return "APP_STATE_IDLE";
1339 case APP_STATE_READY:
1340 return "APP_STATE_READY";
1341 case APP_STATE_RUNNING:
1342 return "APP_STATE_RUNNING";
1343 case APP_STATE_TIMEOUT:
1344 return "APP_STATE_TIMEOUT";
1345 default:
1346 return "unknown state=" + mAppTransitionState;
1347 }
1348 }
1349
1350 private String transitTypeToString() {
1351 switch (mNextAppTransitionType) {
1352 case NEXT_TRANSIT_TYPE_NONE:
1353 return "NEXT_TRANSIT_TYPE_NONE";
1354 case NEXT_TRANSIT_TYPE_CUSTOM:
1355 return "NEXT_TRANSIT_TYPE_CUSTOM";
Winson Chung044d5292014-11-06 11:05:19 -08001356 case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
1357 return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE";
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001358 case NEXT_TRANSIT_TYPE_SCALE_UP:
1359 return "NEXT_TRANSIT_TYPE_SCALE_UP";
1360 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
1361 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP";
1362 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
1363 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN";
Winson Chunga4ccb862014-08-22 15:26:27 -07001364 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP:
1365 return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP";
1366 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN:
1367 return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001368 default:
1369 return "unknown type=" + mNextAppTransitionType;
1370 }
1371 }
1372
Craig Mautner164d4bb2012-11-26 13:51:23 -08001373 @Override
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001374 public void dump(PrintWriter pw, String prefix) {
1375 pw.print(prefix); pw.println(this);
1376 pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString());
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001377 if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) {
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001378 pw.print(prefix); pw.print("mNextAppTransitionType=");
1379 pw.println(transitTypeToString());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001380 }
1381 switch (mNextAppTransitionType) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001382 case NEXT_TRANSIT_TYPE_CUSTOM:
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001383 pw.print(prefix); pw.print("mNextAppTransitionPackage=");
Craig Mautner164d4bb2012-11-26 13:51:23 -08001384 pw.println(mNextAppTransitionPackage);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001385 pw.print(prefix); pw.print("mNextAppTransitionEnter=0x");
Craig Mautner164d4bb2012-11-26 13:51:23 -08001386 pw.print(Integer.toHexString(mNextAppTransitionEnter));
1387 pw.print(" mNextAppTransitionExit=0x");
1388 pw.println(Integer.toHexString(mNextAppTransitionExit));
1389 break;
Winson Chung044d5292014-11-06 11:05:19 -08001390 case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001391 pw.print(prefix); pw.print("mNextAppTransitionPackage=");
Winson Chung044d5292014-11-06 11:05:19 -08001392 pw.println(mNextAppTransitionPackage);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001393 pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x");
Winson Chung044d5292014-11-06 11:05:19 -08001394 pw.print(Integer.toHexString(mNextAppTransitionInPlace));
1395 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001396 case NEXT_TRANSIT_TYPE_SCALE_UP: {
1397 getDefaultNextAppTransitionStartRect(mTmpStartRect);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001398 pw.print(prefix); pw.print("mNextAppTransitionStartX=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001399 pw.print(mTmpStartRect.left);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001400 pw.print(" mNextAppTransitionStartY=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001401 pw.println(mTmpStartRect.top);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001402 pw.print(prefix); pw.print("mNextAppTransitionStartWidth=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001403 pw.print(mTmpStartRect.width());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001404 pw.print(" mNextAppTransitionStartHeight=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001405 pw.println(mTmpStartRect.height());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001406 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001407 }
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001408 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
1409 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
Winson Chunga4ccb862014-08-22 15:26:27 -07001410 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP:
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001411 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: {
1412 pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec=");
1413 pw.println(mDefaultNextAppTransitionAnimationSpec);
1414 pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs=");
1415 pw.println(mNextAppTransitionAnimationsSpecs);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001416 pw.print(prefix); pw.print("mNextAppTransitionScaleUp=");
1417 pw.println(mNextAppTransitionScaleUp);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001418 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001419 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001420 }
1421 if (mNextAppTransitionCallback != null) {
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001422 pw.print(prefix); pw.print("mNextAppTransitionCallback=");
1423 pw.println(mNextAppTransitionCallback);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001424 }
1425 }
Amith Yamasani4befbec2013-07-10 16:18:01 -07001426
1427 public void setCurrentUser(int newUserId) {
1428 mCurrentUserId = newUserId;
1429 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001430}