blob: eaf45f4ab224d04044eb1b69905860a55ee27a8e [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;
Jorim Jaggi787e9dd2016-03-15 10:52:40 +010055import android.graphics.Path;
Winson Chung399f6202014-03-19 10:47:20 -070056import android.graphics.Rect;
Craig Mautner164d4bb2012-11-26 13:51:23 -080057import android.os.Debug;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010058import android.os.IBinder;
Craig Mautner164d4bb2012-11-26 13:51:23 -080059import android.os.IRemoteCallback;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +010060import android.os.RemoteException;
Manu Cornetd7376802017-01-13 13:44:07 -080061import android.os.SystemProperties;
Jorim Jaggi42625d1b2016-02-11 20:11:07 -080062import android.util.ArraySet;
Craig Mautner164d4bb2012-11-26 13:51:23 -080063import android.util.Slog;
Filip Gruszczynski170192a2015-08-16 17:46:34 -070064import android.util.SparseArray;
65import android.view.AppTransitionAnimationSpec;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +010066import android.view.IAppTransitionAnimationSpecsFuture;
Craig Mautner164d4bb2012-11-26 13:51:23 -080067import android.view.WindowManager;
Craig Mautner164d4bb2012-11-26 13:51:23 -080068import android.view.animation.AlphaAnimation;
69import android.view.animation.Animation;
70import android.view.animation.AnimationSet;
71import android.view.animation.AnimationUtils;
Winson Chung399f6202014-03-19 10:47:20 -070072import android.view.animation.ClipRectAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080073import android.view.animation.Interpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070074import android.view.animation.PathInterpolator;
Craig Mautner164d4bb2012-11-26 13:51:23 -080075import android.view.animation.ScaleAnimation;
Winson Chung399f6202014-03-19 10:47:20 -070076import android.view.animation.TranslateAnimation;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070077
Craig Mautner164d4bb2012-11-26 13:51:23 -080078import com.android.internal.util.DumpUtils.Dump;
79import com.android.server.AttributeCache;
80import com.android.server.wm.WindowManagerService.H;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -080081import com.android.server.wm.animation.ClipRectLRAnimation;
82import com.android.server.wm.animation.ClipRectTBAnimation;
Jorim Jaggi787e9dd2016-03-15 10:52:40 +010083import com.android.server.wm.animation.CurvedTranslateAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -080084
85import java.io.PrintWriter;
Jorim Jaggi77ba4802015-02-18 13:57:50 +010086import java.util.ArrayList;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +010087import java.util.concurrent.ExecutorService;
88import java.util.concurrent.Executors;
Craig Mautner164d4bb2012-11-26 13:51:23 -080089
Craig Mautner164d4bb2012-11-26 13:51:23 -080090// State management of app transitions. When we are preparing for a
91// transition, mNextAppTransition will be the kind of transition to
92// perform or TRANSIT_NONE if we are not waiting. If we are waiting,
93// mOpeningApps and mClosingApps are the lists of tokens that will be
94// made visible or hidden at the next transition.
95public class AppTransition implements Dump {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080096 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppTransition" : TAG_WM;
Jorim Jaggi1d763a62015-06-02 17:07:39 -070097 private static final int CLIP_REVEAL_TRANSLATION_Y_DP = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -080098
Craig Mautner4b71aa12012-12-27 17:20:01 -080099 /** Not set up for a transition. */
100 public static final int TRANSIT_UNSET = -1;
101 /** No animation for transition. */
102 public static final int TRANSIT_NONE = 0;
103 /** 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 -0700104 public static final int TRANSIT_ACTIVITY_OPEN = 6;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800105 /** The window in the top-most activity is being closed to reveal the
106 * previous activity in the same task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700107 public static final int TRANSIT_ACTIVITY_CLOSE = 7;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800108 /** A window in a new task is being opened on top of an existing one
109 * in another activity's task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700110 public static final int TRANSIT_TASK_OPEN = 8;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800111 /** A window in the top-most activity is being closed to reveal the
112 * previous activity in a different task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700113 public static final int TRANSIT_TASK_CLOSE = 9;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800114 /** A window in an existing task is being displayed on top of an existing one
115 * in another activity's task. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700116 public static final int TRANSIT_TASK_TO_FRONT = 10;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800117 /** A window in an existing task is being put below all other tasks. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700118 public static final int TRANSIT_TASK_TO_BACK = 11;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800119 /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that
120 * does, effectively closing the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700121 public static final int TRANSIT_WALLPAPER_CLOSE = 12;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800122 /** A window in a new activity that does have a wallpaper is being opened on one that didn't,
123 * effectively opening the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700124 public static final int TRANSIT_WALLPAPER_OPEN = 13;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800125 /** A window in a new activity is being opened on top of an existing one, and both are on top
126 * of the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700127 public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800128 /** The window in the top-most activity is being closed to reveal the previous activity, and
129 * both are on top of the wallpaper. */
Craig Mautnerbb742462014-07-07 15:28:55 -0700130 public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
131 /** A window in a new task is being opened behind an existing one in another activity's task.
132 * The new window will show briefly and then be gone. */
133 public static final int TRANSIT_TASK_OPEN_BEHIND = 16;
Winson Chung044d5292014-11-06 11:05:19 -0800134 /** A window in a task is being animated in-place. */
135 public static final int TRANSIT_TASK_IN_PLACE = 17;
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700136 /** An activity is being relaunched (e.g. due to configuration change). */
137 public static final int TRANSIT_ACTIVITY_RELAUNCH = 18;
Jorim Jaggi192086e2016-03-11 17:17:03 +0100138 /** A task is being docked from recents. */
139 public static final int TRANSIT_DOCK_TASK_FROM_RECENTS = 19;
Jorim Jaggife762342016-10-13 14:33:27 +0200140 /** Keyguard is going away */
141 public static final int TRANSIT_KEYGUARD_GOING_AWAY = 20;
142 /** Keyguard is going away with showing an activity behind that requests wallpaper */
143 public static final int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;
144 /** Keyguard is being occluded */
145 public static final int TRANSIT_KEYGUARD_OCCLUDE = 22;
146 /** Keyguard is being unoccluded */
147 public static final int TRANSIT_KEYGUARD_UNOCCLUDE = 23;
148
149 /** Transition flag: Keyguard is going away, but keeping the notification shade open */
150 public static final int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1;
151 /** Transition flag: Keyguard is going away, but doesn't want an animation for it */
152 public static final int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2;
153 /** Transition flag: Keyguard is going away while it was showing the system wallpaper. */
154 public static final int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800155
Winson Chunga4ccb862014-08-22 15:26:27 -0700156 /** Fraction of animation at which the recents thumbnail stays completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700157 private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800158 /** Fraction of animation at which the recents thumbnail becomes completely transparent */
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700159 private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800160
Filip Gruszczynski84fa3352016-01-25 16:28:49 -0800161 static final int DEFAULT_APP_TRANSITION_DURATION = 336;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800162
163 /** Interpolator to be used for animations that respond directly to a touch */
164 static final Interpolator TOUCH_RESPONSE_INTERPOLATOR =
165 new PathInterpolator(0.3f, 0f, 0.1f, 1f);
166
Jorim Jaggic69bd222016-03-15 14:38:37 +0100167 private static final Interpolator THUMBNAIL_DOCK_INTERPOLATOR =
168 new PathInterpolator(0.85f, 0f, 1f, 1f);
169
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800170 /**
171 * Maximum duration for the clip reveal animation. This is used when there is a lot of movement
172 * involved, to make it more understandable.
173 */
174 private static final int MAX_CLIP_REVEAL_TRANSITION_DURATION = 420;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700175 private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336;
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700176 private static final long APP_TRANSITION_TIMEOUT_MS = 5000;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800177
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800178 private final Context mContext;
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -0800179 private final WindowManagerService mService;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800180
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800181 private int mNextAppTransition = TRANSIT_UNSET;
Jorim Jaggife762342016-10-13 14:33:27 +0200182 private int mNextAppTransitionFlags = 0;
Chong Zhang60091a92016-07-27 17:52:45 -0700183 private int mLastUsedAppTransition = TRANSIT_UNSET;
184 private String mLastOpeningApp;
185 private String mLastClosingApp;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800186
187 private static final int NEXT_TRANSIT_TYPE_NONE = 0;
188 private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1;
189 private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2;
190 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3;
191 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4;
Winson Chunga4ccb862014-08-22 15:26:27 -0700192 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5;
193 private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6;
Winson Chung044d5292014-11-06 11:05:19 -0800194 private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7;
Chet Haase10e23ab2015-02-11 15:08:38 -0800195 private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800196 private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
197
Winson Chung399f6202014-03-19 10:47:20 -0700198 // These are the possible states for the enter/exit activities during a thumbnail transition
199 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0;
200 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1;
201 private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2;
202 private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3;
203
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800204 private String mNextAppTransitionPackage;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800205 // Used for thumbnail transitions. True if we're scaling up, false if scaling down
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800206 private boolean mNextAppTransitionScaleUp;
207 private IRemoteCallback mNextAppTransitionCallback;
Jorim Jaggi7cc7b082015-11-10 16:06:54 +0100208 private IRemoteCallback mNextAppTransitionFutureCallback;
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -0700209 private IRemoteCallback mAnimationFinishedCallback;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800210 private int mNextAppTransitionEnter;
211 private int mNextAppTransitionExit;
Winson Chung044d5292014-11-06 11:05:19 -0800212 private int mNextAppTransitionInPlace;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700213
214 // Keyed by task id.
215 private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs
216 = new SparseArray<>();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100217 private IAppTransitionAnimationSpecsFuture mNextAppTransitionAnimationsSpecsFuture;
218 private boolean mNextAppTransitionAnimationsSpecsPending;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700219 private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec;
220
Winson Chunga4ccb862014-08-22 15:26:27 -0700221 private Rect mNextAppTransitionInsets = new Rect();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800222
Winson Chung2820c452014-04-15 15:34:44 -0700223 private Rect mTmpFromClipRect = new Rect();
224 private Rect mTmpToClipRect = new Rect();
225
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700226 private final Rect mTmpRect = new Rect();
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700227
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800228 private final static int APP_STATE_IDLE = 0;
229 private final static int APP_STATE_READY = 1;
230 private final static int APP_STATE_RUNNING = 2;
231 private final static int APP_STATE_TIMEOUT = 3;
232 private int mAppTransitionState = APP_STATE_IDLE;
233
234 private final int mConfigShortAnimTime;
Craig Mautner321bdf52012-12-18 09:53:24 -0800235 private final Interpolator mDecelerateInterpolator;
Winson Chunga4ccb862014-08-22 15:26:27 -0700236 private final Interpolator mThumbnailFadeInInterpolator;
237 private final Interpolator mThumbnailFadeOutInterpolator;
Chet Haase10e23ab2015-02-11 15:08:38 -0800238 private final Interpolator mLinearOutSlowInInterpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700239 private final Interpolator mFastOutLinearInInterpolator;
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100240 private final Interpolator mFastOutSlowInInterpolator;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700241 private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f);
242
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700243 private final int mClipRevealTranslationY;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800244
Amith Yamasani4befbec2013-07-10 16:18:01 -0700245 private int mCurrentUserId = 0;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800246 private long mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION;
Amith Yamasani4befbec2013-07-10 16:18:01 -0700247
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100248 private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100249 private final ExecutorService mDefaultExecutor = Executors.newSingleThreadExecutor();
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100250
Jorim Jaggif97ed922016-02-18 18:57:07 -0800251 private int mLastClipRevealMaxTranslation;
252 private boolean mLastHadClipReveal;
Jorim Jaggi363ab982016-04-26 19:51:20 -0700253 private boolean mProlongedAnimationsEnded;
Jorim Jaggif97ed922016-02-18 18:57:07 -0800254
Manu Cornetd7376802017-01-13 13:44:07 -0800255 private final boolean mGridLayoutRecentsEnabled;
256
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -0800257 AppTransition(Context context, WindowManagerService service) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800258 mContext = context;
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -0800259 mService = service;
Chet Haase10e23ab2015-02-11 15:08:38 -0800260 mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
261 com.android.internal.R.interpolator.linear_out_slow_in);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700262 mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
263 com.android.internal.R.interpolator.fast_out_linear_in);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100264 mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
265 com.android.internal.R.interpolator.fast_out_slow_in);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800266 mConfigShortAnimTime = context.getResources().getInteger(
267 com.android.internal.R.integer.config_shortAnimTime);
Craig Mautner321bdf52012-12-18 09:53:24 -0800268 mDecelerateInterpolator = AnimationUtils.loadInterpolator(context,
269 com.android.internal.R.interpolator.decelerate_cubic);
Winson Chunga4ccb862014-08-22 15:26:27 -0700270 mThumbnailFadeInInterpolator = new Interpolator() {
271 @Override
272 public float getInterpolation(float input) {
273 // Linear response for first fraction, then complete after that.
274 if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) {
275 return 0f;
276 }
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700277 float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) /
Winson Chunga4ccb862014-08-22 15:26:27 -0700278 (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700279 return mFastOutLinearInInterpolator.getInterpolation(t);
Winson Chunga4ccb862014-08-22 15:26:27 -0700280 }
281 };
282 mThumbnailFadeOutInterpolator = new Interpolator() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800283 @Override
284 public float getInterpolation(float input) {
285 // Linear response for first fraction, then complete after that.
286 if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) {
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700287 float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION;
288 return mLinearOutSlowInInterpolator.getInterpolation(t);
Craig Mautner321bdf52012-12-18 09:53:24 -0800289 }
Winson Chunga4ccb862014-08-22 15:26:27 -0700290 return 1f;
Craig Mautner321bdf52012-12-18 09:53:24 -0800291 }
292 };
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700293 mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP
294 * mContext.getResources().getDisplayMetrics().density);
Manu Cornetd7376802017-01-13 13:44:07 -0800295 mGridLayoutRecentsEnabled = SystemProperties.getBoolean("ro.recents.grid", false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800296 }
297
298 boolean isTransitionSet() {
299 return mNextAppTransition != TRANSIT_UNSET;
300 }
301
Craig Mautner164d4bb2012-11-26 13:51:23 -0800302 boolean isTransitionEqual(int transit) {
303 return mNextAppTransition == transit;
304 }
305
306 int getAppTransition() {
Craig Mautner321bdf52012-12-18 09:53:24 -0800307 return mNextAppTransition;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800308 }
309
Jorim Jaggife762342016-10-13 14:33:27 +0200310 private void setAppTransition(int transit, int flags) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800311 mNextAppTransition = transit;
Jorim Jaggife762342016-10-13 14:33:27 +0200312 mNextAppTransitionFlags |= flags;
Chong Zhang60091a92016-07-27 17:52:45 -0700313 setLastAppTransition(TRANSIT_UNSET, null, null);
314 }
315
316 void setLastAppTransition(int transit, AppWindowToken openingApp, AppWindowToken closingApp) {
317 mLastUsedAppTransition = transit;
318 mLastOpeningApp = "" + openingApp;
319 mLastClosingApp = "" + closingApp;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800320 }
321
322 boolean isReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800323 return mAppTransitionState == APP_STATE_READY
324 || mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800325 }
326
Craig Mautnerae446592012-12-06 19:05:05 -0800327 void setReady() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800328 mAppTransitionState = APP_STATE_READY;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100329 fetchAppTransitionSpecsFromFuture();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800330 }
331
332 boolean isRunning() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800333 return mAppTransitionState == APP_STATE_RUNNING;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800334 }
335
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800336 void setIdle() {
337 mAppTransitionState = APP_STATE_IDLE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800338 }
339
340 boolean isTimeout() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800341 return mAppTransitionState == APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800342 }
343
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800344 void setTimeout() {
345 mAppTransitionState = APP_STATE_TIMEOUT;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800346 }
347
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700348 Bitmap getAppTransitionThumbnailHeader(int taskId) {
349 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800350 if (spec == null) {
351 spec = mDefaultNextAppTransitionAnimationSpec;
352 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700353 return spec != null ? spec.bitmap : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800354 }
355
Winson Chunga4ccb862014-08-22 15:26:27 -0700356 /** Returns whether the next thumbnail transition is aspect scaled up. */
357 boolean isNextThumbnailTransitionAspectScaled() {
358 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
359 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
360 }
361
362 /** Returns whether the next thumbnail transition is scaling up. */
363 boolean isNextThumbnailTransitionScaleUp() {
364 return mNextAppTransitionScaleUp;
365 }
366
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800367 boolean isNextAppTransitionThumbnailUp() {
368 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
369 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP;
370 }
371
372 boolean isNextAppTransitionThumbnailDown() {
373 return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN ||
374 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
375 }
376
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100377 /**
378 * @return true if and only if we are currently fetching app transition specs from the future
379 * passed into {@link #overridePendingAppTransitionMultiThumbFuture}
380 */
381 boolean isFetchingAppTransitionsSpecs() {
382 return mNextAppTransitionAnimationsSpecsPending;
383 }
384
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700385 private boolean prepare() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800386 if (!isRunning()) {
387 mAppTransitionState = APP_STATE_IDLE;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100388 notifyAppTransitionPendingLocked();
Jorim Jaggif97ed922016-02-18 18:57:07 -0800389 mLastHadClipReveal = false;
390 mLastClipRevealMaxTranslation = 0;
391 mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION;
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700392 return true;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800393 }
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -0700394 return false;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800395 }
396
Jorim Jaggife762342016-10-13 14:33:27 +0200397 /**
398 * @return bit-map of WindowManagerPolicy#FINISH_LAYOUT_REDO_* to indicate whether another
399 * layout pass needs to be done
400 */
401 int goodToGo(int transit, AppWindowAnimator topOpeningAppAnimator,
402 AppWindowAnimator topClosingAppAnimator, ArraySet<AppWindowToken> openingApps,
403 ArraySet<AppWindowToken> closingApps) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800404 mNextAppTransition = TRANSIT_UNSET;
Jorim Jaggife762342016-10-13 14:33:27 +0200405 mNextAppTransitionFlags = 0;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800406 mAppTransitionState = APP_STATE_RUNNING;
Jorim Jaggife762342016-10-13 14:33:27 +0200407 int redoLayout = notifyAppTransitionStartingLocked(transit,
Jorim Jaggi42625d1b2016-02-11 20:11:07 -0800408 topOpeningAppAnimator != null ? topOpeningAppAnimator.mAppToken.token : null,
409 topClosingAppAnimator != null ? topClosingAppAnimator.mAppToken.token : null,
410 topOpeningAppAnimator != null ? topOpeningAppAnimator.animation : null,
411 topClosingAppAnimator != null ? topClosingAppAnimator.animation : null);
412 mService.getDefaultDisplayContentLocked().getDockedDividerController()
Jorim Jaggife762342016-10-13 14:33:27 +0200413 .notifyAppTransitionStarting(openingApps, transit);
Jorim Jaggi363ab982016-04-26 19:51:20 -0700414
415 // Prolong the start for the transition when docking a task from recents, unless recents
416 // ended it already then we don't need to wait.
Jorim Jaggife762342016-10-13 14:33:27 +0200417 if (transit == TRANSIT_DOCK_TASK_FROM_RECENTS && !mProlongedAnimationsEnded) {
Jorim Jaggi363ab982016-04-26 19:51:20 -0700418 for (int i = openingApps.size() - 1; i >= 0; i--) {
419 final AppWindowAnimator appAnimator = openingApps.valueAt(i).mAppAnimator;
420 appAnimator.startProlongAnimation(PROLONG_ANIMATION_AT_START);
421 }
422 }
Jorim Jaggife762342016-10-13 14:33:27 +0200423 return redoLayout;
Jorim Jaggi363ab982016-04-26 19:51:20 -0700424 }
425
426 /**
427 * Let the transitions manager know that the somebody wanted to end the prolonged animations.
428 */
429 void notifyProlongedAnimationsEnded() {
430 mProlongedAnimationsEnded = true;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800431 }
432
433 void clear() {
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800434 mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800435 mNextAppTransitionPackage = null;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700436 mNextAppTransitionAnimationsSpecs.clear();
Jorim Jaggi65193992015-11-23 16:49:59 -0800437 mNextAppTransitionAnimationsSpecsFuture = null;
438 mDefaultNextAppTransitionAnimationSpec = null;
439 mAnimationFinishedCallback = null;
Jorim Jaggi363ab982016-04-26 19:51:20 -0700440 mProlongedAnimationsEnded = false;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800441 }
442
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800443 void freeze() {
Jorim Jaggife762342016-10-13 14:33:27 +0200444 final int transit = mNextAppTransition;
445 setAppTransition(AppTransition.TRANSIT_UNSET, 0 /* flags */);
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800446 clear();
447 setReady();
Jorim Jaggife762342016-10-13 14:33:27 +0200448 notifyAppTransitionCancelledLocked(transit);
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100449 }
450
451 void registerListenerLocked(AppTransitionListener listener) {
452 mListeners.add(listener);
453 }
454
Wale Ogunwalea48eadb2015-05-14 17:43:12 -0700455 public void notifyAppTransitionFinishedLocked(IBinder token) {
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100456 for (int i = 0; i < mListeners.size(); i++) {
457 mListeners.get(i).onAppTransitionFinishedLocked(token);
458 }
459 }
460
461 private void notifyAppTransitionPendingLocked() {
462 for (int i = 0; i < mListeners.size(); i++) {
463 mListeners.get(i).onAppTransitionPendingLocked();
464 }
465 }
466
Jorim Jaggife762342016-10-13 14:33:27 +0200467 private void notifyAppTransitionCancelledLocked(int transit) {
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100468 for (int i = 0; i < mListeners.size(); i++) {
Jorim Jaggife762342016-10-13 14:33:27 +0200469 mListeners.get(i).onAppTransitionCancelledLocked(transit);
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100470 }
471 }
472
Jorim Jaggife762342016-10-13 14:33:27 +0200473 private int notifyAppTransitionStartingLocked(int transit, IBinder openToken,
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100474 IBinder closeToken, Animation openAnimation, Animation closeAnimation) {
Jorim Jaggife762342016-10-13 14:33:27 +0200475 int redoLayout = 0;
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100476 for (int i = 0; i < mListeners.size(); i++) {
Jorim Jaggife762342016-10-13 14:33:27 +0200477 redoLayout |= mListeners.get(i).onAppTransitionStartingLocked(transit, openToken,
478 closeToken, openAnimation, closeAnimation);
Jorim Jaggi77ba4802015-02-18 13:57:50 +0100479 }
Jorim Jaggife762342016-10-13 14:33:27 +0200480 return redoLayout;
Craig Mautner9a29a5d2012-12-27 19:03:40 -0800481 }
482
Craig Mautner164d4bb2012-11-26 13:51:23 -0800483 private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
484 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
485 + (lp != null ? lp.packageName : null)
486 + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null));
487 if (lp != null && lp.windowAnimations != 0) {
488 // If this is a system resource, don't try to load it from the
489 // application resources. It is nice to avoid loading application
490 // resources if we can.
491 String packageName = lp.packageName != null ? lp.packageName : "android";
492 int resId = lp.windowAnimations;
493 if ((resId&0xFF000000) == 0x01000000) {
494 packageName = "android";
495 }
496 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
497 + packageName);
498 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700499 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800500 }
501 return null;
502 }
503
504 private AttributeCache.Entry getCachedAnimations(String packageName, int resId) {
505 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package="
506 + packageName + " resId=0x" + Integer.toHexString(resId));
507 if (packageName != null) {
508 if ((resId&0xFF000000) == 0x01000000) {
509 packageName = "android";
510 }
511 if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package="
512 + packageName);
513 return AttributeCache.instance().get(packageName, resId,
Amith Yamasani4befbec2013-07-10 16:18:01 -0700514 com.android.internal.R.styleable.WindowAnimation, mCurrentUserId);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800515 }
516 return null;
517 }
518
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700519 Animation loadAnimationAttr(WindowManager.LayoutParams lp, int animAttr) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800520 int anim = 0;
521 Context context = mContext;
522 if (animAttr >= 0) {
523 AttributeCache.Entry ent = getCachedAnimations(lp);
524 if (ent != null) {
525 context = ent.context;
526 anim = ent.array.getResourceId(animAttr, 0);
527 }
528 }
529 if (anim != 0) {
530 return AnimationUtils.loadAnimation(context, anim);
531 }
532 return null;
533 }
534
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700535 Animation loadAnimationRes(WindowManager.LayoutParams lp, int resId) {
536 Context context = mContext;
537 if (resId >= 0) {
538 AttributeCache.Entry ent = getCachedAnimations(lp);
539 if (ent != null) {
540 context = ent.context;
541 }
542 return AnimationUtils.loadAnimation(context, resId);
543 }
544 return null;
545 }
546
547 private Animation loadAnimationRes(String packageName, int resId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -0800548 int anim = 0;
549 Context context = mContext;
550 if (resId >= 0) {
551 AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
552 if (ent != null) {
553 context = ent.context;
554 anim = resId;
555 }
556 }
557 if (anim != 0) {
558 return AnimationUtils.loadAnimation(context, anim);
559 }
560 return null;
561 }
562
Craig Mautner164d4bb2012-11-26 13:51:23 -0800563 /**
564 * Compute the pivot point for an animation that is scaling from a small
565 * rect on screen to a larger rect. The pivot point varies depending on
566 * the distance between the inner and outer edges on both sides. This
567 * function computes the pivot point for one dimension.
568 * @param startPos Offset from left/top edge of outer rectangle to
569 * left/top edge of inner rectangle.
570 * @param finalScale The scaling factor between the size of the outer
571 * and inner rectangles.
572 */
573 private static float computePivot(int startPos, float finalScale) {
Jorim Jaggic6c89a82016-01-28 17:48:21 -0800574
575 /*
576 Theorem of intercepting lines:
577
578 + + +-----------------------------------------------+
579 | | | |
580 | | | |
581 | | | |
582 | | | |
583 x | y | | |
584 | | | |
585 | | | |
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 p ++
626
627 scale = (x - y) / x
628 <=> x = -y / (scale - 1)
629 */
Craig Mautner164d4bb2012-11-26 13:51:23 -0800630 final float denom = finalScale-1;
631 if (Math.abs(denom) < .0001f) {
632 return startPos;
633 }
634 return -startPos / denom;
635 }
636
Filip Gruszczynski541f92c2015-10-25 17:15:06 -0700637 private Animation createScaleUpAnimationLocked(int transit, boolean enter,
638 Rect containingFrame) {
639 Animation a;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700640 getDefaultNextAppTransitionStartRect(mTmpRect);
Filip Gruszczynski541f92c2015-10-25 17:15:06 -0700641 final int appWidth = containingFrame.width();
642 final int appHeight = containingFrame.height();
Craig Mautner164d4bb2012-11-26 13:51:23 -0800643 if (enter) {
644 // Entering app zooms out from the center of the initial rect.
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700645 float scaleW = mTmpRect.width() / (float) appWidth;
646 float scaleH = mTmpRect.height() / (float) appHeight;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800647 Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700648 computePivot(mTmpRect.left, scaleW),
Winson4c3fecd2016-07-13 12:29:48 -0700649 computePivot(mTmpRect.top, scaleH));
Craig Mautner321bdf52012-12-18 09:53:24 -0800650 scale.setInterpolator(mDecelerateInterpolator);
651
Craig Mautner164d4bb2012-11-26 13:51:23 -0800652 Animation alpha = new AlphaAnimation(0, 1);
Winson Chunga4ccb862014-08-22 15:26:27 -0700653 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
Craig Mautner321bdf52012-12-18 09:53:24 -0800654
655 AnimationSet set = new AnimationSet(false);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800656 set.addAnimation(scale);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800657 set.addAnimation(alpha);
658 set.setDetachWallpaper(true);
659 a = set;
Craig Mautner4b71aa12012-12-27 17:20:01 -0800660 } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
661 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800662 // If we are on top of the wallpaper, we need an animation that
663 // correctly handles the wallpaper staying static behind all of
664 // the animated elements. To do this, will just have the existing
665 // element fade out.
666 a = new AlphaAnimation(1, 0);
667 a.setDetachWallpaper(true);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800668 } else {
Craig Mautner321bdf52012-12-18 09:53:24 -0800669 // For normal animations, the exiting element just holds in place.
670 a = new AlphaAnimation(1, 1);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800671 }
Craig Mautner321bdf52012-12-18 09:53:24 -0800672
673 // Pick the desired duration. If this is an inter-activity transition,
674 // it is the standard duration for that. Otherwise we use the longer
675 // task transition duration.
676 final long duration;
677 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800678 case TRANSIT_ACTIVITY_OPEN:
679 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800680 duration = mConfigShortAnimTime;
681 break;
682 default:
683 duration = DEFAULT_APP_TRANSITION_DURATION;
684 break;
685 }
686 a.setDuration(duration);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800687 a.setFillAfter(true);
Craig Mautner321bdf52012-12-18 09:53:24 -0800688 a.setInterpolator(mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800689 a.initialize(appWidth, appHeight, appWidth, appHeight);
690 return a;
691 }
692
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700693 private void getDefaultNextAppTransitionStartRect(Rect rect) {
694 if (mDefaultNextAppTransitionAnimationSpec == null ||
695 mDefaultNextAppTransitionAnimationSpec.rect == null) {
696 Slog.wtf(TAG, "Starting rect for app requested, but none available", new Throwable());
697 rect.setEmpty();
698 } else {
699 rect.set(mDefaultNextAppTransitionAnimationSpec.rect);
700 }
701 }
702
703 void getNextAppTransitionStartRect(int taskId, Rect rect) {
704 AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800705 if (spec == null) {
706 spec = mDefaultNextAppTransitionAnimationSpec;
707 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700708 if (spec == null || spec.rect == null) {
709 Slog.wtf(TAG, "Starting rect for task: " + taskId + " requested, but not available",
710 new Throwable());
711 rect.setEmpty();
712 } else {
713 rect.set(spec.rect);
714 }
715 }
716
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800717 private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height,
718 Bitmap bitmap) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700719 mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */,
Filip Gruszczynski7248c562015-11-09 13:05:40 -0800720 bitmap, new Rect(left, top, left + width, top + height));
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700721 }
722
Jorim Jaggif97ed922016-02-18 18:57:07 -0800723 /**
724 * @return the duration of the last clip reveal animation
725 */
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800726 long getLastClipRevealTransitionDuration() {
727 return mLastClipRevealTransitionDuration;
728 }
729
730 /**
Jorim Jaggif97ed922016-02-18 18:57:07 -0800731 * @return the maximum distance the app surface is traveling of the last clip reveal animation
732 */
733 int getLastClipRevealMaxTranslation() {
734 return mLastClipRevealMaxTranslation;
735 }
736
737 /**
738 * @return true if in the last app transition had a clip reveal animation, false otherwise
739 */
740 boolean hadClipRevealAnimation() {
741 return mLastHadClipReveal;
742 }
743
744 /**
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800745 * Calculates the duration for the clip reveal animation. If the clip is "cut off", meaning that
746 * the start rect is outside of the target rect, and there is a lot of movement going on.
747 *
748 * @param cutOff whether the start rect was not fully contained by the end rect
749 * @param translationX the total translation the surface moves in x direction
750 * @param translationY the total translation the surfaces moves in y direction
751 * @param displayFrame our display frame
752 *
753 * @return the duration of the clip reveal animation, in milliseconds
754 */
755 private long calculateClipRevealTransitionDuration(boolean cutOff, float translationX,
756 float translationY, Rect displayFrame) {
757 if (!cutOff) {
758 return DEFAULT_APP_TRANSITION_DURATION;
759 }
760 final float fraction = Math.max(Math.abs(translationX) / displayFrame.width(),
761 Math.abs(translationY) / displayFrame.height());
762 return (long) (DEFAULT_APP_TRANSITION_DURATION + fraction *
763 (MAX_CLIP_REVEAL_TRANSITION_DURATION - DEFAULT_APP_TRANSITION_DURATION));
764 }
765
766 private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame,
767 Rect displayFrame) {
Chet Haase10e23ab2015-02-11 15:08:38 -0800768 final Animation anim;
769 if (enter) {
Craig Mautner80b1f642015-04-22 10:59:09 -0700770 final int appWidth = appFrame.width();
771 final int appHeight = appFrame.height();
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800772
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700773 // mTmpRect will contain an area around the launcher icon that was pressed. We will
Filip Gruszczynski82861362015-10-16 14:21:09 -0700774 // clip reveal from that area in the final area of the app.
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700775 getDefaultNextAppTransitionStartRect(mTmpRect);
Craig Mautner80b1f642015-04-22 10:59:09 -0700776
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700777 float t = 0f;
778 if (appHeight > 0) {
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800779 t = (float) mTmpRect.top / displayFrame.height();
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700780 }
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800781 int translationY = mClipRevealTranslationY + (int)(displayFrame.height() / 7f * t);
782 int translationX = 0;
783 int translationYCorrection = translationY;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700784 int centerX = mTmpRect.centerX();
785 int centerY = mTmpRect.centerY();
786 int halfWidth = mTmpRect.width() / 2;
787 int halfHeight = mTmpRect.height() / 2;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800788 int clipStartX = centerX - halfWidth - appFrame.left;
789 int clipStartY = centerY - halfHeight - appFrame.top;
790 boolean cutOff = false;
791
792 // If the starting rectangle is fully or partially outside of the target rectangle, we
793 // need to start the clipping at the edge and then achieve the rest with translation
794 // and extending the clip rect from that edge.
795 if (appFrame.top > centerY - halfHeight) {
796 translationY = (centerY - halfHeight) - appFrame.top;
797 translationYCorrection = 0;
798 clipStartY = 0;
799 cutOff = true;
800 }
801 if (appFrame.left > centerX - halfWidth) {
802 translationX = (centerX - halfWidth) - appFrame.left;
803 clipStartX = 0;
804 cutOff = true;
805 }
806 if (appFrame.right < centerX + halfWidth) {
807 translationX = (centerX + halfWidth) - appFrame.right;
808 clipStartX = appWidth - mTmpRect.width();
809 cutOff = true;
810 }
811 final long duration = calculateClipRevealTransitionDuration(cutOff, translationX,
812 translationY, displayFrame);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700813
814 // Clip third of the from size of launch icon, expand to full width/height
Chet Haase10e23ab2015-02-11 15:08:38 -0800815 Animation clipAnimLR = new ClipRectLRAnimation(
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800816 clipStartX, clipStartX + mTmpRect.width(), 0, appWidth);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700817 clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800818 clipAnimLR.setDuration((long) (duration / 2.5f));
Filip Gruszczynski82861362015-10-16 14:21:09 -0700819
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800820 TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0);
821 translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR
822 : mLinearOutSlowInInterpolator);
823 translate.setDuration(duration);
Chet Haase10e23ab2015-02-11 15:08:38 -0800824
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800825 Animation clipAnimTB = new ClipRectTBAnimation(
826 clipStartY, clipStartY + mTmpRect.height(),
827 0, appHeight,
828 translationYCorrection, 0,
829 mLinearOutSlowInInterpolator);
830 clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
831 clipAnimTB.setDuration(duration);
Chet Haase10e23ab2015-02-11 15:08:38 -0800832
833 // Quick fade-in from icon to app window
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800834 final long alphaDuration = duration / 4;
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700835 AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
Chet Haase10e23ab2015-02-11 15:08:38 -0800836 alpha.setDuration(alphaDuration);
Jorim Jaggi1d763a62015-06-02 17:07:39 -0700837 alpha.setInterpolator(mLinearOutSlowInInterpolator);
Chet Haase10e23ab2015-02-11 15:08:38 -0800838
839 AnimationSet set = new AnimationSet(false);
840 set.addAnimation(clipAnimLR);
841 set.addAnimation(clipAnimTB);
Filip Gruszczynski82861362015-10-16 14:21:09 -0700842 set.addAnimation(translate);
Chet Haase10e23ab2015-02-11 15:08:38 -0800843 set.addAnimation(alpha);
Filip Gruszczynski9e2cf5b2015-07-31 12:20:40 -0700844 set.setZAdjustment(Animation.ZORDER_TOP);
Chet Haase10e23ab2015-02-11 15:08:38 -0800845 set.initialize(appWidth, appHeight, appWidth, appHeight);
846 anim = set;
Jorim Jaggif97ed922016-02-18 18:57:07 -0800847 mLastHadClipReveal = true;
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -0800848 mLastClipRevealTransitionDuration = duration;
Jorim Jaggif97ed922016-02-18 18:57:07 -0800849
850 // If the start rect was full inside the target rect (cutOff == false), we don't need
851 // to store the translation, because it's only used if cutOff == true.
852 mLastClipRevealMaxTranslation = cutOff
853 ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0;
Chet Haase10e23ab2015-02-11 15:08:38 -0800854 } else {
855 final long duration;
856 switch (transit) {
857 case TRANSIT_ACTIVITY_OPEN:
858 case TRANSIT_ACTIVITY_CLOSE:
859 duration = mConfigShortAnimTime;
860 break;
861 default:
862 duration = DEFAULT_APP_TRANSITION_DURATION;
863 break;
864 }
865 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
866 transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
867 // If we are on top of the wallpaper, we need an animation that
868 // correctly handles the wallpaper staying static behind all of
869 // the animated elements. To do this, will just have the existing
870 // element fade out.
871 anim = new AlphaAnimation(1, 0);
872 anim.setDetachWallpaper(true);
873 } else {
874 // For normal animations, the exiting element just holds in place.
875 anim = new AlphaAnimation(1, 1);
876 }
877 anim.setInterpolator(mDecelerateInterpolator);
878 anim.setDuration(duration);
879 anim.setFillAfter(true);
880 }
881 return anim;
882 }
883
Winson Chung399f6202014-03-19 10:47:20 -0700884 /**
885 * Prepares the specified animation with a standard duration, interpolator, etc.
886 */
Winson Chung5393dff2014-05-08 14:25:43 -0700887 Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight,
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100888 long duration, Interpolator interpolator) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700889 if (duration > 0) {
890 a.setDuration(duration);
891 }
Winson Chung5393dff2014-05-08 14:25:43 -0700892 a.setFillAfter(true);
Jorim Jaggic69bd222016-03-15 14:38:37 +0100893 if (interpolator != null) {
894 a.setInterpolator(interpolator);
895 }
Winson Chung5393dff2014-05-08 14:25:43 -0700896 a.initialize(appWidth, appHeight, appWidth, appHeight);
897 return a;
898 }
899
900 /**
901 * Prepares the specified animation with a standard duration, interpolator, etc.
902 */
Winson Chung399f6202014-03-19 10:47:20 -0700903 Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) {
Craig Mautner321bdf52012-12-18 09:53:24 -0800904 // Pick the desired duration. If this is an inter-activity transition,
905 // it is the standard duration for that. Otherwise we use the longer
906 // task transition duration.
Winson Chung5393dff2014-05-08 14:25:43 -0700907 final int duration;
Craig Mautner321bdf52012-12-18 09:53:24 -0800908 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -0800909 case TRANSIT_ACTIVITY_OPEN:
910 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner321bdf52012-12-18 09:53:24 -0800911 duration = mConfigShortAnimTime;
912 break;
913 default:
914 duration = DEFAULT_APP_TRANSITION_DURATION;
915 break;
916 }
Winson Chung5393dff2014-05-08 14:25:43 -0700917 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration,
918 mDecelerateInterpolator);
Craig Mautner164d4bb2012-11-26 13:51:23 -0800919 }
920
Winson Chung399f6202014-03-19 10:47:20 -0700921 /**
922 * Return the current thumbnail transition state.
923 */
924 int getThumbnailTransitionState(boolean enter) {
925 if (enter) {
926 if (mNextAppTransitionScaleUp) {
927 return THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
928 } else {
929 return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN;
930 }
931 } else {
932 if (mNextAppTransitionScaleUp) {
933 return THUMBNAIL_TRANSITION_EXIT_SCALE_UP;
934 } else {
935 return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN;
936 }
937 }
938 }
939
940 /**
941 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700942 * when a thumbnail is specified with the pending animation override.
Winson Chung399f6202014-03-19 10:47:20 -0700943 */
Jorim Jaggide63d442016-03-14 14:56:56 +0100944 Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, @Nullable Rect contentInsets,
Winsonb2024762016-04-05 17:32:30 -0700945 Bitmap thumbnailHeader, final int taskId, int uiMode, int orientation) {
Winson Chung399f6202014-03-19 10:47:20 -0700946 Animation a;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700947 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chung399f6202014-03-19 10:47:20 -0700948 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700949 final int thumbHeightI = thumbnailHeader.getHeight();
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700950 final int appWidth = appRect.width();
Winson Chung399f6202014-03-19 10:47:20 -0700951
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -0700952 float scaleW = appWidth / thumbWidth;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -0700953 getNextAppTransitionStartRect(taskId, mTmpRect);
Jorim Jaggi09072002016-03-25 16:48:42 -0700954 final float fromX;
Manu Cornet57b61492017-01-24 18:19:05 +0900955 float fromY;
Jorim Jaggi09072002016-03-25 16:48:42 -0700956 final float toX;
Manu Cornet57b61492017-01-24 18:19:05 +0900957 float toY;
Jorim Jaggi09072002016-03-25 16:48:42 -0700958 final float pivotX;
959 final float pivotY;
Manu Cornetd7376802017-01-13 13:44:07 -0800960 if (shouldScaleDownThumbnailTransition(uiMode, orientation)) {
Jorim Jaggi09072002016-03-25 16:48:42 -0700961 fromX = mTmpRect.left;
962 fromY = mTmpRect.top;
963
964 // For the curved translate animation to work, the pivot points needs to be at the
965 // same absolute position as the one from the real surface.
966 toX = mTmpRect.width() / 2 * (scaleW - 1f) + appRect.left;
967 toY = appRect.height() / 2 * (1 - 1 / scaleW) + appRect.top;
968 pivotX = mTmpRect.width() / 2;
969 pivotY = appRect.height() / 2 / scaleW;
Manu Cornet57b61492017-01-24 18:19:05 +0900970 if (mGridLayoutRecentsEnabled) {
971 // In the grid layout, the header is displayed above the thumbnail instead of
972 // overlapping it.
973 fromY -= thumbHeightI;
974 toY -= thumbHeightI * scaleW;
975 }
Jorim Jaggi09072002016-03-25 16:48:42 -0700976 } else {
977 pivotX = 0;
978 pivotY = 0;
979 fromX = mTmpRect.left;
980 fromY = mTmpRect.top;
981 toX = appRect.left;
982 toY = appRect.top;
983 }
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100984 final long duration = getAspectScaleDuration();
985 final Interpolator interpolator = getAspectScaleInterpolator();
Winson Chung399f6202014-03-19 10:47:20 -0700986 if (mNextAppTransitionScaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700987 // Animation up from the thumbnail to the full screen
Jorim Jaggi8448f332016-03-14 17:50:37 +0100988 Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, pivotX, pivotY);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100989 scale.setInterpolator(interpolator);
990 scale.setDuration(duration);
Jorim Jaggic6c89a82016-01-28 17:48:21 -0800991 Animation alpha = new AlphaAnimation(1f, 0f);
Jorim Jaggic69bd222016-03-15 14:38:37 +0100992 alpha.setInterpolator(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS
993 ? THUMBNAIL_DOCK_INTERPOLATOR : mThumbnailFadeOutInterpolator);
994 alpha.setDuration(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS
995 ? duration / 2
996 : duration);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +0100997 Animation translate = createCurvedMotion(fromX, toX, fromY, toY);
998 translate.setInterpolator(interpolator);
999 translate.setDuration(duration);
Winson Chung399f6202014-03-19 10:47:20 -07001000
Jorim Jaggide63d442016-03-14 14:56:56 +01001001 mTmpFromClipRect.set(0, 0, thumbWidthI, thumbHeightI);
1002 mTmpToClipRect.set(appRect);
1003
1004 // Containing frame is in screen space, but we need the clip rect in the
1005 // app space.
1006 mTmpToClipRect.offsetTo(0, 0);
Jorim Jaggic69bd222016-03-15 14:38:37 +01001007 mTmpToClipRect.right = (int) (mTmpToClipRect.right / scaleW);
1008 mTmpToClipRect.bottom = (int) (mTmpToClipRect.bottom / scaleW);
Jorim Jaggide63d442016-03-14 14:56:56 +01001009
1010 if (contentInsets != null) {
Jorim Jaggi8448f332016-03-14 17:50:37 +01001011 mTmpToClipRect.inset((int) (-contentInsets.left * scaleW),
1012 (int) (-contentInsets.top * scaleW),
1013 (int) (-contentInsets.right * scaleW),
1014 (int) (-contentInsets.bottom * scaleW));
Jorim Jaggide63d442016-03-14 14:56:56 +01001015 }
1016
1017 Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001018 clipAnim.setInterpolator(interpolator);
1019 clipAnim.setDuration(duration);
Jorim Jaggide63d442016-03-14 14:56:56 +01001020
Winson Chung399f6202014-03-19 10:47:20 -07001021 // This AnimationSet uses the Interpolators assigned above.
1022 AnimationSet set = new AnimationSet(false);
1023 set.addAnimation(scale);
Manu Cornet57b61492017-01-24 18:19:05 +09001024 if (!mGridLayoutRecentsEnabled) {
1025 // In the grid layout, the header should be shown for the whole animation.
1026 set.addAnimation(alpha);
1027 }
Winson Chunga4ccb862014-08-22 15:26:27 -07001028 set.addAnimation(translate);
Jorim Jaggide63d442016-03-14 14:56:56 +01001029 set.addAnimation(clipAnim);
Winson Chung399f6202014-03-19 10:47:20 -07001030 a = set;
1031 } else {
Winson Chunga4ccb862014-08-22 15:26:27 -07001032 // Animation down from the full screen to the thumbnail
Jorim Jaggi8448f332016-03-14 17:50:37 +01001033 Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, pivotX, pivotY);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001034 scale.setInterpolator(interpolator);
1035 scale.setDuration(duration);
Winson Chunga4ccb862014-08-22 15:26:27 -07001036 Animation alpha = new AlphaAnimation(0f, 1f);
1037 alpha.setInterpolator(mThumbnailFadeInInterpolator);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001038 alpha.setDuration(duration);
1039 Animation translate = createCurvedMotion(toX, fromX, toY, fromY);
1040 translate.setInterpolator(interpolator);
1041 translate.setDuration(duration);
Winson Chung399f6202014-03-19 10:47:20 -07001042
Winson Chunga4ccb862014-08-22 15:26:27 -07001043 // This AnimationSet uses the Interpolators assigned above.
1044 AnimationSet set = new AnimationSet(false);
1045 set.addAnimation(scale);
Manu Cornet57b61492017-01-24 18:19:05 +09001046 if (!mGridLayoutRecentsEnabled) {
1047 // In the grid layout, the header should be shown for the whole animation.
1048 set.addAnimation(alpha);
1049 }
Winson Chunga4ccb862014-08-22 15:26:27 -07001050 set.addAnimation(translate);
1051 a = set;
1052
1053 }
Filip Gruszczynskidfb25d32015-08-14 11:06:18 -07001054 return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0,
Jorim Jaggic69bd222016-03-15 14:38:37 +01001055 null);
Winson Chung399f6202014-03-19 10:47:20 -07001056 }
1057
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001058 private Animation createCurvedMotion(float fromX, float toX, float fromY, float toY) {
1059
1060 // Almost no x-change - use linear animation
Jorim Jaggic69bd222016-03-15 14:38:37 +01001061 if (Math.abs(toX - fromX) < 1f || mNextAppTransition != TRANSIT_DOCK_TASK_FROM_RECENTS) {
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001062 return new TranslateAnimation(fromX, toX, fromY, toY);
1063 } else {
1064 final Path path = createCurvedPath(fromX, toX, fromY, toY);
1065 return new CurvedTranslateAnimation(path);
1066 }
1067 }
1068
1069 private Path createCurvedPath(float fromX, float toX, float fromY, float toY) {
1070 final Path path = new Path();
1071 path.moveTo(fromX, fromY);
Jorim Jaggi1f458fb2016-03-25 17:36:37 -07001072
1073 if (fromY > toY) {
1074 // If the object needs to go up, move it in horizontal direction first, then vertical.
1075 path.cubicTo(fromX, fromY, toX, 0.9f * fromY + 0.1f * toY, toX, toY);
1076 } else {
1077 // If the object needs to go down, move it in vertical direction first, then horizontal.
1078 path.cubicTo(fromX, fromY, fromX, 0.1f * fromY + 0.9f * toY, toX, toY);
1079 }
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001080 return path;
1081 }
1082
1083 private long getAspectScaleDuration() {
1084 if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) {
Jorim Jaggic69bd222016-03-15 14:38:37 +01001085 return (long) (THUMBNAIL_APP_TRANSITION_DURATION * 1.35f);
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001086 } else {
1087 return THUMBNAIL_APP_TRANSITION_DURATION;
1088 }
1089 }
1090
1091 private Interpolator getAspectScaleInterpolator() {
1092 if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) {
1093 return mFastOutSlowInInterpolator;
1094 } else {
1095 return TOUCH_RESPONSE_INTERPOLATOR;
1096 }
1097 }
1098
Winson Chung399f6202014-03-19 10:47:20 -07001099 /**
1100 * This alternate animation is created when we are doing a thumbnail transition, for the
1101 * activity that is leaving, and the activity that is entering.
1102 */
Winson Chunga4ccb862014-08-22 15:26:27 -07001103 Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState,
Winsonb2024762016-04-05 17:32:30 -07001104 int uiMode, int orientation, int transit, Rect containingFrame, Rect contentInsets,
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001105 @Nullable Rect surfaceInsets, boolean freeform, int taskId) {
Winson Chung399f6202014-03-19 10:47:20 -07001106 Animation a;
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001107 final int appWidth = containingFrame.width();
1108 final int appHeight = containingFrame.height();
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001109 getDefaultNextAppTransitionStartRect(mTmpRect);
1110 final int thumbWidthI = mTmpRect.width();
Winson Chung399f6202014-03-19 10:47:20 -07001111 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001112 final int thumbHeightI = mTmpRect.height();
Winson Chung399f6202014-03-19 10:47:20 -07001113 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
Winsoncbb625b2016-07-06 15:24:15 -07001114 final int thumbStartX = mTmpRect.left - containingFrame.left - contentInsets.left;
Winson21700932016-03-24 17:26:23 -07001115 final int thumbStartY = mTmpRect.top - containingFrame.top;
Winson Chung399f6202014-03-19 10:47:20 -07001116
1117 switch (thumbTransitState) {
Jorim Jaggi8448f332016-03-14 17:50:37 +01001118 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP:
1119 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
1120 final boolean scaleUp = thumbTransitState == THUMBNAIL_TRANSITION_ENTER_SCALE_UP;
1121 if (freeform && scaleUp) {
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001122 a = createAspectScaledThumbnailEnterFreeformAnimationLocked(
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001123 containingFrame, surfaceInsets, taskId);
Jorim Jaggi8448f332016-03-14 17:50:37 +01001124 } else if (freeform) {
1125 a = createAspectScaledThumbnailExitFreeformAnimationLocked(
1126 containingFrame, surfaceInsets, taskId);
Winson Chung2820c452014-04-15 15:34:44 -07001127 } else {
Winson21700932016-03-24 17:26:23 -07001128 AnimationSet set = new AnimationSet(true);
1129
1130 // In portrait, we scale to fit the width
Filip Gruszczynskiefd3d1b2015-10-14 13:57:55 -07001131 mTmpFromClipRect.set(containingFrame);
Filip Gruszczynskiefd3d1b2015-10-14 13:57:55 -07001132 mTmpToClipRect.set(containingFrame);
Jorim Jaggic6c89a82016-01-28 17:48:21 -08001133
1134 // Containing frame is in screen space, but we need the clip rect in the
1135 // app space.
1136 mTmpFromClipRect.offsetTo(0, 0);
1137 mTmpToClipRect.offsetTo(0, 0);
1138
1139 // Exclude insets region from the source clip.
1140 mTmpFromClipRect.inset(contentInsets);
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001141 mNextAppTransitionInsets.set(contentInsets);
1142
Manu Cornetd7376802017-01-13 13:44:07 -08001143 if (shouldScaleDownThumbnailTransition(uiMode, orientation)) {
Jorim Jaggic69bd222016-03-15 14:38:37 +01001144 // We scale the width and clip to the top/left square
1145 float scale = thumbWidth /
1146 (appWidth - contentInsets.left - contentInsets.right);
Manu Cornetb68b7652017-01-23 19:37:53 +09001147 if (!mGridLayoutRecentsEnabled) {
1148 int unscaledThumbHeight = (int) (thumbHeight / scale);
1149 mTmpFromClipRect.bottom = mTmpFromClipRect.top + unscaledThumbHeight;
1150 }
Jorim Jaggic69bd222016-03-15 14:38:37 +01001151
1152 mNextAppTransitionInsets.set(contentInsets);
1153
Jorim Jaggi8448f332016-03-14 17:50:37 +01001154 Animation scaleAnim = new ScaleAnimation(
1155 scaleUp ? scale : 1, scaleUp ? 1 : scale,
1156 scaleUp ? scale : 1, scaleUp ? 1 : scale,
Jorim Jaggic69bd222016-03-15 14:38:37 +01001157 containingFrame.width() / 2f,
1158 containingFrame.height() / 2f + contentInsets.top);
Jorim Jaggi8448f332016-03-14 17:50:37 +01001159 final float targetX = (mTmpRect.left - containingFrame.left);
Jorim Jaggic69bd222016-03-15 14:38:37 +01001160 final float x = containingFrame.width() / 2f
1161 - containingFrame.width() / 2f * scale;
Jorim Jaggi8448f332016-03-14 17:50:37 +01001162 final float targetY = (mTmpRect.top - containingFrame.top);
Jorim Jaggic69bd222016-03-15 14:38:37 +01001163 final float y = containingFrame.height() / 2f
1164 - containingFrame.height() / 2f * scale;
Jorim Jaggi8448f332016-03-14 17:50:37 +01001165 final float startX = targetX - x;
1166 final float startY = targetY - y;
1167 Animation clipAnim = scaleUp
1168 ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)
1169 : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect);
1170 Animation translateAnim = scaleUp
Jorim Jaggic69bd222016-03-15 14:38:37 +01001171 ? createCurvedMotion(startX, 0, startY - contentInsets.top, 0)
1172 : createCurvedMotion(0, startX, 0, startY - contentInsets.top);
1173
Winson21700932016-03-24 17:26:23 -07001174 set.addAnimation(clipAnim);
1175 set.addAnimation(scaleAnim);
1176 set.addAnimation(translateAnim);
1177
1178 } else {
1179 // In landscape, we don't scale at all and only crop
1180 mTmpFromClipRect.bottom = mTmpFromClipRect.top + thumbHeightI;
1181 mTmpFromClipRect.right = mTmpFromClipRect.left + thumbWidthI;
1182
Jorim Jaggi8448f332016-03-14 17:50:37 +01001183 Animation clipAnim = scaleUp
1184 ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)
1185 : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect);
1186 Animation translateAnim = scaleUp
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001187 ? createCurvedMotion(thumbStartX, 0,
1188 thumbStartY - contentInsets.top, 0)
1189 : createCurvedMotion(0, thumbStartX, 0,
1190 thumbStartY - contentInsets.top);
Winson21700932016-03-24 17:26:23 -07001191
1192 set.addAnimation(clipAnim);
1193 set.addAnimation(translateAnim);
1194 }
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001195 a = set;
Winson21700932016-03-24 17:26:23 -07001196 a.setZAdjustment(Animation.ZORDER_TOP);
Winson Chung2820c452014-04-15 15:34:44 -07001197 }
Winson Chung399f6202014-03-19 10:47:20 -07001198 break;
1199 }
1200 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
Winson Chunga4ccb862014-08-22 15:26:27 -07001201 // Previous app window during the scale up
Winson Chung399f6202014-03-19 10:47:20 -07001202 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001203 // Fade out the source activity if we are animating to a wallpaper
Winson Chung399f6202014-03-19 10:47:20 -07001204 // activity.
1205 a = new AlphaAnimation(1, 0);
1206 } else {
Winson Chung399f6202014-03-19 10:47:20 -07001207 a = new AlphaAnimation(1, 1);
1208 }
1209 break;
1210 }
1211 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
Winson Chunga4ccb862014-08-22 15:26:27 -07001212 // Target app window during the scale down
1213 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
1214 // Fade in the destination activity if we are animating from a wallpaper
1215 // activity.
1216 a = new AlphaAnimation(0, 1);
1217 } else {
1218 a = new AlphaAnimation(1, 1);
1219 }
Winson Chung399f6202014-03-19 10:47:20 -07001220 break;
1221 }
Winson Chung399f6202014-03-19 10:47:20 -07001222 default:
1223 throw new RuntimeException("Invalid thumbnail transition state");
1224 }
1225
Jorim Jaggi787e9dd2016-03-15 10:52:40 +01001226 return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight,
1227 getAspectScaleDuration(), getAspectScaleInterpolator());
Winson Chung399f6202014-03-19 10:47:20 -07001228 }
1229
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001230 private Animation createAspectScaledThumbnailEnterFreeformAnimationLocked(Rect frame,
1231 @Nullable Rect surfaceInsets, int taskId) {
1232 getNextAppTransitionStartRect(taskId, mTmpRect);
1233 return createAspectScaledThumbnailFreeformAnimationLocked(mTmpRect, frame, surfaceInsets,
1234 true);
1235 }
1236
1237 private Animation createAspectScaledThumbnailExitFreeformAnimationLocked(Rect frame,
1238 @Nullable Rect surfaceInsets, int taskId) {
1239 getNextAppTransitionStartRect(taskId, mTmpRect);
1240 return createAspectScaledThumbnailFreeformAnimationLocked(frame, mTmpRect, surfaceInsets,
1241 false);
1242 }
1243
1244 private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame,
1245 Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) {
1246 final float sourceWidth = sourceFrame.width();
1247 final float sourceHeight = sourceFrame.height();
1248 final float destWidth = destFrame.width();
1249 final float destHeight = destFrame.height();
1250 final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth;
1251 final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight;
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001252 AnimationSet set = new AnimationSet(true);
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001253 final int surfaceInsetsH = surfaceInsets == null
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001254 ? 0 : surfaceInsets.left + surfaceInsets.right;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001255 final int surfaceInsetsV = surfaceInsets == null
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001256 ? 0 : surfaceInsets.top + surfaceInsets.bottom;
1257 // We want the scaling to happen from the center of the surface. In order to achieve that,
1258 // we need to account for surface insets that will be used to enlarge the surface.
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001259 final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2;
1260 final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2;
1261 final ScaleAnimation scale = enter ?
1262 new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter)
1263 : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter);
1264 final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2;
1265 final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2;
1266 final int destHCenter = destFrame.left + destFrame.width() / 2;
1267 final int destVCenter = destFrame.top + destFrame.height() / 2;
1268 final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter;
1269 final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter;
1270 final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0)
1271 : new TranslateAnimation(0, fromX, 0, fromY);
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001272 set.addAnimation(scale);
1273 set.addAnimation(translation);
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001274
1275 final IRemoteCallback callback = mAnimationFinishedCallback;
1276 if (callback != null) {
1277 set.setAnimationListener(new Animation.AnimationListener() {
1278 @Override
1279 public void onAnimationStart(Animation animation) { }
1280
1281 @Override
1282 public void onAnimationEnd(Animation animation) {
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08001283 mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget();
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001284 }
1285
1286 @Override
1287 public void onAnimationRepeat(Animation animation) { }
1288 });
1289 }
Filip Gruszczynski71b0d2d2015-08-12 18:52:26 -07001290 return set;
1291 }
1292
Winson Chung399f6202014-03-19 10:47:20 -07001293 /**
Winson Chunga4ccb862014-08-22 15:26:27 -07001294 * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001295 * when a thumbnail is specified with the pending animation override.
Winson Chunga4ccb862014-08-22 15:26:27 -07001296 */
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001297 Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit,
1298 Bitmap thumbnailHeader) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001299 Animation a;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001300 getDefaultNextAppTransitionStartRect(mTmpRect);
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001301 final int thumbWidthI = thumbnailHeader.getWidth();
Winson Chunga4ccb862014-08-22 15:26:27 -07001302 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001303 final int thumbHeightI = thumbnailHeader.getHeight();
Winson Chunga4ccb862014-08-22 15:26:27 -07001304 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
1305
1306 if (mNextAppTransitionScaleUp) {
1307 // Animation for the thumbnail zooming from its initial size to the full screen
1308 float scaleW = appWidth / thumbWidth;
1309 float scaleH = appHeight / thumbHeight;
1310 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001311 computePivot(mTmpRect.left, 1 / scaleW),
1312 computePivot(mTmpRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -07001313 scale.setInterpolator(mDecelerateInterpolator);
1314
1315 Animation alpha = new AlphaAnimation(1, 0);
1316 alpha.setInterpolator(mThumbnailFadeOutInterpolator);
1317
1318 // This AnimationSet uses the Interpolators assigned above.
1319 AnimationSet set = new AnimationSet(false);
1320 set.addAnimation(scale);
1321 set.addAnimation(alpha);
1322 a = set;
1323 } else {
1324 // Animation for the thumbnail zooming down from the full screen to its final size
1325 float scaleW = appWidth / thumbWidth;
1326 float scaleH = appHeight / thumbHeight;
1327 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001328 computePivot(mTmpRect.left, 1 / scaleW),
1329 computePivot(mTmpRect.top, 1 / scaleH));
Winson Chunga4ccb862014-08-22 15:26:27 -07001330 }
1331
1332 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
1333 }
1334
1335 /**
Winson Chung399f6202014-03-19 10:47:20 -07001336 * This animation is created when we are doing a thumbnail transition, for the activity that is
1337 * leaving, and the activity that is entering.
1338 */
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001339 Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame,
1340 int transit, int taskId) {
1341 final int appWidth = containingFrame.width();
1342 final int appHeight = containingFrame.height();
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001343 Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
Winson Chung399f6202014-03-19 10:47:20 -07001344 Animation a;
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001345 getDefaultNextAppTransitionStartRect(mTmpRect);
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001346 final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
Winson Chung399f6202014-03-19 10:47:20 -07001347 final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001348 final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
Winson Chung399f6202014-03-19 10:47:20 -07001349 final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
1350
1351 switch (thumbTransitState) {
1352 case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
1353 // Entering app scales up with the thumbnail
1354 float scaleW = thumbWidth / appWidth;
1355 float scaleH = thumbHeight / appHeight;
1356 a = new ScaleAnimation(scaleW, 1, scaleH, 1,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001357 computePivot(mTmpRect.left, scaleW),
1358 computePivot(mTmpRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -07001359 break;
1360 }
1361 case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: {
1362 // Exiting app while the thumbnail is scaling up should fade or stay in place
1363 if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
1364 // Fade out while bringing up selected activity. This keeps the
1365 // current activity from showing through a launching wallpaper
1366 // activity.
1367 a = new AlphaAnimation(1, 0);
1368 } else {
1369 // noop animation
1370 a = new AlphaAnimation(1, 1);
1371 }
1372 break;
1373 }
1374 case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: {
1375 // Entering the other app, it should just be visible while we scale the thumbnail
1376 // down above it
1377 a = new AlphaAnimation(1, 1);
1378 break;
1379 }
1380 case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
1381 // Exiting the current app, the app should scale down with the thumbnail
1382 float scaleW = thumbWidth / appWidth;
1383 float scaleH = thumbHeight / appHeight;
1384 Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
Filip Gruszczynskid64ef3e2015-10-27 17:58:02 -07001385 computePivot(mTmpRect.left, scaleW),
1386 computePivot(mTmpRect.top, scaleH));
Winson Chung399f6202014-03-19 10:47:20 -07001387
1388 Animation alpha = new AlphaAnimation(1, 0);
1389
1390 AnimationSet set = new AnimationSet(true);
1391 set.addAnimation(scale);
1392 set.addAnimation(alpha);
1393 set.setZAdjustment(Animation.ZORDER_TOP);
1394 a = set;
1395 break;
1396 }
1397 default:
1398 throw new RuntimeException("Invalid thumbnail transition state");
1399 }
1400
1401 return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
1402 }
1403
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001404 private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001405 getDefaultNextAppTransitionStartRect(mTmpFromClipRect);
1406 final int left = mTmpFromClipRect.left;
1407 final int top = mTmpFromClipRect.top;
1408 mTmpFromClipRect.offset(-left, -top);
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001409 // TODO: Isn't that strange that we ignore exact position of the containingFrame?
1410 mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height());
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001411 AnimationSet set = new AnimationSet(true);
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001412 float fromWidth = mTmpFromClipRect.width();
1413 float toWidth = mTmpToClipRect.width();
1414 float fromHeight = mTmpFromClipRect.height();
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001415 // While the window might span the whole display, the actual content will be cropped to the
1416 // system decoration frame, for example when the window is docked. We need to take into
1417 // account the visible height when constructing the animation.
1418 float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom;
1419 int translateAdjustment = 0;
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001420 if (fromWidth <= toWidth && fromHeight <= toHeight) {
1421 // The final window is larger in both dimensions than current window (e.g. we are
1422 // maximizing), so we can simply unclip the new window and there will be no disappearing
1423 // frame.
1424 set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect));
1425 } else {
1426 // The disappearing window has one larger dimension. We need to apply scaling, so the
1427 // first frame of the entry animation matches the old window.
1428 set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1));
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001429 // We might not be going exactly full screen, but instead be aligned under the status
1430 // bar using cropping. We still need to account for the cropped part, which will also
1431 // be scaled.
1432 translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight);
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001433 }
1434
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001435 // We animate the translation from the old position of the removed window, to the new
1436 // position of the added window. The latter might not be full screen, for example docked for
1437 // docked windows.
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001438 TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left,
Filip Gruszczynski2dfcf842015-10-25 13:40:47 -07001439 0, top - containingFrame.top - translateAdjustment, 0);
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001440 set.addAnimation(translate);
1441 set.setDuration(DEFAULT_APP_TRANSITION_DURATION);
Filip Gruszczynskie95b0ae2015-09-30 10:55:33 -07001442 set.setZAdjustment(Animation.ZORDER_TOP);
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001443 return set;
1444 }
1445
Jorim Jaggic554b772015-06-04 16:07:57 -07001446 /**
1447 * @return true if and only if the first frame of the transition can be skipped, i.e. the first
1448 * frame of the transition doesn't change the visuals on screen, so we can start
1449 * directly with the second one
1450 */
1451 boolean canSkipFirstFrame() {
1452 return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM
1453 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE
Jorim Jaggife762342016-10-13 14:33:27 +02001454 && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL
1455 && mNextAppTransition != TRANSIT_KEYGUARD_GOING_AWAY;
Jorim Jaggic554b772015-06-04 16:07:57 -07001456 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08001457
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001458 /**
1459 *
1460 * @param frame These are the bounds of the window when it finishes the animation. This is where
1461 * the animation must usually finish in entrance animation, as the next frame will
1462 * display the window at these coordinates. In case of exit animation, this is
1463 * where the animation must start, as the frame before the animation is displaying
1464 * the window at these bounds.
1465 * @param insets Knowing where the window will be positioned is not enough. Some parts of the
1466 * window might be obscured, usually by the system windows (status bar and
1467 * navigation bar) and we use content insets to convey that information. This
1468 * usually affects the animation aspects vertically, as the system decoration is
1469 * at the top and the bottom. For example when we animate from full screen to
1470 * recents, we want to exclude the covered parts, because they won't match the
1471 * thumbnail after the last frame is executed.
1472 * @param surfaceInsets In rare situation the surface is larger than the content and we need to
1473 * know about this to make the animation frames match. We currently use
1474 * this for freeform windows, which have larger surfaces to display
1475 * shadows. When we animate them from recents, we want to match the content
1476 * to the recents thumbnail and hence need to account for the surface being
1477 * bigger.
1478 */
Winsonb2024762016-04-05 17:32:30 -07001479 Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, int uiMode,
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -08001480 int orientation, Rect frame, Rect displayFrame, Rect insets,
1481 @Nullable Rect surfaceInsets, boolean isVoiceInteraction, boolean freeform,
1482 int taskId) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001483 Animation a;
Jorim Jaggife762342016-10-13 14:33:27 +02001484 if (isKeyguardGoingAwayTransit(transit) && enter) {
1485 a = loadKeyguardExitAnimation(transit);
1486 } else if (transit == TRANSIT_KEYGUARD_OCCLUDE) {
1487 a = null;
1488 } else if (transit == TRANSIT_KEYGUARD_UNOCCLUDE && !enter) {
1489 a = loadAnimationRes(lp, com.android.internal.R.anim.wallpaper_open_exit);
1490 } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001491 || transit == TRANSIT_TASK_OPEN
1492 || transit == TRANSIT_TASK_TO_FRONT)) {
1493 a = loadAnimationRes(lp, enter
1494 ? com.android.internal.R.anim.voice_activity_open_enter
1495 : com.android.internal.R.anim.voice_activity_open_exit);
1496 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1497 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001498 + " anim=" + a + " transit=" + appTransitionToString(transit)
1499 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001500 } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE
1501 || transit == TRANSIT_TASK_CLOSE
1502 || transit == TRANSIT_TASK_TO_BACK)) {
1503 a = loadAnimationRes(lp, enter
1504 ? com.android.internal.R.anim.voice_activity_close_enter
1505 : com.android.internal.R.anim.voice_activity_close_exit);
1506 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1507 "applyAnimation voice:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001508 + " anim=" + a + " transit=" + appTransitionToString(transit)
1509 + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3));
Filip Gruszczynski55a309f2015-09-04 17:15:01 -07001510 } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) {
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001511 a = createRelaunchAnimation(frame, insets);
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001512 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1513 "applyAnimation:"
1514 + " anim=" + a + " nextAppTransition=" + mNextAppTransition
1515 + " transit=" + appTransitionToString(transit)
1516 + " Callers=" + Debug.getCallers(3));
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001517 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
1518 a = loadAnimationRes(mNextAppTransitionPackage, enter ?
Craig Mautner164d4bb2012-11-26 13:51:23 -08001519 mNextAppTransitionEnter : mNextAppTransitionExit);
1520 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1521 "applyAnimation:"
1522 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001523 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001524 + " Callers=" + Debug.getCallers(3));
Winson Chung044d5292014-11-06 11:05:19 -08001525 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
1526 a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
1527 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1528 "applyAnimation:"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001529 + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE"
1530 + " transit=" + appTransitionToString(transit)
1531 + " Callers=" + Debug.getCallers(3));
Chet Haase10e23ab2015-02-11 15:08:38 -08001532 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) {
Jorim Jaggi8fe7e0a2016-02-12 19:43:39 -08001533 a = createClipRevealAnimationLocked(transit, enter, frame, displayFrame);
Chet Haase10e23ab2015-02-11 15:08:38 -08001534 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1535 "applyAnimation:"
1536 + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL"
Filip Gruszczynski49b80af2015-09-24 09:04:26 -07001537 + " transit=" + appTransitionToString(transit)
Chet Haase10e23ab2015-02-11 15:08:38 -08001538 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001539 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001540 a = createScaleUpAnimationLocked(transit, enter, frame);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001541 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1542 "applyAnimation:"
1543 + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001544 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001545 + " Callers=" + Debug.getCallers(3));
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001546 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
1547 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001548 mNextAppTransitionScaleUp =
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001549 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
Winson Chunga4ccb862014-08-22 15:26:27 -07001550 a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter),
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001551 frame, transit, taskId);
Winson Chunga4ccb862014-08-22 15:26:27 -07001552 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1553 String animName = mNextAppTransitionScaleUp ?
1554 "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
1555 Slog.v(TAG, "applyAnimation:"
1556 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001557 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Winson Chunga4ccb862014-08-22 15:26:27 -07001558 + " Callers=" + Debug.getCallers(3));
1559 }
1560 } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP ||
1561 mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) {
1562 mNextAppTransitionScaleUp =
1563 (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP);
1564 a = createAspectScaledThumbnailEnterExitAnimationLocked(
Winsonb2024762016-04-05 17:32:30 -07001565 getThumbnailTransitionState(enter), uiMode, orientation, transit, frame,
Filip Gruszczynski541f92c2015-10-25 17:15:06 -07001566 insets, surfaceInsets, freeform, taskId);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001567 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
1568 String animName = mNextAppTransitionScaleUp ?
Winson Chunga4ccb862014-08-22 15:26:27 -07001569 "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN";
Craig Mautner164d4bb2012-11-26 13:51:23 -08001570 Slog.v(TAG, "applyAnimation:"
1571 + " anim=" + a + " nextAppTransition=" + animName
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001572 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001573 + " Callers=" + Debug.getCallers(3));
1574 }
1575 } else {
1576 int animAttr = 0;
1577 switch (transit) {
Craig Mautner4b71aa12012-12-27 17:20:01 -08001578 case TRANSIT_ACTIVITY_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001579 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001580 ? WindowAnimation_activityOpenEnterAnimation
1581 : WindowAnimation_activityOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001582 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001583 case TRANSIT_ACTIVITY_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001584 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001585 ? WindowAnimation_activityCloseEnterAnimation
1586 : WindowAnimation_activityCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001587 break;
Jorim Jaggi192086e2016-03-11 17:17:03 +01001588 case TRANSIT_DOCK_TASK_FROM_RECENTS:
Craig Mautner4b71aa12012-12-27 17:20:01 -08001589 case TRANSIT_TASK_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001590 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001591 ? WindowAnimation_taskOpenEnterAnimation
1592 : WindowAnimation_taskOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001593 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001594 case TRANSIT_TASK_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001595 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001596 ? WindowAnimation_taskCloseEnterAnimation
1597 : WindowAnimation_taskCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001598 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001599 case TRANSIT_TASK_TO_FRONT:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001600 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001601 ? WindowAnimation_taskToFrontEnterAnimation
1602 : WindowAnimation_taskToFrontExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001603 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001604 case TRANSIT_TASK_TO_BACK:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001605 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001606 ? WindowAnimation_taskToBackEnterAnimation
1607 : WindowAnimation_taskToBackExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001608 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001609 case TRANSIT_WALLPAPER_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001610 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001611 ? WindowAnimation_wallpaperOpenEnterAnimation
1612 : WindowAnimation_wallpaperOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001613 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001614 case TRANSIT_WALLPAPER_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001615 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001616 ? WindowAnimation_wallpaperCloseEnterAnimation
1617 : WindowAnimation_wallpaperCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001618 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001619 case TRANSIT_WALLPAPER_INTRA_OPEN:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001620 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001621 ? WindowAnimation_wallpaperIntraOpenEnterAnimation
1622 : WindowAnimation_wallpaperIntraOpenExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001623 break;
Craig Mautner4b71aa12012-12-27 17:20:01 -08001624 case TRANSIT_WALLPAPER_INTRA_CLOSE:
Craig Mautner164d4bb2012-11-26 13:51:23 -08001625 animAttr = enter
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001626 ? WindowAnimation_wallpaperIntraCloseEnterAnimation
1627 : WindowAnimation_wallpaperIntraCloseExitAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001628 break;
Craig Mautnerbb742462014-07-07 15:28:55 -07001629 case TRANSIT_TASK_OPEN_BEHIND:
1630 animAttr = enter
1631 ? WindowAnimation_launchTaskBehindSourceAnimation
Craig Mautner3b2cd1d2014-08-25 14:25:54 -07001632 : WindowAnimation_launchTaskBehindTargetAnimation;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001633 }
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001634 a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001635 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
1636 "applyAnimation:"
1637 + " anim=" + a
1638 + " animAttr=0x" + Integer.toHexString(animAttr)
Wale Ogunwale8ebc82a2015-05-13 15:27:12 -07001639 + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
Craig Mautner164d4bb2012-11-26 13:51:23 -08001640 + " Callers=" + Debug.getCallers(3));
1641 }
1642 return a;
1643 }
1644
Jorim Jaggife762342016-10-13 14:33:27 +02001645 private Animation loadKeyguardExitAnimation(int transit) {
1646 if ((mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) {
1647 return null;
1648 }
1649 final boolean toShade =
1650 (mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0;
1651 return mService.mPolicy.createHiddenByKeyguardExit(
1652 transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER, toShade);
1653 }
1654
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +01001655 int getAppStackClipMode() {
Matthew Ngbf1d9852017-03-14 12:23:09 -07001656 // When dismiss keyguard animation occurs, clip before the animation to prevent docked
1657 // app from showing beyond the divider
1658 if (mNextAppTransition == TRANSIT_KEYGUARD_GOING_AWAY
1659 || mNextAppTransition == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER) {
1660 return STACK_CLIP_BEFORE_ANIM;
1661 }
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +01001662 return mNextAppTransition == TRANSIT_ACTIVITY_RELAUNCH
Jorim Jaggic69bd222016-03-15 14:38:37 +01001663 || mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS
Jorim Jaggi1f458fb2016-03-25 17:36:37 -07001664 || mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL
Jorim Jaggi6a7c90a2016-03-11 15:04:59 +01001665 ? STACK_CLIP_NONE
1666 : STACK_CLIP_AFTER_ANIM;
1667 }
1668
Jorim Jaggife762342016-10-13 14:33:27 +02001669 public int getTransitFlags() {
1670 return mNextAppTransitionFlags;
1671 }
1672
Craig Mautner164d4bb2012-11-26 13:51:23 -08001673 void postAnimationCallback() {
1674 if (mNextAppTransitionCallback != null) {
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08001675 mService.mH.sendMessage(mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK,
1676 mNextAppTransitionCallback));
Craig Mautner164d4bb2012-11-26 13:51:23 -08001677 mNextAppTransitionCallback = null;
1678 }
1679 }
1680
1681 void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
Filip Gruszczynskid1431422015-09-08 11:18:54 -07001682 IRemoteCallback startedCallback) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001683 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001684 clear();
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001685 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001686 mNextAppTransitionPackage = packageName;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001687 mNextAppTransitionEnter = enterAnim;
1688 mNextAppTransitionExit = exitAnim;
1689 postAnimationCallback();
1690 mNextAppTransitionCallback = startedCallback;
1691 } else {
1692 postAnimationCallback();
1693 }
1694 }
1695
1696 void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001697 int startHeight) {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001698 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001699 clear();
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001700 mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP;
Winson4c3fecd2016-07-13 12:29:48 -07001701 putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001702 postAnimationCallback();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001703 }
1704 }
1705
Chet Haase10e23ab2015-02-11 15:08:38 -08001706 void overridePendingAppTransitionClipReveal(int startX, int startY,
1707 int startWidth, int startHeight) {
1708 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001709 clear();
Chet Haase10e23ab2015-02-11 15:08:38 -08001710 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL;
Filip Gruszczynski7248c562015-11-09 13:05:40 -08001711 putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null);
Chet Haase10e23ab2015-02-11 15:08:38 -08001712 postAnimationCallback();
Chet Haase10e23ab2015-02-11 15:08:38 -08001713 }
1714 }
1715
Craig Mautner164d4bb2012-11-26 13:51:23 -08001716 void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
1717 IRemoteCallback startedCallback, boolean scaleUp) {
1718 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001719 clear();
Craig Mautner9a29a5d2012-12-27 19:03:40 -08001720 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP
1721 : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN;
Craig Mautner164d4bb2012-11-26 13:51:23 -08001722 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski7248c562015-11-09 13:05:40 -08001723 putDefaultNextAppTransitionCoordinates(startX, startY, 0, 0, srcThumb);
Craig Mautner164d4bb2012-11-26 13:51:23 -08001724 postAnimationCallback();
1725 mNextAppTransitionCallback = startedCallback;
1726 } else {
1727 postAnimationCallback();
1728 }
1729 }
1730
Winson Chunga4ccb862014-08-22 15:26:27 -07001731 void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY,
Winson Chung2e7f3bd2014-09-05 13:17:22 +02001732 int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) {
Winson Chunga4ccb862014-08-22 15:26:27 -07001733 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001734 clear();
Winson Chunga4ccb862014-08-22 15:26:27 -07001735 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1736 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
Winson Chunga4ccb862014-08-22 15:26:27 -07001737 mNextAppTransitionScaleUp = scaleUp;
Filip Gruszczynski7248c562015-11-09 13:05:40 -08001738 putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight,
1739 srcThumb);
Winson Chunga4ccb862014-08-22 15:26:27 -07001740 postAnimationCallback();
1741 mNextAppTransitionCallback = startedCallback;
1742 } else {
1743 postAnimationCallback();
1744 }
1745 }
1746
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001747 public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs,
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001748 IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback,
1749 boolean scaleUp) {
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001750 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001751 clear();
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001752 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1753 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001754 mNextAppTransitionScaleUp = scaleUp;
Jorim Jaggi43102412015-11-11 16:28:37 +01001755 if (specs != null) {
1756 for (int i = 0; i < specs.length; i++) {
1757 AppTransitionAnimationSpec spec = specs[i];
1758 if (spec != null) {
1759 mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec);
1760 if (i == 0) {
1761 // In full screen mode, the transition code depends on the default spec
1762 // to be set.
1763 Rect rect = spec.rect;
1764 putDefaultNextAppTransitionCoordinates(rect.left, rect.top,
Filip Gruszczynskie3264d82015-11-20 17:10:04 -08001765 rect.width(), rect.height(), spec.bitmap);
Jorim Jaggi43102412015-11-11 16:28:37 +01001766 }
Filip Gruszczynskid1431422015-09-08 11:18:54 -07001767 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001768 }
1769 }
1770 postAnimationCallback();
Filip Gruszczynski1a5203d2015-10-29 17:43:49 -07001771 mNextAppTransitionCallback = onAnimationStartedCallback;
1772 mAnimationFinishedCallback = onAnimationFinishedCallback;
Filip Gruszczynski170192a2015-08-16 17:46:34 -07001773 } else {
1774 postAnimationCallback();
1775 }
1776 }
1777
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001778 void overridePendingAppTransitionMultiThumbFuture(
1779 IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback callback,
1780 boolean scaleUp) {
1781 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001782 clear();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001783 mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP
1784 : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001785 mNextAppTransitionAnimationsSpecsFuture = specsFuture;
1786 mNextAppTransitionScaleUp = scaleUp;
Jorim Jaggi7cc7b082015-11-10 16:06:54 +01001787 mNextAppTransitionFutureCallback = callback;
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001788 }
1789 }
1790
Winson Chung044d5292014-11-06 11:05:19 -08001791 void overrideInPlaceAppTransition(String packageName, int anim) {
1792 if (isTransitionSet()) {
Jorim Jaggi65193992015-11-23 16:49:59 -08001793 clear();
Winson Chung044d5292014-11-06 11:05:19 -08001794 mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE;
1795 mNextAppTransitionPackage = packageName;
1796 mNextAppTransitionInPlace = anim;
1797 } else {
1798 postAnimationCallback();
1799 }
1800 }
1801
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001802 /**
1803 * If a future is set for the app transition specs, fetch it in another thread.
1804 */
1805 private void fetchAppTransitionSpecsFromFuture() {
1806 if (mNextAppTransitionAnimationsSpecsFuture != null) {
1807 mNextAppTransitionAnimationsSpecsPending = true;
1808 final IAppTransitionAnimationSpecsFuture future
1809 = mNextAppTransitionAnimationsSpecsFuture;
1810 mNextAppTransitionAnimationsSpecsFuture = null;
1811 mDefaultExecutor.execute(new Runnable() {
1812 @Override
1813 public void run() {
1814 AppTransitionAnimationSpec[] specs = null;
1815 try {
1816 specs = future.get();
1817 } catch (RemoteException e) {
1818 Slog.w(TAG, "Failed to fetch app transition specs: " + e);
1819 }
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08001820 synchronized (mService.mWindowMap) {
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001821 mNextAppTransitionAnimationsSpecsPending = false;
Jorim Jaggi7cc7b082015-11-10 16:06:54 +01001822 overridePendingAppTransitionMultiThumb(specs,
1823 mNextAppTransitionFutureCallback, null /* finishedCallback */,
1824 mNextAppTransitionScaleUp);
1825 mNextAppTransitionFutureCallback = null;
Filip Gruszczynski96daf322015-11-18 18:01:27 -08001826 if (specs != null) {
1827 mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
1828 }
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001829 }
Filip Gruszczynski1a4dfe52015-11-15 10:58:57 -08001830 mService.requestTraversal();
Jorim Jaggi2f7d2922015-10-29 13:08:29 +01001831 }
1832 });
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) {
2066 return isTvUiMode(uiMode)
2067 || mGridLayoutRecentsEnabled
2068 || orientation == Configuration.ORIENTATION_PORTRAIT;
2069 }
2070
2071 /**
Winsonb2024762016-04-05 17:32:30 -07002072 * @return whether the specified {@param uiMode} is the TV mode.
2073 */
2074 private boolean isTvUiMode(int uiMode) {
2075 return (uiMode & Configuration.UI_MODE_TYPE_TELEVISION) > 0;
2076 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08002077}