blob: 9d8f1241a7aed639b288fd3ea2410bcb62d67c75 [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 Gruszczynski82861362015-10-16 14:21:09 -070019import static android.view.WindowManagerInternal.AppTransitionListener;
20import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation;
21import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
22import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation;
23import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
24import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation;
25import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation;
26import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation;
27import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation;
28import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation;
29import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation;
30import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation;
31import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
32import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation;
33import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation;
34import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation;
35import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation;
36import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation;
37import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation;
38import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation;
39import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
40import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation;
41import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
Jorim Jaggi363ab982016-04-26 19:51:20 -070042import static com.android.server.wm.AppWindowAnimator.PROLONG_ANIMATION_AT_START;
Filip Gruszczynski198dcbf2016-01-18 10:02:00 -080043import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
44import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080045import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
46import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Matthew Ngbf1d9852017-03-14 12:23:09 -070047import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_BEFORE_ANIM;
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +010048import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE;
49import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM;
Filip Gruszczynski82861362015-10-16 14:21:09 -070050
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -070051import android.annotation.Nullable;
Craig Mautner164d4bb2012-11-26 13:51:23 -080052import android.content.Context;
Winson21700932016-03-24 17:26:23 -070053import android.content.res.Configuration;
Craig Mautner164d4bb2012-11-26 13:51:23 -080054import android.graphics.Bitmap;
Winson Chungaa7fa012017-05-24 15:50:06 -070055import android.graphics.GraphicBuffer;
Jorim Jaggi787e9dd2016-03-15 10:52:40 +010056import android.graphics.Path;
Winson Chung399f6202014-03-19 10:47:20 -070057import android.graphics.Rect;
Jorim Jaggied410b62017-05-05 15:16:14 +020058import android.os.Binder;
Craig Mautner164d4bb2012-11-26 13:51:23 -080059import android.os.Debug;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010060import android.os.IBinder;
Craig Mautner164d4bb2012-11-26 13:51:23 -080061import android.os.IRemoteCallback;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +010062import android.os.RemoteException;
Manu Cornetd7376802017-01-13 13:44:07 -080063import android.os.SystemProperties;
Jorim Jaggi42625d1b2016-02-11 20:11:07 -080064import android.util.ArraySet;
Craig Mautner164d4bb2012-11-26 13:51:23 -080065import android.util.Slog;
Filip Gruszczynski170192a2015-08-16 17:46:34 -070066import android.util.SparseArray;
67import android.view.AppTransitionAnimationSpec;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +010068import android.view.IAppTransitionAnimationSpecsFuture;
Craig Mautner164d4bb2012-11-26 13:51:23 -080069import android.view.WindowManager;
Craig Mautner164d4bb2012-11-26 13:51:23 -080070import android.view.animation.AlphaAnimation;
71import android.view.animation.Animation;
72import android.view.animation.AnimationSet;
73import android.view.animation.AnimationUtils;
Winson Chung399f6202014-03-19 10:47:20 -070074import android.view.animation.ClipRectAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080075import android.view.animation.Interpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070076import android.view.animation.PathInterpolator;
Craig Mautner164d4bb2012-11-26 13:51:23 -080077import android.view.animation.ScaleAnimation;
Winson Chung399f6202014-03-19 10:47:20 -070078import android.view.animation.TranslateAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070079
Craig Mautner164d4bb2012-11-26 13:51:23 -080080import com.android.internal.util.DumpUtils.Dump;
81import com.android.server.AttributeCache;
82import com.android.server.wm.WindowManagerService.H;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -080083import com.android.server.wm.animation.ClipRectLRAnimation;
84import com.android.server.wm.animation.ClipRectTBAnimation;
Jorim Jaggi787e9dd2016-03-15 10:52:40 +010085import com.android.server.wm.animation.CurvedTranslateAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080086
87import java.io.PrintWriter;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010088import java.util.ArrayList;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +010089import java.util.concurrent.ExecutorService;
90import java.util.concurrent.Executors;
Craig Mautner164d4bb2012-11-26 13:51:23 -080091
Craig Mautner164d4bb2012-11-26 13:51:23 -080092// State management of app transitions. When we are preparing for a
93// transition, mNextAppTransition will be the kind of transition to
94// perform or TRANSIT_NONE if we are not waiting. If we are waiting,
95// mOpeningApps and mClosingApps are the lists of tokens that will be
96// made visible or hidden at the next transition.
97public class AppTransition implements Dump {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080098 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppTransition" : TAG_WM;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070099 private static final int CLIP_REVEAL_TRANSLATION_Y_DP = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800100
Craig Mautner4b71aa12012-12-27 17:20:01 -0800101 /** Not set up for a transition. */
102 public static final int TRANSIT_UNSET = -1;
103 /** No animation for transition. */
104 public static final int TRANSIT_NONE = 0;
105 /** 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 -0700106 public static final int TRANSIT_ACTIVITY_OPEN = 6;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800107 /** The window in the top-most activity is being closed to reveal the
108 * previous activity in the same task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700109 public static final int TRANSIT_ACTIVITY_CLOSE = 7;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800110 /** A window in a new task is being opened on top of an existing one
111 * in another activity's task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700112 public static final int TRANSIT_TASK_OPEN = 8;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800113 /** A window in the top-most activity is being closed to reveal the
114 * previous activity in a different task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700115 public static final int TRANSIT_TASK_CLOSE = 9;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800116 /** A window in an existing task is being displayed on top of an existing one
117 * in another activity's task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700118 public static final int TRANSIT_TASK_TO_FRONT = 10;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800119 /** A window in an existing task is being put below all other tasks. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700120 public static final int TRANSIT_TASK_TO_BACK = 11;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800121 /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that
122 * does, effectively closing the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700123 public static final int TRANSIT_WALLPAPER_CLOSE = 12;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800124 /** A window in a new activity that does have a wallpaper is being opened on one that didn't,
125 * effectively opening the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700126 public static final int TRANSIT_WALLPAPER_OPEN = 13;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800127 /** A window in a new activity is being opened on top of an existing one, and both are on top
128 * of the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700129 public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800130 /** The window in the top-most activity is being closed to reveal the previous activity, and
131 * both are on top of the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700132 public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
133 /** A window in a new task is being opened behind an existing one in another activity's task.
134 * The new window will show briefly and then be gone. */
135 public static final int TRANSIT_TASK_OPEN_BEHIND = 16;
Winson Chung044d5292014-11-06 11:05:19 -0800136 /** A window in a task is being animated in-place. */
137 public static final int TRANSIT_TASK_IN_PLACE = 17;
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700138 /** An activity is being relaunched (e.g. due to configuration change). */
139 public static final int TRANSIT_ACTIVITY_RELAUNCH = 18;
Jorim Jaggi192086e2016-03-11 17:17:03 +0100140 /** A task is being docked from recents. */
141 public static final int TRANSIT_DOCK_TASK_FROM_RECENTS = 19;
Jorim Jaggife762342016-10-13 14:33:27 +0200142 /** Keyguard is going away */
143 public static final int TRANSIT_KEYGUARD_GOING_AWAY = 20;
144 /** Keyguard is going away with showing an activity behind that requests wallpaper */
145 public static final int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;
146 /** Keyguard is being occluded */
147 public static final int TRANSIT_KEYGUARD_OCCLUDE = 22;
148 /** Keyguard is being unoccluded */
149 public static final int TRANSIT_KEYGUARD_UNOCCLUDE = 23;
150
151 /** Transition flag: Keyguard is going away, but keeping the notification shade open */
152 public static final int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1;
153 /** Transition flag: Keyguard is going away, but doesn't want an animation for it */
154 public static final int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2;
155 /** Transition flag: Keyguard is going away while it was showing the system wallpaper. */
156 public static final int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800157
Winson Chunga4ccb862014-08-22 15:26:27 -0700158 /** Fraction of animation at which the recents thumbnail stays completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700159 private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800160 /** Fraction of animation at which the recents thumbnail becomes completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700161 private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800162
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800163 static final int DEFAULT_APP_TRANSITION_DURATION = 336;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800164
165 /** Interpolator to be used for animations that respond directly to a touch */
166 static final Interpolator TOUCH_RESPONSE_INTERPOLATOR =
167 new PathInterpolator(0.3f, 0f, 0.1f, 1f);
168
Jorim Jaggic69bd222016-03-15 14:38:37 +0100169 private static final Interpolator THUMBNAIL_DOCK_INTERPOLATOR =
170 new PathInterpolator(0.85f, 0f, 1f, 1f);
171
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800172 /**
173 * Maximum duration for the clip reveal animation. This is used when there is a lot of movement
174 * involved, to make it more understandable.
175 */
176 private static final int MAX_CLIP_REVEAL_TRANSITION_DURATION = 420;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700177 private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336;
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700178 private static final long APP_TRANSITION_TIMEOUT_MS = 5000;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800179
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800180 private final Context mContext;
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -0800181 private final WindowManagerService mService;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800182
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800183 private int mNextAppTransition = TRANSIT_UNSET;
Jorim Jaggife762342016-10-13 14:33:27 +0200184 private int mNextAppTransitionFlags = 0;
Chong Zhang60091a92016-07-27 17:52:45 -0700185 private int mLastUsedAppTransition = TRANSIT_UNSET;
186 private String mLastOpeningApp;
187 private String mLastClosingApp;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800188
189 private static final int NEXT_TRANSIT_TYPE_NONE = 0;
190 private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1;
191 private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2;
192 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3;
193 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4;
Winson Chunga4ccb862014-08-22 15:26:27 -0700194 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5;
195 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6;
Winson Chung044d5292014-11-06 11:05:19 -0800196 private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7;
Chet Haase10e23ab2015-02-11 15:08:38 -0800197 private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800198 private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
199
Winson Chung399f6202014-03-19 10:47:20 -0700200 // These are the possible states for the enter/exit activities during a thumbnail transition
201 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0;
202 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1;
203 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2;
204 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3;
205
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800206 private String mNextAppTransitionPackage;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800207 // Used for thumbnail transitions. True if we're scaling up, false if scaling down
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800208 private boolean mNextAppTransitionScaleUp;
209 private IRemoteCallback mNextAppTransitionCallback;
Jorim Jaggi7cc7b082015-11-10 16:06:54 +0100210 private IRemoteCallback mNextAppTransitionFutureCallback;
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -0700211 private IRemoteCallback mAnimationFinishedCallback;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800212 private int mNextAppTransitionEnter;
213 private int mNextAppTransitionExit;
Winson Chung044d5292014-11-06 11:05:19 -0800214 private int mNextAppTransitionInPlace;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700215
216 // Keyed by task id.
217 private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs
218 = new SparseArray<>();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100219 private IAppTransitionAnimationSpecsFuture mNextAppTransitionAnimationsSpecsFuture;
220 private boolean mNextAppTransitionAnimationsSpecsPending;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700221 private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec;
222
Winson Chunga4ccb862014-08-22 15:26:27 -0700223 private Rect mNextAppTransitionInsets = new Rect();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800224
Winson Chung2820c452014-04-15 15:34:44 -0700225 private Rect mTmpFromClipRect = new Rect();
226 private Rect mTmpToClipRect = new Rect();
227
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700228 private final Rect mTmpRect = new Rect();
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700229
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800230 private final static int APP_STATE_IDLE = 0;
231 private final static int APP_STATE_READY = 1;
232 private final static int APP_STATE_RUNNING = 2;
233 private final static int APP_STATE_TIMEOUT = 3;
234 private int mAppTransitionState = APP_STATE_IDLE;
235
236 private final int mConfigShortAnimTime;
Craig Mautner321bdf52012-12-18 09:53:24 -0800237 private final Interpolator mDecelerateInterpolator;
Winson Chunga4ccb862014-08-22 15:26:27 -0700238 private final Interpolator mThumbnailFadeInInterpolator;
239 private final Interpolator mThumbnailFadeOutInterpolator;
Chet Haase10e23ab2015-02-11 15:08:38 -0800240 private final Interpolator mLinearOutSlowInInterpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700241 private final Interpolator mFastOutLinearInInterpolator;
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100242 private final Interpolator mFastOutSlowInInterpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700243 private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f);
244
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700245 private final int mClipRevealTranslationY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800246
Amith Yamasani4befbec2013-07-10 16:18:01 -0700247 private int mCurrentUserId = 0;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800248 private long mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION;
Amith Yamasani4befbec2013-07-10 16:18:01 -0700249
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100250 private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100251 private final ExecutorService mDefaultExecutor = Executors.newSingleThreadExecutor();
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100252
Jorim Jaggif97ed922016-02-18 18:57:07 -0800253 private int mLastClipRevealMaxTranslation;
254 private boolean mLastHadClipReveal;
Jorim Jaggi363ab982016-04-26 19:51:20 -0700255 private boolean mProlongedAnimationsEnded;
Jorim Jaggif97ed922016-02-18 18:57:07 -0800256
Manu Cornetd7376802017-01-13 13:44:07 -0800257 private final boolean mGridLayoutRecentsEnabled;
258
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -0800259 AppTransition(Context context, WindowManagerService service) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800260 mContext = context;
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -0800261 mService = service;
Chet Haase10e23ab2015-02-11 15:08:38 -0800262 mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
263 com.android.internal.R.interpolator.linear_out_slow_in);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700264 mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
265 com.android.internal.R.interpolator.fast_out_linear_in);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100266 mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
267 com.android.internal.R.interpolator.fast_out_slow_in);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800268 mConfigShortAnimTime = context.getResources().getInteger(
269 com.android.internal.R.integer.config_shortAnimTime);
Craig Mautner321bdf52012-12-18 09:53:24 -0800270 mDecelerateInterpolator = AnimationUtils.loadInterpolator(context,
271 com.android.internal.R.interpolator.decelerate_cubic);
Winson Chunga4ccb862014-08-22 15:26:27 -0700272 mThumbnailFadeInInterpolator = new Interpolator() {
273 @Override
274 public float getInterpolation(float input) {
275 // Linear response for first fraction, then complete after that.
276 if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) {
277 return 0f;
278 }
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700279 float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) /
Winson Chunga4ccb862014-08-22 15:26:27 -0700280 (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700281 return mFastOutLinearInInterpolator.getInterpolation(t);
Winson Chunga4ccb862014-08-22 15:26:27 -0700282 }
283 };
284 mThumbnailFadeOutInterpolator = new Interpolator() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800285 @Override
286 public float getInterpolation(float input) {
287 // Linear response for first fraction, then complete after that.
288 if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) {
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700289 float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION;
290 return mLinearOutSlowInInterpolator.getInterpolation(t);
Craig Mautner321bdf52012-12-18 09:53:24 -0800291 }
Winson Chunga4ccb862014-08-22 15:26:27 -0700292 return 1f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800293 }
294 };
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700295 mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP
296 * mContext.getResources().getDisplayMetrics().density);
Manu Cornetd7376802017-01-13 13:44:07 -0800297 mGridLayoutRecentsEnabled = SystemProperties.getBoolean("ro.recents.grid", false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800298 }
299
300 boolean isTransitionSet() {
301 return mNextAppTransition != TRANSIT_UNSET;
302 }
303
Craig Mautner164d4bb2012-11-26 13:51:23 -0800304 boolean isTransitionEqual(int transit) {
305 return mNextAppTransition == transit;
306 }
307
308 int getAppTransition() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800309 return mNextAppTransition;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800310 }
311
Jorim Jaggife762342016-10-13 14:33:27 +0200312 private void setAppTransition(int transit, int flags) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800313 mNextAppTransition = transit;
Jorim Jaggife762342016-10-13 14:33:27 +0200314 mNextAppTransitionFlags |= flags;
Chong Zhang60091a92016-07-27 17:52:45 -0700315 setLastAppTransition(TRANSIT_UNSET, null, null);
316 }
317
318 void setLastAppTransition(int transit, AppWindowToken openingApp, AppWindowToken closingApp) {
319 mLastUsedAppTransition = transit;
320 mLastOpeningApp = "" + openingApp;
321 mLastClosingApp = "" + closingApp;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800322 }
323
324 boolean isReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800325 return mAppTransitionState == APP_STATE_READY
326 || mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800327 }
328
Craig Mautnerae446592012-12-06 19:05:05 -0800329 void setReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800330 mAppTransitionState = APP_STATE_READY;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100331 fetchAppTransitionSpecsFromFuture();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800332 }
333
334 boolean isRunning() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800335 return mAppTransitionState == APP_STATE_RUNNING;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800336 }
337
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800338 void setIdle() {
339 mAppTransitionState = APP_STATE_IDLE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800340 }
341
342 boolean isTimeout() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800343 return mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800344 }
345
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800346 void setTimeout() {
347 mAppTransitionState = APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800348 }
349
Winson Chungaa7fa012017-05-24 15:50:06 -0700350 GraphicBuffer getAppTransitionThumbnailHeader(int taskId) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700351 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800352 if (spec == null) {
353 spec = mDefaultNextAppTransitionAnimationSpec;
354 }
Winson Chungaa7fa012017-05-24 15:50:06 -0700355 return spec != null ? spec.buffer : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800356 }
357
Winson Chunga4ccb862014-08-22 15:26:27 -0700358 /** Returns whether the next thumbnail transition is aspect scaled up. */
359 boolean isNextThumbnailTransitionAspectScaled() {
360 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
361 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
362 }
363
364 /** Returns whether the next thumbnail transition is scaling up. */
365 boolean isNextThumbnailTransitionScaleUp() {
366 return mNextAppTransitionScaleUp;
367 }
368
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800369 boolean isNextAppTransitionThumbnailUp() {
370 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
371 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP;
372 }
373
374 boolean isNextAppTransitionThumbnailDown() {
375 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN ||
376 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
377 }
378
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100379 /**
380 * @return true if and only if we are currently fetching app transition specs from the future
381 * passed into {@link #overridePendingAppTransitionMultiThumbFuture}
382 */
383 boolean isFetchingAppTransitionsSpecs() {
384 return mNextAppTransitionAnimationsSpecsPending;
385 }
386
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700387 private boolean prepare() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800388 if (!isRunning()) {
389 mAppTransitionState = APP_STATE_IDLE;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100390 notifyAppTransitionPendingLocked();
Jorim Jaggif97ed922016-02-18 18:57:07 -0800391 mLastHadClipReveal = false;
392 mLastClipRevealMaxTranslation = 0;
393 mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION;
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700394 return true;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800395 }
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700396 return false;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800397 }
398
Jorim Jaggife762342016-10-13 14:33:27 +0200399 /**
400 * @return bit-map of WindowManagerPolicy#FINISH_LAYOUT_REDO_* to indicate whether another
401 * layout pass needs to be done
402 */
403 int goodToGo(int transit, AppWindowAnimator topOpeningAppAnimator,
404 AppWindowAnimator topClosingAppAnimator, ArraySet<AppWindowToken> openingApps,
405 ArraySet<AppWindowToken> closingApps) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800406 mNextAppTransition = TRANSIT_UNSET;
Jorim Jaggife762342016-10-13 14:33:27 +0200407 mNextAppTransitionFlags = 0;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800408 mAppTransitionState = APP_STATE_RUNNING;
Jorim Jaggife762342016-10-13 14:33:27 +0200409 int redoLayout = notifyAppTransitionStartingLocked(transit,
Jorim Jaggi42625d1b2016-02-11 20:11:07 -0800410 topOpeningAppAnimator != null ? topOpeningAppAnimator.mAppToken.token : null,
411 topClosingAppAnimator != null ? topClosingAppAnimator.mAppToken.token : null,
412 topOpeningAppAnimator != null ? topOpeningAppAnimator.animation : null,
413 topClosingAppAnimator != null ? topClosingAppAnimator.animation : null);
414 mService.getDefaultDisplayContentLocked().getDockedDividerController()
Jorim Jaggife762342016-10-13 14:33:27 +0200415 .notifyAppTransitionStarting(openingApps, transit);
Jorim Jaggi363ab982016-04-26 19:51:20 -0700416
417 // Prolong the start for the transition when docking a task from recents, unless recents
418 // ended it already then we don't need to wait.
Jorim Jaggife762342016-10-13 14:33:27 +0200419 if (transit == TRANSIT_DOCK_TASK_FROM_RECENTS && !mProlongedAnimationsEnded) {
Jorim Jaggi363ab982016-04-26 19:51:20 -0700420 for (int i = openingApps.size() - 1; i >= 0; i--) {
421 final AppWindowAnimator appAnimator = openingApps.valueAt(i).mAppAnimator;
422 appAnimator.startProlongAnimation(PROLONG_ANIMATION_AT_START);
423 }
424 }
Jorim Jaggife762342016-10-13 14:33:27 +0200425 return redoLayout;
Jorim Jaggi363ab982016-04-26 19:51:20 -0700426 }
427
428 /**
429 * Let the transitions manager know that the somebody wanted to end the prolonged animations.
430 */
431 void notifyProlongedAnimationsEnded() {
432 mProlongedAnimationsEnded = true;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800433 }
434
435 void clear() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800436 mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800437 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700438 mNextAppTransitionAnimationsSpecs.clear();
Jorim Jaggi65193992015-11-23 16:49:59 -0800439 mNextAppTransitionAnimationsSpecsFuture = null;
440 mDefaultNextAppTransitionAnimationSpec = null;
441 mAnimationFinishedCallback = null;
Jorim Jaggi363ab982016-04-26 19:51:20 -0700442 mProlongedAnimationsEnded = false;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800443 }
444
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800445 void freeze() {
Jorim Jaggife762342016-10-13 14:33:27 +0200446 final int transit = mNextAppTransition;
447 setAppTransition(AppTransition.TRANSIT_UNSET, 0 /* flags */);
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800448 clear();
449 setReady();
Jorim Jaggife762342016-10-13 14:33:27 +0200450 notifyAppTransitionCancelledLocked(transit);
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100451 }
452
453 void registerListenerLocked(AppTransitionListener listener) {
454 mListeners.add(listener);
455 }
456
Wale Ogunwalea48eadb2015-05-14 17:43:12 -0700457 public void notifyAppTransitionFinishedLocked(IBinder token) {
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100458 for (int i = 0; i < mListeners.size(); i++) {
459 mListeners.get(i).onAppTransitionFinishedLocked(token);
460 }
461 }
462
463 private void notifyAppTransitionPendingLocked() {
464 for (int i = 0; i < mListeners.size(); i++) {
465 mListeners.get(i).onAppTransitionPendingLocked();
466 }
467 }
468
Jorim Jaggife762342016-10-13 14:33:27 +0200469 private void notifyAppTransitionCancelledLocked(int transit) {
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100470 for (int i = 0; i < mListeners.size(); i++) {
Jorim Jaggife762342016-10-13 14:33:27 +0200471 mListeners.get(i).onAppTransitionCancelledLocked(transit);
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100472 }
473 }
474
Jorim Jaggife762342016-10-13 14:33:27 +0200475 private int notifyAppTransitionStartingLocked(int transit, IBinder openToken,
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100476 IBinder closeToken, Animation openAnimation, Animation closeAnimation) {
Jorim Jaggife762342016-10-13 14:33:27 +0200477 int redoLayout = 0;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100478 for (int i = 0; i < mListeners.size(); i++) {
Jorim Jaggife762342016-10-13 14:33:27 +0200479 redoLayout |= mListeners.get(i).onAppTransitionStartingLocked(transit, openToken,
480 closeToken, openAnimation, closeAnimation);
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100481 }
Jorim Jaggife762342016-10-13 14:33:27 +0200482 return redoLayout;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800483 }
484
Craig Mautner164d4bb2012-11-26 13:51:23 -0800485 private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
486 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
487 + (lp != null ? lp.packageName : null)
488 + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null));
489 if (lp != null && lp.windowAnimations != 0) {
490 // If this is a system resource, don't try to load it from the
491 // application resources. It is nice to avoid loading application
492 // resources if we can.
493 String packageName = lp.packageName != null ? lp.packageName : "android";
494 int resId = lp.windowAnimations;
495 if ((resId&0xFF000000) == 0x01000000) {
496 packageName = "android";
497 }
498 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
499 + packageName);
500 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700501 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800502 }
503 return null;
504 }
505
506 private AttributeCache.Entry getCachedAnimations(String packageName, int resId) {
507 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package="
508 + packageName + " resId=0x" + Integer.toHexString(resId));
509 if (packageName != null) {
510 if ((resId&0xFF000000) == 0x01000000) {
511 packageName = "android";
512 }
513 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
514 + packageName);
515 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700516 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800517 }
518 return null;
519 }
520
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700521 Animation loadAnimationAttr(WindowManager.LayoutParams lp, int animAttr) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800522 int anim = 0;
523 Context context = mContext;
524 if (animAttr >= 0) {
525 AttributeCache.Entry ent = getCachedAnimations(lp);
526 if (ent != null) {
527 context = ent.context;
528 anim = ent.array.getResourceId(animAttr, 0);
529 }
530 }
531 if (anim != 0) {
532 return AnimationUtils.loadAnimation(context, anim);
533 }
534 return null;
535 }
536
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700537 Animation loadAnimationRes(WindowManager.LayoutParams lp, int resId) {
538 Context context = mContext;
539 if (resId >= 0) {
540 AttributeCache.Entry ent = getCachedAnimations(lp);
541 if (ent != null) {
542 context = ent.context;
543 }
544 return AnimationUtils.loadAnimation(context, resId);
545 }
546 return null;
547 }
548
549 private Animation loadAnimationRes(String packageName, int resId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800550 int anim = 0;
551 Context context = mContext;
552 if (resId >= 0) {
553 AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
554 if (ent != null) {
555 context = ent.context;
556 anim = resId;
557 }
558 }
559 if (anim != 0) {
560 return AnimationUtils.loadAnimation(context, anim);
561 }
562 return null;
563 }
564
Craig Mautner164d4bb2012-11-26 13:51:23 -0800565 /**
566 * Compute the pivot point for an animation that is scaling from a small
567 * rect on screen to a larger rect. The pivot point varies depending on
568 * the distance between the inner and outer edges on both sides. This
569 * function computes the pivot point for one dimension.
570 * @param startPos Offset from left/top edge of outer rectangle to
571 * left/top edge of inner rectangle.
572 * @param finalScale The scaling factor between the size of the outer
573 * and inner rectangles.
574 */
575 private static float computePivot(int startPos, float finalScale) {
Jorim Jaggic6c89a82016-01-28 17:48:21 -0800576
577 /*
578 Theorem of intercepting lines:
579
580 + + +-----------------------------------------------+
581 | | | |
582 | | | |
583 | | | |
584 | | | |
585 x | y | | |
586 | | | |
587 | | | |
588 | | | |
589 | | | |
590 | + | +--------------------+ |
591 | | | | |
592 | | | | |
593 | | | | |
594 | | | | |
595 | | | | |
596 | | | | |
597 | | | | |
598 | | | | |
599 | | | | |
600 | | | | |
601 | | | | |
602 | | | | |
603 | | | | |
604 | | | | |
605 | | | | |
606 | | | | |
607 | | | | |
608 | | +--------------------+ |
609 | | |
610 | | |
611 | | |
612 | | |
613 | | |
614 | | |
615 | | |
616 | +-----------------------------------------------+
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 + ++
627 p ++
628
629 scale = (x - y) / x
630 <=> x = -y / (scale - 1)
631 */
Craig Mautner164d4bb2012-11-26 13:51:23 -0800632 final float denom = finalScale-1;
633 if (Math.abs(denom) < .0001f) {
634 return startPos;
635 }
636 return -startPos / denom;
637 }
638
Filip Gruszczynski541f92c2015-10-25 17:15:06 -0700639 private Animation createScaleUpAnimationLocked(int transit, boolean enter,
640 Rect containingFrame) {
641 Animation a;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700642 getDefaultNextAppTransitionStartRect(mTmpRect);
Filip Gruszczynski541f92c2015-10-25 17:15:06 -0700643 final int appWidth = containingFrame.width();
644 final int appHeight = containingFrame.height();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800645 if (enter) {
646 // Entering app zooms out from the center of the initial rect.
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700647 float scaleW = mTmpRect.width() / (float) appWidth;
648 float scaleH = mTmpRect.height() / (float) appHeight;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800649 Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700650 computePivot(mTmpRect.left, scaleW),
Winson4c3fecd2016-07-13 12:29:48 -0700651 computePivot(mTmpRect.top, scaleH));
Craig Mautner321bdf52012-12-18 09:53:24 -0800652 scale.setInterpolator(mDecelerateInterpolator);
653
Craig Mautner164d4bb2012-11-26 13:51:23 -0800654 Animation alpha = new AlphaAnimation(0, 1);
Winson Chunga4ccb862014-08-22 15:26:27 -0700655 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
Craig Mautner321bdf52012-12-18 09:53:24 -0800656
657 AnimationSet set = new AnimationSet(false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800658 set.addAnimation(scale);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800659 set.addAnimation(alpha);
660 set.setDetachWallpaper(true);
661 a = set;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800662 } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
663 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800664 // If we are on top of the wallpaper, we need an animation that
665 // correctly handles the wallpaper staying static behind all of
666 // the animated elements. To do this, will just have the existing
667 // element fade out.
668 a = new AlphaAnimation(1, 0);
669 a.setDetachWallpaper(true);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800670 } else {
Craig Mautner321bdf52012-12-18 09:53:24 -0800671 // For normal animations, the exiting element just holds in place.
672 a = new AlphaAnimation(1, 1);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800673 }
Craig Mautner321bdf52012-12-18 09:53:24 -0800674
675 // Pick the desired duration. If this is an inter-activity transition,
676 // it is the standard duration for that. Otherwise we use the longer
677 // task transition duration.
678 final long duration;
679 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800680 case TRANSIT_ACTIVITY_OPEN:
681 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800682 duration = mConfigShortAnimTime;
683 break;
684 default:
685 duration = DEFAULT_APP_TRANSITION_DURATION;
686 break;
687 }
688 a.setDuration(duration);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800689 a.setFillAfter(true);
Craig Mautner321bdf52012-12-18 09:53:24 -0800690 a.setInterpolator(mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800691 a.initialize(appWidth, appHeight, appWidth, appHeight);
692 return a;
693 }
694
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700695 private void getDefaultNextAppTransitionStartRect(Rect rect) {
696 if (mDefaultNextAppTransitionAnimationSpec == null ||
697 mDefaultNextAppTransitionAnimationSpec.rect == null) {
Jorim Jaggi2550f3f2017-03-14 20:15:59 +0100698 Slog.e(TAG, "Starting rect for app requested, but none available", new Throwable());
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700699 rect.setEmpty();
700 } else {
701 rect.set(mDefaultNextAppTransitionAnimationSpec.rect);
702 }
703 }
704
705 void getNextAppTransitionStartRect(int taskId, Rect rect) {
706 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800707 if (spec == null) {
708 spec = mDefaultNextAppTransitionAnimationSpec;
709 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700710 if (spec == null || spec.rect == null) {
Jorim Jaggi2550f3f2017-03-14 20:15:59 +0100711 Slog.e(TAG, "Starting rect for task: " + taskId + " requested, but not available",
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700712 new Throwable());
713 rect.setEmpty();
714 } else {
715 rect.set(spec.rect);
716 }
717 }
718
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800719 private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height,
Winson Chungaa7fa012017-05-24 15:50:06 -0700720 GraphicBuffer buffer) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700721 mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */,
Winson Chungaa7fa012017-05-24 15:50:06 -0700722 buffer, new Rect(left, top, left + width, top + height));
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700723 }
724
Jorim Jaggif97ed922016-02-18 18:57:07 -0800725 /**
726 * @return the duration of the last clip reveal animation
727 */
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800728 long getLastClipRevealTransitionDuration() {
729 return mLastClipRevealTransitionDuration;
730 }
731
732 /**
Jorim Jaggif97ed922016-02-18 18:57:07 -0800733 * @return the maximum distance the app surface is traveling of the last clip reveal animation
734 */
735 int getLastClipRevealMaxTranslation() {
736 return mLastClipRevealMaxTranslation;
737 }
738
739 /**
740 * @return true if in the last app transition had a clip reveal animation, false otherwise
741 */
742 boolean hadClipRevealAnimation() {
743 return mLastHadClipReveal;
744 }
745
746 /**
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800747 * Calculates the duration for the clip reveal animation. If the clip is "cut off", meaning that
748 * the start rect is outside of the target rect, and there is a lot of movement going on.
749 *
750 * @param cutOff whether the start rect was not fully contained by the end rect
751 * @param translationX the total translation the surface moves in x direction
752 * @param translationY the total translation the surfaces moves in y direction
753 * @param displayFrame our display frame
754 *
755 * @return the duration of the clip reveal animation, in milliseconds
756 */
757 private long calculateClipRevealTransitionDuration(boolean cutOff, float translationX,
758 float translationY, Rect displayFrame) {
759 if (!cutOff) {
760 return DEFAULT_APP_TRANSITION_DURATION;
761 }
762 final float fraction = Math.max(Math.abs(translationX) / displayFrame.width(),
763 Math.abs(translationY) / displayFrame.height());
764 return (long) (DEFAULT_APP_TRANSITION_DURATION + fraction *
765 (MAX_CLIP_REVEAL_TRANSITION_DURATION - DEFAULT_APP_TRANSITION_DURATION));
766 }
767
768 private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame,
769 Rect displayFrame) {
Chet Haase10e23ab2015-02-11 15:08:38 -0800770 final Animation anim;
771 if (enter) {
Craig Mautner80b1f642015-04-22 10:59:09 -0700772 final int appWidth = appFrame.width();
773 final int appHeight = appFrame.height();
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800774
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700775 // mTmpRect will contain an area around the launcher icon that was pressed. We will
Filip Gruszczynski82861362015-10-16 14:21:09 -0700776 // clip reveal from that area in the final area of the app.
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700777 getDefaultNextAppTransitionStartRect(mTmpRect);
Craig Mautner80b1f642015-04-22 10:59:09 -0700778
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700779 float t = 0f;
780 if (appHeight > 0) {
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800781 t = (float) mTmpRect.top / displayFrame.height();
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700782 }
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800783 int translationY = mClipRevealTranslationY + (int)(displayFrame.height() / 7f * t);
784 int translationX = 0;
785 int translationYCorrection = translationY;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700786 int centerX = mTmpRect.centerX();
787 int centerY = mTmpRect.centerY();
788 int halfWidth = mTmpRect.width() / 2;
789 int halfHeight = mTmpRect.height() / 2;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800790 int clipStartX = centerX - halfWidth - appFrame.left;
791 int clipStartY = centerY - halfHeight - appFrame.top;
792 boolean cutOff = false;
793
794 // If the starting rectangle is fully or partially outside of the target rectangle, we
795 // need to start the clipping at the edge and then achieve the rest with translation
796 // and extending the clip rect from that edge.
797 if (appFrame.top > centerY - halfHeight) {
798 translationY = (centerY - halfHeight) - appFrame.top;
799 translationYCorrection = 0;
800 clipStartY = 0;
801 cutOff = true;
802 }
803 if (appFrame.left > centerX - halfWidth) {
804 translationX = (centerX - halfWidth) - appFrame.left;
805 clipStartX = 0;
806 cutOff = true;
807 }
808 if (appFrame.right < centerX + halfWidth) {
809 translationX = (centerX + halfWidth) - appFrame.right;
810 clipStartX = appWidth - mTmpRect.width();
811 cutOff = true;
812 }
813 final long duration = calculateClipRevealTransitionDuration(cutOff, translationX,
814 translationY, displayFrame);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700815
816 // Clip third of the from size of launch icon, expand to full width/height
Chet Haase10e23ab2015-02-11 15:08:38 -0800817 Animation clipAnimLR = new ClipRectLRAnimation(
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800818 clipStartX, clipStartX + mTmpRect.width(), 0, appWidth);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700819 clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800820 clipAnimLR.setDuration((long) (duration / 2.5f));
Filip Gruszczynski82861362015-10-16 14:21:09 -0700821
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800822 TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0);
823 translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR
824 : mLinearOutSlowInInterpolator);
825 translate.setDuration(duration);
Chet Haase10e23ab2015-02-11 15:08:38 -0800826
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800827 Animation clipAnimTB = new ClipRectTBAnimation(
828 clipStartY, clipStartY + mTmpRect.height(),
829 0, appHeight,
830 translationYCorrection, 0,
831 mLinearOutSlowInInterpolator);
832 clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
833 clipAnimTB.setDuration(duration);
Chet Haase10e23ab2015-02-11 15:08:38 -0800834
835 // Quick fade-in from icon to app window
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800836 final long alphaDuration = duration / 4;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700837 AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
Chet Haase10e23ab2015-02-11 15:08:38 -0800838 alpha.setDuration(alphaDuration);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700839 alpha.setInterpolator(mLinearOutSlowInInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800840
841 AnimationSet set = new AnimationSet(false);
842 set.addAnimation(clipAnimLR);
843 set.addAnimation(clipAnimTB);
Filip Gruszczynski82861362015-10-16 14:21:09 -0700844 set.addAnimation(translate);
Chet Haase10e23ab2015-02-11 15:08:38 -0800845 set.addAnimation(alpha);
Filip Gruszczynski9e2cf5b2015-07-31 12:20:40 -0700846 set.setZAdjustment(Animation.ZORDER_TOP);
Chet Haase10e23ab2015-02-11 15:08:38 -0800847 set.initialize(appWidth, appHeight, appWidth, appHeight);
848 anim = set;
Jorim Jaggif97ed922016-02-18 18:57:07 -0800849 mLastHadClipReveal = true;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800850 mLastClipRevealTransitionDuration = duration;
Jorim Jaggif97ed922016-02-18 18:57:07 -0800851
852 // If the start rect was full inside the target rect (cutOff == false), we don't need
853 // to store the translation, because it's only used if cutOff == true.
854 mLastClipRevealMaxTranslation = cutOff
855 ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0;
Chet Haase10e23ab2015-02-11 15:08:38 -0800856 } else {
857 final long duration;
858 switch (transit) {
859 case TRANSIT_ACTIVITY_OPEN:
860 case TRANSIT_ACTIVITY_CLOSE:
861 duration = mConfigShortAnimTime;
862 break;
863 default:
864 duration = DEFAULT_APP_TRANSITION_DURATION;
865 break;
866 }
867 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
868 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
869 // If we are on top of the wallpaper, we need an animation that
870 // correctly handles the wallpaper staying static behind all of
871 // the animated elements. To do this, will just have the existing
872 // element fade out.
873 anim = new AlphaAnimation(1, 0);
874 anim.setDetachWallpaper(true);
875 } else {
876 // For normal animations, the exiting element just holds in place.
877 anim = new AlphaAnimation(1, 1);
878 }
879 anim.setInterpolator(mDecelerateInterpolator);
880 anim.setDuration(duration);
881 anim.setFillAfter(true);
882 }
883 return anim;
884 }
885
Winson Chung399f6202014-03-19 10:47:20 -0700886 /**
887 * Prepares the specified animation with a standard duration, interpolator, etc.
888 */
Winson Chung5393dff2014-05-08 14:25:43 -0700889 Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight,
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100890 long duration, Interpolator interpolator) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700891 if (duration > 0) {
892 a.setDuration(duration);
893 }
Winson Chung5393dff2014-05-08 14:25:43 -0700894 a.setFillAfter(true);
Jorim Jaggic69bd222016-03-15 14:38:37 +0100895 if (interpolator != null) {
896 a.setInterpolator(interpolator);
897 }
Winson Chung5393dff2014-05-08 14:25:43 -0700898 a.initialize(appWidth, appHeight, appWidth, appHeight);
899 return a;
900 }
901
902 /**
903 * Prepares the specified animation with a standard duration, interpolator, etc.
904 */
Winson Chung399f6202014-03-19 10:47:20 -0700905 Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800906 // Pick the desired duration. If this is an inter-activity transition,
907 // it is the standard duration for that. Otherwise we use the longer
908 // task transition duration.
Winson Chung5393dff2014-05-08 14:25:43 -0700909 final int duration;
Craig Mautner321bdf52012-12-18 09:53:24 -0800910 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800911 case TRANSIT_ACTIVITY_OPEN:
912 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800913 duration = mConfigShortAnimTime;
914 break;
915 default:
916 duration = DEFAULT_APP_TRANSITION_DURATION;
917 break;
918 }
Winson Chung5393dff2014-05-08 14:25:43 -0700919 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration,
920 mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800921 }
922
Winson Chung399f6202014-03-19 10:47:20 -0700923 /**
924 * Return the current thumbnail transition state.
925 */
926 int getThumbnailTransitionState(boolean enter) {
927 if (enter) {
928 if (mNextAppTransitionScaleUp) {
929 return THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
930 } else {
931 return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN;
932 }
933 } else {
934 if (mNextAppTransitionScaleUp) {
935 return THUMBNAIL_TRANSITION_EXIT_SCALE_UP;
936 } else {
937 return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN;
938 }
939 }
940 }
941
942 /**
943 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700944 * when a thumbnail is specified with the pending animation override.
Winson Chung399f6202014-03-19 10:47:20 -0700945 */
Jorim Jaggide63d442016-03-14 14:56:56 +0100946 Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, @Nullable Rect contentInsets,
Winson Chungaa7fa012017-05-24 15:50:06 -0700947 GraphicBuffer thumbnailHeader, final int taskId, int uiMode, int orientation) {
Winson Chung399f6202014-03-19 10:47:20 -0700948 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700949 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chung399f6202014-03-19 10:47:20 -0700950 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700951 final int thumbHeightI = thumbnailHeader.getHeight();
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700952 final int appWidth = appRect.width();
Winson Chung399f6202014-03-19 10:47:20 -0700953
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700954 float scaleW = appWidth / thumbWidth;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700955 getNextAppTransitionStartRect(taskId, mTmpRect);
Jorim Jaggi09072002016-03-25 16:48:42 -0700956 final float fromX;
Manu Cornet57b61492017-01-24 18:19:05 +0900957 float fromY;
Jorim Jaggi09072002016-03-25 16:48:42 -0700958 final float toX;
Manu Cornet57b61492017-01-24 18:19:05 +0900959 float toY;
Jorim Jaggi09072002016-03-25 16:48:42 -0700960 final float pivotX;
961 final float pivotY;
Manu Cornetd7376802017-01-13 13:44:07 -0800962 if (shouldScaleDownThumbnailTransition(uiMode, orientation)) {
Jorim Jaggi09072002016-03-25 16:48:42 -0700963 fromX = mTmpRect.left;
964 fromY = mTmpRect.top;
965
966 // For the curved translate animation to work, the pivot points needs to be at the
967 // same absolute position as the one from the real surface.
968 toX = mTmpRect.width() / 2 * (scaleW - 1f) + appRect.left;
969 toY = appRect.height() / 2 * (1 - 1 / scaleW) + appRect.top;
970 pivotX = mTmpRect.width() / 2;
971 pivotY = appRect.height() / 2 / scaleW;
Manu Cornet57b61492017-01-24 18:19:05 +0900972 if (mGridLayoutRecentsEnabled) {
973 // In the grid layout, the header is displayed above the thumbnail instead of
974 // overlapping it.
975 fromY -= thumbHeightI;
976 toY -= thumbHeightI * scaleW;
977 }
Jorim Jaggi09072002016-03-25 16:48:42 -0700978 } else {
979 pivotX = 0;
980 pivotY = 0;
981 fromX = mTmpRect.left;
982 fromY = mTmpRect.top;
983 toX = appRect.left;
984 toY = appRect.top;
985 }
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100986 final long duration = getAspectScaleDuration();
987 final Interpolator interpolator = getAspectScaleInterpolator();
Winson Chung399f6202014-03-19 10:47:20 -0700988 if (mNextAppTransitionScaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700989 // Animation up from the thumbnail to the full screen
Jorim Jaggi8448f332016-03-14 17:50:37 +0100990 Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, pivotX, pivotY);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100991 scale.setInterpolator(interpolator);
992 scale.setDuration(duration);
Jorim Jaggic6c89a82016-01-28 17:48:21 -0800993 Animation alpha = new AlphaAnimation(1f, 0f);
Jorim Jaggic69bd222016-03-15 14:38:37 +0100994 alpha.setInterpolator(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS
995 ? THUMBNAIL_DOCK_INTERPOLATOR : mThumbnailFadeOutInterpolator);
996 alpha.setDuration(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS
997 ? duration / 2
998 : duration);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100999 Animation translate = createCurvedMotion(fromX, toX, fromY, toY);
1000 translate.setInterpolator(interpolator);
1001 translate.setDuration(duration);
Winson Chung399f6202014-03-19 10:47:20 -07001002
Jorim Jaggide63d442016-03-14 14:56:56 +01001003 mTmpFromClipRect.set(0, 0, thumbWidthI, thumbHeightI);
1004 mTmpToClipRect.set(appRect);
1005
1006 // Containing frame is in screen space, but we need the clip rect in the
1007 // app space.
1008 mTmpToClipRect.offsetTo(0, 0);
Jorim Jaggic69bd222016-03-15 14:38:37 +01001009 mTmpToClipRect.right = (int) (mTmpToClipRect.right / scaleW);
1010 mTmpToClipRect.bottom = (int) (mTmpToClipRect.bottom / scaleW);
Jorim Jaggide63d442016-03-14 14:56:56 +01001011
1012 if (contentInsets != null) {
Jorim Jaggi8448f332016-03-14 17:50:37 +01001013 mTmpToClipRect.inset((int) (-contentInsets.left * scaleW),
1014 (int) (-contentInsets.top * scaleW),
1015 (int) (-contentInsets.right * scaleW),
1016 (int) (-contentInsets.bottom * scaleW));
Jorim Jaggide63d442016-03-14 14:56:56 +01001017 }
1018
1019 Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001020 clipAnim.setInterpolator(interpolator);
1021 clipAnim.setDuration(duration);
Jorim Jaggide63d442016-03-14 14:56:56 +01001022
Winson Chung399f6202014-03-19 10:47:20 -07001023 // This AnimationSet uses the Interpolators assigned above.
1024 AnimationSet set = new AnimationSet(false);
1025 set.addAnimation(scale);
Manu Cornet57b61492017-01-24 18:19:05 +09001026 if (!mGridLayoutRecentsEnabled) {
1027 // In the grid layout, the header should be shown for the whole animation.
1028 set.addAnimation(alpha);
1029 }
Winson Chunga4ccb862014-08-22 15:26:27 -07001030 set.addAnimation(translate);
Jorim Jaggide63d442016-03-14 14:56:56 +01001031 set.addAnimation(clipAnim);
Winson Chung399f6202014-03-19 10:47:20 -07001032 a = set;
1033 } else {
Winson Chunga4ccb862014-08-22 15:26:27 -07001034 // Animation down from the full screen to the thumbnail
Jorim Jaggi8448f332016-03-14 17:50:37 +01001035 Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, pivotX, pivotY);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001036 scale.setInterpolator(interpolator);
1037 scale.setDuration(duration);
Winson Chunga4ccb862014-08-22 15:26:27 -07001038 Animation alpha = new AlphaAnimation(0f, 1f);
1039 alpha.setInterpolator(mThumbnailFadeInInterpolator);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001040 alpha.setDuration(duration);
1041 Animation translate = createCurvedMotion(toX, fromX, toY, fromY);
1042 translate.setInterpolator(interpolator);
1043 translate.setDuration(duration);
Winson Chung399f6202014-03-19 10:47:20 -07001044
Winson Chunga4ccb862014-08-22 15:26:27 -07001045 // This AnimationSet uses the Interpolators assigned above.
1046 AnimationSet set = new AnimationSet(false);
1047 set.addAnimation(scale);
Manu Cornet57b61492017-01-24 18:19:05 +09001048 if (!mGridLayoutRecentsEnabled) {
1049 // In the grid layout, the header should be shown for the whole animation.
1050 set.addAnimation(alpha);
1051 }
Winson Chunga4ccb862014-08-22 15:26:27 -07001052 set.addAnimation(translate);
1053 a = set;
1054
1055 }
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -07001056 return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0,
Jorim Jaggic69bd222016-03-15 14:38:37 +01001057 null);
Winson Chung399f6202014-03-19 10:47:20 -07001058 }
1059
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001060 private Animation createCurvedMotion(float fromX, float toX, float fromY, float toY) {
1061
1062 // Almost no x-change - use linear animation
Jorim Jaggic69bd222016-03-15 14:38:37 +01001063 if (Math.abs(toX - fromX) < 1f || mNextAppTransition != TRANSIT_DOCK_TASK_FROM_RECENTS) {
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001064 return new TranslateAnimation(fromX, toX, fromY, toY);
1065 } else {
1066 final Path path = createCurvedPath(fromX, toX, fromY, toY);
1067 return new CurvedTranslateAnimation(path);
1068 }
1069 }
1070
1071 private Path createCurvedPath(float fromX, float toX, float fromY, float toY) {
1072 final Path path = new Path();
1073 path.moveTo(fromX, fromY);
Jorim Jaggi1f458fb2016-03-25 17:36:37 -07001074
1075 if (fromY > toY) {
1076 // If the object needs to go up, move it in horizontal direction first, then vertical.
1077 path.cubicTo(fromX, fromY, toX, 0.9f * fromY + 0.1f * toY, toX, toY);
1078 } else {
1079 // If the object needs to go down, move it in vertical direction first, then horizontal.
1080 path.cubicTo(fromX, fromY, fromX, 0.1f * fromY + 0.9f * toY, toX, toY);
1081 }
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001082 return path;
1083 }
1084
1085 private long getAspectScaleDuration() {
1086 if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) {
Jorim Jaggic69bd222016-03-15 14:38:37 +01001087 return (long) (THUMBNAIL_APP_TRANSITION_DURATION * 1.35f);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001088 } else {
1089 return THUMBNAIL_APP_TRANSITION_DURATION;
1090 }
1091 }
1092
1093 private Interpolator getAspectScaleInterpolator() {
1094 if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) {
1095 return mFastOutSlowInInterpolator;
1096 } else {
1097 return TOUCH_RESPONSE_INTERPOLATOR;
1098 }
1099 }
1100
Winson Chung399f6202014-03-19 10:47:20 -07001101 /**
1102 * This alternate animation is created when we are doing a thumbnail transition, for the
1103 * activity that is leaving, and the activity that is entering.
1104 */
Winson Chunga4ccb862014-08-22 15:26:27 -07001105 Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState,
Winsonb2024762016-04-05 17:32:30 -07001106 int uiMode, int orientation, int transit, Rect containingFrame, Rect contentInsets,
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001107 @Nullable Rect surfaceInsets, boolean freeform, int taskId) {
Winson Chung399f6202014-03-19 10:47:20 -07001108 Animation a;
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001109 final int appWidth = containingFrame.width();
1110 final int appHeight = containingFrame.height();
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001111 getDefaultNextAppTransitionStartRect(mTmpRect);
1112 final int thumbWidthI = mTmpRect.width();
Winson Chung399f6202014-03-19 10:47:20 -07001113 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001114 final int thumbHeightI = mTmpRect.height();
Winson Chung399f6202014-03-19 10:47:20 -07001115 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
Winsoncbb625b2016-07-06 15:24:15 -07001116 final int thumbStartX = mTmpRect.left - containingFrame.left - contentInsets.left;
Winson21700932016-03-24 17:26:23 -07001117 final int thumbStartY = mTmpRect.top - containingFrame.top;
Winson Chung399f6202014-03-19 10:47:20 -07001118
1119 switch (thumbTransitState) {
Jorim Jaggi8448f332016-03-14 17:50:37 +01001120 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP:
1121 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
1122 final boolean scaleUp = thumbTransitState == THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
1123 if (freeform && scaleUp) {
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001124 a = createAspectScaledThumbnailEnterFreeformAnimationLocked(
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001125 containingFrame, surfaceInsets, taskId);
Jorim Jaggi8448f332016-03-14 17:50:37 +01001126 } else if (freeform) {
1127 a = createAspectScaledThumbnailExitFreeformAnimationLocked(
1128 containingFrame, surfaceInsets, taskId);
Winson Chung2820c452014-04-15 15:34:44 -07001129 } else {
Winson21700932016-03-24 17:26:23 -07001130 AnimationSet set = new AnimationSet(true);
1131
1132 // In portrait, we scale to fit the width
Filip Gruszczynskiefd3d1b2015-10-14 13:57:55 -07001133 mTmpFromClipRect.set(containingFrame);
Filip Gruszczynskiefd3d1b2015-10-14 13:57:55 -07001134 mTmpToClipRect.set(containingFrame);
Jorim Jaggic6c89a82016-01-28 17:48:21 -08001135
1136 // Containing frame is in screen space, but we need the clip rect in the
1137 // app space.
1138 mTmpFromClipRect.offsetTo(0, 0);
1139 mTmpToClipRect.offsetTo(0, 0);
1140
1141 // Exclude insets region from the source clip.
1142 mTmpFromClipRect.inset(contentInsets);
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001143 mNextAppTransitionInsets.set(contentInsets);
1144
Manu Cornetd7376802017-01-13 13:44:07 -08001145 if (shouldScaleDownThumbnailTransition(uiMode, orientation)) {
Jorim Jaggic69bd222016-03-15 14:38:37 +01001146 // We scale the width and clip to the top/left square
1147 float scale = thumbWidth /
1148 (appWidth - contentInsets.left - contentInsets.right);
Manu Cornetb68b7652017-01-23 19:37:53 +09001149 if (!mGridLayoutRecentsEnabled) {
1150 int unscaledThumbHeight = (int) (thumbHeight / scale);
1151 mTmpFromClipRect.bottom = mTmpFromClipRect.top + unscaledThumbHeight;
1152 }
Jorim Jaggic69bd222016-03-15 14:38:37 +01001153
1154 mNextAppTransitionInsets.set(contentInsets);
1155
Jorim Jaggi8448f332016-03-14 17:50:37 +01001156 Animation scaleAnim = new ScaleAnimation(
1157 scaleUp ? scale : 1, scaleUp ? 1 : scale,
1158 scaleUp ? scale : 1, scaleUp ? 1 : scale,
Jorim Jaggic69bd222016-03-15 14:38:37 +01001159 containingFrame.width() / 2f,
1160 containingFrame.height() / 2f + contentInsets.top);
Jorim Jaggi8448f332016-03-14 17:50:37 +01001161 final float targetX = (mTmpRect.left - containingFrame.left);
Jorim Jaggic69bd222016-03-15 14:38:37 +01001162 final float x = containingFrame.width() / 2f
1163 - containingFrame.width() / 2f * scale;
Jorim Jaggi8448f332016-03-14 17:50:37 +01001164 final float targetY = (mTmpRect.top - containingFrame.top);
Jorim Jaggic69bd222016-03-15 14:38:37 +01001165 final float y = containingFrame.height() / 2f
1166 - containingFrame.height() / 2f * scale;
Jorim Jaggi8448f332016-03-14 17:50:37 +01001167 final float startX = targetX - x;
1168 final float startY = targetY - y;
1169 Animation clipAnim = scaleUp
1170 ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)
1171 : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect);
1172 Animation translateAnim = scaleUp
Jorim Jaggic69bd222016-03-15 14:38:37 +01001173 ? createCurvedMotion(startX, 0, startY - contentInsets.top, 0)
1174 : createCurvedMotion(0, startX, 0, startY - contentInsets.top);
1175
Winson21700932016-03-24 17:26:23 -07001176 set.addAnimation(clipAnim);
1177 set.addAnimation(scaleAnim);
1178 set.addAnimation(translateAnim);
1179
1180 } else {
1181 // In landscape, we don't scale at all and only crop
1182 mTmpFromClipRect.bottom = mTmpFromClipRect.top + thumbHeightI;
1183 mTmpFromClipRect.right = mTmpFromClipRect.left + thumbWidthI;
1184
Jorim Jaggi8448f332016-03-14 17:50:37 +01001185 Animation clipAnim = scaleUp
1186 ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)
1187 : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect);
1188 Animation translateAnim = scaleUp
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001189 ? createCurvedMotion(thumbStartX, 0,
1190 thumbStartY - contentInsets.top, 0)
1191 : createCurvedMotion(0, thumbStartX, 0,
1192 thumbStartY - contentInsets.top);
Winson21700932016-03-24 17:26:23 -07001193
1194 set.addAnimation(clipAnim);
1195 set.addAnimation(translateAnim);
1196 }
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001197 a = set;
Winson21700932016-03-24 17:26:23 -07001198 a.setZAdjustment(Animation.ZORDER_TOP);
Winson Chung2820c452014-04-15 15:34:44 -07001199 }
Winson Chung399f6202014-03-19 10:47:20 -07001200 break;
1201 }
1202 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
Winson Chunga4ccb862014-08-22 15:26:27 -07001203 // Previous app window during the scale up
Winson Chung399f6202014-03-19 10:47:20 -07001204 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001205 // Fade out the source activity if we are animating to a wallpaper
Winson Chung399f6202014-03-19 10:47:20 -07001206 // activity.
1207 a = new AlphaAnimation(1, 0);
1208 } else {
Winson Chung399f6202014-03-19 10:47:20 -07001209 a = new AlphaAnimation(1, 1);
1210 }
1211 break;
1212 }
1213 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
Winson Chunga4ccb862014-08-22 15:26:27 -07001214 // Target app window during the scale down
1215 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
1216 // Fade in the destination activity if we are animating from a wallpaper
1217 // activity.
1218 a = new AlphaAnimation(0, 1);
1219 } else {
1220 a = new AlphaAnimation(1, 1);
1221 }
Winson Chung399f6202014-03-19 10:47:20 -07001222 break;
1223 }
Winson Chung399f6202014-03-19 10:47:20 -07001224 default:
1225 throw new RuntimeException("Invalid thumbnail transition state");
1226 }
1227
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001228 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight,
1229 getAspectScaleDuration(), getAspectScaleInterpolator());
Winson Chung399f6202014-03-19 10:47:20 -07001230 }
1231
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001232 private Animation createAspectScaledThumbnailEnterFreeformAnimationLocked(Rect frame,
1233 @Nullable Rect surfaceInsets, int taskId) {
1234 getNextAppTransitionStartRect(taskId, mTmpRect);
1235 return createAspectScaledThumbnailFreeformAnimationLocked(mTmpRect, frame, surfaceInsets,
1236 true);
1237 }
1238
1239 private Animation createAspectScaledThumbnailExitFreeformAnimationLocked(Rect frame,
1240 @Nullable Rect surfaceInsets, int taskId) {
1241 getNextAppTransitionStartRect(taskId, mTmpRect);
1242 return createAspectScaledThumbnailFreeformAnimationLocked(frame, mTmpRect, surfaceInsets,
1243 false);
1244 }
1245
1246 private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame,
1247 Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) {
1248 final float sourceWidth = sourceFrame.width();
1249 final float sourceHeight = sourceFrame.height();
1250 final float destWidth = destFrame.width();
1251 final float destHeight = destFrame.height();
1252 final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth;
1253 final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight;
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001254 AnimationSet set = new AnimationSet(true);
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001255 final int surfaceInsetsH = surfaceInsets == null
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001256 ? 0 : surfaceInsets.left + surfaceInsets.right;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001257 final int surfaceInsetsV = surfaceInsets == null
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001258 ? 0 : surfaceInsets.top + surfaceInsets.bottom;
1259 // We want the scaling to happen from the center of the surface. In order to achieve that,
1260 // we need to account for surface insets that will be used to enlarge the surface.
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001261 final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2;
1262 final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2;
1263 final ScaleAnimation scale = enter ?
1264 new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter)
1265 : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter);
1266 final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2;
1267 final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2;
1268 final int destHCenter = destFrame.left + destFrame.width() / 2;
1269 final int destVCenter = destFrame.top + destFrame.height() / 2;
1270 final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter;
1271 final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter;
1272 final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0)
1273 : new TranslateAnimation(0, fromX, 0, fromY);
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001274 set.addAnimation(scale);
1275 set.addAnimation(translation);
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001276
1277 final IRemoteCallback callback = mAnimationFinishedCallback;
1278 if (callback != null) {
1279 set.setAnimationListener(new Animation.AnimationListener() {
1280 @Override
1281 public void onAnimationStart(Animation animation) { }
1282
1283 @Override
1284 public void onAnimationEnd(Animation animation) {
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08001285 mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget();
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001286 }
1287
1288 @Override
1289 public void onAnimationRepeat(Animation animation) { }
1290 });
1291 }
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001292 return set;
1293 }
1294
Winson Chung399f6202014-03-19 10:47:20 -07001295 /**
Winson Chunga4ccb862014-08-22 15:26:27 -07001296 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001297 * when a thumbnail is specified with the pending animation override.
Winson Chunga4ccb862014-08-22 15:26:27 -07001298 */
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001299 Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit,
Winson Chungaa7fa012017-05-24 15:50:06 -07001300 GraphicBuffer thumbnailHeader) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001301 Animation a;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001302 getDefaultNextAppTransitionStartRect(mTmpRect);
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001303 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chunga4ccb862014-08-22 15:26:27 -07001304 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001305 final int thumbHeightI = thumbnailHeader.getHeight();
Winson Chunga4ccb862014-08-22 15:26:27 -07001306 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
1307
1308 if (mNextAppTransitionScaleUp) {
1309 // Animation for the thumbnail zooming from its initial size to the full screen
1310 float scaleW = appWidth / thumbWidth;
1311 float scaleH = appHeight / thumbHeight;
1312 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001313 computePivot(mTmpRect.left, 1 / scaleW),
1314 computePivot(mTmpRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -07001315 scale.setInterpolator(mDecelerateInterpolator);
1316
1317 Animation alpha = new AlphaAnimation(1, 0);
1318 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
1319
1320 // This AnimationSet uses the Interpolators assigned above.
1321 AnimationSet set = new AnimationSet(false);
1322 set.addAnimation(scale);
1323 set.addAnimation(alpha);
1324 a = set;
1325 } else {
1326 // Animation for the thumbnail zooming down from the full screen to its final size
1327 float scaleW = appWidth / thumbWidth;
1328 float scaleH = appHeight / thumbHeight;
1329 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001330 computePivot(mTmpRect.left, 1 / scaleW),
1331 computePivot(mTmpRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -07001332 }
1333
1334 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
1335 }
1336
1337 /**
Winson Chung399f6202014-03-19 10:47:20 -07001338 * This animation is created when we are doing a thumbnail transition, for the activity that is
1339 * leaving, and the activity that is entering.
1340 */
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001341 Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame,
1342 int transit, int taskId) {
1343 final int appWidth = containingFrame.width();
1344 final int appHeight = containingFrame.height();
Winson Chungaa7fa012017-05-24 15:50:06 -07001345 final GraphicBuffer thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
Winson Chung399f6202014-03-19 10:47:20 -07001346 Animation a;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001347 getDefaultNextAppTransitionStartRect(mTmpRect);
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001348 final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
Winson Chung399f6202014-03-19 10:47:20 -07001349 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001350 final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
Winson Chung399f6202014-03-19 10:47:20 -07001351 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
1352
1353 switch (thumbTransitState) {
1354 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
1355 // Entering app scales up with the thumbnail
1356 float scaleW = thumbWidth / appWidth;
1357 float scaleH = thumbHeight / appHeight;
1358 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001359 computePivot(mTmpRect.left, scaleW),
1360 computePivot(mTmpRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -07001361 break;
1362 }
1363 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
1364 // Exiting app while the thumbnail is scaling up should fade or stay in place
1365 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
1366 // Fade out while bringing up selected activity. This keeps the
1367 // current activity from showing through a launching wallpaper
1368 // activity.
1369 a = new AlphaAnimation(1, 0);
1370 } else {
1371 // noop animation
1372 a = new AlphaAnimation(1, 1);
1373 }
1374 break;
1375 }
1376 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
1377 // Entering the other app, it should just be visible while we scale the thumbnail
1378 // down above it
1379 a = new AlphaAnimation(1, 1);
1380 break;
1381 }
1382 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
1383 // Exiting the current app, the app should scale down with the thumbnail
1384 float scaleW = thumbWidth / appWidth;
1385 float scaleH = thumbHeight / appHeight;
1386 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001387 computePivot(mTmpRect.left, scaleW),
1388 computePivot(mTmpRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -07001389
1390 Animation alpha = new AlphaAnimation(1, 0);
1391
1392 AnimationSet set = new AnimationSet(true);
1393 set.addAnimation(scale);
1394 set.addAnimation(alpha);
1395 set.setZAdjustment(Animation.ZORDER_TOP);
1396 a = set;
1397 break;
1398 }
1399 default:
1400 throw new RuntimeException("Invalid thumbnail transition state");
1401 }
1402
1403 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
1404 }
1405
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001406 private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001407 getDefaultNextAppTransitionStartRect(mTmpFromClipRect);
1408 final int left = mTmpFromClipRect.left;
1409 final int top = mTmpFromClipRect.top;
1410 mTmpFromClipRect.offset(-left, -top);
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001411 // TODO: Isn't that strange that we ignore exact position of the containingFrame?
1412 mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height());
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001413 AnimationSet set = new AnimationSet(true);
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001414 float fromWidth = mTmpFromClipRect.width();
1415 float toWidth = mTmpToClipRect.width();
1416 float fromHeight = mTmpFromClipRect.height();
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001417 // While the window might span the whole display, the actual content will be cropped to the
1418 // system decoration frame, for example when the window is docked. We need to take into
1419 // account the visible height when constructing the animation.
1420 float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom;
1421 int translateAdjustment = 0;
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001422 if (fromWidth <= toWidth && fromHeight <= toHeight) {
1423 // The final window is larger in both dimensions than current window (e.g. we are
1424 // maximizing), so we can simply unclip the new window and there will be no disappearing
1425 // frame.
1426 set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect));
1427 } else {
1428 // The disappearing window has one larger dimension. We need to apply scaling, so the
1429 // first frame of the entry animation matches the old window.
1430 set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1));
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001431 // We might not be going exactly full screen, but instead be aligned under the status
1432 // bar using cropping. We still need to account for the cropped part, which will also
1433 // be scaled.
1434 translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight);
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001435 }
1436
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001437 // We animate the translation from the old position of the removed window, to the new
1438 // position of the added window. The latter might not be full screen, for example docked for
1439 // docked windows.
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001440 TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left,
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001441 0, top - containingFrame.top - translateAdjustment, 0);
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001442 set.addAnimation(translate);
1443 set.setDuration(DEFAULT_APP_TRANSITION_DURATION);
Filip Gruszczynskie95b0ae2015-09-30 10:55:33 -07001444 set.setZAdjustment(Animation.ZORDER_TOP);
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001445 return set;
1446 }
1447
Jorim Jaggic554b772015-06-04 16:07:57 -07001448 /**
1449 * @return true if and only if the first frame of the transition can be skipped, i.e. the first
1450 * frame of the transition doesn't change the visuals on screen, so we can start
1451 * directly with the second one
1452 */
1453 boolean canSkipFirstFrame() {
1454 return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM
1455 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE
Jorim Jaggife762342016-10-13 14:33:27 +02001456 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL
1457 && mNextAppTransition != TRANSIT_KEYGUARD_GOING_AWAY;
Jorim Jaggic554b772015-06-04 16:07:57 -07001458 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001459
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001460 /**
1461 *
1462 * @param frame These are the bounds of the window when it finishes the animation. This is where
1463 * the animation must usually finish in entrance animation, as the next frame will
1464 * display the window at these coordinates. In case of exit animation, this is
1465 * where the animation must start, as the frame before the animation is displaying
1466 * the window at these bounds.
1467 * @param insets Knowing where the window will be positioned is not enough. Some parts of the
1468 * window might be obscured, usually by the system windows (status bar and
1469 * navigation bar) and we use content insets to convey that information. This
1470 * usually affects the animation aspects vertically, as the system decoration is
1471 * at the top and the bottom. For example when we animate from full screen to
1472 * recents, we want to exclude the covered parts, because they won't match the
1473 * thumbnail after the last frame is executed.
1474 * @param surfaceInsets In rare situation the surface is larger than the content and we need to
1475 * know about this to make the animation frames match. We currently use
1476 * this for freeform windows, which have larger surfaces to display
1477 * shadows. When we animate them from recents, we want to match the content
1478 * to the recents thumbnail and hence need to account for the surface being
1479 * bigger.
1480 */
Winsonb2024762016-04-05 17:32:30 -07001481 Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, int uiMode,
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -08001482 int orientation, Rect frame, Rect displayFrame, Rect insets,
1483 @Nullable Rect surfaceInsets, boolean isVoiceInteraction, boolean freeform,
1484 int taskId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001485 Animation a;
Jorim Jaggife762342016-10-13 14:33:27 +02001486 if (isKeyguardGoingAwayTransit(transit) && enter) {
1487 a = loadKeyguardExitAnimation(transit);
1488 } else if (transit == TRANSIT_KEYGUARD_OCCLUDE) {
1489 a = null;
1490 } else if (transit == TRANSIT_KEYGUARD_UNOCCLUDE && !enter) {
1491 a = loadAnimationRes(lp, com.android.internal.R.anim.wallpaper_open_exit);
1492 } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001493 || transit == TRANSIT_TASK_OPEN
1494 || transit == TRANSIT_TASK_TO_FRONT)) {
1495 a = loadAnimationRes(lp, enter
1496 ? com.android.internal.R.anim.voice_activity_open_enter
1497 : com.android.internal.R.anim.voice_activity_open_exit);
1498 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1499 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001500 + " anim=" + a + " transit=" + appTransitionToString(transit)
1501 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001502 } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE
1503 || transit == TRANSIT_TASK_CLOSE
1504 || transit == TRANSIT_TASK_TO_BACK)) {
1505 a = loadAnimationRes(lp, enter
1506 ? com.android.internal.R.anim.voice_activity_close_enter
1507 : com.android.internal.R.anim.voice_activity_close_exit);
1508 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1509 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001510 + " anim=" + a + " transit=" + appTransitionToString(transit)
1511 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001512 } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) {
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001513 a = createRelaunchAnimation(frame, insets);
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001514 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1515 "applyAnimation:"
1516 + " anim=" + a + " nextAppTransition=" + mNextAppTransition
1517 + " transit=" + appTransitionToString(transit)
1518 + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001519 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
1520 a = loadAnimationRes(mNextAppTransitionPackage, enter ?
Craig Mautner164d4bb2012-11-26 13:51:23 -08001521 mNextAppTransitionEnter : mNextAppTransitionExit);
1522 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1523 "applyAnimation:"
1524 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001525 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001526 + " Callers=" + Debug.getCallers(3));
Winson Chung044d5292014-11-06 11:05:19 -08001527 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
1528 a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
1529 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1530 "applyAnimation:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001531 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE"
1532 + " transit=" + appTransitionToString(transit)
1533 + " Callers=" + Debug.getCallers(3));
Chet Haase10e23ab2015-02-11 15:08:38 -08001534 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) {
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -08001535 a = createClipRevealAnimationLocked(transit, enter, frame, displayFrame);
Chet Haase10e23ab2015-02-11 15:08:38 -08001536 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1537 "applyAnimation:"
1538 + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL"
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001539 + " transit=" + appTransitionToString(transit)
Chet Haase10e23ab2015-02-11 15:08:38 -08001540 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001541 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001542 a = createScaleUpAnimationLocked(transit, enter, frame);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001543 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1544 "applyAnimation:"
1545 + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001546 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001547 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001548 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
1549 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001550 mNextAppTransitionScaleUp =
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001551 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
Winson Chunga4ccb862014-08-22 15:26:27 -07001552 a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter),
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001553 frame, transit, taskId);
Winson Chunga4ccb862014-08-22 15:26:27 -07001554 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1555 String animName = mNextAppTransitionScaleUp ?
1556 "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
1557 Slog.v(TAG, "applyAnimation:"
1558 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001559 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Winson Chunga4ccb862014-08-22 15:26:27 -07001560 + " Callers=" + Debug.getCallers(3));
1561 }
1562 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
1563 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) {
1564 mNextAppTransitionScaleUp =
1565 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP);
1566 a = createAspectScaledThumbnailEnterExitAnimationLocked(
Winsonb2024762016-04-05 17:32:30 -07001567 getThumbnailTransitionState(enter), uiMode, orientation, transit, frame,
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001568 insets, surfaceInsets, freeform, taskId);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001569 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1570 String animName = mNextAppTransitionScaleUp ?
Winson Chunga4ccb862014-08-22 15:26:27 -07001571 "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner164d4bb2012-11-26 13:51:23 -08001572 Slog.v(TAG, "applyAnimation:"
1573 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001574 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001575 + " Callers=" + Debug.getCallers(3));
1576 }
1577 } else {
1578 int animAttr = 0;
1579 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -08001580 case TRANSIT_ACTIVITY_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001581 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001582 ? WindowAnimation_activityOpenEnterAnimation
1583 : WindowAnimation_activityOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001584 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001585 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001586 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001587 ? WindowAnimation_activityCloseEnterAnimation
1588 : WindowAnimation_activityCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001589 break;
Jorim Jaggi192086e2016-03-11 17:17:03 +01001590 case TRANSIT_DOCK_TASK_FROM_RECENTS:
Craig Mautner4b71aa12012-12-27 17:20:01 -08001591 case TRANSIT_TASK_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001592 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001593 ? WindowAnimation_taskOpenEnterAnimation
1594 : WindowAnimation_taskOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001595 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001596 case TRANSIT_TASK_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001597 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001598 ? WindowAnimation_taskCloseEnterAnimation
1599 : WindowAnimation_taskCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001600 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001601 case TRANSIT_TASK_TO_FRONT:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001602 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001603 ? WindowAnimation_taskToFrontEnterAnimation
1604 : WindowAnimation_taskToFrontExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001605 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001606 case TRANSIT_TASK_TO_BACK:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001607 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001608 ? WindowAnimation_taskToBackEnterAnimation
1609 : WindowAnimation_taskToBackExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001610 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001611 case TRANSIT_WALLPAPER_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001612 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001613 ? WindowAnimation_wallpaperOpenEnterAnimation
1614 : WindowAnimation_wallpaperOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001615 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001616 case TRANSIT_WALLPAPER_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001617 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001618 ? WindowAnimation_wallpaperCloseEnterAnimation
1619 : WindowAnimation_wallpaperCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001620 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001621 case TRANSIT_WALLPAPER_INTRA_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001622 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001623 ? WindowAnimation_wallpaperIntraOpenEnterAnimation
1624 : WindowAnimation_wallpaperIntraOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001625 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001626 case TRANSIT_WALLPAPER_INTRA_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001627 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001628 ? WindowAnimation_wallpaperIntraCloseEnterAnimation
1629 : WindowAnimation_wallpaperIntraCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001630 break;
Craig Mautnerbb742462014-07-07 15:28:55 -07001631 case TRANSIT_TASK_OPEN_BEHIND:
1632 animAttr = enter
1633 ? WindowAnimation_launchTaskBehindSourceAnimation
Craig Mautner3b2cd1d2014-08-25 14:25:54 -07001634 : WindowAnimation_launchTaskBehindTargetAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001635 }
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001636 a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001637 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1638 "applyAnimation:"
1639 + " anim=" + a
1640 + " animAttr=0x" + Integer.toHexString(animAttr)
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001641 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001642 + " Callers=" + Debug.getCallers(3));
1643 }
1644 return a;
1645 }
1646
Jorim Jaggife762342016-10-13 14:33:27 +02001647 private Animation loadKeyguardExitAnimation(int transit) {
1648 if ((mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) {
1649 return null;
1650 }
1651 final boolean toShade =
1652 (mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0;
1653 return mService.mPolicy.createHiddenByKeyguardExit(
1654 transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER, toShade);
1655 }
1656
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +01001657 int getAppStackClipMode() {
Matthew Ngbf1d9852017-03-14 12:23:09 -07001658 // When dismiss keyguard animation occurs, clip before the animation to prevent docked
1659 // app from showing beyond the divider
1660 if (mNextAppTransition == TRANSIT_KEYGUARD_GOING_AWAY
1661 || mNextAppTransition == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER) {
1662 return STACK_CLIP_BEFORE_ANIM;
1663 }
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +01001664 return mNextAppTransition == TRANSIT_ACTIVITY_RELAUNCH
Jorim Jaggic69bd222016-03-15 14:38:37 +01001665 || mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS
Jorim Jaggi1f458fb2016-03-25 17:36:37 -07001666 || mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +01001667 ? STACK_CLIP_NONE
1668 : STACK_CLIP_AFTER_ANIM;
1669 }
1670
Jorim Jaggife762342016-10-13 14:33:27 +02001671 public int getTransitFlags() {
1672 return mNextAppTransitionFlags;
1673 }
1674
Craig Mautner164d4bb2012-11-26 13:51:23 -08001675 void postAnimationCallback() {
1676 if (mNextAppTransitionCallback != null) {
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08001677 mService.mH.sendMessage(mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK,
1678 mNextAppTransitionCallback));
Craig Mautner164d4bb2012-11-26 13:51:23 -08001679 mNextAppTransitionCallback = null;
1680 }
1681 }
1682
1683 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
Filip Gruszczynskid1431422015-09-08 11:18:54 -07001684 IRemoteCallback startedCallback) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001685 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001686 clear();
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001687 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001688 mNextAppTransitionPackage = packageName;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001689 mNextAppTransitionEnter = enterAnim;
1690 mNextAppTransitionExit = exitAnim;
1691 postAnimationCallback();
1692 mNextAppTransitionCallback = startedCallback;
1693 } else {
1694 postAnimationCallback();
1695 }
1696 }
1697
1698 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001699 int startHeight) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001700 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001701 clear();
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001702 mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP;
Winson4c3fecd2016-07-13 12:29:48 -07001703 putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001704 postAnimationCallback();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001705 }
1706 }
1707
Chet Haase10e23ab2015-02-11 15:08:38 -08001708 void overridePendingAppTransitionClipReveal(int startX, int startY,
1709 int startWidth, int startHeight) {
1710 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001711 clear();
Chet Haase10e23ab2015-02-11 15:08:38 -08001712 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL;
Filip Gruszczynski7248c562015-11-09 13:05:40 -08001713 putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null);
Chet Haase10e23ab2015-02-11 15:08:38 -08001714 postAnimationCallback();
Chet Haase10e23ab2015-02-11 15:08:38 -08001715 }
1716 }
1717
Winson Chungaa7fa012017-05-24 15:50:06 -07001718 void overridePendingAppTransitionThumb(GraphicBuffer srcThumb, int startX, int startY,
Craig Mautner164d4bb2012-11-26 13:51:23 -08001719 IRemoteCallback startedCallback, boolean scaleUp) {
1720 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001721 clear();
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001722 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP
1723 : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001724 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski7248c562015-11-09 13:05:40 -08001725 putDefaultNextAppTransitionCoordinates(startX, startY, 0, 0, srcThumb);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001726 postAnimationCallback();
1727 mNextAppTransitionCallback = startedCallback;
1728 } else {
1729 postAnimationCallback();
1730 }
1731 }
1732
Winson Chungaa7fa012017-05-24 15:50:06 -07001733 void overridePendingAppTransitionAspectScaledThumb(GraphicBuffer srcThumb, int startX, int startY,
Winson Chung2e7f3bd2014-09-05 13:17:22 +02001734 int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001735 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001736 clear();
Winson Chunga4ccb862014-08-22 15:26:27 -07001737 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1738 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
Winson Chunga4ccb862014-08-22 15:26:27 -07001739 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski7248c562015-11-09 13:05:40 -08001740 putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight,
1741 srcThumb);
Winson Chunga4ccb862014-08-22 15:26:27 -07001742 postAnimationCallback();
1743 mNextAppTransitionCallback = startedCallback;
1744 } else {
1745 postAnimationCallback();
1746 }
1747 }
1748
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001749 public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs,
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001750 IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback,
1751 boolean scaleUp) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001752 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001753 clear();
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001754 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1755 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001756 mNextAppTransitionScaleUp = scaleUp;
Jorim Jaggi43102412015-11-11 16:28:37 +01001757 if (specs != null) {
1758 for (int i = 0; i < specs.length; i++) {
1759 AppTransitionAnimationSpec spec = specs[i];
1760 if (spec != null) {
1761 mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec);
1762 if (i == 0) {
1763 // In full screen mode, the transition code depends on the default spec
1764 // to be set.
1765 Rect rect = spec.rect;
1766 putDefaultNextAppTransitionCoordinates(rect.left, rect.top,
Winson Chungaa7fa012017-05-24 15:50:06 -07001767 rect.width(), rect.height(), spec.buffer);
Jorim Jaggi43102412015-11-11 16:28:37 +01001768 }
Filip Gruszczynskid1431422015-09-08 11:18:54 -07001769 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001770 }
1771 }
1772 postAnimationCallback();
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001773 mNextAppTransitionCallback = onAnimationStartedCallback;
1774 mAnimationFinishedCallback = onAnimationFinishedCallback;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001775 } else {
1776 postAnimationCallback();
1777 }
1778 }
1779
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001780 void overridePendingAppTransitionMultiThumbFuture(
1781 IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback callback,
1782 boolean scaleUp) {
1783 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001784 clear();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001785 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1786 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001787 mNextAppTransitionAnimationsSpecsFuture = specsFuture;
1788 mNextAppTransitionScaleUp = scaleUp;
Jorim Jaggi7cc7b082015-11-10 16:06:54 +01001789 mNextAppTransitionFutureCallback = callback;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001790 }
1791 }
1792
Winson Chung044d5292014-11-06 11:05:19 -08001793 void overrideInPlaceAppTransition(String packageName, int anim) {
1794 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001795 clear();
Winson Chung044d5292014-11-06 11:05:19 -08001796 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE;
1797 mNextAppTransitionPackage = packageName;
1798 mNextAppTransitionInPlace = anim;
1799 } else {
1800 postAnimationCallback();
1801 }
1802 }
1803
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001804 /**
1805 * If a future is set for the app transition specs, fetch it in another thread.
1806 */
1807 private void fetchAppTransitionSpecsFromFuture() {
1808 if (mNextAppTransitionAnimationsSpecsFuture != null) {
1809 mNextAppTransitionAnimationsSpecsPending = true;
1810 final IAppTransitionAnimationSpecsFuture future
1811 = mNextAppTransitionAnimationsSpecsFuture;
1812 mNextAppTransitionAnimationsSpecsFuture = null;
Jorim Jaggied410b62017-05-05 15:16:14 +02001813 mDefaultExecutor.execute(() -> {
1814 AppTransitionAnimationSpec[] specs = null;
1815 try {
1816 Binder.allowBlocking(future.asBinder());
1817 specs = future.get();
1818 } catch (RemoteException e) {
1819 Slog.w(TAG, "Failed to fetch app transition specs: " + e);
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001820 }
Jorim Jaggied410b62017-05-05 15:16:14 +02001821 synchronized (mService.mWindowMap) {
1822 mNextAppTransitionAnimationsSpecsPending = false;
1823 overridePendingAppTransitionMultiThumb(specs,
1824 mNextAppTransitionFutureCallback, null /* finishedCallback */,
1825 mNextAppTransitionScaleUp);
1826 mNextAppTransitionFutureCallback = null;
1827 if (specs != null) {
1828 mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
1829 }
1830 }
1831 mService.requestTraversal();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001832 });
1833 }
1834 }
1835
Craig Mautner164d4bb2012-11-26 13:51:23 -08001836 @Override
1837 public String toString() {
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001838 return "mNextAppTransition=" + appTransitionToString(mNextAppTransition);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001839 }
1840
Craig Mautner4b71aa12012-12-27 17:20:01 -08001841 /**
1842 * Returns the human readable name of a window transition.
1843 *
1844 * @param transition The window transition.
1845 * @return The transition symbolic name.
1846 */
1847 public static String appTransitionToString(int transition) {
1848 switch (transition) {
1849 case TRANSIT_UNSET: {
1850 return "TRANSIT_UNSET";
1851 }
1852 case TRANSIT_NONE: {
1853 return "TRANSIT_NONE";
1854 }
Craig Mautner4b71aa12012-12-27 17:20:01 -08001855 case TRANSIT_ACTIVITY_OPEN: {
1856 return "TRANSIT_ACTIVITY_OPEN";
1857 }
1858 case TRANSIT_ACTIVITY_CLOSE: {
1859 return "TRANSIT_ACTIVITY_CLOSE";
1860 }
1861 case TRANSIT_TASK_OPEN: {
1862 return "TRANSIT_TASK_OPEN";
1863 }
1864 case TRANSIT_TASK_CLOSE: {
1865 return "TRANSIT_TASK_CLOSE";
1866 }
1867 case TRANSIT_TASK_TO_FRONT: {
1868 return "TRANSIT_TASK_TO_FRONT";
1869 }
1870 case TRANSIT_TASK_TO_BACK: {
1871 return "TRANSIT_TASK_TO_BACK";
1872 }
1873 case TRANSIT_WALLPAPER_CLOSE: {
1874 return "TRANSIT_WALLPAPER_CLOSE";
1875 }
1876 case TRANSIT_WALLPAPER_OPEN: {
1877 return "TRANSIT_WALLPAPER_OPEN";
1878 }
1879 case TRANSIT_WALLPAPER_INTRA_OPEN: {
1880 return "TRANSIT_WALLPAPER_INTRA_OPEN";
1881 }
1882 case TRANSIT_WALLPAPER_INTRA_CLOSE: {
1883 return "TRANSIT_WALLPAPER_INTRA_CLOSE";
1884 }
Craig Mautnerbb742462014-07-07 15:28:55 -07001885 case TRANSIT_TASK_OPEN_BEHIND: {
1886 return "TRANSIT_TASK_OPEN_BEHIND";
1887 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001888 case TRANSIT_ACTIVITY_RELAUNCH: {
1889 return "TRANSIT_ACTIVITY_RELAUNCH";
1890 }
Jorim Jaggi192086e2016-03-11 17:17:03 +01001891 case TRANSIT_DOCK_TASK_FROM_RECENTS: {
1892 return "TRANSIT_DOCK_TASK_FROM_RECENTS";
1893 }
Jorim Jaggife762342016-10-13 14:33:27 +02001894 case TRANSIT_KEYGUARD_GOING_AWAY: {
1895 return "TRANSIT_KEYGUARD_GOING_AWAY";
1896 }
1897 case TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER: {
1898 return "TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER";
1899 }
1900 case TRANSIT_KEYGUARD_OCCLUDE: {
1901 return "TRANSIT_KEYGUARD_OCCLUDE";
1902 }
1903 case TRANSIT_KEYGUARD_UNOCCLUDE: {
1904 return "TRANSIT_KEYGUARD_UNOCCLUDE";
1905 }
Craig Mautner4b71aa12012-12-27 17:20:01 -08001906 default: {
1907 return "<UNKNOWN>";
1908 }
1909 }
1910 }
1911
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001912 private String appStateToString() {
1913 switch (mAppTransitionState) {
1914 case APP_STATE_IDLE:
1915 return "APP_STATE_IDLE";
1916 case APP_STATE_READY:
1917 return "APP_STATE_READY";
1918 case APP_STATE_RUNNING:
1919 return "APP_STATE_RUNNING";
1920 case APP_STATE_TIMEOUT:
1921 return "APP_STATE_TIMEOUT";
1922 default:
1923 return "unknown state=" + mAppTransitionState;
1924 }
1925 }
1926
1927 private String transitTypeToString() {
1928 switch (mNextAppTransitionType) {
1929 case NEXT_TRANSIT_TYPE_NONE:
1930 return "NEXT_TRANSIT_TYPE_NONE";
1931 case NEXT_TRANSIT_TYPE_CUSTOM:
1932 return "NEXT_TRANSIT_TYPE_CUSTOM";
Winson Chung044d5292014-11-06 11:05:19 -08001933 case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
1934 return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE";
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001935 case NEXT_TRANSIT_TYPE_SCALE_UP:
1936 return "NEXT_TRANSIT_TYPE_SCALE_UP";
1937 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
1938 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP";
1939 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
1940 return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN";
Winson Chunga4ccb862014-08-22 15:26:27 -07001941 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP:
1942 return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP";
1943 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN:
1944 return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001945 default:
1946 return "unknown type=" + mNextAppTransitionType;
1947 }
1948 }
1949
Craig Mautner164d4bb2012-11-26 13:51:23 -08001950 @Override
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001951 public void dump(PrintWriter pw, String prefix) {
1952 pw.print(prefix); pw.println(this);
1953 pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString());
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001954 if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) {
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001955 pw.print(prefix); pw.print("mNextAppTransitionType=");
1956 pw.println(transitTypeToString());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001957 }
1958 switch (mNextAppTransitionType) {
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001959 case NEXT_TRANSIT_TYPE_CUSTOM:
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001960 pw.print(prefix); pw.print("mNextAppTransitionPackage=");
Craig Mautner164d4bb2012-11-26 13:51:23 -08001961 pw.println(mNextAppTransitionPackage);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001962 pw.print(prefix); pw.print("mNextAppTransitionEnter=0x");
Craig Mautner164d4bb2012-11-26 13:51:23 -08001963 pw.print(Integer.toHexString(mNextAppTransitionEnter));
1964 pw.print(" mNextAppTransitionExit=0x");
1965 pw.println(Integer.toHexString(mNextAppTransitionExit));
1966 break;
Winson Chung044d5292014-11-06 11:05:19 -08001967 case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001968 pw.print(prefix); pw.print("mNextAppTransitionPackage=");
Winson Chung044d5292014-11-06 11:05:19 -08001969 pw.println(mNextAppTransitionPackage);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001970 pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x");
Winson Chung044d5292014-11-06 11:05:19 -08001971 pw.print(Integer.toHexString(mNextAppTransitionInPlace));
1972 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001973 case NEXT_TRANSIT_TYPE_SCALE_UP: {
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001974 getDefaultNextAppTransitionStartRect(mTmpRect);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001975 pw.print(prefix); pw.print("mNextAppTransitionStartX=");
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001976 pw.print(mTmpRect.left);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001977 pw.print(" mNextAppTransitionStartY=");
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001978 pw.println(mTmpRect.top);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001979 pw.print(prefix); pw.print("mNextAppTransitionStartWidth=");
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001980 pw.print(mTmpRect.width());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001981 pw.print(" mNextAppTransitionStartHeight=");
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001982 pw.println(mTmpRect.height());
Craig Mautner164d4bb2012-11-26 13:51:23 -08001983 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001984 }
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001985 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
1986 case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
Winson Chunga4ccb862014-08-22 15:26:27 -07001987 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP:
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001988 case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: {
1989 pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec=");
1990 pw.println(mDefaultNextAppTransitionAnimationSpec);
1991 pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs=");
1992 pw.println(mNextAppTransitionAnimationsSpecs);
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001993 pw.print(prefix); pw.print("mNextAppTransitionScaleUp=");
1994 pw.println(mNextAppTransitionScaleUp);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001995 break;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001996 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001997 }
1998 if (mNextAppTransitionCallback != null) {
Dianne Hackbornae6688b2015-02-11 17:02:41 -08001999 pw.print(prefix); pw.print("mNextAppTransitionCallback=");
2000 pw.println(mNextAppTransitionCallback);
Craig Mautner164d4bb2012-11-26 13:51:23 -08002001 }
Chong Zhang60091a92016-07-27 17:52:45 -07002002 if (mLastUsedAppTransition != TRANSIT_NONE) {
2003 pw.print(prefix); pw.print("mLastUsedAppTransition=");
2004 pw.println(appTransitionToString(mLastUsedAppTransition));
2005 pw.print(prefix); pw.print("mLastOpeningApp=");
2006 pw.println(mLastOpeningApp);
2007 pw.print(prefix); pw.print("mLastClosingApp=");
2008 pw.println(mLastClosingApp);
2009 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08002010 }
Amith Yamasani4befbec2013-07-10 16:18:01 -07002011
2012 public void setCurrentUser(int newUserId) {
2013 mCurrentUserId = newUserId;
2014 }
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002015
2016 /**
2017 * @return true if transition is not running and should not be skipped, false if transition is
2018 * already running
2019 */
Jorim Jaggife762342016-10-13 14:33:27 +02002020 boolean prepareAppTransitionLocked(int transit, boolean alwaysKeepCurrent, int flags,
2021 boolean forceOverride) {
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002022 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:"
2023 + " transit=" + appTransitionToString(transit)
2024 + " " + this
2025 + " alwaysKeepCurrent=" + alwaysKeepCurrent
2026 + " Callers=" + Debug.getCallers(3));
Jorim Jaggife762342016-10-13 14:33:27 +02002027 if (forceOverride || isKeyguardTransit(transit) || !isTransitionSet()
2028 || mNextAppTransition == TRANSIT_NONE) {
2029 setAppTransition(transit, flags);
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002030 } else if (!alwaysKeepCurrent) {
2031 if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) {
2032 // Opening a new task always supersedes a close for the anim.
Jorim Jaggife762342016-10-13 14:33:27 +02002033 setAppTransition(transit, flags);
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002034 } else if (transit == TRANSIT_ACTIVITY_OPEN
2035 && isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) {
2036 // Opening a new activity always supersedes a close for the anim.
Jorim Jaggife762342016-10-13 14:33:27 +02002037 setAppTransition(transit, flags);
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002038 }
2039 }
2040 boolean prepared = prepare();
2041 if (isTransitionSet()) {
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08002042 mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
2043 mService.mH.sendEmptyMessageDelayed(H.APP_TRANSITION_TIMEOUT, APP_TRANSITION_TIMEOUT_MS);
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002044 }
2045 return prepared;
2046 }
Winsonb2024762016-04-05 17:32:30 -07002047
2048 /**
Jorim Jaggife762342016-10-13 14:33:27 +02002049 * @return true if {@param transit} is representing a transition in which Keyguard is going
2050 * away, false otherwise
2051 */
2052 public static boolean isKeyguardGoingAwayTransit(int transit) {
2053 return transit == TRANSIT_KEYGUARD_GOING_AWAY
2054 || transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
2055 }
2056
2057 private static boolean isKeyguardTransit(int transit) {
2058 return isKeyguardGoingAwayTransit(transit) || transit == TRANSIT_KEYGUARD_OCCLUDE
2059 || transit == TRANSIT_KEYGUARD_UNOCCLUDE;
2060 }
2061
2062 /**
Manu Cornetd7376802017-01-13 13:44:07 -08002063 * @return whether the transition should show the thumbnail being scaled down.
2064 */
2065 private boolean shouldScaleDownThumbnailTransition(int uiMode, int orientation) {
Sid Soundararajan0e88d322017-03-07 15:37:30 -08002066 return mGridLayoutRecentsEnabled
Manu Cornetd7376802017-01-13 13:44:07 -08002067 || orientation == Configuration.ORIENTATION_PORTRAIT;
2068 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08002069}