blob: 5dc6887522f3611614552fc4d85f4c2fdbd17662 [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;
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700125 /** An activity is being relaunched (e.g. due to configuration change). */
126 public static final int TRANSIT_ACTIVITY_RELAUNCH = 18;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800127
Winson Chunga4ccb862014-08-22 15:26:27 -0700128 /** Fraction of animation at which the recents thumbnail stays completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700129 private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800130 /** Fraction of animation at which the recents thumbnail becomes completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700131 private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800132
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700133 private static final int DEFAULT_APP_TRANSITION_DURATION = 336;
134 private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336;
135 private static final int THUMBNAIL_APP_TRANSITION_ALPHA_DURATION = 336;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800136
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800137 private final Context mContext;
138 private final Handler mH;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800139
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800140 private int mNextAppTransition = TRANSIT_UNSET;
141
142 private static final int NEXT_TRANSIT_TYPE_NONE = 0;
143 private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1;
144 private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2;
145 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3;
146 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4;
Winson Chunga4ccb862014-08-22 15:26:27 -0700147 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5;
148 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6;
Winson Chung044d5292014-11-06 11:05:19 -0800149 private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7;
Chet Haase10e23ab2015-02-11 15:08:38 -0800150 private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800151 private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
152
Winson Chung399f6202014-03-19 10:47:20 -0700153 // These are the possible states for the enter/exit activities during a thumbnail transition
154 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0;
155 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1;
156 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2;
157 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3;
158
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800159 private String mNextAppTransitionPackage;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800160 // Used for thumbnail transitions. True if we're scaling up, false if scaling down
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800161 private boolean mNextAppTransitionScaleUp;
162 private IRemoteCallback mNextAppTransitionCallback;
163 private int mNextAppTransitionEnter;
164 private int mNextAppTransitionExit;
Winson Chung044d5292014-11-06 11:05:19 -0800165 private int mNextAppTransitionInPlace;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700166
167 // Keyed by task id.
168 private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs
169 = new SparseArray<>();
170 private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec;
171
Winson Chunga4ccb862014-08-22 15:26:27 -0700172 private Rect mNextAppTransitionInsets = new Rect();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800173
Winson Chung2820c452014-04-15 15:34:44 -0700174 private Rect mTmpFromClipRect = new Rect();
175 private Rect mTmpToClipRect = new Rect();
176
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700177 private final Rect mTmpStartRect = new Rect();
178
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800179 private final static int APP_STATE_IDLE = 0;
180 private final static int APP_STATE_READY = 1;
181 private final static int APP_STATE_RUNNING = 2;
182 private final static int APP_STATE_TIMEOUT = 3;
183 private int mAppTransitionState = APP_STATE_IDLE;
184
185 private final int mConfigShortAnimTime;
Craig Mautner321bdf52012-12-18 09:53:24 -0800186 private final Interpolator mDecelerateInterpolator;
Winson Chunga4ccb862014-08-22 15:26:27 -0700187 private final Interpolator mThumbnailFadeInInterpolator;
188 private final Interpolator mThumbnailFadeOutInterpolator;
Chet Haase10e23ab2015-02-11 15:08:38 -0800189 private final Interpolator mLinearOutSlowInInterpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700190 private final Interpolator mFastOutLinearInInterpolator;
191 private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f);
192
193 /** Interpolator to be used for animations that respond directly to a touch */
194 private final Interpolator mTouchResponseInterpolator =
195 new PathInterpolator(0.3f, 0f, 0.1f, 1f);
196
197 private final int mClipRevealTranslationY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800198
Amith Yamasani4befbec2013-07-10 16:18:01 -0700199 private int mCurrentUserId = 0;
200
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100201 private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>();
202
Craig Mautner164d4bb2012-11-26 13:51:23 -0800203 AppTransition(Context context, Handler h) {
204 mContext = context;
205 mH = h;
Chet Haase10e23ab2015-02-11 15:08:38 -0800206 mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
207 com.android.internal.R.interpolator.linear_out_slow_in);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700208 mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
209 com.android.internal.R.interpolator.fast_out_linear_in);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800210 mConfigShortAnimTime = context.getResources().getInteger(
211 com.android.internal.R.integer.config_shortAnimTime);
Craig Mautner321bdf52012-12-18 09:53:24 -0800212 mDecelerateInterpolator = AnimationUtils.loadInterpolator(context,
213 com.android.internal.R.interpolator.decelerate_cubic);
Winson Chunga4ccb862014-08-22 15:26:27 -0700214 mThumbnailFadeInInterpolator = new Interpolator() {
215 @Override
216 public float getInterpolation(float input) {
217 // Linear response for first fraction, then complete after that.
218 if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) {
219 return 0f;
220 }
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700221 float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) /
Winson Chunga4ccb862014-08-22 15:26:27 -0700222 (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700223 return mFastOutLinearInInterpolator.getInterpolation(t);
Winson Chunga4ccb862014-08-22 15:26:27 -0700224 }
225 };
226 mThumbnailFadeOutInterpolator = new Interpolator() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800227 @Override
228 public float getInterpolation(float input) {
229 // Linear response for first fraction, then complete after that.
230 if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) {
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700231 float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION;
232 return mLinearOutSlowInInterpolator.getInterpolation(t);
Craig Mautner321bdf52012-12-18 09:53:24 -0800233 }
Winson Chunga4ccb862014-08-22 15:26:27 -0700234 return 1f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800235 }
236 };
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700237 mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP
238 * mContext.getResources().getDisplayMetrics().density);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800239 }
240
241 boolean isTransitionSet() {
242 return mNextAppTransition != TRANSIT_UNSET;
243 }
244
245 boolean isTransitionNone() {
246 return mNextAppTransition == TRANSIT_NONE;
247 }
248
249 boolean isTransitionEqual(int transit) {
250 return mNextAppTransition == transit;
251 }
252
253 int getAppTransition() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800254 return mNextAppTransition;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800255 }
256
257 void setAppTransition(int transit) {
258 mNextAppTransition = transit;
259 }
260
261 boolean isReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800262 return mAppTransitionState == APP_STATE_READY
263 || mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800264 }
265
Craig Mautnerae446592012-12-06 19:05:05 -0800266 void setReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800267 mAppTransitionState = APP_STATE_READY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800268 }
269
270 boolean isRunning() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800271 return mAppTransitionState == APP_STATE_RUNNING;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800272 }
273
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800274 void setIdle() {
275 mAppTransitionState = APP_STATE_IDLE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800276 }
277
278 boolean isTimeout() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800279 return mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800280 }
281
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800282 void setTimeout() {
283 mAppTransitionState = APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800284 }
285
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700286 Bitmap getAppTransitionThumbnailHeader(int taskId) {
287 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
288 return spec != null ? spec.bitmap : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800289 }
290
Winson Chunga4ccb862014-08-22 15:26:27 -0700291 /** Returns whether the next thumbnail transition is aspect scaled up. */
292 boolean isNextThumbnailTransitionAspectScaled() {
293 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
294 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
295 }
296
297 /** Returns whether the next thumbnail transition is scaling up. */
298 boolean isNextThumbnailTransitionScaleUp() {
299 return mNextAppTransitionScaleUp;
300 }
301
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700302 boolean prepare() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800303 if (!isRunning()) {
304 mAppTransitionState = APP_STATE_IDLE;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100305 notifyAppTransitionPendingLocked();
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700306 return true;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800307 }
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700308 return false;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800309 }
310
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100311 void goodToGo(AppWindowAnimator openingAppAnimator, AppWindowAnimator closingAppAnimator) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800312 mNextAppTransition = TRANSIT_UNSET;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800313 mAppTransitionState = APP_STATE_RUNNING;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100314 notifyAppTransitionStartingLocked(
315 openingAppAnimator != null ? openingAppAnimator.mAppToken.token : null,
316 closingAppAnimator != null ? closingAppAnimator.mAppToken.token : null,
317 openingAppAnimator != null ? openingAppAnimator.animation : null,
318 closingAppAnimator != null ? closingAppAnimator.animation : null);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800319 }
320
321 void clear() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800322 mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800323 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700324 mNextAppTransitionAnimationsSpecs.clear();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800325 }
326
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800327 void freeze() {
328 setAppTransition(AppTransition.TRANSIT_UNSET);
329 clear();
330 setReady();
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100331 notifyAppTransitionCancelledLocked();
332 }
333
334 void registerListenerLocked(AppTransitionListener listener) {
335 mListeners.add(listener);
336 }
337
Wale Ogunwalea48eadb2015-05-14 17:43:12 -0700338 public void notifyAppTransitionFinishedLocked(IBinder token) {
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100339 for (int i = 0; i < mListeners.size(); i++) {
340 mListeners.get(i).onAppTransitionFinishedLocked(token);
341 }
342 }
343
344 private void notifyAppTransitionPendingLocked() {
345 for (int i = 0; i < mListeners.size(); i++) {
346 mListeners.get(i).onAppTransitionPendingLocked();
347 }
348 }
349
350 private void notifyAppTransitionCancelledLocked() {
351 for (int i = 0; i < mListeners.size(); i++) {
352 mListeners.get(i).onAppTransitionCancelledLocked();
353 }
354 }
355
356 private void notifyAppTransitionStartingLocked(IBinder openToken,
357 IBinder closeToken, Animation openAnimation, Animation closeAnimation) {
358 for (int i = 0; i < mListeners.size(); i++) {
359 mListeners.get(i).onAppTransitionStartingLocked(openToken, closeToken, openAnimation,
360 closeAnimation);
361 }
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800362 }
363
Craig Mautner164d4bb2012-11-26 13:51:23 -0800364 private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
365 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
366 + (lp != null ? lp.packageName : null)
367 + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null));
368 if (lp != null && lp.windowAnimations != 0) {
369 // If this is a system resource, don't try to load it from the
370 // application resources. It is nice to avoid loading application
371 // resources if we can.
372 String packageName = lp.packageName != null ? lp.packageName : "android";
373 int resId = lp.windowAnimations;
374 if ((resId&0xFF000000) == 0x01000000) {
375 packageName = "android";
376 }
377 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
378 + packageName);
379 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700380 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800381 }
382 return null;
383 }
384
385 private AttributeCache.Entry getCachedAnimations(String packageName, int resId) {
386 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package="
387 + packageName + " resId=0x" + Integer.toHexString(resId));
388 if (packageName != null) {
389 if ((resId&0xFF000000) == 0x01000000) {
390 packageName = "android";
391 }
392 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
393 + packageName);
394 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700395 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800396 }
397 return null;
398 }
399
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700400 Animation loadAnimationAttr(WindowManager.LayoutParams lp, int animAttr) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800401 int anim = 0;
402 Context context = mContext;
403 if (animAttr >= 0) {
404 AttributeCache.Entry ent = getCachedAnimations(lp);
405 if (ent != null) {
406 context = ent.context;
407 anim = ent.array.getResourceId(animAttr, 0);
408 }
409 }
410 if (anim != 0) {
411 return AnimationUtils.loadAnimation(context, anim);
412 }
413 return null;
414 }
415
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700416 Animation loadAnimationRes(WindowManager.LayoutParams lp, int resId) {
417 Context context = mContext;
418 if (resId >= 0) {
419 AttributeCache.Entry ent = getCachedAnimations(lp);
420 if (ent != null) {
421 context = ent.context;
422 }
423 return AnimationUtils.loadAnimation(context, resId);
424 }
425 return null;
426 }
427
428 private Animation loadAnimationRes(String packageName, int resId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800429 int anim = 0;
430 Context context = mContext;
431 if (resId >= 0) {
432 AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
433 if (ent != null) {
434 context = ent.context;
435 anim = resId;
436 }
437 }
438 if (anim != 0) {
439 return AnimationUtils.loadAnimation(context, anim);
440 }
441 return null;
442 }
443
Craig Mautner164d4bb2012-11-26 13:51:23 -0800444 /**
445 * Compute the pivot point for an animation that is scaling from a small
446 * rect on screen to a larger rect. The pivot point varies depending on
447 * the distance between the inner and outer edges on both sides. This
448 * function computes the pivot point for one dimension.
449 * @param startPos Offset from left/top edge of outer rectangle to
450 * left/top edge of inner rectangle.
451 * @param finalScale The scaling factor between the size of the outer
452 * and inner rectangles.
453 */
454 private static float computePivot(int startPos, float finalScale) {
455 final float denom = finalScale-1;
456 if (Math.abs(denom) < .0001f) {
457 return startPos;
458 }
459 return -startPos / denom;
460 }
461
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700462 private Animation createScaleUpAnimationLocked(
463 int transit, boolean enter, int appWidth, int appHeight) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800464 Animation a = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700465 getDefaultNextAppTransitionStartRect(mTmpStartRect);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800466 if (enter) {
467 // Entering app zooms out from the center of the initial rect.
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700468 float scaleW = mTmpStartRect.width() / (float) appWidth;
469 float scaleH = mTmpStartRect.height() / (float) appHeight;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800470 Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700471 computePivot(mTmpStartRect.left, scaleW),
472 computePivot(mTmpStartRect.right, scaleH));
Craig Mautner321bdf52012-12-18 09:53:24 -0800473 scale.setInterpolator(mDecelerateInterpolator);
474
Craig Mautner164d4bb2012-11-26 13:51:23 -0800475 Animation alpha = new AlphaAnimation(0, 1);
Winson Chunga4ccb862014-08-22 15:26:27 -0700476 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
Craig Mautner321bdf52012-12-18 09:53:24 -0800477
478 AnimationSet set = new AnimationSet(false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800479 set.addAnimation(scale);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800480 set.addAnimation(alpha);
481 set.setDetachWallpaper(true);
482 a = set;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800483 } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
484 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800485 // If we are on top of the wallpaper, we need an animation that
486 // correctly handles the wallpaper staying static behind all of
487 // the animated elements. To do this, will just have the existing
488 // element fade out.
489 a = new AlphaAnimation(1, 0);
490 a.setDetachWallpaper(true);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800491 } else {
Craig Mautner321bdf52012-12-18 09:53:24 -0800492 // For normal animations, the exiting element just holds in place.
493 a = new AlphaAnimation(1, 1);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800494 }
Craig Mautner321bdf52012-12-18 09:53:24 -0800495
496 // Pick the desired duration. If this is an inter-activity transition,
497 // it is the standard duration for that. Otherwise we use the longer
498 // task transition duration.
499 final long duration;
500 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800501 case TRANSIT_ACTIVITY_OPEN:
502 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800503 duration = mConfigShortAnimTime;
504 break;
505 default:
506 duration = DEFAULT_APP_TRANSITION_DURATION;
507 break;
508 }
509 a.setDuration(duration);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800510 a.setFillAfter(true);
Craig Mautner321bdf52012-12-18 09:53:24 -0800511 a.setInterpolator(mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800512 a.initialize(appWidth, appHeight, appWidth, appHeight);
513 return a;
514 }
515
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700516 private void getDefaultNextAppTransitionStartRect(Rect rect) {
517 if (mDefaultNextAppTransitionAnimationSpec == null ||
518 mDefaultNextAppTransitionAnimationSpec.rect == null) {
519 Slog.wtf(TAG, "Starting rect for app requested, but none available", new Throwable());
520 rect.setEmpty();
521 } else {
522 rect.set(mDefaultNextAppTransitionAnimationSpec.rect);
523 }
524 }
525
526 void getNextAppTransitionStartRect(int taskId, Rect rect) {
527 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
528 if (spec == null || spec.rect == null) {
529 Slog.wtf(TAG, "Starting rect for task: " + taskId + " requested, but not available",
530 new Throwable());
531 rect.setEmpty();
532 } else {
533 rect.set(spec.rect);
534 }
535 }
536
537 private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height) {
538 mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */,
539 null /* bitmap */, new Rect(left, top, left + width, top + height));
540 }
541
Craig Mautner80b1f642015-04-22 10:59:09 -0700542 private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame) {
Chet Haase10e23ab2015-02-11 15:08:38 -0800543 final Animation anim;
544 if (enter) {
545 // Reveal will expand and move faster in horizontal direction
546
Craig Mautner80b1f642015-04-22 10:59:09 -0700547 final int appWidth = appFrame.width();
548 final int appHeight = appFrame.height();
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700549 getDefaultNextAppTransitionStartRect(mTmpStartRect);
Craig Mautner80b1f642015-04-22 10:59:09 -0700550
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700551 float t = 0f;
552 if (appHeight > 0) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700553 t = (float) mTmpStartRect.left / appHeight;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700554 }
555 int translationY = mClipRevealTranslationY
556 + (int)(appHeight / 7f * t);
557
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700558 int centerX = mTmpStartRect.centerX();
559 int centerY = mTmpStartRect.centerY();
560 int halfWidth = mTmpStartRect.width() / 2;
561 int halfHeight = mTmpStartRect.height() / 2;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700562
563 // Clip third of the from size of launch icon, expand to full width/height
Chet Haase10e23ab2015-02-11 15:08:38 -0800564 Animation clipAnimLR = new ClipRectLRAnimation(
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700565 centerX - halfWidth, centerX + halfWidth, 0, appWidth);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700566 clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
567 clipAnimLR.setDuration((long) (DEFAULT_APP_TRANSITION_DURATION / 2.5f));
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700568 Animation clipAnimTB = new ClipRectTBAnimation(centerY - halfHeight - translationY,
569 centerY + halfHeight/ 2 - translationY, 0, appHeight);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700570 clipAnimTB.setInterpolator(mTouchResponseInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800571 clipAnimTB.setDuration(DEFAULT_APP_TRANSITION_DURATION);
572
Chet Haase10e23ab2015-02-11 15:08:38 -0800573 TranslateYAnimation translateY = new TranslateYAnimation(
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700574 Animation.ABSOLUTE, translationY, Animation.ABSOLUTE, 0);
575 translateY.setInterpolator(mLinearOutSlowInInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800576 translateY.setDuration(DEFAULT_APP_TRANSITION_DURATION);
577
578 // Quick fade-in from icon to app window
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700579 final int alphaDuration = DEFAULT_APP_TRANSITION_DURATION / 4;
580 AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
Chet Haase10e23ab2015-02-11 15:08:38 -0800581 alpha.setDuration(alphaDuration);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700582 alpha.setInterpolator(mLinearOutSlowInInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800583
584 AnimationSet set = new AnimationSet(false);
585 set.addAnimation(clipAnimLR);
586 set.addAnimation(clipAnimTB);
Chet Haase10e23ab2015-02-11 15:08:38 -0800587 set.addAnimation(translateY);
588 set.addAnimation(alpha);
Filip Gruszczynski9e2cf5b2015-07-31 12:20:40 -0700589 set.setZAdjustment(Animation.ZORDER_TOP);
Chet Haase10e23ab2015-02-11 15:08:38 -0800590 set.initialize(appWidth, appHeight, appWidth, appHeight);
591 anim = set;
592 } else {
593 final long duration;
594 switch (transit) {
595 case TRANSIT_ACTIVITY_OPEN:
596 case TRANSIT_ACTIVITY_CLOSE:
597 duration = mConfigShortAnimTime;
598 break;
599 default:
600 duration = DEFAULT_APP_TRANSITION_DURATION;
601 break;
602 }
603 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
604 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
605 // If we are on top of the wallpaper, we need an animation that
606 // correctly handles the wallpaper staying static behind all of
607 // the animated elements. To do this, will just have the existing
608 // element fade out.
609 anim = new AlphaAnimation(1, 0);
610 anim.setDetachWallpaper(true);
611 } else {
612 // For normal animations, the exiting element just holds in place.
613 anim = new AlphaAnimation(1, 1);
614 }
615 anim.setInterpolator(mDecelerateInterpolator);
616 anim.setDuration(duration);
617 anim.setFillAfter(true);
618 }
619 return anim;
620 }
621
Winson Chung399f6202014-03-19 10:47:20 -0700622 /**
623 * Prepares the specified animation with a standard duration, interpolator, etc.
624 */
Winson Chung5393dff2014-05-08 14:25:43 -0700625 Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight,
626 int duration, Interpolator interpolator) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700627 if (duration > 0) {
628 a.setDuration(duration);
629 }
Winson Chung5393dff2014-05-08 14:25:43 -0700630 a.setFillAfter(true);
631 a.setInterpolator(interpolator);
632 a.initialize(appWidth, appHeight, appWidth, appHeight);
633 return a;
634 }
635
636 /**
637 * Prepares the specified animation with a standard duration, interpolator, etc.
638 */
Winson Chung399f6202014-03-19 10:47:20 -0700639 Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800640 // Pick the desired duration. If this is an inter-activity transition,
641 // it is the standard duration for that. Otherwise we use the longer
642 // task transition duration.
Winson Chung5393dff2014-05-08 14:25:43 -0700643 final int duration;
Craig Mautner321bdf52012-12-18 09:53:24 -0800644 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800645 case TRANSIT_ACTIVITY_OPEN:
646 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800647 duration = mConfigShortAnimTime;
648 break;
649 default:
650 duration = DEFAULT_APP_TRANSITION_DURATION;
651 break;
652 }
Winson Chung5393dff2014-05-08 14:25:43 -0700653 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration,
654 mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800655 }
656
Winson Chung399f6202014-03-19 10:47:20 -0700657 /**
658 * Return the current thumbnail transition state.
659 */
660 int getThumbnailTransitionState(boolean enter) {
661 if (enter) {
662 if (mNextAppTransitionScaleUp) {
663 return THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
664 } else {
665 return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN;
666 }
667 } else {
668 if (mNextAppTransitionScaleUp) {
669 return THUMBNAIL_TRANSITION_EXIT_SCALE_UP;
670 } else {
671 return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN;
672 }
673 }
674 }
675
676 /**
677 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700678 * when a thumbnail is specified with the pending animation override.
Winson Chung399f6202014-03-19 10:47:20 -0700679 */
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700680 Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, Bitmap thumbnailHeader,
681 final int taskId) {
Winson Chung399f6202014-03-19 10:47:20 -0700682 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700683 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chung399f6202014-03-19 10:47:20 -0700684 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700685 final int thumbHeightI = thumbnailHeader.getHeight();
Winson Chung399f6202014-03-19 10:47:20 -0700686 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700687 final int appWidth = appRect.width();
Winson Chung399f6202014-03-19 10:47:20 -0700688
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700689 float scaleW = appWidth / thumbWidth;
Winson Chunga4ccb862014-08-22 15:26:27 -0700690 float unscaledHeight = thumbHeight * scaleW;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700691 getNextAppTransitionStartRect(taskId, mTmpStartRect);
692 float unscaledStartY = mTmpStartRect.top - (unscaledHeight - thumbHeight) / 2f;
Winson Chung399f6202014-03-19 10:47:20 -0700693 if (mNextAppTransitionScaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700694 // Animation up from the thumbnail to the full screen
695 Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700696 mTmpStartRect.left + (thumbWidth / 2f), mTmpStartRect.top + (thumbHeight / 2f));
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700697 scale.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700698 scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
Winson Chung399f6202014-03-19 10:47:20 -0700699 Animation alpha = new AlphaAnimation(1, 0);
Winson Chunga4ccb862014-08-22 15:26:27 -0700700 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
701 alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION);
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700702 final float toX = appRect.left + appRect.width() / 2 -
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700703 (mTmpStartRect.left + thumbWidth / 2);
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700704 final float toY = appRect.top + mNextAppTransitionInsets.top + -unscaledStartY;
705 Animation translate = new TranslateAnimation(0, toX, 0, toY);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700706 translate.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700707 translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
Winson Chung399f6202014-03-19 10:47:20 -0700708
709 // This AnimationSet uses the Interpolators assigned above.
710 AnimationSet set = new AnimationSet(false);
711 set.addAnimation(scale);
712 set.addAnimation(alpha);
Winson Chunga4ccb862014-08-22 15:26:27 -0700713 set.addAnimation(translate);
Winson Chung399f6202014-03-19 10:47:20 -0700714 a = set;
715 } else {
Winson Chunga4ccb862014-08-22 15:26:27 -0700716 // Animation down from the full screen to the thumbnail
717 Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700718 mTmpStartRect.left + (thumbWidth / 2f), mTmpStartRect.top + (thumbHeight / 2f));
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700719 scale.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700720 scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
721 Animation alpha = new AlphaAnimation(0f, 1f);
722 alpha.setInterpolator(mThumbnailFadeInInterpolator);
723 alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION);
724 Animation translate = new TranslateAnimation(0, 0, -unscaledStartY +
725 mNextAppTransitionInsets.top, 0);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700726 translate.setInterpolator(mTouchResponseInterpolator);
Winson Chunga4ccb862014-08-22 15:26:27 -0700727 translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION);
Winson Chung399f6202014-03-19 10:47:20 -0700728
Winson Chunga4ccb862014-08-22 15:26:27 -0700729 // This AnimationSet uses the Interpolators assigned above.
730 AnimationSet set = new AnimationSet(false);
731 set.addAnimation(scale);
732 set.addAnimation(alpha);
733 set.addAnimation(translate);
734 a = set;
735
736 }
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700737 return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0,
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700738 mTouchResponseInterpolator);
Winson Chung399f6202014-03-19 10:47:20 -0700739 }
740
741 /**
742 * This alternate animation is created when we are doing a thumbnail transition, for the
743 * activity that is leaving, and the activity that is entering.
744 */
Winson Chunga4ccb862014-08-22 15:26:27 -0700745 Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState,
746 int appWidth, int appHeight, int orientation, int transit, Rect containingFrame,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700747 Rect contentInsets, @Nullable Rect surfaceInsets, boolean resizedWindow,
748 int taskId) {
Winson Chung399f6202014-03-19 10:47:20 -0700749 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700750 getDefaultNextAppTransitionStartRect(mTmpStartRect);
751 final int thumbWidthI = mTmpStartRect.width();
Winson Chung399f6202014-03-19 10:47:20 -0700752 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700753 final int thumbHeightI = mTmpStartRect.height();
Winson Chung399f6202014-03-19 10:47:20 -0700754 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
755
Winson Chung2820c452014-04-15 15:34:44 -0700756 // Used for the ENTER_SCALE_UP and EXIT_SCALE_DOWN transitions
757 float scale = 1f;
758 int scaledTopDecor = 0;
759
Winson Chung399f6202014-03-19 10:47:20 -0700760 switch (thumbTransitState) {
761 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700762 if (resizedWindow) {
763 a = createAspectScaledThumbnailEnterNonFullscreenAnimationLocked(
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700764 containingFrame, surfaceInsets, taskId);
Winson Chung2820c452014-04-15 15:34:44 -0700765 } else {
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700766 // App window scaling up to become full screen
767 if (orientation == Configuration.ORIENTATION_PORTRAIT) {
768 // In portrait, we scale the width and clip to the top/left square
769 scale = thumbWidth / appWidth;
770 scaledTopDecor = (int) (scale * contentInsets.top);
771 int unscaledThumbHeight = (int) (thumbHeight / scale);
772 mTmpFromClipRect.set(containingFrame);
773 mTmpFromClipRect.bottom = (mTmpFromClipRect.top + unscaledThumbHeight);
774 mTmpToClipRect.set(containingFrame);
775 } else {
776 // In landscape, we scale the height and clip to the top/left square
777 scale = thumbHeight / (appHeight - contentInsets.top);
778 scaledTopDecor = (int) (scale * contentInsets.top);
779 int unscaledThumbWidth = (int) (thumbWidth / scale);
780 mTmpFromClipRect.set(containingFrame);
781 mTmpFromClipRect.right = (mTmpFromClipRect.left + unscaledThumbWidth);
782 mTmpToClipRect.set(containingFrame);
783 }
784 // exclude top screen decor (status bar) region from the source clip.
785 mTmpFromClipRect.top = contentInsets.top;
786
787 mNextAppTransitionInsets.set(contentInsets);
788
789 Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700790 computePivot(mTmpStartRect.left, scale),
791 computePivot(mTmpStartRect.top, scale));
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700792 Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
793 Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0);
794
795 AnimationSet set = new AnimationSet(true);
796 set.addAnimation(clipAnim);
797 set.addAnimation(scaleAnim);
798 set.addAnimation(translateAnim);
799 a = set;
Winson Chung2820c452014-04-15 15:34:44 -0700800 }
Winson Chung399f6202014-03-19 10:47:20 -0700801 break;
802 }
803 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
Winson Chunga4ccb862014-08-22 15:26:27 -0700804 // Previous app window during the scale up
Winson Chung399f6202014-03-19 10:47:20 -0700805 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700806 // Fade out the source activity if we are animating to a wallpaper
Winson Chung399f6202014-03-19 10:47:20 -0700807 // activity.
808 a = new AlphaAnimation(1, 0);
809 } else {
Winson Chung399f6202014-03-19 10:47:20 -0700810 a = new AlphaAnimation(1, 1);
811 }
812 break;
813 }
814 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
Winson Chunga4ccb862014-08-22 15:26:27 -0700815 // Target app window during the scale down
816 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
817 // Fade in the destination activity if we are animating from a wallpaper
818 // activity.
819 a = new AlphaAnimation(0, 1);
820 } else {
821 a = new AlphaAnimation(1, 1);
822 }
Winson Chung399f6202014-03-19 10:47:20 -0700823 break;
824 }
825 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
Winson Chunga4ccb862014-08-22 15:26:27 -0700826 // App window scaling down from full screen
Winson Chung2820c452014-04-15 15:34:44 -0700827 if (orientation == Configuration.ORIENTATION_PORTRAIT) {
828 // In portrait, we scale the width and clip to the top/left square
829 scale = thumbWidth / appWidth;
830 scaledTopDecor = (int) (scale * contentInsets.top);
831 int unscaledThumbHeight = (int) (thumbHeight / scale);
832 mTmpFromClipRect.set(containingFrame);
833 mTmpToClipRect.set(containingFrame);
834 mTmpToClipRect.bottom = (mTmpToClipRect.top + unscaledThumbHeight);
835 } else {
836 // In landscape, we scale the height and clip to the top/left square
837 scale = thumbHeight / (appHeight - contentInsets.top);
838 scaledTopDecor = (int) (scale * contentInsets.top);
839 int unscaledThumbWidth = (int) (thumbWidth / scale);
840 mTmpFromClipRect.set(containingFrame);
841 mTmpToClipRect.set(containingFrame);
842 mTmpToClipRect.right = (mTmpToClipRect.left + unscaledThumbWidth);
843 }
Wale Ogunwale35a57f82015-07-01 15:07:36 -0700844 // exclude top screen decor (status bar) region from the destination clip.
845 mTmpToClipRect.top = contentInsets.top;
846
Winson Chunga4ccb862014-08-22 15:26:27 -0700847 mNextAppTransitionInsets.set(contentInsets);
Winson Chung399f6202014-03-19 10:47:20 -0700848
849 Animation scaleAnim = new ScaleAnimation(1, scale, 1, scale,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700850 computePivot(mTmpStartRect.left, scale),
851 computePivot(mTmpStartRect.top, scale));
Winson Chung2820c452014-04-15 15:34:44 -0700852 Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
Winson Chung399f6202014-03-19 10:47:20 -0700853 Animation translateAnim = new TranslateAnimation(0, 0, 0, -scaledTopDecor);
854
855 AnimationSet set = new AnimationSet(true);
Winson Chung399f6202014-03-19 10:47:20 -0700856 set.addAnimation(clipAnim);
857 set.addAnimation(scaleAnim);
858 set.addAnimation(translateAnim);
859
860 a = set;
861 a.setZAdjustment(Animation.ZORDER_TOP);
862 break;
863 }
864 default:
865 throw new RuntimeException("Invalid thumbnail transition state");
866 }
867
Winson Chungab79fce2014-11-04 16:15:22 -0800868 int duration = Math.max(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION,
869 THUMBNAIL_APP_TRANSITION_DURATION);
870 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration,
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700871 mTouchResponseInterpolator);
Winson Chung399f6202014-03-19 10:47:20 -0700872 }
873
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700874 private Animation createAspectScaledThumbnailEnterNonFullscreenAnimationLocked(
Filip Gruszczynski1a1d8312015-08-26 17:00:47 -0700875 Rect frame, @Nullable Rect surfaceInsets, int taskId) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700876 getNextAppTransitionStartRect(taskId, mTmpStartRect);
Filip Gruszczynski1a1d8312015-08-26 17:00:47 -0700877 float width = frame.width();
878 float height = frame.height();
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700879 float scaleWidth = mTmpStartRect.width() / width;
880 float scaleHeight = mTmpStartRect.height() / height;
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700881 AnimationSet set = new AnimationSet(true);
882 int surfaceInsetsHorizontal = surfaceInsets == null
883 ? 0 : surfaceInsets.left + surfaceInsets.right;
884 int surfaceInsetsVertical = surfaceInsets == null
885 ? 0 : surfaceInsets.top + surfaceInsets.bottom;
886 // We want the scaling to happen from the center of the surface. In order to achieve that,
887 // we need to account for surface insets that will be used to enlarge the surface.
888 ScaleAnimation scale = new ScaleAnimation(scaleWidth, 1, scaleHeight, 1,
889 (width + surfaceInsetsHorizontal) / 2, (height + surfaceInsetsVertical) / 2);
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700890 int fromX = mTmpStartRect.left + mTmpStartRect.width() / 2
Filip Gruszczynski1a1d8312015-08-26 17:00:47 -0700891 - (frame.left + frame.width() / 2);
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700892 int fromY = mTmpStartRect.top + mTmpStartRect.height() / 2
Filip Gruszczynski1a1d8312015-08-26 17:00:47 -0700893 - (frame.top + frame.height() / 2);
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -0700894 TranslateAnimation translation = new TranslateAnimation(fromX, 0, fromY, 0);
895 set.addAnimation(scale);
896 set.addAnimation(translation);
897 return set;
898 }
899
Winson Chung399f6202014-03-19 10:47:20 -0700900 /**
Winson Chunga4ccb862014-08-22 15:26:27 -0700901 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700902 * when a thumbnail is specified with the pending animation override.
Winson Chunga4ccb862014-08-22 15:26:27 -0700903 */
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700904 Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit,
905 Bitmap thumbnailHeader) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700906 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700907 getDefaultNextAppTransitionStartRect(mTmpStartRect);
908 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chunga4ccb862014-08-22 15:26:27 -0700909 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700910 final int thumbHeightI = thumbnailHeader.getHeight();
Winson Chunga4ccb862014-08-22 15:26:27 -0700911 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
912
913 if (mNextAppTransitionScaleUp) {
914 // Animation for the thumbnail zooming from its initial size to the full screen
915 float scaleW = appWidth / thumbWidth;
916 float scaleH = appHeight / thumbHeight;
917 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700918 computePivot(mTmpStartRect.left, 1 / scaleW),
919 computePivot(mTmpStartRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -0700920 scale.setInterpolator(mDecelerateInterpolator);
921
922 Animation alpha = new AlphaAnimation(1, 0);
923 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
924
925 // This AnimationSet uses the Interpolators assigned above.
926 AnimationSet set = new AnimationSet(false);
927 set.addAnimation(scale);
928 set.addAnimation(alpha);
929 a = set;
930 } else {
931 // Animation for the thumbnail zooming down from the full screen to its final size
932 float scaleW = appWidth / thumbWidth;
933 float scaleH = appHeight / thumbHeight;
934 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700935 computePivot(mTmpStartRect.left, 1 / scaleW),
936 computePivot(mTmpStartRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -0700937 }
938
939 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
940 }
941
942 /**
Winson Chung399f6202014-03-19 10:47:20 -0700943 * This animation is created when we are doing a thumbnail transition, for the activity that is
944 * leaving, and the activity that is entering.
945 */
946 Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700947 int appHeight, int transit, int taskId) {
948 Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
Winson Chung399f6202014-03-19 10:47:20 -0700949 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700950 getDefaultNextAppTransitionStartRect(mTmpStartRect);
951 final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
Winson Chung399f6202014-03-19 10:47:20 -0700952 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700953 final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
Winson Chung399f6202014-03-19 10:47:20 -0700954 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
955
956 switch (thumbTransitState) {
957 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
958 // Entering app scales up with the thumbnail
959 float scaleW = thumbWidth / appWidth;
960 float scaleH = thumbHeight / appHeight;
961 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700962 computePivot(mTmpStartRect.left, scaleW),
963 computePivot(mTmpStartRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -0700964 break;
965 }
966 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
967 // Exiting app while the thumbnail is scaling up should fade or stay in place
968 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
969 // Fade out while bringing up selected activity. This keeps the
970 // current activity from showing through a launching wallpaper
971 // activity.
972 a = new AlphaAnimation(1, 0);
973 } else {
974 // noop animation
975 a = new AlphaAnimation(1, 1);
976 }
977 break;
978 }
979 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
980 // Entering the other app, it should just be visible while we scale the thumbnail
981 // down above it
982 a = new AlphaAnimation(1, 1);
983 break;
984 }
985 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
986 // Exiting the current app, the app should scale down with the thumbnail
987 float scaleW = thumbWidth / appWidth;
988 float scaleH = thumbHeight / appHeight;
989 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700990 computePivot(mTmpStartRect.left, scaleW),
991 computePivot(mTmpStartRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -0700992
993 Animation alpha = new AlphaAnimation(1, 0);
994
995 AnimationSet set = new AnimationSet(true);
996 set.addAnimation(scale);
997 set.addAnimation(alpha);
998 set.setZAdjustment(Animation.ZORDER_TOP);
999 a = set;
1000 break;
1001 }
1002 default:
1003 throw new RuntimeException("Invalid thumbnail transition state");
1004 }
1005
1006 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
1007 }
1008
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001009 private Animation createRelaunchAnimation(int appWidth, int appHeight) {
1010 getDefaultNextAppTransitionStartRect(mTmpFromClipRect);
1011 final int left = mTmpFromClipRect.left;
1012 final int top = mTmpFromClipRect.top;
1013 mTmpFromClipRect.offset(-left, -top);
1014 mTmpToClipRect.set(0, 0, appWidth, appHeight);
1015 AnimationSet set = new AnimationSet(true);
1016 ClipRectAnimation clip = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
1017 TranslateAnimation translate = new TranslateAnimation(left, 0, top, 0);
1018 clip.setInterpolator(mDecelerateInterpolator);
1019 set.addAnimation(clip);
1020 set.addAnimation(translate);
1021 set.setDuration(DEFAULT_APP_TRANSITION_DURATION);
1022 return set;
1023 }
1024
Jorim Jaggic554b772015-06-04 16:07:57 -07001025 /**
1026 * @return true if and only if the first frame of the transition can be skipped, i.e. the first
1027 * frame of the transition doesn't change the visuals on screen, so we can start
1028 * directly with the second one
1029 */
1030 boolean canSkipFirstFrame() {
1031 return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM
1032 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE
1033 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL;
1034 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001035
1036 Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter,
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001037 int appWidth, int appHeight, int orientation, Rect containingFrame, Rect contentInsets,
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001038 @Nullable Rect surfaceInsets, Rect appFrame, boolean isVoiceInteraction,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001039 boolean resizedWindow, int taskId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001040 Animation a;
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001041 if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN
1042 || transit == TRANSIT_TASK_OPEN
1043 || transit == TRANSIT_TASK_TO_FRONT)) {
1044 a = loadAnimationRes(lp, enter
1045 ? com.android.internal.R.anim.voice_activity_open_enter
1046 : com.android.internal.R.anim.voice_activity_open_exit);
1047 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1048 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001049 + " anim=" + a + " transit=" + appTransitionToString(transit)
1050 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001051 } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE
1052 || transit == TRANSIT_TASK_CLOSE
1053 || transit == TRANSIT_TASK_TO_BACK)) {
1054 a = loadAnimationRes(lp, enter
1055 ? com.android.internal.R.anim.voice_activity_close_enter
1056 : com.android.internal.R.anim.voice_activity_close_exit);
1057 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1058 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001059 + " anim=" + a + " transit=" + appTransitionToString(transit)
1060 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001061 } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) {
1062 a = createRelaunchAnimation(appWidth, appHeight);
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001063 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
1064 a = loadAnimationRes(mNextAppTransitionPackage, enter ?
Craig Mautner164d4bb2012-11-26 13:51:23 -08001065 mNextAppTransitionEnter : mNextAppTransitionExit);
1066 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1067 "applyAnimation:"
1068 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
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));
Winson Chung044d5292014-11-06 11:05:19 -08001071 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
1072 a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
1073 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1074 "applyAnimation:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001075 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE"
1076 + " transit=" + appTransitionToString(transit)
1077 + " Callers=" + Debug.getCallers(3));
Chet Haase10e23ab2015-02-11 15:08:38 -08001078 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) {
Craig Mautner80b1f642015-04-22 10:59:09 -07001079 a = createClipRevealAnimationLocked(transit, enter, appFrame);
Chet Haase10e23ab2015-02-11 15:08:38 -08001080 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1081 "applyAnimation:"
1082 + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL"
1083 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001084 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001085 a = createScaleUpAnimationLocked(transit, enter, appWidth, appHeight);
1086 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1087 "applyAnimation:"
1088 + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001089 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001090 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001091 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
1092 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001093 mNextAppTransitionScaleUp =
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001094 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
Winson Chunga4ccb862014-08-22 15:26:27 -07001095 a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter),
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001096 appWidth, appHeight, transit, taskId);
Winson Chunga4ccb862014-08-22 15:26:27 -07001097 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1098 String animName = mNextAppTransitionScaleUp ?
1099 "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
1100 Slog.v(TAG, "applyAnimation:"
1101 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001102 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Winson Chunga4ccb862014-08-22 15:26:27 -07001103 + " Callers=" + Debug.getCallers(3));
1104 }
1105 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
1106 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) {
1107 mNextAppTransitionScaleUp =
1108 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP);
1109 a = createAspectScaledThumbnailEnterExitAnimationLocked(
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001110 getThumbnailTransitionState(enter), appWidth, appHeight, orientation, transit,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001111 containingFrame, contentInsets, surfaceInsets, resizedWindow, taskId);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001112 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1113 String animName = mNextAppTransitionScaleUp ?
Winson Chunga4ccb862014-08-22 15:26:27 -07001114 "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner164d4bb2012-11-26 13:51:23 -08001115 Slog.v(TAG, "applyAnimation:"
1116 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001117 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001118 + " Callers=" + Debug.getCallers(3));
1119 }
1120 } else {
1121 int animAttr = 0;
1122 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -08001123 case TRANSIT_ACTIVITY_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001124 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001125 ? WindowAnimation_activityOpenEnterAnimation
1126 : WindowAnimation_activityOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001127 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001128 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001129 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001130 ? WindowAnimation_activityCloseEnterAnimation
1131 : WindowAnimation_activityCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001132 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001133 case TRANSIT_TASK_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001134 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001135 ? WindowAnimation_taskOpenEnterAnimation
1136 : WindowAnimation_taskOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001137 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001138 case TRANSIT_TASK_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001139 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001140 ? WindowAnimation_taskCloseEnterAnimation
1141 : WindowAnimation_taskCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001142 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001143 case TRANSIT_TASK_TO_FRONT:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001144 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001145 ? WindowAnimation_taskToFrontEnterAnimation
1146 : WindowAnimation_taskToFrontExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001147 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001148 case TRANSIT_TASK_TO_BACK:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001149 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001150 ? WindowAnimation_taskToBackEnterAnimation
1151 : WindowAnimation_taskToBackExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001152 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001153 case TRANSIT_WALLPAPER_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001154 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001155 ? WindowAnimation_wallpaperOpenEnterAnimation
1156 : WindowAnimation_wallpaperOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001157 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001158 case TRANSIT_WALLPAPER_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001159 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001160 ? WindowAnimation_wallpaperCloseEnterAnimation
1161 : WindowAnimation_wallpaperCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001162 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001163 case TRANSIT_WALLPAPER_INTRA_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001164 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001165 ? WindowAnimation_wallpaperIntraOpenEnterAnimation
1166 : WindowAnimation_wallpaperIntraOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001167 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001168 case TRANSIT_WALLPAPER_INTRA_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001169 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001170 ? WindowAnimation_wallpaperIntraCloseEnterAnimation
1171 : WindowAnimation_wallpaperIntraCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001172 break;
Craig Mautnerbb742462014-07-07 15:28:55 -07001173 case TRANSIT_TASK_OPEN_BEHIND:
1174 animAttr = enter
1175 ? WindowAnimation_launchTaskBehindSourceAnimation
Craig Mautner3b2cd1d2014-08-25 14:25:54 -07001176 : WindowAnimation_launchTaskBehindTargetAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001177 }
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001178 a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001179 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1180 "applyAnimation:"
1181 + " anim=" + a
1182 + " animAttr=0x" + Integer.toHexString(animAttr)
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001183 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001184 + " Callers=" + Debug.getCallers(3));
1185 }
1186 return a;
1187 }
1188
1189 void postAnimationCallback() {
1190 if (mNextAppTransitionCallback != null) {
1191 mH.sendMessage(mH.obtainMessage(H.DO_ANIMATION_CALLBACK, mNextAppTransitionCallback));
1192 mNextAppTransitionCallback = null;
1193 }
1194 }
1195
1196 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
1197 IRemoteCallback startedCallback) {
1198 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001199 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001200 mNextAppTransitionPackage = packageName;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001201 mNextAppTransitionAnimationsSpecs.clear();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001202 mNextAppTransitionEnter = enterAnim;
1203 mNextAppTransitionExit = exitAnim;
1204 postAnimationCallback();
1205 mNextAppTransitionCallback = startedCallback;
1206 } else {
1207 postAnimationCallback();
1208 }
1209 }
1210
1211 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001212 int startHeight) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001213 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001214 mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001215 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001216 mNextAppTransitionAnimationsSpecs.clear();
1217 putDefaultNextAppTransitionCoordinates(startX, startY, startX + startWidth,
1218 startY + startHeight);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001219 postAnimationCallback();
1220 mNextAppTransitionCallback = null;
1221 }
1222 }
1223
Chet Haase10e23ab2015-02-11 15:08:38 -08001224 void overridePendingAppTransitionClipReveal(int startX, int startY,
1225 int startWidth, int startHeight) {
1226 if (isTransitionSet()) {
1227 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001228 putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight);
Chet Haase10e23ab2015-02-11 15:08:38 -08001229 postAnimationCallback();
1230 mNextAppTransitionCallback = null;
1231 }
1232 }
1233
Craig Mautner164d4bb2012-11-26 13:51:23 -08001234 void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
1235 IRemoteCallback startedCallback, boolean scaleUp) {
1236 if (isTransitionSet()) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001237 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP
1238 : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001239 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001240 mNextAppTransitionAnimationsSpecs.clear();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001241 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001242 putDefaultNextAppTransitionCoordinates(startX, startY, 0 ,0);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001243 postAnimationCallback();
1244 mNextAppTransitionCallback = startedCallback;
1245 } else {
1246 postAnimationCallback();
1247 }
1248 }
1249
Winson Chunga4ccb862014-08-22 15:26:27 -07001250 void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY,
Winson Chung2e7f3bd2014-09-05 13:17:22 +02001251 int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001252 if (isTransitionSet()) {
1253 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1254 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
1255 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001256 mNextAppTransitionAnimationsSpecs.clear();
Winson Chunga4ccb862014-08-22 15:26:27 -07001257 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001258 putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight);
Winson Chunga4ccb862014-08-22 15:26:27 -07001259 postAnimationCallback();
1260 mNextAppTransitionCallback = startedCallback;
1261 } else {
1262 postAnimationCallback();
1263 }
1264 }
1265
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001266 public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs,
1267 IRemoteCallback callback, boolean scaleUp) {
1268 if (isTransitionSet()) {
1269 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1270 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
1271 mNextAppTransitionPackage = null;
1272 mNextAppTransitionAnimationsSpecs.clear();
1273 mNextAppTransitionScaleUp = scaleUp;
1274 for (int i = 0; i < specs.length; i++) {
1275 AppTransitionAnimationSpec spec = specs[i];
1276 if (spec != null) {
1277 mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec);
1278 }
1279 }
1280 postAnimationCallback();
1281 mNextAppTransitionCallback = callback;
1282 } else {
1283 postAnimationCallback();
1284 }
1285 }
1286
Winson Chung044d5292014-11-06 11:05:19 -08001287 void overrideInPlaceAppTransition(String packageName, int anim) {
1288 if (isTransitionSet()) {
1289 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE;
1290 mNextAppTransitionPackage = packageName;
1291 mNextAppTransitionInPlace = anim;
1292 } else {
1293 postAnimationCallback();
1294 }
1295 }
1296
Craig Mautner164d4bb2012-11-26 13:51:23 -08001297 @Override
1298 public String toString() {
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001299 return "mNextAppTransition=" + appTransitionToString(mNextAppTransition);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001300 }
1301
Craig Mautner4b71aa12012-12-27 17:20:01 -08001302 /**
1303 * Returns the human readable name of a window transition.
1304 *
1305 * @param transition The window transition.
1306 * @return The transition symbolic name.
1307 */
1308 public static String appTransitionToString(int transition) {
1309 switch (transition) {
1310 case TRANSIT_UNSET: {
1311 return "TRANSIT_UNSET";
1312 }
1313 case TRANSIT_NONE: {
1314 return "TRANSIT_NONE";
1315 }
Craig Mautner4b71aa12012-12-27 17:20:01 -08001316 case TRANSIT_ACTIVITY_OPEN: {
1317 return "TRANSIT_ACTIVITY_OPEN";
1318 }
1319 case TRANSIT_ACTIVITY_CLOSE: {
1320 return "TRANSIT_ACTIVITY_CLOSE";
1321 }
1322 case TRANSIT_TASK_OPEN: {
1323 return "TRANSIT_TASK_OPEN";
1324 }
1325 case TRANSIT_TASK_CLOSE: {
1326 return "TRANSIT_TASK_CLOSE";
1327 }
1328 case TRANSIT_TASK_TO_FRONT: {
1329 return "TRANSIT_TASK_TO_FRONT";
1330 }
1331 case TRANSIT_TASK_TO_BACK: {
1332 return "TRANSIT_TASK_TO_BACK";
1333 }
1334 case TRANSIT_WALLPAPER_CLOSE: {
1335 return "TRANSIT_WALLPAPER_CLOSE";
1336 }
1337 case TRANSIT_WALLPAPER_OPEN: {
1338 return "TRANSIT_WALLPAPER_OPEN";
1339 }
1340 case TRANSIT_WALLPAPER_INTRA_OPEN: {
1341 return "TRANSIT_WALLPAPER_INTRA_OPEN";
1342 }
1343 case TRANSIT_WALLPAPER_INTRA_CLOSE: {
1344 return "TRANSIT_WALLPAPER_INTRA_CLOSE";
1345 }
Craig Mautnerbb742462014-07-07 15:28:55 -07001346 case TRANSIT_TASK_OPEN_BEHIND: {
1347 return "TRANSIT_TASK_OPEN_BEHIND";
1348 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001349 case TRANSIT_ACTIVITY_RELAUNCH: {
1350 return "TRANSIT_ACTIVITY_RELAUNCH";
1351 }
Craig Mautner4b71aa12012-12-27 17:20:01 -08001352 default: {
1353 return "<UNKNOWN>";
1354 }
1355 }
1356 }
1357
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001358 private String appStateToString() {
1359 switch (mAppTransitionState) {
1360 case APP_STATE_IDLE:
1361 return "APP_STATE_IDLE";
1362 case APP_STATE_READY:
1363 return "APP_STATE_READY";
1364 case APP_STATE_RUNNING:
1365 return "APP_STATE_RUNNING";
1366 case APP_STATE_TIMEOUT:
1367 return "APP_STATE_TIMEOUT";
1368 default:
1369 return "unknown state=" + mAppTransitionState;
1370 }
1371 }
1372
1373 private String transitTypeToString() {
1374 switch (mNextAppTransitionType) {
1375 case NEXT_TRANSIT_TYPE_NONE:
1376 return "NEXT_TRANSIT_TYPE_NONE";
1377 case NEXT_TRANSIT_TYPE_CUSTOM:
1378 return "NEXT_TRANSIT_TYPE_CUSTOM";
Winson Chung044d5292014-11-06 11:05:19 -08001379 case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
1380 return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE";
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001381 case NEXT_TRANSIT_TYPE_SCALE_UP:
1382 return "NEXT_TRANSIT_TYPE_SCALE_UP";
1383 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
1384 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP";
1385 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
1386 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN";
Winson Chunga4ccb862014-08-22 15:26:27 -07001387 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP:
1388 return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP";
1389 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN:
1390 return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001391 default:
1392 return "unknown type=" + mNextAppTransitionType;
1393 }
1394 }
1395
Craig Mautner164d4bb2012-11-26 13:51:23 -08001396 @Override
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001397 public void dump(PrintWriter pw, String prefix) {
1398 pw.print(prefix); pw.println(this);
1399 pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString());
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001400 if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) {
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001401 pw.print(prefix); pw.print("mNextAppTransitionType=");
1402 pw.println(transitTypeToString());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001403 }
1404 switch (mNextAppTransitionType) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001405 case NEXT_TRANSIT_TYPE_CUSTOM:
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001406 pw.print(prefix); pw.print("mNextAppTransitionPackage=");
Craig Mautner164d4bb2012-11-26 13:51:23 -08001407 pw.println(mNextAppTransitionPackage);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001408 pw.print(prefix); pw.print("mNextAppTransitionEnter=0x");
Craig Mautner164d4bb2012-11-26 13:51:23 -08001409 pw.print(Integer.toHexString(mNextAppTransitionEnter));
1410 pw.print(" mNextAppTransitionExit=0x");
1411 pw.println(Integer.toHexString(mNextAppTransitionExit));
1412 break;
Winson Chung044d5292014-11-06 11:05:19 -08001413 case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001414 pw.print(prefix); pw.print("mNextAppTransitionPackage=");
Winson Chung044d5292014-11-06 11:05:19 -08001415 pw.println(mNextAppTransitionPackage);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001416 pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x");
Winson Chung044d5292014-11-06 11:05:19 -08001417 pw.print(Integer.toHexString(mNextAppTransitionInPlace));
1418 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001419 case NEXT_TRANSIT_TYPE_SCALE_UP: {
1420 getDefaultNextAppTransitionStartRect(mTmpStartRect);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001421 pw.print(prefix); pw.print("mNextAppTransitionStartX=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001422 pw.print(mTmpStartRect.left);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001423 pw.print(" mNextAppTransitionStartY=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001424 pw.println(mTmpStartRect.top);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001425 pw.print(prefix); pw.print("mNextAppTransitionStartWidth=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001426 pw.print(mTmpStartRect.width());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001427 pw.print(" mNextAppTransitionStartHeight=");
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001428 pw.println(mTmpStartRect.height());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001429 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001430 }
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001431 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
1432 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
Winson Chunga4ccb862014-08-22 15:26:27 -07001433 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP:
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001434 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: {
1435 pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec=");
1436 pw.println(mDefaultNextAppTransitionAnimationSpec);
1437 pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs=");
1438 pw.println(mNextAppTransitionAnimationsSpecs);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001439 pw.print(prefix); pw.print("mNextAppTransitionScaleUp=");
1440 pw.println(mNextAppTransitionScaleUp);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001441 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001442 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001443 }
1444 if (mNextAppTransitionCallback != null) {
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001445 pw.print(prefix); pw.print("mNextAppTransitionCallback=");
1446 pw.println(mNextAppTransitionCallback);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001447 }
1448 }
Amith Yamasani4befbec2013-07-10 16:18:01 -07001449
1450 public void setCurrentUser(int newUserId) {
1451 mCurrentUserId = newUserId;
1452 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001453}