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