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