Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server.wm; |
| 18 | |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams; |
| 20 | import static android.view.WindowManager.TRANSIT_ACTIVITY_CLOSE; |
| 21 | import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN; |
| 22 | import static android.view.WindowManager.TRANSIT_ACTIVITY_RELAUNCH; |
Adrian Roos | 9357721 | 2018-04-10 14:12:10 -0700 | [diff] [blame] | 23 | import static android.view.WindowManager.TRANSIT_CRASHING_ACTIVITY_CLOSE; |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 24 | import static android.view.WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS; |
| 25 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION; |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 26 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION; |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 27 | import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE; |
| 28 | import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; |
| 29 | import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER; |
| 30 | import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE; |
| 31 | import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; |
| 32 | import static android.view.WindowManager.TRANSIT_NONE; |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 33 | import static android.view.WindowManager.TRANSIT_SHOW_SINGLE_TASK_DISPLAY; |
Evan Rosky | cf76bed | 2019-01-15 10:33:58 -0800 | [diff] [blame] | 34 | import static android.view.WindowManager.TRANSIT_TASK_CHANGE_WINDOWING_MODE; |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 35 | import static android.view.WindowManager.TRANSIT_TASK_CLOSE; |
Jorim Jaggi | cecf424 | 2018-02-21 18:46:53 +0100 | [diff] [blame] | 36 | import static android.view.WindowManager.TRANSIT_TASK_IN_PLACE; |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 37 | import static android.view.WindowManager.TRANSIT_TASK_OPEN; |
| 38 | import static android.view.WindowManager.TRANSIT_TASK_OPEN_BEHIND; |
| 39 | import static android.view.WindowManager.TRANSIT_TASK_TO_BACK; |
| 40 | import static android.view.WindowManager.TRANSIT_TASK_TO_FRONT; |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 41 | import static android.view.WindowManager.TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE; |
| 42 | import static android.view.WindowManager.TRANSIT_TRANSLUCENT_ACTIVITY_OPEN; |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 43 | import static android.view.WindowManager.TRANSIT_UNSET; |
| 44 | import static android.view.WindowManager.TRANSIT_WALLPAPER_CLOSE; |
| 45 | import static android.view.WindowManager.TRANSIT_WALLPAPER_INTRA_CLOSE; |
| 46 | import static android.view.WindowManager.TRANSIT_WALLPAPER_INTRA_OPEN; |
| 47 | import static android.view.WindowManager.TRANSIT_WALLPAPER_OPEN; |
Tony Mak | 83546a8 | 2018-01-22 13:56:20 +0000 | [diff] [blame] | 48 | |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 49 | import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation; |
| 50 | import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation; |
| 51 | import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation; |
| 52 | import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation; |
| 53 | import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation; |
| 54 | import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation; |
| 55 | import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation; |
| 56 | import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation; |
| 57 | import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation; |
| 58 | import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation; |
| 59 | import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation; |
| 60 | import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation; |
| 61 | import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation; |
| 62 | import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation; |
| 63 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation; |
| 64 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation; |
| 65 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation; |
| 66 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation; |
| 67 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation; |
| 68 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation; |
| 69 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation; |
| 70 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation; |
Aurimas Liutikas | d8ebfef | 2019-01-16 12:46:42 -0800 | [diff] [blame] | 71 | import static com.android.server.wm.AppTransitionProto.APP_TRANSITION_STATE; |
| 72 | import static com.android.server.wm.AppTransitionProto.LAST_USED_APP_TRANSITION; |
Filip Gruszczynski | 198dcbf | 2016-01-18 10:02:00 -0800 | [diff] [blame] | 73 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 74 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 75 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 76 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 77 | import static com.android.server.wm.WindowManagerInternal.AppTransitionListener; |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 78 | import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; |
Matthew Ng | bf1d985 | 2017-03-14 12:23:09 -0700 | [diff] [blame] | 79 | import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_BEFORE_ANIM; |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 80 | import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE; |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 81 | |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 82 | import android.annotation.DrawableRes; |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 83 | import android.annotation.NonNull; |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 84 | import android.annotation.Nullable; |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 85 | import android.app.ActivityManager; |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 86 | import android.content.ComponentName; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 87 | import android.content.Context; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 88 | import android.content.res.Configuration; |
Todd Kennedy | 64c57a8 | 2018-04-19 15:17:24 -0700 | [diff] [blame] | 89 | import android.content.res.ResourceId; |
Aurimas Liutikas | d8ebfef | 2019-01-16 12:46:42 -0800 | [diff] [blame] | 90 | import android.content.res.Resources; |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 91 | import android.content.res.Resources.NotFoundException; |
lumark | ce596d3 | 2019-06-12 16:58:35 +0800 | [diff] [blame] | 92 | import android.content.res.TypedArray; |
John Reck | 519ad48 | 2018-02-12 17:08:48 -0800 | [diff] [blame] | 93 | import android.graphics.Bitmap; |
| 94 | import android.graphics.Canvas; |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 95 | import android.graphics.Color; |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 96 | import android.graphics.GraphicBuffer; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 97 | import android.graphics.Path; |
John Reck | 519ad48 | 2018-02-12 17:08:48 -0800 | [diff] [blame] | 98 | import android.graphics.Picture; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 99 | import android.graphics.Rect; |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 100 | import android.graphics.drawable.Drawable; |
Jorim Jaggi | ed410b6 | 2017-05-05 15:16:14 +0200 | [diff] [blame] | 101 | import android.os.Binder; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 102 | import android.os.Debug; |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 103 | import android.os.Handler; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 104 | import android.os.IBinder; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 105 | import android.os.IRemoteCallback; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 106 | import android.os.RemoteException; |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 107 | import android.os.SystemClock; |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 108 | import android.os.SystemProperties; |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 109 | import android.os.UserHandle; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 110 | import android.util.ArraySet; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 111 | import android.util.Slog; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 112 | import android.util.SparseArray; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 113 | import android.util.proto.ProtoOutputStream; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 114 | import android.view.AppTransitionAnimationSpec; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 115 | import android.view.IAppTransitionAnimationSpecsFuture; |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 116 | import android.view.RemoteAnimationAdapter; |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 117 | import android.view.WindowManager.TransitionFlags; |
| 118 | import android.view.WindowManager.TransitionType; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 119 | import android.view.animation.AlphaAnimation; |
| 120 | import android.view.animation.Animation; |
| 121 | import android.view.animation.AnimationSet; |
| 122 | import android.view.animation.AnimationUtils; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 123 | import android.view.animation.ClipRectAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 124 | import android.view.animation.Interpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 125 | import android.view.animation.PathInterpolator; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 126 | import android.view.animation.ScaleAnimation; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 127 | import android.view.animation.TranslateAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 128 | |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 129 | import com.android.internal.R; |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 130 | import com.android.internal.annotations.VisibleForTesting; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 131 | import com.android.internal.util.DumpUtils.Dump; |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 132 | import com.android.internal.util.function.pooled.PooledLambda; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 133 | import com.android.server.AttributeCache; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 134 | import com.android.server.wm.animation.ClipRectLRAnimation; |
| 135 | import com.android.server.wm.animation.ClipRectTBAnimation; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 136 | import com.android.server.wm.animation.CurvedTranslateAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 137 | |
| 138 | import java.io.PrintWriter; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 139 | import java.util.ArrayList; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 140 | import java.util.concurrent.ExecutorService; |
| 141 | import java.util.concurrent.Executors; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 142 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 143 | // State management of app transitions. When we are preparing for a |
| 144 | // transition, mNextAppTransition will be the kind of transition to |
| 145 | // perform or TRANSIT_NONE if we are not waiting. If we are waiting, |
| 146 | // mOpeningApps and mClosingApps are the lists of tokens that will be |
| 147 | // made visible or hidden at the next transition. |
| 148 | public class AppTransition implements Dump { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 149 | private static final String TAG = TAG_WITH_CLASS_NAME ? "AppTransition" : TAG_WM; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 150 | private static final int CLIP_REVEAL_TRANSLATION_Y_DP = 8; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 151 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 152 | /** Fraction of animation at which the recents thumbnail stays completely transparent */ |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 153 | private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 154 | /** Fraction of animation at which the recents thumbnail becomes completely transparent */ |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 155 | private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 156 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 157 | static final int DEFAULT_APP_TRANSITION_DURATION = 336; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 158 | |
| 159 | /** Interpolator to be used for animations that respond directly to a touch */ |
| 160 | static final Interpolator TOUCH_RESPONSE_INTERPOLATOR = |
| 161 | new PathInterpolator(0.3f, 0f, 0.1f, 1f); |
| 162 | |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 163 | private static final Interpolator THUMBNAIL_DOCK_INTERPOLATOR = |
| 164 | new PathInterpolator(0.85f, 0f, 1f, 1f); |
| 165 | |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 166 | /** |
| 167 | * Maximum duration for the clip reveal animation. This is used when there is a lot of movement |
| 168 | * involved, to make it more understandable. |
| 169 | */ |
| 170 | private static final int MAX_CLIP_REVEAL_TRANSITION_DURATION = 420; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 171 | private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 172 | private static final long APP_TRANSITION_TIMEOUT_MS = 5000; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 173 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 174 | private final Context mContext; |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 175 | private final WindowManagerService mService; |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 176 | private final DisplayContent mDisplayContent; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 177 | |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 178 | private @TransitionType int mNextAppTransition = TRANSIT_UNSET; |
| 179 | private @TransitionFlags int mNextAppTransitionFlags = 0; |
Chong Zhang | 60091a9 | 2016-07-27 17:52:45 -0700 | [diff] [blame] | 180 | private int mLastUsedAppTransition = TRANSIT_UNSET; |
| 181 | private String mLastOpeningApp; |
| 182 | private String mLastClosingApp; |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 183 | private String mLastChangingApp; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 184 | |
| 185 | private static final int NEXT_TRANSIT_TYPE_NONE = 0; |
| 186 | private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1; |
| 187 | private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2; |
| 188 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3; |
| 189 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 190 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5; |
| 191 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 192 | private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 193 | private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8; |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 194 | |
| 195 | /** |
| 196 | * Refers to the transition to activity started by using {@link |
| 197 | * android.content.pm.crossprofile.CrossProfileApps#startMainActivity(ComponentName, UserHandle) |
| 198 | * }. |
| 199 | */ |
| 200 | private static final int NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS = 9; |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 201 | private static final int NEXT_TRANSIT_TYPE_REMOTE = 10; |
| 202 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 203 | private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; |
| 204 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 205 | // These are the possible states for the enter/exit activities during a thumbnail transition |
| 206 | private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0; |
| 207 | private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1; |
| 208 | private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2; |
| 209 | private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3; |
| 210 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 211 | private String mNextAppTransitionPackage; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 212 | // Used for thumbnail transitions. True if we're scaling up, false if scaling down |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 213 | private boolean mNextAppTransitionScaleUp; |
| 214 | private IRemoteCallback mNextAppTransitionCallback; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 215 | private IRemoteCallback mNextAppTransitionFutureCallback; |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 216 | private IRemoteCallback mAnimationFinishedCallback; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 217 | private int mNextAppTransitionEnter; |
| 218 | private int mNextAppTransitionExit; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 219 | private int mNextAppTransitionInPlace; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 220 | |
| 221 | // Keyed by task id. |
| 222 | private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs |
| 223 | = new SparseArray<>(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 224 | private IAppTransitionAnimationSpecsFuture mNextAppTransitionAnimationsSpecsFuture; |
| 225 | private boolean mNextAppTransitionAnimationsSpecsPending; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 226 | private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec; |
| 227 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 228 | private Rect mNextAppTransitionInsets = new Rect(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 229 | |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 230 | private Rect mTmpFromClipRect = new Rect(); |
| 231 | private Rect mTmpToClipRect = new Rect(); |
| 232 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 233 | private final Rect mTmpRect = new Rect(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 234 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 235 | private final static int APP_STATE_IDLE = 0; |
| 236 | private final static int APP_STATE_READY = 1; |
| 237 | private final static int APP_STATE_RUNNING = 2; |
| 238 | private final static int APP_STATE_TIMEOUT = 3; |
| 239 | private int mAppTransitionState = APP_STATE_IDLE; |
| 240 | |
| 241 | private final int mConfigShortAnimTime; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 242 | private final Interpolator mDecelerateInterpolator; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 243 | private final Interpolator mThumbnailFadeInInterpolator; |
| 244 | private final Interpolator mThumbnailFadeOutInterpolator; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 245 | private final Interpolator mLinearOutSlowInInterpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 246 | private final Interpolator mFastOutLinearInInterpolator; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 247 | private final Interpolator mFastOutSlowInInterpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 248 | private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f); |
| 249 | |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 250 | private final int mClipRevealTranslationY; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 251 | |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 252 | private int mCurrentUserId = 0; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 253 | private long mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION; |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 254 | |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 255 | private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 256 | private final ExecutorService mDefaultExecutor = Executors.newSingleThreadExecutor(); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 257 | |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 258 | private int mLastClipRevealMaxTranslation; |
| 259 | private boolean mLastHadClipReveal; |
| 260 | |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 261 | private final boolean mGridLayoutRecentsEnabled; |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 262 | private final boolean mLowRamRecentsEnabled; |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 263 | |
lumark | ce596d3 | 2019-06-12 16:58:35 +0800 | [diff] [blame] | 264 | private final int mDefaultWindowAnimationStyleResId; |
| 265 | |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 266 | private RemoteAnimationController mRemoteAnimationController; |
| 267 | |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 268 | final Handler mHandler; |
| 269 | final Runnable mHandleAppTransitionTimeoutRunnable = () -> handleAppTransitionTimeout(); |
| 270 | |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 271 | AppTransition(Context context, WindowManagerService service, DisplayContent displayContent) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 272 | mContext = context; |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 273 | mService = service; |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 274 | mHandler = new Handler(service.mH.getLooper()); |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 275 | mDisplayContent = displayContent; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 276 | mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 277 | com.android.internal.R.interpolator.linear_out_slow_in); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 278 | mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context, |
| 279 | com.android.internal.R.interpolator.fast_out_linear_in); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 280 | mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 281 | com.android.internal.R.interpolator.fast_out_slow_in); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 282 | mConfigShortAnimTime = context.getResources().getInteger( |
| 283 | com.android.internal.R.integer.config_shortAnimTime); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 284 | mDecelerateInterpolator = AnimationUtils.loadInterpolator(context, |
| 285 | com.android.internal.R.interpolator.decelerate_cubic); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 286 | mThumbnailFadeInInterpolator = new Interpolator() { |
| 287 | @Override |
| 288 | public float getInterpolation(float input) { |
| 289 | // Linear response for first fraction, then complete after that. |
| 290 | if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) { |
| 291 | return 0f; |
| 292 | } |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 293 | float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) / |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 294 | (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 295 | return mFastOutLinearInInterpolator.getInterpolation(t); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 296 | } |
| 297 | }; |
| 298 | mThumbnailFadeOutInterpolator = new Interpolator() { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 299 | @Override |
| 300 | public float getInterpolation(float input) { |
| 301 | // Linear response for first fraction, then complete after that. |
| 302 | if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) { |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 303 | float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION; |
| 304 | return mLinearOutSlowInInterpolator.getInterpolation(t); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 305 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 306 | return 1f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 307 | } |
| 308 | }; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 309 | mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP |
| 310 | * mContext.getResources().getDisplayMetrics().density); |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 311 | mGridLayoutRecentsEnabled = SystemProperties.getBoolean("ro.recents.grid", false); |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 312 | mLowRamRecentsEnabled = ActivityManager.isLowRamDeviceStatic(); |
lumark | ce596d3 | 2019-06-12 16:58:35 +0800 | [diff] [blame] | 313 | |
| 314 | final TypedArray windowStyle = mContext.getTheme().obtainStyledAttributes( |
| 315 | com.android.internal.R.styleable.Window); |
| 316 | mDefaultWindowAnimationStyleResId = windowStyle.getResourceId( |
| 317 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
| 318 | windowStyle.recycle(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | boolean isTransitionSet() { |
| 322 | return mNextAppTransition != TRANSIT_UNSET; |
| 323 | } |
| 324 | |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 325 | boolean isTransitionEqual(@TransitionType int transit) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 326 | return mNextAppTransition == transit; |
| 327 | } |
| 328 | |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 329 | @TransitionType int getAppTransition() { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 330 | return mNextAppTransition; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 331 | } |
| 332 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 333 | private void setAppTransition(int transit, int flags) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 334 | mNextAppTransition = transit; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 335 | mNextAppTransitionFlags |= flags; |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 336 | setLastAppTransition(TRANSIT_UNSET, null, null, null); |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 337 | updateBooster(); |
Chong Zhang | 60091a9 | 2016-07-27 17:52:45 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 340 | void setLastAppTransition(int transit, AppWindowToken openingApp, AppWindowToken closingApp, |
| 341 | AppWindowToken changingApp) { |
Chong Zhang | 60091a9 | 2016-07-27 17:52:45 -0700 | [diff] [blame] | 342 | mLastUsedAppTransition = transit; |
| 343 | mLastOpeningApp = "" + openingApp; |
| 344 | mLastClosingApp = "" + closingApp; |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 345 | mLastChangingApp = "" + changingApp; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | boolean isReady() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 349 | return mAppTransitionState == APP_STATE_READY |
| 350 | || mAppTransitionState == APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 351 | } |
| 352 | |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 353 | void setReady() { |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 354 | setAppTransitionState(APP_STATE_READY); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 355 | fetchAppTransitionSpecsFromFuture(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | boolean isRunning() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 359 | return mAppTransitionState == APP_STATE_RUNNING; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 360 | } |
| 361 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 362 | void setIdle() { |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 363 | setAppTransitionState(APP_STATE_IDLE); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | boolean isTimeout() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 367 | return mAppTransitionState == APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 368 | } |
| 369 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 370 | void setTimeout() { |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 371 | setAppTransitionState(APP_STATE_TIMEOUT); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 372 | } |
| 373 | |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 374 | GraphicBuffer getAppTransitionThumbnailHeader(int taskId) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 375 | AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId); |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 376 | if (spec == null) { |
| 377 | spec = mDefaultNextAppTransitionAnimationSpec; |
| 378 | } |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 379 | return spec != null ? spec.buffer : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 380 | } |
| 381 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 382 | /** Returns whether the next thumbnail transition is aspect scaled up. */ |
| 383 | boolean isNextThumbnailTransitionAspectScaled() { |
| 384 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 385 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 386 | } |
| 387 | |
| 388 | /** Returns whether the next thumbnail transition is scaling up. */ |
| 389 | boolean isNextThumbnailTransitionScaleUp() { |
| 390 | return mNextAppTransitionScaleUp; |
| 391 | } |
| 392 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 393 | boolean isNextAppTransitionThumbnailUp() { |
| 394 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || |
| 395 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP; |
| 396 | } |
| 397 | |
| 398 | boolean isNextAppTransitionThumbnailDown() { |
| 399 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN || |
| 400 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 401 | } |
| 402 | |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 403 | |
| 404 | boolean isNextAppTransitionOpenCrossProfileApps() { |
| 405 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS; |
| 406 | } |
| 407 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 408 | /** |
| 409 | * @return true if and only if we are currently fetching app transition specs from the future |
| 410 | * passed into {@link #overridePendingAppTransitionMultiThumbFuture} |
| 411 | */ |
| 412 | boolean isFetchingAppTransitionsSpecs() { |
| 413 | return mNextAppTransitionAnimationsSpecsPending; |
| 414 | } |
| 415 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 416 | private boolean prepare() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 417 | if (!isRunning()) { |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 418 | setAppTransitionState(APP_STATE_IDLE); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 419 | notifyAppTransitionPendingLocked(); |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 420 | mLastHadClipReveal = false; |
| 421 | mLastClipRevealMaxTranslation = 0; |
| 422 | mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION; |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 423 | return true; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 424 | } |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 425 | return false; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 426 | } |
| 427 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 428 | /** |
| 429 | * @return bit-map of WindowManagerPolicy#FINISH_LAYOUT_REDO_* to indicate whether another |
| 430 | * layout pass needs to be done |
| 431 | */ |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 432 | int goodToGo(int transit, AppWindowToken topOpeningApp, ArraySet<AppWindowToken> openingApps) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 433 | mNextAppTransition = TRANSIT_UNSET; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 434 | mNextAppTransitionFlags = 0; |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 435 | setAppTransitionState(APP_STATE_RUNNING); |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 436 | final AnimationAdapter topOpeningAnim = topOpeningApp != null |
| 437 | ? topOpeningApp.getAnimation() |
| 438 | : null; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 439 | int redoLayout = notifyAppTransitionStartingLocked(transit, |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 440 | topOpeningAnim != null ? topOpeningAnim.getDurationHint() : 0, |
| 441 | topOpeningAnim != null |
| 442 | ? topOpeningAnim.getStatusBarTransitionsStartTime() |
| 443 | : SystemClock.uptimeMillis(), |
| 444 | AnimationAdapter.STATUS_BAR_TRANSITION_DURATION); |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 445 | mDisplayContent.getDockedDividerController() |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 446 | .notifyAppTransitionStarting(openingApps, transit); |
Jorim Jaggi | 363ab98 | 2016-04-26 19:51:20 -0700 | [diff] [blame] | 447 | |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 448 | if (mRemoteAnimationController != null) { |
| 449 | mRemoteAnimationController.goodToGo(); |
| 450 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 451 | return redoLayout; |
Jorim Jaggi | 363ab98 | 2016-04-26 19:51:20 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 454 | void clear() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 455 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 456 | mNextAppTransitionPackage = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 457 | mNextAppTransitionAnimationsSpecs.clear(); |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 458 | mRemoteAnimationController = null; |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 459 | mNextAppTransitionAnimationsSpecsFuture = null; |
| 460 | mDefaultNextAppTransitionAnimationSpec = null; |
| 461 | mAnimationFinishedCallback = null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 462 | } |
| 463 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 464 | void freeze() { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 465 | final int transit = mNextAppTransition; |
Arthur Hung | 442aff2 | 2019-05-07 19:49:31 +0800 | [diff] [blame] | 466 | // The RemoteAnimationControl didn't register AppTransitionListener and |
| 467 | // only initialized the finish and timeout callback when goodToGo(). |
| 468 | // So cancel the remote animation here to prevent the animation can't do |
| 469 | // finish after transition state cleared. |
| 470 | if (mRemoteAnimationController != null) { |
| 471 | mRemoteAnimationController.cancelAnimation("freeze"); |
| 472 | } |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 473 | setAppTransition(TRANSIT_UNSET, 0 /* flags */); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 474 | clear(); |
| 475 | setReady(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 476 | notifyAppTransitionCancelledLocked(transit); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 477 | } |
| 478 | |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 479 | private void setAppTransitionState(int state) { |
| 480 | mAppTransitionState = state; |
| 481 | updateBooster(); |
| 482 | } |
| 483 | |
| 484 | /** |
| 485 | * Updates whether we currently boost wm locked sections and the animation thread. We want to |
| 486 | * boost the priorities to a more important value whenever an app transition is going to happen |
| 487 | * soon or an app transition is running. |
| 488 | */ |
Jorim Jaggi | c8cc229 | 2018-03-15 20:16:15 +0100 | [diff] [blame] | 489 | void updateBooster() { |
| 490 | WindowManagerService.sThreadPriorityBooster.setAppTransitionRunning(needsBoosting()); |
| 491 | } |
| 492 | |
| 493 | private boolean needsBoosting() { |
| 494 | final boolean recentsAnimRunning = mService.getRecentsAnimationController() != null; |
| 495 | return mNextAppTransition != TRANSIT_UNSET |
| 496 | || mAppTransitionState == APP_STATE_READY |
| 497 | || mAppTransitionState == APP_STATE_RUNNING |
| 498 | || recentsAnimRunning; |
Jorim Jaggi | 245281c | 2017-06-07 14:33:04 -0700 | [diff] [blame] | 499 | } |
| 500 | |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 501 | void registerListenerLocked(AppTransitionListener listener) { |
| 502 | mListeners.add(listener); |
| 503 | } |
| 504 | |
lumark | 5428446 | 2019-03-05 20:44:27 +0800 | [diff] [blame] | 505 | void unregisterListener(AppTransitionListener listener) { |
| 506 | mListeners.remove(listener); |
| 507 | } |
| 508 | |
Wale Ogunwale | a48eadb | 2015-05-14 17:43:12 -0700 | [diff] [blame] | 509 | public void notifyAppTransitionFinishedLocked(IBinder token) { |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 510 | for (int i = 0; i < mListeners.size(); i++) { |
| 511 | mListeners.get(i).onAppTransitionFinishedLocked(token); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | private void notifyAppTransitionPendingLocked() { |
| 516 | for (int i = 0; i < mListeners.size(); i++) { |
| 517 | mListeners.get(i).onAppTransitionPendingLocked(); |
| 518 | } |
| 519 | } |
| 520 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 521 | private void notifyAppTransitionCancelledLocked(int transit) { |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 522 | for (int i = 0; i < mListeners.size(); i++) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 523 | mListeners.get(i).onAppTransitionCancelledLocked(transit); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 527 | private int notifyAppTransitionStartingLocked(int transit, long duration, |
| 528 | long statusBarAnimationStartTime, long statusBarAnimationDuration) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 529 | int redoLayout = 0; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 530 | for (int i = 0; i < mListeners.size(); i++) { |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 531 | redoLayout |= mListeners.get(i).onAppTransitionStartingLocked(transit, duration, |
| 532 | statusBarAnimationStartTime, statusBarAnimationDuration); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 533 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 534 | return redoLayout; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 535 | } |
| 536 | |
lumark | ce596d3 | 2019-06-12 16:58:35 +0800 | [diff] [blame] | 537 | @VisibleForTesting |
| 538 | int getDefaultWindowAnimationStyleResId() { |
| 539 | return mDefaultWindowAnimationStyleResId; |
| 540 | } |
| 541 | |
| 542 | /** Returns window animation style ID from {@link LayoutParams} or from system in some cases */ |
| 543 | @VisibleForTesting |
| 544 | int getAnimationStyleResId(@NonNull LayoutParams lp) { |
| 545 | int resId = lp.windowAnimations; |
| 546 | if (lp.type == LayoutParams.TYPE_APPLICATION_STARTING) { |
| 547 | // Note that we don't want application to customize starting window animation. |
| 548 | // Since this window is specific for displaying while app starting, |
| 549 | // application should not change its animation directly. |
| 550 | // In this case, it will use system resource to get default animation. |
| 551 | resId = mDefaultWindowAnimationStyleResId; |
| 552 | } |
| 553 | return resId; |
| 554 | } |
| 555 | |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 556 | private AttributeCache.Entry getCachedAnimations(LayoutParams lp) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 557 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg=" |
| 558 | + (lp != null ? lp.packageName : null) |
| 559 | + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null)); |
| 560 | if (lp != null && lp.windowAnimations != 0) { |
| 561 | // If this is a system resource, don't try to load it from the |
| 562 | // application resources. It is nice to avoid loading application |
| 563 | // resources if we can. |
| 564 | String packageName = lp.packageName != null ? lp.packageName : "android"; |
lumark | ce596d3 | 2019-06-12 16:58:35 +0800 | [diff] [blame] | 565 | int resId = getAnimationStyleResId(lp); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 566 | if ((resId&0xFF000000) == 0x01000000) { |
| 567 | packageName = "android"; |
| 568 | } |
| 569 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package=" |
| 570 | + packageName); |
| 571 | return AttributeCache.instance().get(packageName, resId, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 572 | com.android.internal.R.styleable.WindowAnimation, mCurrentUserId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 573 | } |
| 574 | return null; |
| 575 | } |
| 576 | |
| 577 | private AttributeCache.Entry getCachedAnimations(String packageName, int resId) { |
| 578 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package=" |
| 579 | + packageName + " resId=0x" + Integer.toHexString(resId)); |
| 580 | if (packageName != null) { |
| 581 | if ((resId&0xFF000000) == 0x01000000) { |
| 582 | packageName = "android"; |
| 583 | } |
| 584 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package=" |
| 585 | + packageName); |
| 586 | return AttributeCache.instance().get(packageName, resId, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 587 | com.android.internal.R.styleable.WindowAnimation, mCurrentUserId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 588 | } |
| 589 | return null; |
| 590 | } |
| 591 | |
Jorim Jaggi | 0a1523d | 2018-04-19 17:48:38 +0200 | [diff] [blame] | 592 | Animation loadAnimationAttr(LayoutParams lp, int animAttr, int transit) { |
Aurimas Liutikas | d8ebfef | 2019-01-16 12:46:42 -0800 | [diff] [blame] | 593 | int resId = Resources.ID_NULL; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 594 | Context context = mContext; |
Jorim Jaggi | 5f95b00 | 2018-04-19 13:27:52 +0000 | [diff] [blame] | 595 | if (animAttr >= 0) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 596 | AttributeCache.Entry ent = getCachedAnimations(lp); |
| 597 | if (ent != null) { |
| 598 | context = ent.context; |
Todd Kennedy | 64c57a8 | 2018-04-19 15:17:24 -0700 | [diff] [blame] | 599 | resId = ent.array.getResourceId(animAttr, 0); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 600 | } |
| 601 | } |
Todd Kennedy | 64c57a8 | 2018-04-19 15:17:24 -0700 | [diff] [blame] | 602 | resId = updateToTranslucentAnimIfNeeded(resId, transit); |
| 603 | if (ResourceId.isValid(resId)) { |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 604 | return loadAnimationSafely(context, resId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 605 | } |
| 606 | return null; |
| 607 | } |
| 608 | |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 609 | private Animation loadAnimationRes(LayoutParams lp, int resId) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 610 | Context context = mContext; |
Todd Kennedy | 64c57a8 | 2018-04-19 15:17:24 -0700 | [diff] [blame] | 611 | if (ResourceId.isValid(resId)) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 612 | AttributeCache.Entry ent = getCachedAnimations(lp); |
| 613 | if (ent != null) { |
| 614 | context = ent.context; |
| 615 | } |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 616 | return loadAnimationSafely(context, resId); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 617 | } |
| 618 | return null; |
| 619 | } |
| 620 | |
| 621 | private Animation loadAnimationRes(String packageName, int resId) { |
Todd Kennedy | 64c57a8 | 2018-04-19 15:17:24 -0700 | [diff] [blame] | 622 | if (ResourceId.isValid(resId)) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 623 | AttributeCache.Entry ent = getCachedAnimations(packageName, resId); |
| 624 | if (ent != null) { |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 625 | return loadAnimationSafely(ent.context, resId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 626 | } |
| 627 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 628 | return null; |
| 629 | } |
| 630 | |
Jorim Jaggi | b142f57 | 2019-03-01 16:08:54 +0100 | [diff] [blame] | 631 | @VisibleForTesting |
| 632 | Animation loadAnimationSafely(Context context, int resId) { |
| 633 | try { |
| 634 | return AnimationUtils.loadAnimation(context, resId); |
| 635 | } catch (NotFoundException e) { |
| 636 | Slog.w(TAG, "Unable to load animation resource", e); |
| 637 | return null; |
| 638 | } |
| 639 | } |
| 640 | |
Jorim Jaggi | 0a1523d | 2018-04-19 17:48:38 +0200 | [diff] [blame] | 641 | private int updateToTranslucentAnimIfNeeded(int anim, int transit) { |
| 642 | if (transit == TRANSIT_TRANSLUCENT_ACTIVITY_OPEN && anim == R.anim.activity_open_enter) { |
| 643 | return R.anim.activity_translucent_open_enter; |
| 644 | } |
| 645 | if (transit == TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE && anim == R.anim.activity_close_exit) { |
| 646 | return R.anim.activity_translucent_close_exit; |
| 647 | } |
| 648 | return anim; |
| 649 | } |
| 650 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 651 | /** |
| 652 | * Compute the pivot point for an animation that is scaling from a small |
| 653 | * rect on screen to a larger rect. The pivot point varies depending on |
| 654 | * the distance between the inner and outer edges on both sides. This |
| 655 | * function computes the pivot point for one dimension. |
| 656 | * @param startPos Offset from left/top edge of outer rectangle to |
| 657 | * left/top edge of inner rectangle. |
| 658 | * @param finalScale The scaling factor between the size of the outer |
| 659 | * and inner rectangles. |
| 660 | */ |
| 661 | private static float computePivot(int startPos, float finalScale) { |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 662 | |
| 663 | /* |
| 664 | Theorem of intercepting lines: |
| 665 | |
| 666 | + + +-----------------------------------------------+ |
| 667 | | | | | |
| 668 | | | | | |
| 669 | | | | | |
| 670 | | | | | |
| 671 | x | y | | | |
| 672 | | | | | |
| 673 | | | | | |
| 674 | | | | | |
| 675 | | | | | |
| 676 | | + | +--------------------+ | |
| 677 | | | | | | |
| 678 | | | | | | |
| 679 | | | | | | |
| 680 | | | | | | |
| 681 | | | | | | |
| 682 | | | | | | |
| 683 | | | | | | |
| 684 | | | | | | |
| 685 | | | | | | |
| 686 | | | | | | |
| 687 | | | | | | |
| 688 | | | | | | |
| 689 | | | | | | |
| 690 | | | | | | |
| 691 | | | | | | |
| 692 | | | | | | |
| 693 | | | | | | |
| 694 | | | +--------------------+ | |
| 695 | | | | |
| 696 | | | | |
| 697 | | | | |
| 698 | | | | |
| 699 | | | | |
| 700 | | | | |
| 701 | | | | |
| 702 | | +-----------------------------------------------+ |
| 703 | | |
| 704 | | |
| 705 | | |
| 706 | | |
| 707 | | |
| 708 | | |
| 709 | | |
| 710 | | |
| 711 | | |
| 712 | + ++ |
| 713 | p ++ |
| 714 | |
| 715 | scale = (x - y) / x |
| 716 | <=> x = -y / (scale - 1) |
| 717 | */ |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 718 | final float denom = finalScale-1; |
| 719 | if (Math.abs(denom) < .0001f) { |
| 720 | return startPos; |
| 721 | } |
| 722 | return -startPos / denom; |
| 723 | } |
| 724 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 725 | private Animation createScaleUpAnimationLocked(int transit, boolean enter, |
| 726 | Rect containingFrame) { |
| 727 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 728 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 729 | final int appWidth = containingFrame.width(); |
| 730 | final int appHeight = containingFrame.height(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 731 | if (enter) { |
| 732 | // Entering app zooms out from the center of the initial rect. |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 733 | float scaleW = mTmpRect.width() / (float) appWidth; |
| 734 | float scaleH = mTmpRect.height() / (float) appHeight; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 735 | Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 736 | computePivot(mTmpRect.left, scaleW), |
Winson | 4c3fecd | 2016-07-13 12:29:48 -0700 | [diff] [blame] | 737 | computePivot(mTmpRect.top, scaleH)); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 738 | scale.setInterpolator(mDecelerateInterpolator); |
| 739 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 740 | Animation alpha = new AlphaAnimation(0, 1); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 741 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 742 | |
| 743 | AnimationSet set = new AnimationSet(false); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 744 | set.addAnimation(scale); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 745 | set.addAnimation(alpha); |
| 746 | set.setDetachWallpaper(true); |
| 747 | a = set; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 748 | } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || |
| 749 | transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 750 | // If we are on top of the wallpaper, we need an animation that |
| 751 | // correctly handles the wallpaper staying static behind all of |
| 752 | // the animated elements. To do this, will just have the existing |
| 753 | // element fade out. |
| 754 | a = new AlphaAnimation(1, 0); |
| 755 | a.setDetachWallpaper(true); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 756 | } else { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 757 | // For normal animations, the exiting element just holds in place. |
| 758 | a = new AlphaAnimation(1, 1); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 759 | } |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 760 | |
| 761 | // Pick the desired duration. If this is an inter-activity transition, |
| 762 | // it is the standard duration for that. Otherwise we use the longer |
| 763 | // task transition duration. |
| 764 | final long duration; |
| 765 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 766 | case TRANSIT_ACTIVITY_OPEN: |
| 767 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 768 | duration = mConfigShortAnimTime; |
| 769 | break; |
| 770 | default: |
| 771 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 772 | break; |
| 773 | } |
| 774 | a.setDuration(duration); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 775 | a.setFillAfter(true); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 776 | a.setInterpolator(mDecelerateInterpolator); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 777 | a.initialize(appWidth, appHeight, appWidth, appHeight); |
| 778 | return a; |
| 779 | } |
| 780 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 781 | private void getDefaultNextAppTransitionStartRect(Rect rect) { |
| 782 | if (mDefaultNextAppTransitionAnimationSpec == null || |
| 783 | mDefaultNextAppTransitionAnimationSpec.rect == null) { |
Jorim Jaggi | 2550f3f | 2017-03-14 20:15:59 +0100 | [diff] [blame] | 784 | Slog.e(TAG, "Starting rect for app requested, but none available", new Throwable()); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 785 | rect.setEmpty(); |
| 786 | } else { |
| 787 | rect.set(mDefaultNextAppTransitionAnimationSpec.rect); |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | void getNextAppTransitionStartRect(int taskId, Rect rect) { |
| 792 | AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId); |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 793 | if (spec == null) { |
| 794 | spec = mDefaultNextAppTransitionAnimationSpec; |
| 795 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 796 | if (spec == null || spec.rect == null) { |
Jorim Jaggi | 2550f3f | 2017-03-14 20:15:59 +0100 | [diff] [blame] | 797 | Slog.e(TAG, "Starting rect for task: " + taskId + " requested, but not available", |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 798 | new Throwable()); |
| 799 | rect.setEmpty(); |
| 800 | } else { |
| 801 | rect.set(spec.rect); |
| 802 | } |
| 803 | } |
| 804 | |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 805 | private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height, |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 806 | GraphicBuffer buffer) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 807 | mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */, |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 808 | buffer, new Rect(left, top, left + width, top + height)); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 809 | } |
| 810 | |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 811 | /** |
| 812 | * @return the duration of the last clip reveal animation |
| 813 | */ |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 814 | long getLastClipRevealTransitionDuration() { |
| 815 | return mLastClipRevealTransitionDuration; |
| 816 | } |
| 817 | |
| 818 | /** |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 819 | * @return the maximum distance the app surface is traveling of the last clip reveal animation |
| 820 | */ |
| 821 | int getLastClipRevealMaxTranslation() { |
| 822 | return mLastClipRevealMaxTranslation; |
| 823 | } |
| 824 | |
| 825 | /** |
| 826 | * @return true if in the last app transition had a clip reveal animation, false otherwise |
| 827 | */ |
| 828 | boolean hadClipRevealAnimation() { |
| 829 | return mLastHadClipReveal; |
| 830 | } |
| 831 | |
| 832 | /** |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 833 | * Calculates the duration for the clip reveal animation. If the clip is "cut off", meaning that |
| 834 | * the start rect is outside of the target rect, and there is a lot of movement going on. |
| 835 | * |
| 836 | * @param cutOff whether the start rect was not fully contained by the end rect |
| 837 | * @param translationX the total translation the surface moves in x direction |
| 838 | * @param translationY the total translation the surfaces moves in y direction |
| 839 | * @param displayFrame our display frame |
| 840 | * |
| 841 | * @return the duration of the clip reveal animation, in milliseconds |
| 842 | */ |
| 843 | private long calculateClipRevealTransitionDuration(boolean cutOff, float translationX, |
| 844 | float translationY, Rect displayFrame) { |
| 845 | if (!cutOff) { |
| 846 | return DEFAULT_APP_TRANSITION_DURATION; |
| 847 | } |
| 848 | final float fraction = Math.max(Math.abs(translationX) / displayFrame.width(), |
| 849 | Math.abs(translationY) / displayFrame.height()); |
| 850 | return (long) (DEFAULT_APP_TRANSITION_DURATION + fraction * |
| 851 | (MAX_CLIP_REVEAL_TRANSITION_DURATION - DEFAULT_APP_TRANSITION_DURATION)); |
| 852 | } |
| 853 | |
| 854 | private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame, |
| 855 | Rect displayFrame) { |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 856 | final Animation anim; |
| 857 | if (enter) { |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 858 | final int appWidth = appFrame.width(); |
| 859 | final int appHeight = appFrame.height(); |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 860 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 861 | // mTmpRect will contain an area around the launcher icon that was pressed. We will |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 862 | // clip reveal from that area in the final area of the app. |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 863 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 864 | |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 865 | float t = 0f; |
| 866 | if (appHeight > 0) { |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 867 | t = (float) mTmpRect.top / displayFrame.height(); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 868 | } |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 869 | int translationY = mClipRevealTranslationY + (int)(displayFrame.height() / 7f * t); |
| 870 | int translationX = 0; |
| 871 | int translationYCorrection = translationY; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 872 | int centerX = mTmpRect.centerX(); |
| 873 | int centerY = mTmpRect.centerY(); |
| 874 | int halfWidth = mTmpRect.width() / 2; |
| 875 | int halfHeight = mTmpRect.height() / 2; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 876 | int clipStartX = centerX - halfWidth - appFrame.left; |
| 877 | int clipStartY = centerY - halfHeight - appFrame.top; |
| 878 | boolean cutOff = false; |
| 879 | |
| 880 | // If the starting rectangle is fully or partially outside of the target rectangle, we |
| 881 | // need to start the clipping at the edge and then achieve the rest with translation |
| 882 | // and extending the clip rect from that edge. |
| 883 | if (appFrame.top > centerY - halfHeight) { |
| 884 | translationY = (centerY - halfHeight) - appFrame.top; |
| 885 | translationYCorrection = 0; |
| 886 | clipStartY = 0; |
| 887 | cutOff = true; |
| 888 | } |
| 889 | if (appFrame.left > centerX - halfWidth) { |
| 890 | translationX = (centerX - halfWidth) - appFrame.left; |
| 891 | clipStartX = 0; |
| 892 | cutOff = true; |
| 893 | } |
| 894 | if (appFrame.right < centerX + halfWidth) { |
| 895 | translationX = (centerX + halfWidth) - appFrame.right; |
| 896 | clipStartX = appWidth - mTmpRect.width(); |
| 897 | cutOff = true; |
| 898 | } |
| 899 | final long duration = calculateClipRevealTransitionDuration(cutOff, translationX, |
| 900 | translationY, displayFrame); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 901 | |
| 902 | // Clip third of the from size of launch icon, expand to full width/height |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 903 | Animation clipAnimLR = new ClipRectLRAnimation( |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 904 | clipStartX, clipStartX + mTmpRect.width(), 0, appWidth); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 905 | clipAnimLR.setInterpolator(mClipHorizontalInterpolator); |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 906 | clipAnimLR.setDuration((long) (duration / 2.5f)); |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 907 | |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 908 | TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0); |
| 909 | translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR |
| 910 | : mLinearOutSlowInInterpolator); |
| 911 | translate.setDuration(duration); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 912 | |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 913 | Animation clipAnimTB = new ClipRectTBAnimation( |
| 914 | clipStartY, clipStartY + mTmpRect.height(), |
| 915 | 0, appHeight, |
| 916 | translationYCorrection, 0, |
| 917 | mLinearOutSlowInInterpolator); |
| 918 | clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR); |
| 919 | clipAnimTB.setDuration(duration); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 920 | |
| 921 | // Quick fade-in from icon to app window |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 922 | final long alphaDuration = duration / 4; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 923 | AlphaAnimation alpha = new AlphaAnimation(0.5f, 1); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 924 | alpha.setDuration(alphaDuration); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 925 | alpha.setInterpolator(mLinearOutSlowInInterpolator); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 926 | |
| 927 | AnimationSet set = new AnimationSet(false); |
| 928 | set.addAnimation(clipAnimLR); |
| 929 | set.addAnimation(clipAnimTB); |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 930 | set.addAnimation(translate); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 931 | set.addAnimation(alpha); |
Filip Gruszczynski | 9e2cf5b | 2015-07-31 12:20:40 -0700 | [diff] [blame] | 932 | set.setZAdjustment(Animation.ZORDER_TOP); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 933 | set.initialize(appWidth, appHeight, appWidth, appHeight); |
| 934 | anim = set; |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 935 | mLastHadClipReveal = true; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 936 | mLastClipRevealTransitionDuration = duration; |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 937 | |
| 938 | // If the start rect was full inside the target rect (cutOff == false), we don't need |
| 939 | // to store the translation, because it's only used if cutOff == true. |
| 940 | mLastClipRevealMaxTranslation = cutOff |
| 941 | ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 942 | } else { |
| 943 | final long duration; |
| 944 | switch (transit) { |
| 945 | case TRANSIT_ACTIVITY_OPEN: |
| 946 | case TRANSIT_ACTIVITY_CLOSE: |
| 947 | duration = mConfigShortAnimTime; |
| 948 | break; |
| 949 | default: |
| 950 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 951 | break; |
| 952 | } |
| 953 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || |
| 954 | transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { |
| 955 | // If we are on top of the wallpaper, we need an animation that |
| 956 | // correctly handles the wallpaper staying static behind all of |
| 957 | // the animated elements. To do this, will just have the existing |
| 958 | // element fade out. |
| 959 | anim = new AlphaAnimation(1, 0); |
| 960 | anim.setDetachWallpaper(true); |
| 961 | } else { |
| 962 | // For normal animations, the exiting element just holds in place. |
| 963 | anim = new AlphaAnimation(1, 1); |
| 964 | } |
| 965 | anim.setInterpolator(mDecelerateInterpolator); |
| 966 | anim.setDuration(duration); |
| 967 | anim.setFillAfter(true); |
| 968 | } |
| 969 | return anim; |
| 970 | } |
| 971 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 972 | /** |
| 973 | * Prepares the specified animation with a standard duration, interpolator, etc. |
| 974 | */ |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 975 | Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight, |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 976 | long duration, Interpolator interpolator) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 977 | if (duration > 0) { |
| 978 | a.setDuration(duration); |
| 979 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 980 | a.setFillAfter(true); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 981 | if (interpolator != null) { |
| 982 | a.setInterpolator(interpolator); |
| 983 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 984 | a.initialize(appWidth, appHeight, appWidth, appHeight); |
| 985 | return a; |
| 986 | } |
| 987 | |
| 988 | /** |
| 989 | * Prepares the specified animation with a standard duration, interpolator, etc. |
| 990 | */ |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 991 | Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 992 | // Pick the desired duration. If this is an inter-activity transition, |
| 993 | // it is the standard duration for that. Otherwise we use the longer |
| 994 | // task transition duration. |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 995 | final int duration; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 996 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 997 | case TRANSIT_ACTIVITY_OPEN: |
| 998 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 999 | duration = mConfigShortAnimTime; |
| 1000 | break; |
| 1001 | default: |
| 1002 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 1003 | break; |
| 1004 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 1005 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration, |
| 1006 | mDecelerateInterpolator); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1007 | } |
| 1008 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1009 | /** |
| 1010 | * Return the current thumbnail transition state. |
| 1011 | */ |
| 1012 | int getThumbnailTransitionState(boolean enter) { |
| 1013 | if (enter) { |
| 1014 | if (mNextAppTransitionScaleUp) { |
| 1015 | return THUMBNAIL_TRANSITION_ENTER_SCALE_UP; |
| 1016 | } else { |
| 1017 | return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN; |
| 1018 | } |
| 1019 | } else { |
| 1020 | if (mNextAppTransitionScaleUp) { |
| 1021 | return THUMBNAIL_TRANSITION_EXIT_SCALE_UP; |
| 1022 | } else { |
| 1023 | return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN; |
| 1024 | } |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | /** |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 1029 | * Creates an overlay with a background color and a thumbnail for the cross profile apps |
| 1030 | * animation. |
| 1031 | */ |
| 1032 | GraphicBuffer createCrossProfileAppsThumbnail( |
| 1033 | @DrawableRes int thumbnailDrawableRes, Rect frame) { |
| 1034 | final int width = frame.width(); |
| 1035 | final int height = frame.height(); |
| 1036 | |
John Reck | 519ad48 | 2018-02-12 17:08:48 -0800 | [diff] [blame] | 1037 | final Picture picture = new Picture(); |
| 1038 | final Canvas canvas = picture.beginRecording(width, height); |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 1039 | canvas.drawColor(Color.argb(0.6f, 0, 0, 0)); |
| 1040 | final int thumbnailSize = mService.mContext.getResources().getDimensionPixelSize( |
| 1041 | com.android.internal.R.dimen.cross_profile_apps_thumbnail_size); |
| 1042 | final Drawable drawable = mService.mContext.getDrawable(thumbnailDrawableRes); |
| 1043 | drawable.setBounds( |
| 1044 | (width - thumbnailSize) / 2, |
| 1045 | (height - thumbnailSize) / 2, |
| 1046 | (width + thumbnailSize) / 2, |
| 1047 | (height + thumbnailSize) / 2); |
Tony Mak | da4af23 | 2018-04-27 11:01:10 +0100 | [diff] [blame] | 1048 | drawable.setTint(mContext.getColor(android.R.color.white)); |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 1049 | drawable.draw(canvas); |
John Reck | 519ad48 | 2018-02-12 17:08:48 -0800 | [diff] [blame] | 1050 | picture.endRecording(); |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 1051 | |
John Reck | 519ad48 | 2018-02-12 17:08:48 -0800 | [diff] [blame] | 1052 | return Bitmap.createBitmap(picture).createGraphicBufferHandle(); |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | Animation createCrossProfileAppsThumbnailAnimationLocked(Rect appRect) { |
| 1056 | final Animation animation = loadAnimationRes( |
| 1057 | "android", com.android.internal.R.anim.cross_profile_apps_thumbnail_enter); |
| 1058 | return prepareThumbnailAnimationWithDuration(animation, appRect.width(), |
| 1059 | appRect.height(), 0, null); |
| 1060 | } |
| 1061 | |
| 1062 | /** |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1063 | * This animation runs for the thumbnail that gets cross faded with the enter/exit activity |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1064 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1065 | */ |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1066 | Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, @Nullable Rect contentInsets, |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 1067 | GraphicBuffer thumbnailHeader, final int taskId, int uiMode, int orientation) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1068 | Animation a; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1069 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1070 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1071 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 1072 | final int appWidth = appRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1073 | |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 1074 | float scaleW = appWidth / thumbWidth; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1075 | getNextAppTransitionStartRect(taskId, mTmpRect); |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame] | 1076 | final float fromX; |
Manu Cornet | 57b6149 | 2017-01-24 18:19:05 +0900 | [diff] [blame] | 1077 | float fromY; |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame] | 1078 | final float toX; |
Manu Cornet | 57b6149 | 2017-01-24 18:19:05 +0900 | [diff] [blame] | 1079 | float toY; |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame] | 1080 | final float pivotX; |
| 1081 | final float pivotY; |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 1082 | if (shouldScaleDownThumbnailTransition(uiMode, orientation)) { |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame] | 1083 | fromX = mTmpRect.left; |
| 1084 | fromY = mTmpRect.top; |
| 1085 | |
| 1086 | // For the curved translate animation to work, the pivot points needs to be at the |
| 1087 | // same absolute position as the one from the real surface. |
| 1088 | toX = mTmpRect.width() / 2 * (scaleW - 1f) + appRect.left; |
| 1089 | toY = appRect.height() / 2 * (1 - 1 / scaleW) + appRect.top; |
| 1090 | pivotX = mTmpRect.width() / 2; |
| 1091 | pivotY = appRect.height() / 2 / scaleW; |
Manu Cornet | 57b6149 | 2017-01-24 18:19:05 +0900 | [diff] [blame] | 1092 | if (mGridLayoutRecentsEnabled) { |
| 1093 | // In the grid layout, the header is displayed above the thumbnail instead of |
| 1094 | // overlapping it. |
| 1095 | fromY -= thumbHeightI; |
| 1096 | toY -= thumbHeightI * scaleW; |
| 1097 | } |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame] | 1098 | } else { |
| 1099 | pivotX = 0; |
| 1100 | pivotY = 0; |
| 1101 | fromX = mTmpRect.left; |
| 1102 | fromY = mTmpRect.top; |
| 1103 | toX = appRect.left; |
| 1104 | toY = appRect.top; |
| 1105 | } |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1106 | final long duration = getAspectScaleDuration(); |
| 1107 | final Interpolator interpolator = getAspectScaleInterpolator(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1108 | if (mNextAppTransitionScaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1109 | // Animation up from the thumbnail to the full screen |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1110 | Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, pivotX, pivotY); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1111 | scale.setInterpolator(interpolator); |
| 1112 | scale.setDuration(duration); |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 1113 | Animation alpha = new AlphaAnimation(1f, 0f); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1114 | alpha.setInterpolator(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
| 1115 | ? THUMBNAIL_DOCK_INTERPOLATOR : mThumbnailFadeOutInterpolator); |
| 1116 | alpha.setDuration(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
| 1117 | ? duration / 2 |
| 1118 | : duration); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1119 | Animation translate = createCurvedMotion(fromX, toX, fromY, toY); |
| 1120 | translate.setInterpolator(interpolator); |
| 1121 | translate.setDuration(duration); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1122 | |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1123 | mTmpFromClipRect.set(0, 0, thumbWidthI, thumbHeightI); |
| 1124 | mTmpToClipRect.set(appRect); |
| 1125 | |
| 1126 | // Containing frame is in screen space, but we need the clip rect in the |
| 1127 | // app space. |
| 1128 | mTmpToClipRect.offsetTo(0, 0); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1129 | mTmpToClipRect.right = (int) (mTmpToClipRect.right / scaleW); |
| 1130 | mTmpToClipRect.bottom = (int) (mTmpToClipRect.bottom / scaleW); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1131 | |
| 1132 | if (contentInsets != null) { |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1133 | mTmpToClipRect.inset((int) (-contentInsets.left * scaleW), |
| 1134 | (int) (-contentInsets.top * scaleW), |
| 1135 | (int) (-contentInsets.right * scaleW), |
| 1136 | (int) (-contentInsets.bottom * scaleW)); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1140 | clipAnim.setInterpolator(interpolator); |
| 1141 | clipAnim.setDuration(duration); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1142 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1143 | // This AnimationSet uses the Interpolators assigned above. |
| 1144 | AnimationSet set = new AnimationSet(false); |
| 1145 | set.addAnimation(scale); |
Manu Cornet | 57b6149 | 2017-01-24 18:19:05 +0900 | [diff] [blame] | 1146 | if (!mGridLayoutRecentsEnabled) { |
| 1147 | // In the grid layout, the header should be shown for the whole animation. |
| 1148 | set.addAnimation(alpha); |
| 1149 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1150 | set.addAnimation(translate); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1151 | set.addAnimation(clipAnim); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1152 | a = set; |
| 1153 | } else { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1154 | // Animation down from the full screen to the thumbnail |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1155 | Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, pivotX, pivotY); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1156 | scale.setInterpolator(interpolator); |
| 1157 | scale.setDuration(duration); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1158 | Animation alpha = new AlphaAnimation(0f, 1f); |
| 1159 | alpha.setInterpolator(mThumbnailFadeInInterpolator); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1160 | alpha.setDuration(duration); |
| 1161 | Animation translate = createCurvedMotion(toX, fromX, toY, fromY); |
| 1162 | translate.setInterpolator(interpolator); |
| 1163 | translate.setDuration(duration); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1164 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1165 | // This AnimationSet uses the Interpolators assigned above. |
| 1166 | AnimationSet set = new AnimationSet(false); |
| 1167 | set.addAnimation(scale); |
Manu Cornet | 57b6149 | 2017-01-24 18:19:05 +0900 | [diff] [blame] | 1168 | if (!mGridLayoutRecentsEnabled) { |
| 1169 | // In the grid layout, the header should be shown for the whole animation. |
| 1170 | set.addAnimation(alpha); |
| 1171 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1172 | set.addAnimation(translate); |
| 1173 | a = set; |
| 1174 | |
| 1175 | } |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 1176 | return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0, |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1177 | null); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1178 | } |
| 1179 | |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1180 | private Animation createCurvedMotion(float fromX, float toX, float fromY, float toY) { |
| 1181 | |
| 1182 | // Almost no x-change - use linear animation |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1183 | if (Math.abs(toX - fromX) < 1f || mNextAppTransition != TRANSIT_DOCK_TASK_FROM_RECENTS) { |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1184 | return new TranslateAnimation(fromX, toX, fromY, toY); |
| 1185 | } else { |
| 1186 | final Path path = createCurvedPath(fromX, toX, fromY, toY); |
| 1187 | return new CurvedTranslateAnimation(path); |
| 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | private Path createCurvedPath(float fromX, float toX, float fromY, float toY) { |
| 1192 | final Path path = new Path(); |
| 1193 | path.moveTo(fromX, fromY); |
Jorim Jaggi | 1f458fb | 2016-03-25 17:36:37 -0700 | [diff] [blame] | 1194 | |
| 1195 | if (fromY > toY) { |
| 1196 | // If the object needs to go up, move it in horizontal direction first, then vertical. |
| 1197 | path.cubicTo(fromX, fromY, toX, 0.9f * fromY + 0.1f * toY, toX, toY); |
| 1198 | } else { |
| 1199 | // If the object needs to go down, move it in vertical direction first, then horizontal. |
| 1200 | path.cubicTo(fromX, fromY, fromX, 0.1f * fromY + 0.9f * toY, toX, toY); |
| 1201 | } |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1202 | return path; |
| 1203 | } |
| 1204 | |
| 1205 | private long getAspectScaleDuration() { |
| 1206 | if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) { |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1207 | return (long) (THUMBNAIL_APP_TRANSITION_DURATION * 1.35f); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1208 | } else { |
| 1209 | return THUMBNAIL_APP_TRANSITION_DURATION; |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | private Interpolator getAspectScaleInterpolator() { |
| 1214 | if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) { |
| 1215 | return mFastOutSlowInInterpolator; |
| 1216 | } else { |
| 1217 | return TOUCH_RESPONSE_INTERPOLATOR; |
| 1218 | } |
| 1219 | } |
| 1220 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1221 | /** |
| 1222 | * This alternate animation is created when we are doing a thumbnail transition, for the |
| 1223 | * activity that is leaving, and the activity that is entering. |
| 1224 | */ |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1225 | Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState, |
Winson | b202476 | 2016-04-05 17:32:30 -0700 | [diff] [blame] | 1226 | int uiMode, int orientation, int transit, Rect containingFrame, Rect contentInsets, |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 1227 | @Nullable Rect surfaceInsets, @Nullable Rect stableInsets, boolean freeform, |
| 1228 | int taskId) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1229 | Animation a; |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1230 | final int appWidth = containingFrame.width(); |
| 1231 | final int appHeight = containingFrame.height(); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1232 | getDefaultNextAppTransitionStartRect(mTmpRect); |
| 1233 | final int thumbWidthI = mTmpRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1234 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1235 | final int thumbHeightI = mTmpRect.height(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1236 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
Winson | cbb625b | 2016-07-06 15:24:15 -0700 | [diff] [blame] | 1237 | final int thumbStartX = mTmpRect.left - containingFrame.left - contentInsets.left; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1238 | final int thumbStartY = mTmpRect.top - containingFrame.top; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1239 | |
| 1240 | switch (thumbTransitState) { |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1241 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: |
| 1242 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 1243 | final boolean scaleUp = thumbTransitState == THUMBNAIL_TRANSITION_ENTER_SCALE_UP; |
| 1244 | if (freeform && scaleUp) { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1245 | a = createAspectScaledThumbnailEnterFreeformAnimationLocked( |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1246 | containingFrame, surfaceInsets, taskId); |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1247 | } else if (freeform) { |
| 1248 | a = createAspectScaledThumbnailExitFreeformAnimationLocked( |
| 1249 | containingFrame, surfaceInsets, taskId); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 1250 | } else { |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1251 | AnimationSet set = new AnimationSet(true); |
| 1252 | |
| 1253 | // In portrait, we scale to fit the width |
Filip Gruszczynski | efd3d1b | 2015-10-14 13:57:55 -0700 | [diff] [blame] | 1254 | mTmpFromClipRect.set(containingFrame); |
Filip Gruszczynski | efd3d1b | 2015-10-14 13:57:55 -0700 | [diff] [blame] | 1255 | mTmpToClipRect.set(containingFrame); |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 1256 | |
| 1257 | // Containing frame is in screen space, but we need the clip rect in the |
| 1258 | // app space. |
| 1259 | mTmpFromClipRect.offsetTo(0, 0); |
| 1260 | mTmpToClipRect.offsetTo(0, 0); |
| 1261 | |
| 1262 | // Exclude insets region from the source clip. |
| 1263 | mTmpFromClipRect.inset(contentInsets); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1264 | mNextAppTransitionInsets.set(contentInsets); |
| 1265 | |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 1266 | if (shouldScaleDownThumbnailTransition(uiMode, orientation)) { |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1267 | // We scale the width and clip to the top/left square |
| 1268 | float scale = thumbWidth / |
| 1269 | (appWidth - contentInsets.left - contentInsets.right); |
Manu Cornet | b68b765 | 2017-01-23 19:37:53 +0900 | [diff] [blame] | 1270 | if (!mGridLayoutRecentsEnabled) { |
| 1271 | int unscaledThumbHeight = (int) (thumbHeight / scale); |
| 1272 | mTmpFromClipRect.bottom = mTmpFromClipRect.top + unscaledThumbHeight; |
| 1273 | } |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1274 | |
| 1275 | mNextAppTransitionInsets.set(contentInsets); |
| 1276 | |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1277 | Animation scaleAnim = new ScaleAnimation( |
| 1278 | scaleUp ? scale : 1, scaleUp ? 1 : scale, |
| 1279 | scaleUp ? scale : 1, scaleUp ? 1 : scale, |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1280 | containingFrame.width() / 2f, |
| 1281 | containingFrame.height() / 2f + contentInsets.top); |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1282 | final float targetX = (mTmpRect.left - containingFrame.left); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1283 | final float x = containingFrame.width() / 2f |
| 1284 | - containingFrame.width() / 2f * scale; |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1285 | final float targetY = (mTmpRect.top - containingFrame.top); |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 1286 | float y = containingFrame.height() / 2f |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1287 | - containingFrame.height() / 2f * scale; |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 1288 | |
| 1289 | // During transition may require clipping offset from any top stable insets |
| 1290 | // such as the statusbar height when statusbar is hidden |
| 1291 | if (mLowRamRecentsEnabled && contentInsets.top == 0 && scaleUp) { |
| 1292 | mTmpFromClipRect.top += stableInsets.top; |
| 1293 | y += stableInsets.top; |
| 1294 | } |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1295 | final float startX = targetX - x; |
| 1296 | final float startY = targetY - y; |
| 1297 | Animation clipAnim = scaleUp |
| 1298 | ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect) |
| 1299 | : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect); |
| 1300 | Animation translateAnim = scaleUp |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1301 | ? createCurvedMotion(startX, 0, startY - contentInsets.top, 0) |
| 1302 | : createCurvedMotion(0, startX, 0, startY - contentInsets.top); |
| 1303 | |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1304 | set.addAnimation(clipAnim); |
| 1305 | set.addAnimation(scaleAnim); |
| 1306 | set.addAnimation(translateAnim); |
| 1307 | |
| 1308 | } else { |
| 1309 | // In landscape, we don't scale at all and only crop |
| 1310 | mTmpFromClipRect.bottom = mTmpFromClipRect.top + thumbHeightI; |
| 1311 | mTmpFromClipRect.right = mTmpFromClipRect.left + thumbWidthI; |
| 1312 | |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1313 | Animation clipAnim = scaleUp |
| 1314 | ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect) |
| 1315 | : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect); |
| 1316 | Animation translateAnim = scaleUp |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1317 | ? createCurvedMotion(thumbStartX, 0, |
| 1318 | thumbStartY - contentInsets.top, 0) |
| 1319 | : createCurvedMotion(0, thumbStartX, 0, |
| 1320 | thumbStartY - contentInsets.top); |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1321 | |
| 1322 | set.addAnimation(clipAnim); |
| 1323 | set.addAnimation(translateAnim); |
| 1324 | } |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1325 | a = set; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1326 | a.setZAdjustment(Animation.ZORDER_TOP); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 1327 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1328 | break; |
| 1329 | } |
| 1330 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1331 | // Previous app window during the scale up |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1332 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1333 | // Fade out the source activity if we are animating to a wallpaper |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1334 | // activity. |
| 1335 | a = new AlphaAnimation(1, 0); |
| 1336 | } else { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1337 | a = new AlphaAnimation(1, 1); |
| 1338 | } |
| 1339 | break; |
| 1340 | } |
| 1341 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1342 | // Target app window during the scale down |
| 1343 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 1344 | // Fade in the destination activity if we are animating from a wallpaper |
| 1345 | // activity. |
| 1346 | a = new AlphaAnimation(0, 1); |
| 1347 | } else { |
| 1348 | a = new AlphaAnimation(1, 1); |
| 1349 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1350 | break; |
| 1351 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1352 | default: |
| 1353 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1354 | } |
| 1355 | |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1356 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, |
| 1357 | getAspectScaleDuration(), getAspectScaleInterpolator()); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1360 | private Animation createAspectScaledThumbnailEnterFreeformAnimationLocked(Rect frame, |
| 1361 | @Nullable Rect surfaceInsets, int taskId) { |
| 1362 | getNextAppTransitionStartRect(taskId, mTmpRect); |
| 1363 | return createAspectScaledThumbnailFreeformAnimationLocked(mTmpRect, frame, surfaceInsets, |
| 1364 | true); |
| 1365 | } |
| 1366 | |
| 1367 | private Animation createAspectScaledThumbnailExitFreeformAnimationLocked(Rect frame, |
| 1368 | @Nullable Rect surfaceInsets, int taskId) { |
| 1369 | getNextAppTransitionStartRect(taskId, mTmpRect); |
| 1370 | return createAspectScaledThumbnailFreeformAnimationLocked(frame, mTmpRect, surfaceInsets, |
| 1371 | false); |
| 1372 | } |
| 1373 | |
| 1374 | private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, |
| 1375 | Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) { |
| 1376 | final float sourceWidth = sourceFrame.width(); |
| 1377 | final float sourceHeight = sourceFrame.height(); |
| 1378 | final float destWidth = destFrame.width(); |
| 1379 | final float destHeight = destFrame.height(); |
| 1380 | final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth; |
| 1381 | final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight; |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1382 | AnimationSet set = new AnimationSet(true); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1383 | final int surfaceInsetsH = surfaceInsets == null |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1384 | ? 0 : surfaceInsets.left + surfaceInsets.right; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1385 | final int surfaceInsetsV = surfaceInsets == null |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1386 | ? 0 : surfaceInsets.top + surfaceInsets.bottom; |
| 1387 | // We want the scaling to happen from the center of the surface. In order to achieve that, |
| 1388 | // we need to account for surface insets that will be used to enlarge the surface. |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1389 | final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2; |
| 1390 | final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2; |
| 1391 | final ScaleAnimation scale = enter ? |
| 1392 | new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) |
| 1393 | : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter); |
| 1394 | final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2; |
| 1395 | final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2; |
| 1396 | final int destHCenter = destFrame.left + destFrame.width() / 2; |
| 1397 | final int destVCenter = destFrame.top + destFrame.height() / 2; |
| 1398 | final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter; |
| 1399 | final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter; |
| 1400 | final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) |
| 1401 | : new TranslateAnimation(0, fromX, 0, fromY); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1402 | set.addAnimation(scale); |
| 1403 | set.addAnimation(translation); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1404 | |
| 1405 | final IRemoteCallback callback = mAnimationFinishedCallback; |
| 1406 | if (callback != null) { |
| 1407 | set.setAnimationListener(new Animation.AnimationListener() { |
| 1408 | @Override |
| 1409 | public void onAnimationStart(Animation animation) { } |
| 1410 | |
| 1411 | @Override |
| 1412 | public void onAnimationEnd(Animation animation) { |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 1413 | mHandler.sendMessage(PooledLambda.obtainMessage( |
| 1414 | AppTransition::doAnimationCallback, callback)); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | @Override |
| 1418 | public void onAnimationRepeat(Animation animation) { } |
| 1419 | }); |
| 1420 | } |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1421 | return set; |
| 1422 | } |
| 1423 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1424 | /** |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1425 | * This animation runs for the thumbnail that gets cross faded with the enter/exit activity |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1426 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1427 | */ |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1428 | Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 1429 | GraphicBuffer thumbnailHeader) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1430 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1431 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1432 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1433 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1434 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1435 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 1436 | |
| 1437 | if (mNextAppTransitionScaleUp) { |
| 1438 | // Animation for the thumbnail zooming from its initial size to the full screen |
| 1439 | float scaleW = appWidth / thumbWidth; |
| 1440 | float scaleH = appHeight / thumbHeight; |
| 1441 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1442 | computePivot(mTmpRect.left, 1 / scaleW), |
| 1443 | computePivot(mTmpRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1444 | scale.setInterpolator(mDecelerateInterpolator); |
| 1445 | |
| 1446 | Animation alpha = new AlphaAnimation(1, 0); |
| 1447 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
| 1448 | |
| 1449 | // This AnimationSet uses the Interpolators assigned above. |
| 1450 | AnimationSet set = new AnimationSet(false); |
| 1451 | set.addAnimation(scale); |
| 1452 | set.addAnimation(alpha); |
| 1453 | a = set; |
| 1454 | } else { |
| 1455 | // Animation for the thumbnail zooming down from the full screen to its final size |
| 1456 | float scaleW = appWidth / thumbWidth; |
| 1457 | float scaleH = appHeight / thumbHeight; |
| 1458 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1459 | computePivot(mTmpRect.left, 1 / scaleW), |
| 1460 | computePivot(mTmpRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1461 | } |
| 1462 | |
| 1463 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1464 | } |
| 1465 | |
| 1466 | /** |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1467 | * This animation is created when we are doing a thumbnail transition, for the activity that is |
| 1468 | * leaving, and the activity that is entering. |
| 1469 | */ |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1470 | Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame, |
| 1471 | int transit, int taskId) { |
| 1472 | final int appWidth = containingFrame.width(); |
| 1473 | final int appHeight = containingFrame.height(); |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 1474 | final GraphicBuffer thumbnailHeader = getAppTransitionThumbnailHeader(taskId); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1475 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1476 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1477 | final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1478 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1479 | final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1480 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 1481 | |
| 1482 | switch (thumbTransitState) { |
| 1483 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: { |
| 1484 | // Entering app scales up with the thumbnail |
| 1485 | float scaleW = thumbWidth / appWidth; |
| 1486 | float scaleH = thumbHeight / appHeight; |
| 1487 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1488 | computePivot(mTmpRect.left, scaleW), |
| 1489 | computePivot(mTmpRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1490 | break; |
| 1491 | } |
| 1492 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
| 1493 | // Exiting app while the thumbnail is scaling up should fade or stay in place |
| 1494 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 1495 | // Fade out while bringing up selected activity. This keeps the |
| 1496 | // current activity from showing through a launching wallpaper |
| 1497 | // activity. |
| 1498 | a = new AlphaAnimation(1, 0); |
| 1499 | } else { |
| 1500 | // noop animation |
| 1501 | a = new AlphaAnimation(1, 1); |
| 1502 | } |
| 1503 | break; |
| 1504 | } |
| 1505 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
| 1506 | // Entering the other app, it should just be visible while we scale the thumbnail |
| 1507 | // down above it |
| 1508 | a = new AlphaAnimation(1, 1); |
| 1509 | break; |
| 1510 | } |
| 1511 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 1512 | // Exiting the current app, the app should scale down with the thumbnail |
| 1513 | float scaleW = thumbWidth / appWidth; |
| 1514 | float scaleH = thumbHeight / appHeight; |
| 1515 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1516 | computePivot(mTmpRect.left, scaleW), |
| 1517 | computePivot(mTmpRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1518 | |
| 1519 | Animation alpha = new AlphaAnimation(1, 0); |
| 1520 | |
| 1521 | AnimationSet set = new AnimationSet(true); |
| 1522 | set.addAnimation(scale); |
| 1523 | set.addAnimation(alpha); |
| 1524 | set.setZAdjustment(Animation.ZORDER_TOP); |
| 1525 | a = set; |
| 1526 | break; |
| 1527 | } |
| 1528 | default: |
| 1529 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1530 | } |
| 1531 | |
| 1532 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1533 | } |
| 1534 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1535 | private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1536 | getDefaultNextAppTransitionStartRect(mTmpFromClipRect); |
| 1537 | final int left = mTmpFromClipRect.left; |
| 1538 | final int top = mTmpFromClipRect.top; |
| 1539 | mTmpFromClipRect.offset(-left, -top); |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1540 | // TODO: Isn't that strange that we ignore exact position of the containingFrame? |
| 1541 | mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height()); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1542 | AnimationSet set = new AnimationSet(true); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1543 | float fromWidth = mTmpFromClipRect.width(); |
| 1544 | float toWidth = mTmpToClipRect.width(); |
| 1545 | float fromHeight = mTmpFromClipRect.height(); |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1546 | // While the window might span the whole display, the actual content will be cropped to the |
| 1547 | // system decoration frame, for example when the window is docked. We need to take into |
| 1548 | // account the visible height when constructing the animation. |
| 1549 | float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom; |
| 1550 | int translateAdjustment = 0; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1551 | if (fromWidth <= toWidth && fromHeight <= toHeight) { |
| 1552 | // The final window is larger in both dimensions than current window (e.g. we are |
| 1553 | // maximizing), so we can simply unclip the new window and there will be no disappearing |
| 1554 | // frame. |
| 1555 | set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)); |
| 1556 | } else { |
| 1557 | // The disappearing window has one larger dimension. We need to apply scaling, so the |
| 1558 | // first frame of the entry animation matches the old window. |
| 1559 | set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1)); |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1560 | // We might not be going exactly full screen, but instead be aligned under the status |
| 1561 | // bar using cropping. We still need to account for the cropped part, which will also |
| 1562 | // be scaled. |
| 1563 | translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1564 | } |
| 1565 | |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1566 | // We animate the translation from the old position of the removed window, to the new |
| 1567 | // position of the added window. The latter might not be full screen, for example docked for |
| 1568 | // docked windows. |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1569 | TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left, |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1570 | 0, top - containingFrame.top - translateAdjustment, 0); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1571 | set.addAnimation(translate); |
| 1572 | set.setDuration(DEFAULT_APP_TRANSITION_DURATION); |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 1573 | set.setZAdjustment(Animation.ZORDER_TOP); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1574 | return set; |
| 1575 | } |
| 1576 | |
Jorim Jaggi | c554b77 | 2015-06-04 16:07:57 -0700 | [diff] [blame] | 1577 | /** |
| 1578 | * @return true if and only if the first frame of the transition can be skipped, i.e. the first |
| 1579 | * frame of the transition doesn't change the visuals on screen, so we can start |
| 1580 | * directly with the second one |
| 1581 | */ |
| 1582 | boolean canSkipFirstFrame() { |
| 1583 | return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM |
| 1584 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1585 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL |
| 1586 | && mNextAppTransition != TRANSIT_KEYGUARD_GOING_AWAY; |
Jorim Jaggi | c554b77 | 2015-06-04 16:07:57 -0700 | [diff] [blame] | 1587 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1588 | |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1589 | RemoteAnimationController getRemoteAnimationController() { |
| 1590 | return mRemoteAnimationController; |
| 1591 | } |
| 1592 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1593 | /** |
| 1594 | * |
| 1595 | * @param frame These are the bounds of the window when it finishes the animation. This is where |
| 1596 | * the animation must usually finish in entrance animation, as the next frame will |
| 1597 | * display the window at these coordinates. In case of exit animation, this is |
| 1598 | * where the animation must start, as the frame before the animation is displaying |
| 1599 | * the window at these bounds. |
| 1600 | * @param insets Knowing where the window will be positioned is not enough. Some parts of the |
| 1601 | * window might be obscured, usually by the system windows (status bar and |
| 1602 | * navigation bar) and we use content insets to convey that information. This |
| 1603 | * usually affects the animation aspects vertically, as the system decoration is |
| 1604 | * at the top and the bottom. For example when we animate from full screen to |
| 1605 | * recents, we want to exclude the covered parts, because they won't match the |
| 1606 | * thumbnail after the last frame is executed. |
| 1607 | * @param surfaceInsets In rare situation the surface is larger than the content and we need to |
| 1608 | * know about this to make the animation frames match. We currently use |
| 1609 | * this for freeform windows, which have larger surfaces to display |
| 1610 | * shadows. When we animate them from recents, we want to match the content |
| 1611 | * to the recents thumbnail and hence need to account for the surface being |
| 1612 | * bigger. |
| 1613 | */ |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 1614 | Animation loadAnimation(LayoutParams lp, int transit, boolean enter, int uiMode, |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 1615 | int orientation, Rect frame, Rect displayFrame, Rect insets, |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 1616 | @Nullable Rect surfaceInsets, @Nullable Rect stableInsets, boolean isVoiceInteraction, |
| 1617 | boolean freeform, int taskId) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1618 | Animation a; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1619 | if (isKeyguardGoingAwayTransit(transit) && enter) { |
| 1620 | a = loadKeyguardExitAnimation(transit); |
| 1621 | } else if (transit == TRANSIT_KEYGUARD_OCCLUDE) { |
Selim Cinek | dbf172e | 2018-08-08 18:31:45 +0000 | [diff] [blame] | 1622 | a = null; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1623 | } else if (transit == TRANSIT_KEYGUARD_UNOCCLUDE && !enter) { |
| 1624 | a = loadAnimationRes(lp, com.android.internal.R.anim.wallpaper_open_exit); |
Adrian Roos | 9357721 | 2018-04-10 14:12:10 -0700 | [diff] [blame] | 1625 | } else if (transit == TRANSIT_CRASHING_ACTIVITY_CLOSE) { |
| 1626 | a = null; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1627 | } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1628 | || transit == TRANSIT_TASK_OPEN |
| 1629 | || transit == TRANSIT_TASK_TO_FRONT)) { |
| 1630 | a = loadAnimationRes(lp, enter |
| 1631 | ? com.android.internal.R.anim.voice_activity_open_enter |
| 1632 | : com.android.internal.R.anim.voice_activity_open_exit); |
| 1633 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1634 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1635 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1636 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1637 | } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE |
| 1638 | || transit == TRANSIT_TASK_CLOSE |
| 1639 | || transit == TRANSIT_TASK_TO_BACK)) { |
| 1640 | a = loadAnimationRes(lp, enter |
| 1641 | ? com.android.internal.R.anim.voice_activity_close_enter |
| 1642 | : com.android.internal.R.anim.voice_activity_close_exit); |
| 1643 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1644 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1645 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1646 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1647 | } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) { |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1648 | a = createRelaunchAnimation(frame, insets); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1649 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1650 | "applyAnimation:" |
| 1651 | + " anim=" + a + " nextAppTransition=" + mNextAppTransition |
| 1652 | + " transit=" + appTransitionToString(transit) |
| 1653 | + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1654 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) { |
| 1655 | a = loadAnimationRes(mNextAppTransitionPackage, enter ? |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1656 | mNextAppTransitionEnter : mNextAppTransitionExit); |
| 1657 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1658 | "applyAnimation:" |
| 1659 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1660 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1661 | + " Callers=" + Debug.getCallers(3)); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1662 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) { |
| 1663 | a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace); |
| 1664 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1665 | "applyAnimation:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1666 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE" |
| 1667 | + " transit=" + appTransitionToString(transit) |
| 1668 | + " Callers=" + Debug.getCallers(3)); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1669 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) { |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 1670 | a = createClipRevealAnimationLocked(transit, enter, frame, displayFrame); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1671 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1672 | "applyAnimation:" |
| 1673 | + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL" |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1674 | + " transit=" + appTransitionToString(transit) |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1675 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1676 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) { |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1677 | a = createScaleUpAnimationLocked(transit, enter, frame); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1678 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1679 | "applyAnimation:" |
| 1680 | + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1681 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1682 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1683 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || |
| 1684 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1685 | mNextAppTransitionScaleUp = |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1686 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1687 | a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter), |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1688 | frame, transit, taskId); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1689 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1690 | String animName = mNextAppTransitionScaleUp ? |
| 1691 | "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN"; |
| 1692 | Slog.v(TAG, "applyAnimation:" |
| 1693 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1694 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1695 | + " Callers=" + Debug.getCallers(3)); |
| 1696 | } |
| 1697 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 1698 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) { |
| 1699 | mNextAppTransitionScaleUp = |
| 1700 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP); |
| 1701 | a = createAspectScaledThumbnailEnterExitAnimationLocked( |
Winson | b202476 | 2016-04-05 17:32:30 -0700 | [diff] [blame] | 1702 | getThumbnailTransitionState(enter), uiMode, orientation, transit, frame, |
Matthew Ng | 43db6d2 | 2017-06-27 15:29:39 -0700 | [diff] [blame] | 1703 | insets, surfaceInsets, stableInsets, freeform, taskId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1704 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1705 | String animName = mNextAppTransitionScaleUp ? |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1706 | "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1707 | Slog.v(TAG, "applyAnimation:" |
| 1708 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1709 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1710 | + " Callers=" + Debug.getCallers(3)); |
| 1711 | } |
Tony Mak | 83546a8 | 2018-01-22 13:56:20 +0000 | [diff] [blame] | 1712 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS && enter) { |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 1713 | a = loadAnimationRes("android", |
| 1714 | com.android.internal.R.anim.task_open_enter_cross_profile_apps); |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 1715 | Slog.v(TAG, |
| 1716 | "applyAnimation NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS:" |
| 1717 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 1718 | + " isEntrance=true" + " Callers=" + Debug.getCallers(3)); |
Evan Rosky | cf76bed | 2019-01-15 10:33:58 -0800 | [diff] [blame] | 1719 | } else if (transit == TRANSIT_TASK_CHANGE_WINDOWING_MODE) { |
| 1720 | // In the absence of a specific adapter, we just want to keep everything stationary. |
| 1721 | a = new AlphaAnimation(1.f, 1.f); |
| 1722 | a.setDuration(WindowChangeAnimationSpec.ANIMATION_DURATION); |
| 1723 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1724 | Slog.v(TAG, "applyAnimation:" |
| 1725 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1726 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
| 1727 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1728 | } else { |
| 1729 | int animAttr = 0; |
| 1730 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1731 | case TRANSIT_ACTIVITY_OPEN: |
Jorim Jaggi | 0a1523d | 2018-04-19 17:48:38 +0200 | [diff] [blame] | 1732 | case TRANSIT_TRANSLUCENT_ACTIVITY_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1733 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1734 | ? WindowAnimation_activityOpenEnterAnimation |
| 1735 | : WindowAnimation_activityOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1736 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1737 | case TRANSIT_ACTIVITY_CLOSE: |
Jorim Jaggi | 0a1523d | 2018-04-19 17:48:38 +0200 | [diff] [blame] | 1738 | case TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1739 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1740 | ? WindowAnimation_activityCloseEnterAnimation |
| 1741 | : WindowAnimation_activityCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1742 | break; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 1743 | case TRANSIT_DOCK_TASK_FROM_RECENTS: |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1744 | case TRANSIT_TASK_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1745 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1746 | ? WindowAnimation_taskOpenEnterAnimation |
| 1747 | : WindowAnimation_taskOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1748 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1749 | case TRANSIT_TASK_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1750 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1751 | ? WindowAnimation_taskCloseEnterAnimation |
| 1752 | : WindowAnimation_taskCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1753 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1754 | case TRANSIT_TASK_TO_FRONT: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1755 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1756 | ? WindowAnimation_taskToFrontEnterAnimation |
| 1757 | : WindowAnimation_taskToFrontExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1758 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1759 | case TRANSIT_TASK_TO_BACK: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1760 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1761 | ? WindowAnimation_taskToBackEnterAnimation |
| 1762 | : WindowAnimation_taskToBackExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1763 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1764 | case TRANSIT_WALLPAPER_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1765 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1766 | ? WindowAnimation_wallpaperOpenEnterAnimation |
| 1767 | : WindowAnimation_wallpaperOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1768 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1769 | case TRANSIT_WALLPAPER_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1770 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1771 | ? WindowAnimation_wallpaperCloseEnterAnimation |
| 1772 | : WindowAnimation_wallpaperCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1773 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1774 | case TRANSIT_WALLPAPER_INTRA_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1775 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1776 | ? WindowAnimation_wallpaperIntraOpenEnterAnimation |
| 1777 | : WindowAnimation_wallpaperIntraOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1778 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1779 | case TRANSIT_WALLPAPER_INTRA_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1780 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1781 | ? WindowAnimation_wallpaperIntraCloseEnterAnimation |
| 1782 | : WindowAnimation_wallpaperIntraCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1783 | break; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1784 | case TRANSIT_TASK_OPEN_BEHIND: |
| 1785 | animAttr = enter |
| 1786 | ? WindowAnimation_launchTaskBehindSourceAnimation |
Craig Mautner | 3b2cd1d | 2014-08-25 14:25:54 -0700 | [diff] [blame] | 1787 | : WindowAnimation_launchTaskBehindTargetAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1788 | } |
Jorim Jaggi | 0a1523d | 2018-04-19 17:48:38 +0200 | [diff] [blame] | 1789 | a = animAttr != 0 ? loadAnimationAttr(lp, animAttr, transit) : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1790 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1791 | "applyAnimation:" |
| 1792 | + " anim=" + a |
| 1793 | + " animAttr=0x" + Integer.toHexString(animAttr) |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1794 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1795 | + " Callers=" + Debug.getCallers(3)); |
| 1796 | } |
| 1797 | return a; |
| 1798 | } |
| 1799 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1800 | private Animation loadKeyguardExitAnimation(int transit) { |
| 1801 | if ((mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) { |
| 1802 | return null; |
| 1803 | } |
| 1804 | final boolean toShade = |
| 1805 | (mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0; |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 1806 | final boolean subtle = |
| 1807 | (mNextAppTransitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION) != 0; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1808 | return mService.mPolicy.createHiddenByKeyguardExit( |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 1809 | transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER, toShade, subtle); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1810 | } |
| 1811 | |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1812 | int getAppStackClipMode() { |
Matthew Ng | bf1d985 | 2017-03-14 12:23:09 -0700 | [diff] [blame] | 1813 | // When dismiss keyguard animation occurs, clip before the animation to prevent docked |
| 1814 | // app from showing beyond the divider |
| 1815 | if (mNextAppTransition == TRANSIT_KEYGUARD_GOING_AWAY |
| 1816 | || mNextAppTransition == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER) { |
| 1817 | return STACK_CLIP_BEFORE_ANIM; |
| 1818 | } |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1819 | return mNextAppTransition == TRANSIT_ACTIVITY_RELAUNCH |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1820 | || mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
Jorim Jaggi | 1f458fb | 2016-03-25 17:36:37 -0700 | [diff] [blame] | 1821 | || mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1822 | ? STACK_CLIP_NONE |
| 1823 | : STACK_CLIP_AFTER_ANIM; |
| 1824 | } |
| 1825 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1826 | public int getTransitFlags() { |
| 1827 | return mNextAppTransitionFlags; |
| 1828 | } |
| 1829 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1830 | void postAnimationCallback() { |
| 1831 | if (mNextAppTransitionCallback != null) { |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 1832 | mHandler.sendMessage(PooledLambda.obtainMessage(AppTransition::doAnimationCallback, |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1833 | mNextAppTransitionCallback)); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1834 | mNextAppTransitionCallback = null; |
| 1835 | } |
| 1836 | } |
| 1837 | |
| 1838 | void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, |
Filip Gruszczynski | d143142 | 2015-09-08 11:18:54 -0700 | [diff] [blame] | 1839 | IRemoteCallback startedCallback) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1840 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1841 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1842 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1843 | mNextAppTransitionPackage = packageName; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1844 | mNextAppTransitionEnter = enterAnim; |
| 1845 | mNextAppTransitionExit = exitAnim; |
| 1846 | postAnimationCallback(); |
| 1847 | mNextAppTransitionCallback = startedCallback; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1848 | } |
| 1849 | } |
| 1850 | |
| 1851 | void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1852 | int startHeight) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1853 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1854 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1855 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP; |
Winson | 4c3fecd | 2016-07-13 12:29:48 -0700 | [diff] [blame] | 1856 | putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1857 | postAnimationCallback(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1858 | } |
| 1859 | } |
| 1860 | |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1861 | void overridePendingAppTransitionClipReveal(int startX, int startY, |
| 1862 | int startWidth, int startHeight) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1863 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1864 | clear(); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1865 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1866 | putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1867 | postAnimationCallback(); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1868 | } |
| 1869 | } |
| 1870 | |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 1871 | void overridePendingAppTransitionThumb(GraphicBuffer srcThumb, int startX, int startY, |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1872 | IRemoteCallback startedCallback, boolean scaleUp) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1873 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1874 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1875 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP |
| 1876 | : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1877 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1878 | putDefaultNextAppTransitionCoordinates(startX, startY, 0, 0, srcThumb); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1879 | postAnimationCallback(); |
| 1880 | mNextAppTransitionCallback = startedCallback; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1881 | } |
| 1882 | } |
| 1883 | |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 1884 | void overridePendingAppTransitionAspectScaledThumb(GraphicBuffer srcThumb, int startX, int startY, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1885 | int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1886 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1887 | clear(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1888 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1889 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1890 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1891 | putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight, |
| 1892 | srcThumb); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1893 | postAnimationCallback(); |
| 1894 | mNextAppTransitionCallback = startedCallback; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1895 | } |
| 1896 | } |
| 1897 | |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1898 | void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs, |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1899 | IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback, |
| 1900 | boolean scaleUp) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1901 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1902 | clear(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1903 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1904 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1905 | mNextAppTransitionScaleUp = scaleUp; |
Jorim Jaggi | 4310241 | 2015-11-11 16:28:37 +0100 | [diff] [blame] | 1906 | if (specs != null) { |
| 1907 | for (int i = 0; i < specs.length; i++) { |
| 1908 | AppTransitionAnimationSpec spec = specs[i]; |
| 1909 | if (spec != null) { |
| 1910 | mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec); |
| 1911 | if (i == 0) { |
| 1912 | // In full screen mode, the transition code depends on the default spec |
| 1913 | // to be set. |
| 1914 | Rect rect = spec.rect; |
| 1915 | putDefaultNextAppTransitionCoordinates(rect.left, rect.top, |
Winson Chung | aa7fa01 | 2017-05-24 15:50:06 -0700 | [diff] [blame] | 1916 | rect.width(), rect.height(), spec.buffer); |
Jorim Jaggi | 4310241 | 2015-11-11 16:28:37 +0100 | [diff] [blame] | 1917 | } |
Filip Gruszczynski | d143142 | 2015-09-08 11:18:54 -0700 | [diff] [blame] | 1918 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1919 | } |
| 1920 | } |
| 1921 | postAnimationCallback(); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1922 | mNextAppTransitionCallback = onAnimationStartedCallback; |
| 1923 | mAnimationFinishedCallback = onAnimationFinishedCallback; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1924 | } |
| 1925 | } |
| 1926 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1927 | void overridePendingAppTransitionMultiThumbFuture( |
| 1928 | IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback callback, |
| 1929 | boolean scaleUp) { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1930 | if (canOverridePendingAppTransition()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1931 | clear(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1932 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1933 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1934 | mNextAppTransitionAnimationsSpecsFuture = specsFuture; |
| 1935 | mNextAppTransitionScaleUp = scaleUp; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 1936 | mNextAppTransitionFutureCallback = callback; |
Riddle Hsu | ec6467c | 2019-02-15 00:10:56 +0800 | [diff] [blame] | 1937 | if (isReady()) { |
| 1938 | fetchAppTransitionSpecsFromFuture(); |
| 1939 | } |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1940 | } |
| 1941 | } |
| 1942 | |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1943 | void overridePendingAppTransitionRemote(RemoteAnimationAdapter remoteAnimationAdapter) { |
Jorim Jaggi | 346702a | 2019-05-08 17:49:33 +0200 | [diff] [blame] | 1944 | if (DEBUG_APP_TRANSITIONS) Slog.i(TAG, "Override pending remote transitionSet=" |
| 1945 | + isTransitionSet() + " adapter=" + remoteAnimationAdapter); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1946 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1947 | clear(); |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1948 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_REMOTE; |
| 1949 | mRemoteAnimationController = new RemoteAnimationController(mService, |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 1950 | remoteAnimationAdapter, mHandler); |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1951 | } |
| 1952 | } |
| 1953 | |
| 1954 | void overrideInPlaceAppTransition(String packageName, int anim) { |
| 1955 | if (canOverridePendingAppTransition()) { |
| 1956 | clear(); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1957 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE; |
| 1958 | mNextAppTransitionPackage = packageName; |
| 1959 | mNextAppTransitionInPlace = anim; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1960 | } |
| 1961 | } |
| 1962 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1963 | /** |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 1964 | * @see {@link #NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS} |
| 1965 | */ |
| 1966 | void overridePendingAppTransitionStartCrossProfileApps() { |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1967 | if (canOverridePendingAppTransition()) { |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 1968 | clear(); |
| 1969 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS; |
| 1970 | postAnimationCallback(); |
| 1971 | } |
| 1972 | } |
| 1973 | |
Jorim Jaggi | 33a701a | 2017-12-01 14:58:18 +0100 | [diff] [blame] | 1974 | private boolean canOverridePendingAppTransition() { |
| 1975 | // Remote animations always take precedence |
| 1976 | return isTransitionSet() && mNextAppTransitionType != NEXT_TRANSIT_TYPE_REMOTE; |
| 1977 | } |
| 1978 | |
Tony Mak | 089c35e | 2017-12-18 20:34:14 +0000 | [diff] [blame] | 1979 | /** |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1980 | * If a future is set for the app transition specs, fetch it in another thread. |
| 1981 | */ |
| 1982 | private void fetchAppTransitionSpecsFromFuture() { |
| 1983 | if (mNextAppTransitionAnimationsSpecsFuture != null) { |
| 1984 | mNextAppTransitionAnimationsSpecsPending = true; |
| 1985 | final IAppTransitionAnimationSpecsFuture future |
| 1986 | = mNextAppTransitionAnimationsSpecsFuture; |
| 1987 | mNextAppTransitionAnimationsSpecsFuture = null; |
Jorim Jaggi | ed410b6 | 2017-05-05 15:16:14 +0200 | [diff] [blame] | 1988 | mDefaultExecutor.execute(() -> { |
| 1989 | AppTransitionAnimationSpec[] specs = null; |
| 1990 | try { |
| 1991 | Binder.allowBlocking(future.asBinder()); |
| 1992 | specs = future.get(); |
| 1993 | } catch (RemoteException e) { |
| 1994 | Slog.w(TAG, "Failed to fetch app transition specs: " + e); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1995 | } |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 1996 | synchronized (mService.mGlobalLock) { |
Jorim Jaggi | ed410b6 | 2017-05-05 15:16:14 +0200 | [diff] [blame] | 1997 | mNextAppTransitionAnimationsSpecsPending = false; |
| 1998 | overridePendingAppTransitionMultiThumb(specs, |
| 1999 | mNextAppTransitionFutureCallback, null /* finishedCallback */, |
| 2000 | mNextAppTransitionScaleUp); |
| 2001 | mNextAppTransitionFutureCallback = null; |
Jorim Jaggi | ed410b6 | 2017-05-05 15:16:14 +0200 | [diff] [blame] | 2002 | } |
| 2003 | mService.requestTraversal(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 2004 | }); |
| 2005 | } |
| 2006 | } |
| 2007 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2008 | @Override |
| 2009 | public String toString() { |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 2010 | return "mNextAppTransition=" + appTransitionToString(mNextAppTransition); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2011 | } |
| 2012 | |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2013 | /** |
| 2014 | * Returns the human readable name of a window transition. |
| 2015 | * |
| 2016 | * @param transition The window transition. |
| 2017 | * @return The transition symbolic name. |
| 2018 | */ |
| 2019 | public static String appTransitionToString(int transition) { |
| 2020 | switch (transition) { |
| 2021 | case TRANSIT_UNSET: { |
| 2022 | return "TRANSIT_UNSET"; |
| 2023 | } |
| 2024 | case TRANSIT_NONE: { |
| 2025 | return "TRANSIT_NONE"; |
| 2026 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2027 | case TRANSIT_ACTIVITY_OPEN: { |
| 2028 | return "TRANSIT_ACTIVITY_OPEN"; |
| 2029 | } |
| 2030 | case TRANSIT_ACTIVITY_CLOSE: { |
| 2031 | return "TRANSIT_ACTIVITY_CLOSE"; |
| 2032 | } |
| 2033 | case TRANSIT_TASK_OPEN: { |
| 2034 | return "TRANSIT_TASK_OPEN"; |
| 2035 | } |
| 2036 | case TRANSIT_TASK_CLOSE: { |
| 2037 | return "TRANSIT_TASK_CLOSE"; |
| 2038 | } |
| 2039 | case TRANSIT_TASK_TO_FRONT: { |
| 2040 | return "TRANSIT_TASK_TO_FRONT"; |
| 2041 | } |
| 2042 | case TRANSIT_TASK_TO_BACK: { |
| 2043 | return "TRANSIT_TASK_TO_BACK"; |
| 2044 | } |
| 2045 | case TRANSIT_WALLPAPER_CLOSE: { |
| 2046 | return "TRANSIT_WALLPAPER_CLOSE"; |
| 2047 | } |
| 2048 | case TRANSIT_WALLPAPER_OPEN: { |
| 2049 | return "TRANSIT_WALLPAPER_OPEN"; |
| 2050 | } |
| 2051 | case TRANSIT_WALLPAPER_INTRA_OPEN: { |
| 2052 | return "TRANSIT_WALLPAPER_INTRA_OPEN"; |
| 2053 | } |
| 2054 | case TRANSIT_WALLPAPER_INTRA_CLOSE: { |
| 2055 | return "TRANSIT_WALLPAPER_INTRA_CLOSE"; |
| 2056 | } |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 2057 | case TRANSIT_TASK_OPEN_BEHIND: { |
| 2058 | return "TRANSIT_TASK_OPEN_BEHIND"; |
| 2059 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 2060 | case TRANSIT_ACTIVITY_RELAUNCH: { |
| 2061 | return "TRANSIT_ACTIVITY_RELAUNCH"; |
| 2062 | } |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 2063 | case TRANSIT_DOCK_TASK_FROM_RECENTS: { |
| 2064 | return "TRANSIT_DOCK_TASK_FROM_RECENTS"; |
| 2065 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2066 | case TRANSIT_KEYGUARD_GOING_AWAY: { |
| 2067 | return "TRANSIT_KEYGUARD_GOING_AWAY"; |
| 2068 | } |
| 2069 | case TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER: { |
| 2070 | return "TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER"; |
| 2071 | } |
| 2072 | case TRANSIT_KEYGUARD_OCCLUDE: { |
| 2073 | return "TRANSIT_KEYGUARD_OCCLUDE"; |
| 2074 | } |
| 2075 | case TRANSIT_KEYGUARD_UNOCCLUDE: { |
| 2076 | return "TRANSIT_KEYGUARD_UNOCCLUDE"; |
| 2077 | } |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 2078 | case TRANSIT_TRANSLUCENT_ACTIVITY_OPEN: { |
| 2079 | return "TRANSIT_TRANSLUCENT_ACTIVITY_OPEN"; |
| 2080 | } |
| 2081 | case TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE: { |
| 2082 | return "TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE"; |
| 2083 | } |
Jorim Jaggi | 9c52ebb | 2018-06-01 14:45:24 +0200 | [diff] [blame] | 2084 | case TRANSIT_CRASHING_ACTIVITY_CLOSE: { |
| 2085 | return "TRANSIT_CRASHING_ACTIVITY_CLOSE"; |
| 2086 | } |
Issei Suzuki | cac2a50 | 2019-04-16 16:52:50 +0200 | [diff] [blame] | 2087 | case TRANSIT_SHOW_SINGLE_TASK_DISPLAY: { |
| 2088 | return "TRANSIT_SHOW_SINGLE_TASK_DISPLAY"; |
| 2089 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2090 | default: { |
Jorim Jaggi | 9c52ebb | 2018-06-01 14:45:24 +0200 | [diff] [blame] | 2091 | return "<UNKNOWN: " + transition + ">"; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2092 | } |
| 2093 | } |
| 2094 | } |
| 2095 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 2096 | private String appStateToString() { |
| 2097 | switch (mAppTransitionState) { |
| 2098 | case APP_STATE_IDLE: |
| 2099 | return "APP_STATE_IDLE"; |
| 2100 | case APP_STATE_READY: |
| 2101 | return "APP_STATE_READY"; |
| 2102 | case APP_STATE_RUNNING: |
| 2103 | return "APP_STATE_RUNNING"; |
| 2104 | case APP_STATE_TIMEOUT: |
| 2105 | return "APP_STATE_TIMEOUT"; |
| 2106 | default: |
| 2107 | return "unknown state=" + mAppTransitionState; |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | private String transitTypeToString() { |
| 2112 | switch (mNextAppTransitionType) { |
| 2113 | case NEXT_TRANSIT_TYPE_NONE: |
| 2114 | return "NEXT_TRANSIT_TYPE_NONE"; |
| 2115 | case NEXT_TRANSIT_TYPE_CUSTOM: |
| 2116 | return "NEXT_TRANSIT_TYPE_CUSTOM"; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 2117 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
| 2118 | return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 2119 | case NEXT_TRANSIT_TYPE_SCALE_UP: |
| 2120 | return "NEXT_TRANSIT_TYPE_SCALE_UP"; |
| 2121 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 2122 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP"; |
| 2123 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
| 2124 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN"; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 2125 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
| 2126 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP"; |
| 2127 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 2128 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Tony Mak | 64b8d56 | 2017-12-28 17:44:02 +0000 | [diff] [blame] | 2129 | case NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS: |
| 2130 | return "NEXT_TRANSIT_TYPE_OPEN_CROSS_PROFILE_APPS"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 2131 | default: |
| 2132 | return "unknown type=" + mNextAppTransitionType; |
| 2133 | } |
| 2134 | } |
| 2135 | |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2136 | void writeToProto(ProtoOutputStream proto, long fieldId) { |
| 2137 | final long token = proto.start(fieldId); |
| 2138 | proto.write(APP_TRANSITION_STATE, mAppTransitionState); |
| 2139 | proto.write(LAST_USED_APP_TRANSITION, mLastUsedAppTransition); |
| 2140 | proto.end(token); |
| 2141 | } |
| 2142 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2143 | @Override |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2144 | public void dump(PrintWriter pw, String prefix) { |
| 2145 | pw.print(prefix); pw.println(this); |
| 2146 | pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString()); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 2147 | if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2148 | pw.print(prefix); pw.print("mNextAppTransitionType="); |
| 2149 | pw.println(transitTypeToString()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2150 | } |
| 2151 | switch (mNextAppTransitionType) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 2152 | case NEXT_TRANSIT_TYPE_CUSTOM: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2153 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2154 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2155 | pw.print(prefix); pw.print("mNextAppTransitionEnter=0x"); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2156 | pw.print(Integer.toHexString(mNextAppTransitionEnter)); |
| 2157 | pw.print(" mNextAppTransitionExit=0x"); |
| 2158 | pw.println(Integer.toHexString(mNextAppTransitionExit)); |
| 2159 | break; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 2160 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2161 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 2162 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2163 | pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x"); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 2164 | pw.print(Integer.toHexString(mNextAppTransitionInPlace)); |
| 2165 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 2166 | case NEXT_TRANSIT_TYPE_SCALE_UP: { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 2167 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2168 | pw.print(prefix); pw.print("mNextAppTransitionStartX="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 2169 | pw.print(mTmpRect.left); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2170 | pw.print(" mNextAppTransitionStartY="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 2171 | pw.println(mTmpRect.top); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2172 | pw.print(prefix); pw.print("mNextAppTransitionStartWidth="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 2173 | pw.print(mTmpRect.width()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2174 | pw.print(" mNextAppTransitionStartHeight="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 2175 | pw.println(mTmpRect.height()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2176 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 2177 | } |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 2178 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 2179 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 2180 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 2181 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: { |
| 2182 | pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec="); |
| 2183 | pw.println(mDefaultNextAppTransitionAnimationSpec); |
| 2184 | pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs="); |
| 2185 | pw.println(mNextAppTransitionAnimationsSpecs); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2186 | pw.print(prefix); pw.print("mNextAppTransitionScaleUp="); |
| 2187 | pw.println(mNextAppTransitionScaleUp); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2188 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 2189 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2190 | } |
| 2191 | if (mNextAppTransitionCallback != null) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 2192 | pw.print(prefix); pw.print("mNextAppTransitionCallback="); |
| 2193 | pw.println(mNextAppTransitionCallback); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2194 | } |
Chong Zhang | 60091a9 | 2016-07-27 17:52:45 -0700 | [diff] [blame] | 2195 | if (mLastUsedAppTransition != TRANSIT_NONE) { |
| 2196 | pw.print(prefix); pw.print("mLastUsedAppTransition="); |
| 2197 | pw.println(appTransitionToString(mLastUsedAppTransition)); |
| 2198 | pw.print(prefix); pw.print("mLastOpeningApp="); |
| 2199 | pw.println(mLastOpeningApp); |
| 2200 | pw.print(prefix); pw.print("mLastClosingApp="); |
| 2201 | pw.println(mLastClosingApp); |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 2202 | pw.print(prefix); pw.print("mLastChangingApp="); |
| 2203 | pw.println(mLastChangingApp); |
Chong Zhang | 60091a9 | 2016-07-27 17:52:45 -0700 | [diff] [blame] | 2204 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2205 | } |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 2206 | |
| 2207 | public void setCurrentUser(int newUserId) { |
| 2208 | mCurrentUserId = newUserId; |
| 2209 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 2210 | |
| 2211 | /** |
| 2212 | * @return true if transition is not running and should not be skipped, false if transition is |
| 2213 | * already running |
| 2214 | */ |
Jorim Jaggi | f84e2f6 | 2018-01-16 14:17:59 +0100 | [diff] [blame] | 2215 | boolean prepareAppTransitionLocked(@TransitionType int transit, boolean alwaysKeepCurrent, |
| 2216 | @TransitionFlags int flags, boolean forceOverride) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 2217 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:" |
| 2218 | + " transit=" + appTransitionToString(transit) |
| 2219 | + " " + this |
| 2220 | + " alwaysKeepCurrent=" + alwaysKeepCurrent |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 2221 | + " displayId=" + mDisplayContent.getDisplayId() |
| 2222 | + " Callers=" + Debug.getCallers(5)); |
Jorim Jaggi | 9c52ebb | 2018-06-01 14:45:24 +0200 | [diff] [blame] | 2223 | final boolean allowSetCrashing = !isKeyguardTransit(mNextAppTransition) |
| 2224 | && transit == TRANSIT_CRASHING_ACTIVITY_CLOSE; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2225 | if (forceOverride || isKeyguardTransit(transit) || !isTransitionSet() |
Jorim Jaggi | 9c52ebb | 2018-06-01 14:45:24 +0200 | [diff] [blame] | 2226 | || mNextAppTransition == TRANSIT_NONE || allowSetCrashing) { |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2227 | setAppTransition(transit, flags); |
Jorim Jaggi | a69243a | 2017-06-15 15:10:38 -0400 | [diff] [blame] | 2228 | } |
| 2229 | // We never want to change from a Keyguard transit to a non-Keyguard transit, as our logic |
Adrian Roos | 9357721 | 2018-04-10 14:12:10 -0700 | [diff] [blame] | 2230 | // relies on the fact that we always execute a Keyguard transition after preparing one. We |
| 2231 | // also don't want to change away from a crashing transition. |
Jorim Jaggi | 9c52ebb | 2018-06-01 14:45:24 +0200 | [diff] [blame] | 2232 | else if (!alwaysKeepCurrent && !isKeyguardTransit(mNextAppTransition) |
| 2233 | && mNextAppTransition != TRANSIT_CRASHING_ACTIVITY_CLOSE) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 2234 | if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) { |
| 2235 | // Opening a new task always supersedes a close for the anim. |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2236 | setAppTransition(transit, flags); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 2237 | } else if (transit == TRANSIT_ACTIVITY_OPEN |
| 2238 | && isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) { |
| 2239 | // Opening a new activity always supersedes a close for the anim. |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2240 | setAppTransition(transit, flags); |
Jorim Jaggi | cecf424 | 2018-02-21 18:46:53 +0100 | [diff] [blame] | 2241 | } else if (isTaskTransit(transit) && isActivityTransit(mNextAppTransition)) { |
| 2242 | // Task animations always supersede activity animations, because if we have both, it |
| 2243 | // usually means that activity transition were just trampoline activities. |
| 2244 | setAppTransition(transit, flags); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 2245 | } |
| 2246 | } |
| 2247 | boolean prepared = prepare(); |
| 2248 | if (isTransitionSet()) { |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 2249 | removeAppTransitionTimeoutCallbacks(); |
| 2250 | mHandler.postDelayed(mHandleAppTransitionTimeoutRunnable, APP_TRANSITION_TIMEOUT_MS); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 2251 | } |
| 2252 | return prepared; |
| 2253 | } |
Winson | b202476 | 2016-04-05 17:32:30 -0700 | [diff] [blame] | 2254 | |
| 2255 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2256 | * @return true if {@param transit} is representing a transition in which Keyguard is going |
| 2257 | * away, false otherwise |
| 2258 | */ |
| 2259 | public static boolean isKeyguardGoingAwayTransit(int transit) { |
| 2260 | return transit == TRANSIT_KEYGUARD_GOING_AWAY |
| 2261 | || transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER; |
| 2262 | } |
| 2263 | |
| 2264 | private static boolean isKeyguardTransit(int transit) { |
| 2265 | return isKeyguardGoingAwayTransit(transit) || transit == TRANSIT_KEYGUARD_OCCLUDE |
| 2266 | || transit == TRANSIT_KEYGUARD_UNOCCLUDE; |
| 2267 | } |
| 2268 | |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 2269 | static boolean isTaskTransit(int transit) { |
| 2270 | return isTaskOpenTransit(transit) |
Jorim Jaggi | cecf424 | 2018-02-21 18:46:53 +0100 | [diff] [blame] | 2271 | || transit == TRANSIT_TASK_CLOSE |
Jorim Jaggi | cecf424 | 2018-02-21 18:46:53 +0100 | [diff] [blame] | 2272 | || transit == TRANSIT_TASK_TO_BACK |
Jorim Jaggi | cecf424 | 2018-02-21 18:46:53 +0100 | [diff] [blame] | 2273 | || transit == TRANSIT_TASK_IN_PLACE; |
| 2274 | } |
| 2275 | |
Jorim Jaggi | 98a9d20 | 2018-03-26 16:17:07 +0200 | [diff] [blame] | 2276 | private static boolean isTaskOpenTransit(int transit) { |
| 2277 | return transit == TRANSIT_TASK_OPEN |
| 2278 | || transit == TRANSIT_TASK_OPEN_BEHIND |
| 2279 | || transit == TRANSIT_TASK_TO_FRONT; |
| 2280 | } |
| 2281 | |
| 2282 | static boolean isActivityTransit(int transit) { |
Jorim Jaggi | cecf424 | 2018-02-21 18:46:53 +0100 | [diff] [blame] | 2283 | return transit == TRANSIT_ACTIVITY_OPEN |
| 2284 | || transit == TRANSIT_ACTIVITY_CLOSE |
| 2285 | || transit == TRANSIT_ACTIVITY_RELAUNCH; |
| 2286 | } |
| 2287 | |
Evan Rosky | ec9488c | 2019-03-01 19:32:12 -0800 | [diff] [blame] | 2288 | static boolean isChangeTransit(int transit) { |
| 2289 | return transit == TRANSIT_TASK_CHANGE_WINDOWING_MODE; |
| 2290 | } |
| 2291 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2292 | /** |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 2293 | * @return whether the transition should show the thumbnail being scaled down. |
| 2294 | */ |
| 2295 | private boolean shouldScaleDownThumbnailTransition(int uiMode, int orientation) { |
Sid Soundararajan | 0e88d32 | 2017-03-07 15:37:30 -0800 | [diff] [blame] | 2296 | return mGridLayoutRecentsEnabled |
Manu Cornet | d737680 | 2017-01-13 13:44:07 -0800 | [diff] [blame] | 2297 | || orientation == Configuration.ORIENTATION_PORTRAIT; |
| 2298 | } |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 2299 | |
| 2300 | private void handleAppTransitionTimeout() { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 2301 | synchronized (mService.mGlobalLock) { |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 2302 | final DisplayContent dc = mDisplayContent; |
| 2303 | if (dc == null) { |
| 2304 | return; |
| 2305 | } |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 2306 | if (isTransitionSet() || !dc.mOpeningApps.isEmpty() || !dc.mClosingApps.isEmpty() |
| 2307 | || !dc.mChangingApps.isEmpty()) { |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 2308 | if (DEBUG_APP_TRANSITIONS) { |
| 2309 | Slog.v(TAG_WM, "*** APP TRANSITION TIMEOUT." |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 2310 | + " displayId=" + dc.getDisplayId() |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 2311 | + " isTransitionSet()=" |
lumark | 588a3e8 | 2018-07-20 18:53:54 +0800 | [diff] [blame] | 2312 | + dc.mAppTransition.isTransitionSet() |
| 2313 | + " mOpeningApps.size()=" + dc.mOpeningApps.size() |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 2314 | + " mClosingApps.size()=" + dc.mClosingApps.size() |
| 2315 | + " mChangingApps.size()=" + dc.mChangingApps.size()); |
lumark | 23b5459 | 2018-10-02 17:17:23 +0800 | [diff] [blame] | 2316 | } |
| 2317 | setTimeout(); |
| 2318 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 2319 | } |
| 2320 | } |
| 2321 | } |
| 2322 | |
| 2323 | private static void doAnimationCallback(@NonNull IRemoteCallback callback) { |
| 2324 | try { |
| 2325 | ((IRemoteCallback) callback).sendResult(null); |
| 2326 | } catch (RemoteException e) { |
| 2327 | } |
| 2328 | } |
| 2329 | |
| 2330 | void removeAppTransitionTimeoutCallbacks() { |
| 2331 | mHandler.removeCallbacks(mHandleAppTransitionTimeoutRunnable); |
| 2332 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 2333 | } |