blob: 7d8b5aff869b409b33e0b2be244081a025f6a465 [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
Craig Mautner164d4bb2012-11-26 13:51:23 -080019import android.content.Context;
20import android.graphics.Bitmap;
21import android.graphics.Point;
Winson Chung399f6202014-03-19 10:47:20 -070022import android.graphics.Rect;
Craig Mautner164d4bb2012-11-26 13:51:23 -080023import android.os.Debug;
24import android.os.Handler;
25import android.os.IRemoteCallback;
Winson Chung399f6202014-03-19 10:47:20 -070026import android.os.SystemProperties;
Craig Mautner164d4bb2012-11-26 13:51:23 -080027import android.util.Slog;
28import android.view.WindowManager;
Craig Mautner164d4bb2012-11-26 13:51:23 -080029import android.view.animation.AlphaAnimation;
30import android.view.animation.Animation;
31import android.view.animation.AnimationSet;
32import android.view.animation.AnimationUtils;
Winson Chung399f6202014-03-19 10:47:20 -070033import android.view.animation.ClipRectAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080034import android.view.animation.Interpolator;
35import android.view.animation.ScaleAnimation;
36
Winson Chung399f6202014-03-19 10:47:20 -070037import android.view.animation.TranslateAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080038import com.android.internal.util.DumpUtils.Dump;
39import com.android.server.AttributeCache;
40import com.android.server.wm.WindowManagerService.H;
41
42import java.io.PrintWriter;
43
Craig Mautner9a29a5d2012-12-27 19:03:40 -080044import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation;
45import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
46import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation;
47import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
48import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation;
49import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation;
50import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation;
51import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation;
52import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation;
53import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation;
54import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation;
55import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
56import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation;
57import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
58import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation;
59import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation;
60import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation;
61import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
62import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation;
63import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation;
64
Craig Mautner164d4bb2012-11-26 13:51:23 -080065// State management of app transitions. When we are preparing for a
66// transition, mNextAppTransition will be the kind of transition to
67// perform or TRANSIT_NONE if we are not waiting. If we are waiting,
68// mOpeningApps and mClosingApps are the lists of tokens that will be
69// made visible or hidden at the next transition.
70public class AppTransition implements Dump {
71 private static final String TAG = "AppTransition";
Craig Mautner321bdf52012-12-18 09:53:24 -080072 private static final boolean DEBUG_APP_TRANSITIONS =
73 WindowManagerService.DEBUG_APP_TRANSITIONS;
74 private static final boolean DEBUG_ANIM = WindowManagerService.DEBUG_ANIM;
75
Craig Mautner9a29a5d2012-12-27 19:03:40 -080076 /** Bit mask that is set for all enter transition. */
Craig Mautner4b71aa12012-12-27 17:20:01 -080077 public static final int TRANSIT_ENTER_MASK = 0x1000;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080078
79 /** Bit mask that is set for all exit transitions. */
Craig Mautner4b71aa12012-12-27 17:20:01 -080080 public static final int TRANSIT_EXIT_MASK = 0x2000;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080081
Craig Mautner4b71aa12012-12-27 17:20:01 -080082 /** Not set up for a transition. */
83 public static final int TRANSIT_UNSET = -1;
84 /** No animation for transition. */
85 public static final int TRANSIT_NONE = 0;
86 /** A window in a new activity is being opened on top of an existing one in the same task. */
87 public static final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
88 /** The window in the top-most activity is being closed to reveal the
89 * previous activity in the same task. */
90 public static final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
91 /** A window in a new task is being opened on top of an existing one
92 * in another activity's task. */
93 public static final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
94 /** A window in the top-most activity is being closed to reveal the
95 * previous activity in a different task. */
96 public static final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
97 /** A window in an existing task is being displayed on top of an existing one
98 * in another activity's task. */
99 public static final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
100 /** A window in an existing task is being put below all other tasks. */
101 public static final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800102 /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that
103 * does, effectively closing the wallpaper. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800104 public static final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800105 /** A window in a new activity that does have a wallpaper is being opened on one that didn't,
106 * effectively opening the wallpaper. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800107 public static final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800108 /** A window in a new activity is being opened on top of an existing one, and both are on top
109 * of the wallpaper. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800110 public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800111 /** The window in the top-most activity is being closed to reveal the previous activity, and
112 * both are on top of the wallpaper. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800113 public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800114
Craig Mautner321bdf52012-12-18 09:53:24 -0800115 /** Fraction of animation at which the recents thumbnail becomes completely transparent */
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800116 private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.25f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800117
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800118 private static final long DEFAULT_APP_TRANSITION_DURATION = 250;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800119
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800120 private final Context mContext;
121 private final Handler mH;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800122
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800123 private int mNextAppTransition = TRANSIT_UNSET;
124
125 private static final int NEXT_TRANSIT_TYPE_NONE = 0;
126 private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1;
127 private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2;
128 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3;
129 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4;
130 private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
131
Winson Chung399f6202014-03-19 10:47:20 -0700132 // These are the possible states for the enter/exit activities during a thumbnail transition
133 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0;
134 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1;
135 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2;
136 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3;
137
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800138 private String mNextAppTransitionPackage;
139 private Bitmap mNextAppTransitionThumbnail;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800140 // Used for thumbnail transitions. True if we're scaling up, false if scaling down
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800141 private boolean mNextAppTransitionScaleUp;
142 private IRemoteCallback mNextAppTransitionCallback;
143 private int mNextAppTransitionEnter;
144 private int mNextAppTransitionExit;
145 private int mNextAppTransitionStartX;
146 private int mNextAppTransitionStartY;
147 private int mNextAppTransitionStartWidth;
148 private int mNextAppTransitionStartHeight;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800149
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800150 private final static int APP_STATE_IDLE = 0;
151 private final static int APP_STATE_READY = 1;
152 private final static int APP_STATE_RUNNING = 2;
153 private final static int APP_STATE_TIMEOUT = 3;
154 private int mAppTransitionState = APP_STATE_IDLE;
155
156 private final int mConfigShortAnimTime;
Craig Mautner321bdf52012-12-18 09:53:24 -0800157 private final Interpolator mDecelerateInterpolator;
158 private final Interpolator mThumbnailFadeoutInterpolator;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800159
Amith Yamasani4befbec2013-07-10 16:18:01 -0700160 private int mCurrentUserId = 0;
Winson Chung399f6202014-03-19 10:47:20 -0700161 private boolean mUseAlternateThumbnailAnimation;
Amith Yamasani4befbec2013-07-10 16:18:01 -0700162
Craig Mautner164d4bb2012-11-26 13:51:23 -0800163 AppTransition(Context context, Handler h) {
164 mContext = context;
165 mH = h;
Winson Chung399f6202014-03-19 10:47:20 -0700166 mUseAlternateThumbnailAnimation =
167 SystemProperties.getBoolean("persist.anim.use_alt_thumbnail", false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800168 mConfigShortAnimTime = context.getResources().getInteger(
169 com.android.internal.R.integer.config_shortAnimTime);
Craig Mautner321bdf52012-12-18 09:53:24 -0800170 mDecelerateInterpolator = AnimationUtils.loadInterpolator(context,
171 com.android.internal.R.interpolator.decelerate_cubic);
172 mThumbnailFadeoutInterpolator = new Interpolator() {
173 @Override
174 public float getInterpolation(float input) {
175 // Linear response for first fraction, then complete after that.
176 if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) {
177 return input / RECENTS_THUMBNAIL_FADEOUT_FRACTION;
178 }
179 return 1.0f;
180 }
181 };
Craig Mautner164d4bb2012-11-26 13:51:23 -0800182 }
183
184 boolean isTransitionSet() {
185 return mNextAppTransition != TRANSIT_UNSET;
186 }
187
188 boolean isTransitionNone() {
189 return mNextAppTransition == TRANSIT_NONE;
190 }
191
192 boolean isTransitionEqual(int transit) {
193 return mNextAppTransition == transit;
194 }
195
196 int getAppTransition() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800197 return mNextAppTransition;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800198 }
199
200 void setAppTransition(int transit) {
201 mNextAppTransition = transit;
202 }
203
204 boolean isReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800205 return mAppTransitionState == APP_STATE_READY
206 || mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800207 }
208
Craig Mautnerae446592012-12-06 19:05:05 -0800209 void setReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800210 mAppTransitionState = APP_STATE_READY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800211 }
212
213 boolean isRunning() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800214 return mAppTransitionState == APP_STATE_RUNNING;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800215 }
216
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800217 void setIdle() {
218 mAppTransitionState = APP_STATE_IDLE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800219 }
220
221 boolean isTimeout() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800222 return mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800223 }
224
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800225 void setTimeout() {
226 mAppTransitionState = APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800227 }
228
229 Bitmap getNextAppTransitionThumbnail() {
230 return mNextAppTransitionThumbnail;
231 }
232
233 void getStartingPoint(Point outPoint) {
234 outPoint.x = mNextAppTransitionStartX;
235 outPoint.y = mNextAppTransitionStartY;
236 }
237
Craig Mautner164d4bb2012-11-26 13:51:23 -0800238 void prepare() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800239 if (!isRunning()) {
240 mAppTransitionState = APP_STATE_IDLE;
241 }
Craig Mautner164d4bb2012-11-26 13:51:23 -0800242 }
243
244 void goodToGo() {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800245 mNextAppTransition = TRANSIT_UNSET;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800246 mAppTransitionState = APP_STATE_RUNNING;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800247 }
248
249 void clear() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800250 mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800251 mNextAppTransitionPackage = null;
252 mNextAppTransitionThumbnail = null;
253 }
254
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800255 void freeze() {
256 setAppTransition(AppTransition.TRANSIT_UNSET);
257 clear();
258 setReady();
259 }
260
Craig Mautner164d4bb2012-11-26 13:51:23 -0800261 private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
262 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
263 + (lp != null ? lp.packageName : null)
264 + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null));
265 if (lp != null && lp.windowAnimations != 0) {
266 // If this is a system resource, don't try to load it from the
267 // application resources. It is nice to avoid loading application
268 // resources if we can.
269 String packageName = lp.packageName != null ? lp.packageName : "android";
270 int resId = lp.windowAnimations;
271 if ((resId&0xFF000000) == 0x01000000) {
272 packageName = "android";
273 }
274 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
275 + packageName);
276 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700277 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800278 }
279 return null;
280 }
281
282 private AttributeCache.Entry getCachedAnimations(String packageName, int resId) {
283 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package="
284 + packageName + " resId=0x" + Integer.toHexString(resId));
285 if (packageName != null) {
286 if ((resId&0xFF000000) == 0x01000000) {
287 packageName = "android";
288 }
289 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
290 + packageName);
291 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700292 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800293 }
294 return null;
295 }
296
297 Animation loadAnimation(WindowManager.LayoutParams lp, int animAttr) {
298 int anim = 0;
299 Context context = mContext;
300 if (animAttr >= 0) {
301 AttributeCache.Entry ent = getCachedAnimations(lp);
302 if (ent != null) {
303 context = ent.context;
304 anim = ent.array.getResourceId(animAttr, 0);
305 }
306 }
307 if (anim != 0) {
308 return AnimationUtils.loadAnimation(context, anim);
309 }
310 return null;
311 }
312
313 private Animation loadAnimation(String packageName, int resId) {
314 int anim = 0;
315 Context context = mContext;
316 if (resId >= 0) {
317 AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
318 if (ent != null) {
319 context = ent.context;
320 anim = resId;
321 }
322 }
323 if (anim != 0) {
324 return AnimationUtils.loadAnimation(context, anim);
325 }
326 return null;
327 }
328
Craig Mautner164d4bb2012-11-26 13:51:23 -0800329 /**
330 * Compute the pivot point for an animation that is scaling from a small
331 * rect on screen to a larger rect. The pivot point varies depending on
332 * the distance between the inner and outer edges on both sides. This
333 * function computes the pivot point for one dimension.
334 * @param startPos Offset from left/top edge of outer rectangle to
335 * left/top edge of inner rectangle.
336 * @param finalScale The scaling factor between the size of the outer
337 * and inner rectangles.
338 */
339 private static float computePivot(int startPos, float finalScale) {
340 final float denom = finalScale-1;
341 if (Math.abs(denom) < .0001f) {
342 return startPos;
343 }
344 return -startPos / denom;
345 }
346
347 private Animation createScaleUpAnimationLocked(int transit, boolean enter,
348 int appWidth, int appHeight) {
349 Animation a = null;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800350 if (enter) {
351 // Entering app zooms out from the center of the initial rect.
352 float scaleW = mNextAppTransitionStartWidth / (float) appWidth;
353 float scaleH = mNextAppTransitionStartHeight / (float) appHeight;
354 Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
355 computePivot(mNextAppTransitionStartX, scaleW),
356 computePivot(mNextAppTransitionStartY, scaleH));
Craig Mautner321bdf52012-12-18 09:53:24 -0800357 scale.setInterpolator(mDecelerateInterpolator);
358
Craig Mautner164d4bb2012-11-26 13:51:23 -0800359 Animation alpha = new AlphaAnimation(0, 1);
Craig Mautner321bdf52012-12-18 09:53:24 -0800360 alpha.setInterpolator(mThumbnailFadeoutInterpolator);
361
362 AnimationSet set = new AnimationSet(false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800363 set.addAnimation(scale);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800364 set.addAnimation(alpha);
365 set.setDetachWallpaper(true);
366 a = set;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800367 } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
368 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800369 // If we are on top of the wallpaper, we need an animation that
370 // correctly handles the wallpaper staying static behind all of
371 // the animated elements. To do this, will just have the existing
372 // element fade out.
373 a = new AlphaAnimation(1, 0);
374 a.setDetachWallpaper(true);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800375 } else {
Craig Mautner321bdf52012-12-18 09:53:24 -0800376 // For normal animations, the exiting element just holds in place.
377 a = new AlphaAnimation(1, 1);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800378 }
Craig Mautner321bdf52012-12-18 09:53:24 -0800379
380 // Pick the desired duration. If this is an inter-activity transition,
381 // it is the standard duration for that. Otherwise we use the longer
382 // task transition duration.
383 final long duration;
384 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800385 case TRANSIT_ACTIVITY_OPEN:
386 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800387 duration = mConfigShortAnimTime;
388 break;
389 default:
390 duration = DEFAULT_APP_TRANSITION_DURATION;
391 break;
392 }
393 a.setDuration(duration);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800394 a.setFillAfter(true);
Craig Mautner321bdf52012-12-18 09:53:24 -0800395 a.setInterpolator(mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800396 a.initialize(appWidth, appHeight, appWidth, appHeight);
397 return a;
398 }
399
Winson Chung399f6202014-03-19 10:47:20 -0700400 /**
401 * Prepares the specified animation with a standard duration, interpolator, etc.
402 */
403 Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800404 // Pick the desired duration. If this is an inter-activity transition,
405 // it is the standard duration for that. Otherwise we use the longer
406 // task transition duration.
407 final long duration;
408 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800409 case TRANSIT_ACTIVITY_OPEN:
410 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800411 duration = mConfigShortAnimTime;
412 break;
413 default:
414 duration = DEFAULT_APP_TRANSITION_DURATION;
415 break;
416 }
417 a.setDuration(duration);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800418 a.setFillAfter(true);
Craig Mautner321bdf52012-12-18 09:53:24 -0800419 a.setInterpolator(mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800420 a.initialize(appWidth, appHeight, appWidth, appHeight);
421 return a;
422 }
423
Winson Chung399f6202014-03-19 10:47:20 -0700424 /**
425 * Return the current thumbnail transition state.
426 */
427 int getThumbnailTransitionState(boolean enter) {
428 if (enter) {
429 if (mNextAppTransitionScaleUp) {
430 return THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
431 } else {
432 return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN;
433 }
434 } else {
435 if (mNextAppTransitionScaleUp) {
436 return THUMBNAIL_TRANSITION_EXIT_SCALE_UP;
437 } else {
438 return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN;
439 }
440 }
441 }
442
443 /**
444 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
445 * when a thumbnail is specified with the activity options.
446 */
447 Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit) {
448 Animation a;
449 final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
450 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
451 final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
452 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
453
454 if (mNextAppTransitionScaleUp) {
455 // Animation for the thumbnail zooming from its initial size to the full screen
456 float scaleW = appWidth / thumbWidth;
457 float scaleH = appHeight / thumbHeight;
458 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
459 computePivot(mNextAppTransitionStartX, 1 / scaleW),
460 computePivot(mNextAppTransitionStartY, 1 / scaleH));
461 scale.setInterpolator(mDecelerateInterpolator);
462
463 Animation alpha = new AlphaAnimation(1, 0);
464 alpha.setInterpolator(mThumbnailFadeoutInterpolator);
465
466 // This AnimationSet uses the Interpolators assigned above.
467 AnimationSet set = new AnimationSet(false);
468 set.addAnimation(scale);
469 set.addAnimation(alpha);
470 a = set;
471 } else {
472 // Animation for the thumbnail zooming down from the full screen to its final size
473 float scaleW = appWidth / thumbWidth;
474 float scaleH = appHeight / thumbHeight;
475 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
476 computePivot(mNextAppTransitionStartX, 1 / scaleW),
477 computePivot(mNextAppTransitionStartY, 1 / scaleH));
478 }
479
480 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
481 }
482
483 /**
484 * This alternate animation is created when we are doing a thumbnail transition, for the
485 * activity that is leaving, and the activity that is entering.
486 */
487 Animation createAlternateThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth,
488 int appHeight, int transit,
489 Rect containingFrame, Rect contentInsets) {
490 Animation a;
491 final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
492 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
493 final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
494 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
495
496 switch (thumbTransitState) {
497 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
498 // Entering app scales up with the thumbnail
499 float scale = thumbWidth / appWidth;
500 int unscaledThumbHeight = (int) (thumbHeight / scale);
501 int scaledTopDecor = (int) (scale * contentInsets.top);
502 Rect fromClipRect = new Rect(containingFrame);
503 fromClipRect.bottom = (fromClipRect.top + unscaledThumbHeight);
504 Rect toClipRect = new Rect(containingFrame);
505
506 Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1,
507 computePivot(mNextAppTransitionStartX, scale),
508 computePivot(mNextAppTransitionStartY, scale));
509 Animation alphaAnim = new AlphaAnimation(1, 1);
510 Animation clipAnim = new ClipRectAnimation(fromClipRect, toClipRect);
511 Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0);
512
513 AnimationSet set = new AnimationSet(true);
514 set.addAnimation(alphaAnim);
515 set.addAnimation(clipAnim);
516 set.addAnimation(scaleAnim);
517 set.addAnimation(translateAnim);
518 a = set;
519 break;
520 }
521 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
522 // Exiting app while the thumbnail is scaling up should fade
523 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
524 // Fade out while bringing up selected activity. This keeps the
525 // current activity from showing through a launching wallpaper
526 // activity.
527 a = new AlphaAnimation(1, 0);
528 } else {
529 // noop animation
530 a = new AlphaAnimation(1, 1);
531 }
532 break;
533 }
534 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
535 // Entering the other app, it should just be visible while we scale the thumbnail
536 // down above it
537 a = new AlphaAnimation(1, 1);
538 break;
539 }
540 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
541 // Exiting the current app, the app should scale down with the thumbnail
542 float scale = thumbWidth / appWidth;
543 int unscaledThumbHeight = (int) (thumbHeight / scale);
544 int scaledTopDecor = (int) (scale * contentInsets.top);
545 Rect fromClipRect = new Rect(containingFrame);
546 Rect toClipRect = new Rect(containingFrame);
547 toClipRect.bottom = (toClipRect.top + unscaledThumbHeight);
548
549 Animation scaleAnim = new ScaleAnimation(1, scale, 1, scale,
550 computePivot(mNextAppTransitionStartX, scale),
551 computePivot(mNextAppTransitionStartY, scale));
552 Animation alphaAnim = new AlphaAnimation(1, 1);
553 Animation clipAnim = new ClipRectAnimation(fromClipRect, toClipRect);
554 Animation translateAnim = new TranslateAnimation(0, 0, 0, -scaledTopDecor);
555
556 AnimationSet set = new AnimationSet(true);
557 set.addAnimation(alphaAnim);
558 set.addAnimation(clipAnim);
559 set.addAnimation(scaleAnim);
560 set.addAnimation(translateAnim);
561
562 a = set;
563 a.setZAdjustment(Animation.ZORDER_TOP);
564 break;
565 }
566 default:
567 throw new RuntimeException("Invalid thumbnail transition state");
568 }
569
570 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
571 }
572
573 /**
574 * This animation is created when we are doing a thumbnail transition, for the activity that is
575 * leaving, and the activity that is entering.
576 */
577 Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth,
578 int appHeight, int transit) {
579 Animation a;
580 final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
581 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
582 final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
583 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
584
585 switch (thumbTransitState) {
586 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
587 // Entering app scales up with the thumbnail
588 float scaleW = thumbWidth / appWidth;
589 float scaleH = thumbHeight / appHeight;
590 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
591 computePivot(mNextAppTransitionStartX, scaleW),
592 computePivot(mNextAppTransitionStartY, scaleH));
593 break;
594 }
595 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
596 // Exiting app while the thumbnail is scaling up should fade or stay in place
597 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
598 // Fade out while bringing up selected activity. This keeps the
599 // current activity from showing through a launching wallpaper
600 // activity.
601 a = new AlphaAnimation(1, 0);
602 } else {
603 // noop animation
604 a = new AlphaAnimation(1, 1);
605 }
606 break;
607 }
608 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
609 // Entering the other app, it should just be visible while we scale the thumbnail
610 // down above it
611 a = new AlphaAnimation(1, 1);
612 break;
613 }
614 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
615 // Exiting the current app, the app should scale down with the thumbnail
616 float scaleW = thumbWidth / appWidth;
617 float scaleH = thumbHeight / appHeight;
618 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
619 computePivot(mNextAppTransitionStartX, scaleW),
620 computePivot(mNextAppTransitionStartY, scaleH));
621
622 Animation alpha = new AlphaAnimation(1, 0);
623
624 AnimationSet set = new AnimationSet(true);
625 set.addAnimation(scale);
626 set.addAnimation(alpha);
627 set.setZAdjustment(Animation.ZORDER_TOP);
628 a = set;
629 break;
630 }
631 default:
632 throw new RuntimeException("Invalid thumbnail transition state");
633 }
634
635 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
636 }
637
Craig Mautner164d4bb2012-11-26 13:51:23 -0800638
639 Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter,
Winson Chung399f6202014-03-19 10:47:20 -0700640 int appWidth, int appHeight, Rect containingFrame, Rect contentInsets) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800641 Animation a;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800642 if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800643 a = loadAnimation(mNextAppTransitionPackage, enter ?
644 mNextAppTransitionEnter : mNextAppTransitionExit);
645 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
646 "applyAnimation:"
647 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
648 + " transit=" + transit + " isEntrance=" + enter
649 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800650 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800651 a = createScaleUpAnimationLocked(transit, enter, appWidth, appHeight);
652 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
653 "applyAnimation:"
654 + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
655 + " transit=" + transit + " isEntrance=" + enter
656 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800657 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
658 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800659 mNextAppTransitionScaleUp =
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800660 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
Winson Chung399f6202014-03-19 10:47:20 -0700661 if (mUseAlternateThumbnailAnimation) {
662 a = createAlternateThumbnailEnterExitAnimationLocked(
663 getThumbnailTransitionState(enter), appWidth, appHeight, transit,
664 containingFrame, contentInsets);
665 } else {
666 a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter),
667 appWidth, appHeight, transit);
668 }
Craig Mautner164d4bb2012-11-26 13:51:23 -0800669 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
670 String animName = mNextAppTransitionScaleUp ?
671 "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
672 Slog.v(TAG, "applyAnimation:"
673 + " anim=" + a + " nextAppTransition=" + animName
674 + " transit=" + transit + " isEntrance=" + enter
675 + " Callers=" + Debug.getCallers(3));
676 }
677 } else {
678 int animAttr = 0;
679 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800680 case TRANSIT_ACTIVITY_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800681 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800682 ? WindowAnimation_activityOpenEnterAnimation
683 : WindowAnimation_activityOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800684 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800685 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800686 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800687 ? WindowAnimation_activityCloseEnterAnimation
688 : WindowAnimation_activityCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800689 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800690 case TRANSIT_TASK_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800691 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800692 ? WindowAnimation_taskOpenEnterAnimation
693 : WindowAnimation_taskOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800694 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800695 case TRANSIT_TASK_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800696 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800697 ? WindowAnimation_taskCloseEnterAnimation
698 : WindowAnimation_taskCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800699 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800700 case TRANSIT_TASK_TO_FRONT:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800701 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800702 ? WindowAnimation_taskToFrontEnterAnimation
703 : WindowAnimation_taskToFrontExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800704 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800705 case TRANSIT_TASK_TO_BACK:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800706 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800707 ? WindowAnimation_taskToBackEnterAnimation
708 : WindowAnimation_taskToBackExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800709 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800710 case TRANSIT_WALLPAPER_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800711 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800712 ? WindowAnimation_wallpaperOpenEnterAnimation
713 : WindowAnimation_wallpaperOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800714 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800715 case TRANSIT_WALLPAPER_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800716 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800717 ? WindowAnimation_wallpaperCloseEnterAnimation
718 : WindowAnimation_wallpaperCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800719 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800720 case TRANSIT_WALLPAPER_INTRA_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800721 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800722 ? WindowAnimation_wallpaperIntraOpenEnterAnimation
723 : WindowAnimation_wallpaperIntraOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800724 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800725 case TRANSIT_WALLPAPER_INTRA_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800726 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800727 ? WindowAnimation_wallpaperIntraCloseEnterAnimation
728 : WindowAnimation_wallpaperIntraCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800729 break;
730 }
731 a = animAttr != 0 ? loadAnimation(lp, animAttr) : null;
732 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
733 "applyAnimation:"
734 + " anim=" + a
735 + " animAttr=0x" + Integer.toHexString(animAttr)
736 + " transit=" + transit + " isEntrance=" + enter
737 + " Callers=" + Debug.getCallers(3));
738 }
739 return a;
740 }
741
742 void postAnimationCallback() {
743 if (mNextAppTransitionCallback != null) {
744 mH.sendMessage(mH.obtainMessage(H.DO_ANIMATION_CALLBACK, mNextAppTransitionCallback));
745 mNextAppTransitionCallback = null;
746 }
747 }
748
749 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
750 IRemoteCallback startedCallback) {
751 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800752 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800753 mNextAppTransitionPackage = packageName;
754 mNextAppTransitionThumbnail = null;
755 mNextAppTransitionEnter = enterAnim;
756 mNextAppTransitionExit = exitAnim;
757 postAnimationCallback();
758 mNextAppTransitionCallback = startedCallback;
759 } else {
760 postAnimationCallback();
761 }
762 }
763
764 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
765 int startHeight) {
766 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800767 mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800768 mNextAppTransitionPackage = null;
769 mNextAppTransitionThumbnail = null;
770 mNextAppTransitionStartX = startX;
771 mNextAppTransitionStartY = startY;
772 mNextAppTransitionStartWidth = startWidth;
773 mNextAppTransitionStartHeight = startHeight;
774 postAnimationCallback();
775 mNextAppTransitionCallback = null;
776 }
777 }
778
779 void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
780 IRemoteCallback startedCallback, boolean scaleUp) {
781 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800782 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP
783 : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800784 mNextAppTransitionPackage = null;
785 mNextAppTransitionThumbnail = srcThumb;
786 mNextAppTransitionScaleUp = scaleUp;
787 mNextAppTransitionStartX = startX;
788 mNextAppTransitionStartY = startY;
789 postAnimationCallback();
790 mNextAppTransitionCallback = startedCallback;
791 } else {
792 postAnimationCallback();
793 }
794 }
795
796 @Override
797 public String toString() {
798 return "mNextAppTransition=0x" + Integer.toHexString(mNextAppTransition);
799 }
800
Craig Mautner4b71aa12012-12-27 17:20:01 -0800801 /**
802 * Returns the human readable name of a window transition.
803 *
804 * @param transition The window transition.
805 * @return The transition symbolic name.
806 */
807 public static String appTransitionToString(int transition) {
808 switch (transition) {
809 case TRANSIT_UNSET: {
810 return "TRANSIT_UNSET";
811 }
812 case TRANSIT_NONE: {
813 return "TRANSIT_NONE";
814 }
815 case TRANSIT_EXIT_MASK: {
816 return "TRANSIT_EXIT_MASK";
817 }
818 case TRANSIT_ACTIVITY_OPEN: {
819 return "TRANSIT_ACTIVITY_OPEN";
820 }
821 case TRANSIT_ACTIVITY_CLOSE: {
822 return "TRANSIT_ACTIVITY_CLOSE";
823 }
824 case TRANSIT_TASK_OPEN: {
825 return "TRANSIT_TASK_OPEN";
826 }
827 case TRANSIT_TASK_CLOSE: {
828 return "TRANSIT_TASK_CLOSE";
829 }
830 case TRANSIT_TASK_TO_FRONT: {
831 return "TRANSIT_TASK_TO_FRONT";
832 }
833 case TRANSIT_TASK_TO_BACK: {
834 return "TRANSIT_TASK_TO_BACK";
835 }
836 case TRANSIT_WALLPAPER_CLOSE: {
837 return "TRANSIT_WALLPAPER_CLOSE";
838 }
839 case TRANSIT_WALLPAPER_OPEN: {
840 return "TRANSIT_WALLPAPER_OPEN";
841 }
842 case TRANSIT_WALLPAPER_INTRA_OPEN: {
843 return "TRANSIT_WALLPAPER_INTRA_OPEN";
844 }
845 case TRANSIT_WALLPAPER_INTRA_CLOSE: {
846 return "TRANSIT_WALLPAPER_INTRA_CLOSE";
847 }
848 default: {
849 return "<UNKNOWN>";
850 }
851 }
852 }
853
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800854 private String appStateToString() {
855 switch (mAppTransitionState) {
856 case APP_STATE_IDLE:
857 return "APP_STATE_IDLE";
858 case APP_STATE_READY:
859 return "APP_STATE_READY";
860 case APP_STATE_RUNNING:
861 return "APP_STATE_RUNNING";
862 case APP_STATE_TIMEOUT:
863 return "APP_STATE_TIMEOUT";
864 default:
865 return "unknown state=" + mAppTransitionState;
866 }
867 }
868
869 private String transitTypeToString() {
870 switch (mNextAppTransitionType) {
871 case NEXT_TRANSIT_TYPE_NONE:
872 return "NEXT_TRANSIT_TYPE_NONE";
873 case NEXT_TRANSIT_TYPE_CUSTOM:
874 return "NEXT_TRANSIT_TYPE_CUSTOM";
875 case NEXT_TRANSIT_TYPE_SCALE_UP:
876 return "NEXT_TRANSIT_TYPE_SCALE_UP";
877 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
878 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP";
879 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
880 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN";
881 default:
882 return "unknown type=" + mNextAppTransitionType;
883 }
884 }
885
Craig Mautner164d4bb2012-11-26 13:51:23 -0800886 @Override
887 public void dump(PrintWriter pw) {
888 pw.print(" " + this);
Craig Mautner28816302013-10-10 20:31:00 -0700889 pw.print(" mAppTransitionState="); pw.println(appStateToString());
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800890 if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) {
891 pw.print(" mNextAppTransitionType="); pw.println(transitTypeToString());
Craig Mautner164d4bb2012-11-26 13:51:23 -0800892 }
893 switch (mNextAppTransitionType) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800894 case NEXT_TRANSIT_TYPE_CUSTOM:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800895 pw.print(" mNextAppTransitionPackage=");
896 pw.println(mNextAppTransitionPackage);
897 pw.print(" mNextAppTransitionEnter=0x");
898 pw.print(Integer.toHexString(mNextAppTransitionEnter));
899 pw.print(" mNextAppTransitionExit=0x");
900 pw.println(Integer.toHexString(mNextAppTransitionExit));
901 break;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800902 case NEXT_TRANSIT_TYPE_SCALE_UP:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800903 pw.print(" mNextAppTransitionStartX="); pw.print(mNextAppTransitionStartX);
904 pw.print(" mNextAppTransitionStartY=");
905 pw.println(mNextAppTransitionStartY);
906 pw.print(" mNextAppTransitionStartWidth=");
907 pw.print(mNextAppTransitionStartWidth);
908 pw.print(" mNextAppTransitionStartHeight=");
909 pw.println(mNextAppTransitionStartHeight);
910 break;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800911 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
912 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
Craig Mautner164d4bb2012-11-26 13:51:23 -0800913 pw.print(" mNextAppTransitionThumbnail=");
914 pw.print(mNextAppTransitionThumbnail);
915 pw.print(" mNextAppTransitionStartX=");
916 pw.print(mNextAppTransitionStartX);
917 pw.print(" mNextAppTransitionStartY=");
918 pw.println(mNextAppTransitionStartY);
919 pw.print(" mNextAppTransitionScaleUp="); pw.println(mNextAppTransitionScaleUp);
920 break;
921 }
922 if (mNextAppTransitionCallback != null) {
923 pw.print(" mNextAppTransitionCallback=");
924 pw.println(mNextAppTransitionCallback);
925 }
926 }
Amith Yamasani4befbec2013-07-10 16:18:01 -0700927
928 public void setCurrentUser(int newUserId) {
929 mCurrentUserId = newUserId;
930 }
Craig Mautner164d4bb2012-11-26 13:51:23 -0800931}