Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
Jorim Jaggi | 54cff64 | 2018-03-15 15:51:32 +0100 | [diff] [blame] | 19 | import static android.app.ActivityManagerInternal.APP_TRANSITION_RECENTS_ANIM; |
Jorim Jaggi | 54cff64 | 2018-03-15 15:51:32 +0100 | [diff] [blame] | 20 | import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 21 | import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 22 | import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 23 | import static android.view.RemoteAnimationTarget.MODE_CLOSING; |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 24 | import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 25 | import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Yi Jin | 6c6e9ca | 2018-03-20 16:53:35 -0700 | [diff] [blame] | 26 | import static com.android.server.wm.AnimationAdapterProto.REMOTE; |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 27 | import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET; |
| 28 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RECENTS_ANIMATIONS; |
| 29 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 30 | |
Winson Chung | 6a38fca | 2018-03-28 17:57:09 -0700 | [diff] [blame] | 31 | import android.annotation.IntDef; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 32 | import android.app.ActivityManager.TaskSnapshot; |
| 33 | import android.app.WindowConfiguration; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 34 | import android.graphics.Point; |
| 35 | import android.graphics.Rect; |
| 36 | import android.os.Binder; |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 37 | import android.os.IBinder.DeathRecipient; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 38 | import android.os.RemoteException; |
| 39 | import android.os.SystemClock; |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 40 | import android.util.ArraySet; |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 41 | import android.util.Slog; |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 42 | import android.util.SparseBooleanArray; |
Jorim Jaggi | 54cff64 | 2018-03-15 15:51:32 +0100 | [diff] [blame] | 43 | import android.util.SparseIntArray; |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 44 | import android.util.proto.ProtoOutputStream; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 45 | import android.view.IRecentsAnimationController; |
| 46 | import android.view.IRecentsAnimationRunner; |
| 47 | import android.view.RemoteAnimationTarget; |
| 48 | import android.view.SurfaceControl; |
| 49 | import android.view.SurfaceControl.Transaction; |
Winson Chung | a840c32 | 2018-04-20 15:58:18 -0700 | [diff] [blame] | 50 | import android.view.inputmethod.InputMethodManagerInternal; |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 51 | import com.android.internal.annotations.VisibleForTesting; |
Winson Chung | a840c32 | 2018-04-20 15:58:18 -0700 | [diff] [blame] | 52 | import com.android.server.LocalServices; |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 53 | import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; |
Jorim Jaggi | 817ebdd | 2018-03-26 15:46:01 +0200 | [diff] [blame] | 54 | import com.android.server.wm.utils.InsetUtils; |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 55 | import com.google.android.collect.Sets; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 56 | import java.io.PrintWriter; |
| 57 | import java.util.ArrayList; |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 58 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 59 | /** |
| 60 | * Controls a single instance of the remote driven recents animation. In particular, this allows |
| 61 | * the calling SystemUI to animate the visible task windows as a part of the transition. The remote |
| 62 | * runner is provided an animation controller which allows it to take screenshots and to notify |
| 63 | * window manager when the animation is completed. In addition, window manager may also notify the |
| 64 | * app if it requires the animation to be canceled at any time (ie. due to timeout, etc.) |
| 65 | */ |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 66 | public class RecentsAnimationController implements DeathRecipient { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 67 | private static final String TAG = RecentsAnimationController.class.getSimpleName(); |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 68 | private static final long FAILSAFE_DELAY = 1000; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 69 | |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 70 | public static final int REORDER_KEEP_IN_PLACE = 0; |
| 71 | public static final int REORDER_MOVE_TO_TOP = 1; |
| 72 | public static final int REORDER_MOVE_TO_ORIGINAL_POSITION = 2; |
Winson Chung | 6a38fca | 2018-03-28 17:57:09 -0700 | [diff] [blame] | 73 | |
| 74 | @IntDef(prefix = { "REORDER_MODE_" }, value = { |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 75 | REORDER_KEEP_IN_PLACE, |
| 76 | REORDER_MOVE_TO_TOP, |
| 77 | REORDER_MOVE_TO_ORIGINAL_POSITION |
Winson Chung | 6a38fca | 2018-03-28 17:57:09 -0700 | [diff] [blame] | 78 | }) |
| 79 | public @interface ReorderMode {} |
| 80 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 81 | private final WindowManagerService mService; |
| 82 | private final IRecentsAnimationRunner mRunner; |
| 83 | private final RecentsAnimationCallbacks mCallbacks; |
| 84 | private final ArrayList<TaskAnimationAdapter> mPendingAnimations = new ArrayList<>(); |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 85 | private final int mDisplayId; |
Winson Chung | 65c5f99 | 2018-04-20 14:58:57 -0700 | [diff] [blame] | 86 | private final Runnable mFailsafeRunnable = () -> |
| 87 | cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "failSafeRunnable"); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 88 | |
| 89 | // The recents component app token that is shown behind the visibile tasks |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 90 | private AppWindowToken mTargetAppToken; |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 91 | private Rect mMinimizedHomeBounds = new Rect(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 92 | |
| 93 | // We start the RecentsAnimationController in a pending-start state since we need to wait for |
| 94 | // the wallpaper/activity to draw before we can give control to the handler to start animating |
| 95 | // the visible task surfaces |
| 96 | private boolean mPendingStart = true; |
| 97 | |
| 98 | // Set when the animation has been canceled |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 99 | private boolean mCanceled; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 100 | |
| 101 | // Whether or not the input consumer is enabled. The input consumer must be both registered and |
| 102 | // enabled for it to start intercepting touch events. |
| 103 | private boolean mInputConsumerEnabled; |
| 104 | |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 105 | // Whether or not the recents animation should cause the primary split-screen stack to be |
| 106 | // minimized |
| 107 | private boolean mSplitScreenMinimized; |
| 108 | |
Adrian Roos | 653c6c1 | 2018-04-09 14:12:46 -0700 | [diff] [blame] | 109 | private final Rect mTmpRect = new Rect(); |
| 110 | |
| 111 | private boolean mLinkedToDeathOfRunner; |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 112 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 113 | public interface RecentsAnimationCallbacks { |
Winson Chung | 65c5f99 | 2018-04-20 14:58:57 -0700 | [diff] [blame] | 114 | void onAnimationFinished(@ReorderMode int reorderMode, boolean runSychronously); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | private final IRecentsAnimationController mController = |
| 118 | new IRecentsAnimationController.Stub() { |
| 119 | |
| 120 | @Override |
| 121 | public TaskSnapshot screenshotTask(int taskId) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 122 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "screenshotTask(" + taskId + "):" |
| 123 | + " mCanceled=" + mCanceled); |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 124 | final long token = Binder.clearCallingIdentity(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 125 | try { |
| 126 | synchronized (mService.getWindowManagerLock()) { |
| 127 | if (mCanceled) { |
| 128 | return null; |
| 129 | } |
| 130 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 131 | final TaskAnimationAdapter adapter = mPendingAnimations.get(i); |
| 132 | final Task task = adapter.mTask; |
| 133 | if (task.mTaskId == taskId) { |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 134 | final TaskSnapshotController snapshotController = |
| 135 | mService.mTaskSnapshotController; |
| 136 | final ArraySet<Task> tasks = Sets.newArraySet(task); |
| 137 | snapshotController.snapshotTasks(tasks); |
| 138 | snapshotController.addSkipClosingAppSnapshotTasks(tasks); |
| 139 | return snapshotController.getSnapshot(taskId, 0 /* userId */, |
| 140 | false /* restoreFromDisk */, false /* reducedResolution */); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | return null; |
| 144 | } |
| 145 | } finally { |
| 146 | Binder.restoreCallingIdentity(token); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | @Override |
| 151 | public void finish(boolean moveHomeToTop) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 152 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "finish(" + moveHomeToTop + "):" |
| 153 | + " mCanceled=" + mCanceled); |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 154 | final long token = Binder.clearCallingIdentity(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 155 | try { |
| 156 | synchronized (mService.getWindowManagerLock()) { |
| 157 | if (mCanceled) { |
| 158 | return; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // Note, the callback will handle its own synchronization, do not lock on WM lock |
| 163 | // prior to calling the callback |
Winson Chung | 6a38fca | 2018-03-28 17:57:09 -0700 | [diff] [blame] | 164 | mCallbacks.onAnimationFinished(moveHomeToTop |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 165 | ? REORDER_MOVE_TO_TOP |
Winson Chung | 65c5f99 | 2018-04-20 14:58:57 -0700 | [diff] [blame] | 166 | : REORDER_MOVE_TO_ORIGINAL_POSITION, |
| 167 | true /* runSynchronously */); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 168 | } finally { |
| 169 | Binder.restoreCallingIdentity(token); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | @Override |
Jorim Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame] | 174 | public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) |
| 175 | throws RemoteException { |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 176 | final long token = Binder.clearCallingIdentity(); |
Jorim Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame] | 177 | try { |
| 178 | synchronized (mService.getWindowManagerLock()) { |
| 179 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 180 | mPendingAnimations.get(i).mTask.setCanAffectSystemUiFlags(behindSystemBars); |
| 181 | } |
| 182 | mService.mWindowPlacerLocked.requestTraversal(); |
| 183 | } |
| 184 | } finally { |
| 185 | Binder.restoreCallingIdentity(token); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | @Override |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 190 | public void setInputConsumerEnabled(boolean enabled) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 191 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "setInputConsumerEnabled(" + enabled + "):" |
| 192 | + " mCanceled=" + mCanceled); |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 193 | final long token = Binder.clearCallingIdentity(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 194 | try { |
| 195 | synchronized (mService.getWindowManagerLock()) { |
| 196 | if (mCanceled) { |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | mInputConsumerEnabled = enabled; |
| 201 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
| 202 | mService.scheduleAnimationLocked(); |
| 203 | } |
| 204 | } finally { |
| 205 | Binder.restoreCallingIdentity(token); |
| 206 | } |
| 207 | } |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 208 | |
| 209 | @Override |
| 210 | public void setSplitScreenMinimized(boolean minimized) { |
| 211 | final long token = Binder.clearCallingIdentity(); |
| 212 | try { |
| 213 | synchronized (mService.getWindowManagerLock()) { |
| 214 | if (mCanceled) { |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | mSplitScreenMinimized = minimized; |
| 219 | mService.checkSplitScreenMinimizedChanged(true /* animate */); |
| 220 | } |
| 221 | } finally { |
| 222 | Binder.restoreCallingIdentity(token); |
| 223 | } |
| 224 | } |
Winson Chung | a840c32 | 2018-04-20 15:58:18 -0700 | [diff] [blame] | 225 | |
| 226 | @Override |
| 227 | public void hideCurrentInputMethod() { |
| 228 | final long token = Binder.clearCallingIdentity(); |
| 229 | try { |
| 230 | final InputMethodManagerInternal inputMethodManagerInternal = |
| 231 | LocalServices.getService(InputMethodManagerInternal.class); |
| 232 | if (inputMethodManagerInternal != null) { |
| 233 | inputMethodManagerInternal.hideCurrentInputMethod(); |
| 234 | } |
| 235 | } finally { |
| 236 | Binder.restoreCallingIdentity(token); |
| 237 | } |
| 238 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | /** |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 242 | * @param remoteAnimationRunner The remote runner which should be notified when the animation is |
| 243 | * ready to start or has been canceled |
| 244 | * @param callbacks Callbacks to be made when the animation finishes |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 245 | */ |
| 246 | RecentsAnimationController(WindowManagerService service, |
| 247 | IRecentsAnimationRunner remoteAnimationRunner, RecentsAnimationCallbacks callbacks, |
| 248 | int displayId) { |
| 249 | mService = service; |
| 250 | mRunner = remoteAnimationRunner; |
| 251 | mCallbacks = callbacks; |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 252 | mDisplayId = displayId; |
| 253 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 254 | |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 255 | /** |
| 256 | * Initializes the recents animation controller. This is a separate call from the constructor |
| 257 | * because it may call cancelAnimation() which needs to properly clean up the controller |
| 258 | * in the window manager. |
| 259 | */ |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 260 | public void initialize(int targetActivityType, SparseBooleanArray recentTaskIds) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 261 | // Make leashes for each of the visible tasks and add it to the recents animation to be |
| 262 | // started |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 263 | final DisplayContent dc = mService.mRoot.getDisplayContent(mDisplayId); |
| 264 | final ArrayList<Task> visibleTasks = dc.getVisibleTasks(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 265 | final int taskCount = visibleTasks.size(); |
| 266 | for (int i = 0; i < taskCount; i++) { |
| 267 | final Task task = visibleTasks.get(i); |
| 268 | final WindowConfiguration config = task.getWindowConfiguration(); |
| 269 | if (config.tasksAreFloating() |
| 270 | || config.getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 271 | || config.getActivityType() == targetActivityType) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 272 | continue; |
| 273 | } |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 274 | addAnimation(task, !recentTaskIds.get(task.mTaskId)); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 275 | } |
| 276 | |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 277 | // Skip the animation if there is nothing to animate |
| 278 | if (mPendingAnimations.isEmpty()) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 279 | cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "initialize-noVisibleTasks"); |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 280 | return; |
| 281 | } |
| 282 | |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 283 | try { |
Adrian Roos | 653c6c1 | 2018-04-09 14:12:46 -0700 | [diff] [blame] | 284 | linkToDeathOfRunner(); |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 285 | } catch (RemoteException e) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 286 | cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "initialize-failedToLinkToDeath"); |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 287 | return; |
| 288 | } |
| 289 | |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 290 | // Adjust the wallpaper visibility for the showing target activity |
| 291 | final AppWindowToken recentsComponentAppToken = dc.getStack(WINDOWING_MODE_UNDEFINED, |
| 292 | targetActivityType).getTopChild().getTopFullscreenAppToken(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 293 | if (recentsComponentAppToken != null) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 294 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "setHomeApp(" |
| 295 | + recentsComponentAppToken.getName() + ")"); |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 296 | mTargetAppToken = recentsComponentAppToken; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 297 | if (recentsComponentAppToken.windowsCanBeWallpaperTarget()) { |
| 298 | dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 299 | dc.setLayoutNeeded(); |
| 300 | } |
| 301 | } |
| 302 | |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 303 | // Save the minimized home height |
| 304 | dc.getDockedDividerController().getHomeStackBoundsInDockedMode(mMinimizedHomeBounds); |
| 305 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 306 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 307 | } |
| 308 | |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 309 | @VisibleForTesting |
| 310 | AnimationAdapter addAnimation(Task task, boolean isRecentTaskInvisible) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 311 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "addAnimation(" + task.getName() + ")"); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 312 | // TODO: Refactor this to use the task's animator |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 313 | final SurfaceAnimator anim = new SurfaceAnimator(task, null /* animationFinishedCallback */, |
Chavi Weingarten | b736e32 | 2018-02-23 00:27:54 +0000 | [diff] [blame] | 314 | mService); |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 315 | final TaskAnimationAdapter taskAdapter = new TaskAnimationAdapter(task, |
| 316 | isRecentTaskInvisible); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 317 | anim.startAnimation(task.getPendingTransaction(), taskAdapter, false /* hidden */); |
| 318 | task.commitPendingTransaction(); |
| 319 | mPendingAnimations.add(taskAdapter); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 320 | return taskAdapter; |
| 321 | } |
| 322 | |
| 323 | @VisibleForTesting |
| 324 | void removeAnimation(TaskAnimationAdapter taskAdapter) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 325 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "removeAnimation(" |
| 326 | + taskAdapter.mTask.mTaskId + ")"); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 327 | taskAdapter.mTask.setCanAffectSystemUiFlags(true); |
| 328 | taskAdapter.mCapturedFinishCallback.onAnimationFinished(taskAdapter); |
| 329 | mPendingAnimations.remove(taskAdapter); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | void startAnimation() { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 333 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "startAnimation(): mPendingStart=" + mPendingStart |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 334 | + " mCanceled=" + mCanceled); |
| 335 | if (!mPendingStart || mCanceled) { |
| 336 | // Skip starting if we've already started or canceled the animation |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 337 | return; |
| 338 | } |
| 339 | try { |
Winson Chung | 2dc3736 | 2018-03-12 17:57:06 -0700 | [diff] [blame] | 340 | final ArrayList<RemoteAnimationTarget> appAnimations = new ArrayList<>(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 341 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 342 | final TaskAnimationAdapter taskAdapter = mPendingAnimations.get(i); |
| 343 | final RemoteAnimationTarget target = taskAdapter.createRemoteAnimationApp(); |
Winson Chung | 2dc3736 | 2018-03-12 17:57:06 -0700 | [diff] [blame] | 344 | if (target != null) { |
| 345 | appAnimations.add(target); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 346 | } else { |
| 347 | removeAnimation(taskAdapter); |
Winson Chung | 2dc3736 | 2018-03-12 17:57:06 -0700 | [diff] [blame] | 348 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 349 | } |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 350 | |
| 351 | // Skip the animation if there is nothing to animate |
| 352 | if (appAnimations.isEmpty()) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 353 | cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "startAnimation-noAppWindows"); |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 354 | return; |
| 355 | } |
| 356 | |
Winson Chung | 2dc3736 | 2018-03-12 17:57:06 -0700 | [diff] [blame] | 357 | final RemoteAnimationTarget[] appTargets = appAnimations.toArray( |
| 358 | new RemoteAnimationTarget[appAnimations.size()]); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 359 | mPendingStart = false; |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 360 | |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 361 | final Rect minimizedHomeBounds = mTargetAppToken != null |
| 362 | && mTargetAppToken.inSplitScreenSecondaryWindowingMode() |
| 363 | ? mMinimizedHomeBounds |
| 364 | : null; |
| 365 | final Rect contentInsets = mTargetAppToken != null |
| 366 | && mTargetAppToken.findMainWindow() != null |
| 367 | ? mTargetAppToken.findMainWindow().mContentInsets |
| 368 | : null; |
Winson Chung | 2dc3736 | 2018-03-12 17:57:06 -0700 | [diff] [blame] | 369 | mRunner.onAnimationStart_New(mController, appTargets, contentInsets, |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 370 | minimizedHomeBounds); |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 371 | if (DEBUG_RECENTS_ANIMATIONS) { |
| 372 | Slog.d(TAG, "startAnimation(): Notify animation start:"); |
| 373 | for (int i = 0; i < mPendingAnimations.size(); i++) { |
| 374 | final Task task = mPendingAnimations.get(i).mTask; |
| 375 | Slog.d(TAG, "\t" + task.mTaskId); |
| 376 | } |
| 377 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 378 | } catch (RemoteException e) { |
| 379 | Slog.e(TAG, "Failed to start recents animation", e); |
| 380 | } |
Jorim Jaggi | 54cff64 | 2018-03-15 15:51:32 +0100 | [diff] [blame] | 381 | final SparseIntArray reasons = new SparseIntArray(); |
| 382 | reasons.put(WINDOWING_MODE_FULLSCREEN, APP_TRANSITION_RECENTS_ANIM); |
| 383 | mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING, |
| 384 | reasons).sendToTarget(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 387 | void cancelAnimation(@ReorderMode int reorderMode, String reason) { |
Winson Chung | 65c5f99 | 2018-04-20 14:58:57 -0700 | [diff] [blame] | 388 | cancelAnimation(reorderMode, false /* runSynchronously */, reason); |
| 389 | } |
| 390 | |
| 391 | void cancelAnimationSynchronously(@ReorderMode int reorderMode, String reason) { |
| 392 | cancelAnimation(reorderMode, true /* runSynchronously */, reason); |
| 393 | } |
| 394 | |
| 395 | private void cancelAnimation(@ReorderMode int reorderMode, boolean runSynchronously, |
| 396 | String reason) { |
| 397 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "cancelAnimation(): reason=" + reason |
| 398 | + " runSynchronously=" + runSynchronously); |
Winson Chung | 65fc89a | 2018-02-28 08:32:12 -0800 | [diff] [blame] | 399 | synchronized (mService.getWindowManagerLock()) { |
| 400 | if (mCanceled) { |
| 401 | // We've already canceled the animation |
| 402 | return; |
| 403 | } |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 404 | mService.mH.removeCallbacks(mFailsafeRunnable); |
Winson Chung | 65fc89a | 2018-02-28 08:32:12 -0800 | [diff] [blame] | 405 | mCanceled = true; |
| 406 | try { |
| 407 | mRunner.onAnimationCanceled(); |
| 408 | } catch (RemoteException e) { |
| 409 | Slog.e(TAG, "Failed to cancel recents animation", e); |
| 410 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 411 | } |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 412 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 413 | // Clean up and return to the previous app |
Winson Chung | 65c5f99 | 2018-04-20 14:58:57 -0700 | [diff] [blame] | 414 | mCallbacks.onAnimationFinished(reorderMode, runSynchronously); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 415 | } |
| 416 | |
Winson Chung | 6a38fca | 2018-03-28 17:57:09 -0700 | [diff] [blame] | 417 | void cleanupAnimation(@ReorderMode int reorderMode) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 418 | if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, |
| 419 | "cleanupAnimation(): Notify animation finished mPendingAnimations=" |
| 420 | + mPendingAnimations.size() + " reorderMode=" + reorderMode); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 421 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 422 | final TaskAnimationAdapter taskAdapter = mPendingAnimations.get(i); |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 423 | if (reorderMode == REORDER_MOVE_TO_TOP || reorderMode == REORDER_KEEP_IN_PLACE) { |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 424 | taskAdapter.mTask.dontAnimateDimExit(); |
chaviw | 87ca63a | 2018-03-26 14:06:17 -0700 | [diff] [blame] | 425 | } |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 426 | removeAnimation(taskAdapter); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 427 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 428 | |
Adrian Roos | 653c6c1 | 2018-04-09 14:12:46 -0700 | [diff] [blame] | 429 | unlinkToDeathOfRunner(); |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 430 | // Clear associated input consumers |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 431 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 432 | mService.destroyInputConsumer(INPUT_CONSUMER_RECENTS_ANIMATION); |
Winson Chung | 0bb66cc | 2018-04-10 11:58:15 -0700 | [diff] [blame] | 433 | |
| 434 | // We have deferred all notifications to the target app as a part of the recents animation, |
| 435 | // so if we are actually transitioning there, notify again here |
| 436 | if (mTargetAppToken != null) { |
| 437 | if (reorderMode == REORDER_MOVE_TO_TOP || reorderMode == REORDER_KEEP_IN_PLACE) { |
| 438 | mService.mAppTransition.notifyAppTransitionFinishedLocked(mTargetAppToken.token); |
| 439 | } |
| 440 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 441 | } |
| 442 | |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 443 | void scheduleFailsafe() { |
| 444 | mService.mH.postDelayed(mFailsafeRunnable, FAILSAFE_DELAY); |
| 445 | } |
| 446 | |
Adrian Roos | 653c6c1 | 2018-04-09 14:12:46 -0700 | [diff] [blame] | 447 | private void linkToDeathOfRunner() throws RemoteException { |
| 448 | if (!mLinkedToDeathOfRunner) { |
| 449 | mRunner.asBinder().linkToDeath(this, 0); |
| 450 | mLinkedToDeathOfRunner = true; |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | private void unlinkToDeathOfRunner() { |
| 455 | if (mLinkedToDeathOfRunner) { |
| 456 | mRunner.asBinder().unlinkToDeath(this, 0); |
| 457 | mLinkedToDeathOfRunner = false; |
| 458 | } |
| 459 | } |
| 460 | |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 461 | @Override |
| 462 | public void binderDied() { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 463 | cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "binderDied"); |
Adrian Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 464 | } |
| 465 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 466 | void checkAnimationReady(WallpaperController wallpaperController) { |
| 467 | if (mPendingStart) { |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 468 | final boolean wallpaperReady = !isTargetOverWallpaper() |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 469 | || (wallpaperController.getWallpaperTarget() != null |
| 470 | && wallpaperController.wallpaperTransitionReady()); |
| 471 | if (wallpaperReady) { |
| 472 | mService.getRecentsAnimationController().startAnimation(); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
Winson Chung | f557c3b | 2018-03-16 10:55:20 -0700 | [diff] [blame] | 477 | boolean isSplitScreenMinimized() { |
| 478 | return mSplitScreenMinimized; |
| 479 | } |
| 480 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 481 | boolean isWallpaperVisible(WindowState w) { |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 482 | return w != null && w.mAppToken != null && mTargetAppToken == w.mAppToken |
| 483 | && isTargetOverWallpaper(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 484 | } |
| 485 | |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 486 | boolean hasInputConsumerForApp(AppWindowToken appToken) { |
| 487 | return mInputConsumerEnabled && isAnimatingApp(appToken); |
| 488 | } |
| 489 | |
| 490 | boolean updateInputConsumerForApp(InputConsumerImpl recentsAnimationInputConsumer, |
| 491 | boolean hasFocus) { |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 492 | // Update the input consumer touchable region to match the target app main window |
| 493 | final WindowState targetAppMainWindow = mTargetAppToken != null |
| 494 | ? mTargetAppToken.findMainWindow() |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 495 | : null; |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 496 | if (targetAppMainWindow != null) { |
| 497 | targetAppMainWindow.getBounds(mTmpRect); |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 498 | recentsAnimationInputConsumer.mWindowHandle.hasFocus = hasFocus; |
| 499 | recentsAnimationInputConsumer.mWindowHandle.touchableRegion.set(mTmpRect); |
| 500 | return true; |
| 501 | } |
| 502 | return false; |
| 503 | } |
| 504 | |
Winson Chung | 0bb66cc | 2018-04-10 11:58:15 -0700 | [diff] [blame] | 505 | boolean isTargetApp(AppWindowToken token) { |
| 506 | return mTargetAppToken != null && token == mTargetAppToken; |
| 507 | } |
| 508 | |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 509 | private boolean isTargetOverWallpaper() { |
| 510 | if (mTargetAppToken == null) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 511 | return false; |
| 512 | } |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 513 | return mTargetAppToken.windowsCanBeWallpaperTarget(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 514 | } |
| 515 | |
Winson Chung | d41f71d | 2018-03-16 15:26:07 -0700 | [diff] [blame] | 516 | boolean isAnimatingTask(Task task) { |
| 517 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 518 | if (task == mPendingAnimations.get(i).mTask) { |
| 519 | return true; |
| 520 | } |
| 521 | } |
| 522 | return false; |
| 523 | } |
| 524 | |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 525 | private boolean isAnimatingApp(AppWindowToken appToken) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 526 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 527 | final Task task = mPendingAnimations.get(i).mTask; |
| 528 | for (int j = task.getChildCount() - 1; j >= 0; j--) { |
| 529 | final AppWindowToken app = task.getChildAt(j); |
| 530 | if (app == appToken) { |
| 531 | return true; |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | return false; |
| 536 | } |
| 537 | |
Winson Chung | da876c9 | 2018-04-05 18:31:06 -0700 | [diff] [blame] | 538 | @VisibleForTesting |
| 539 | class TaskAnimationAdapter implements AnimationAdapter { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 540 | |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 541 | private final Task mTask; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 542 | private SurfaceControl mCapturedLeash; |
| 543 | private OnAnimationFinishedCallback mCapturedFinishCallback; |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 544 | private final boolean mIsRecentTaskInvisible; |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 545 | private RemoteAnimationTarget mTarget; |
Winson Chung | d41f71d | 2018-03-16 15:26:07 -0700 | [diff] [blame] | 546 | private final Point mPosition = new Point(); |
| 547 | private final Rect mBounds = new Rect(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 548 | |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 549 | TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 550 | mTask = task; |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 551 | mIsRecentTaskInvisible = isRecentTaskInvisible; |
Winson Chung | d41f71d | 2018-03-16 15:26:07 -0700 | [diff] [blame] | 552 | final WindowContainer container = mTask.getParent(); |
| 553 | container.getRelativePosition(mPosition); |
| 554 | container.getBounds(mBounds); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | RemoteAnimationTarget createRemoteAnimationApp() { |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 558 | final WindowState mainWindow = mTask.getTopVisibleAppMainWindow(); |
Winson Chung | 2dc3736 | 2018-03-12 17:57:06 -0700 | [diff] [blame] | 559 | if (mainWindow == null) { |
| 560 | return null; |
| 561 | } |
Jorim Jaggi | 817ebdd | 2018-03-26 15:46:01 +0200 | [diff] [blame] | 562 | final Rect insets = new Rect(mainWindow.mContentInsets); |
| 563 | InsetUtils.addInsets(insets, mainWindow.mAppToken.getLetterboxInsets()); |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 564 | mTarget = new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash, |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 565 | !mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect, |
Winson Chung | d41f71d | 2018-03-16 15:26:07 -0700 | [diff] [blame] | 566 | insets, mTask.getPrefixOrderIndex(), mPosition, mBounds, |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 567 | mTask.getWindowConfiguration(), mIsRecentTaskInvisible); |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 568 | return mTarget; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | @Override |
| 572 | public boolean getDetachWallpaper() { |
| 573 | return false; |
| 574 | } |
| 575 | |
| 576 | @Override |
Jorim Jaggi | 82c1786 | 2018-02-21 17:50:18 +0100 | [diff] [blame] | 577 | public boolean getShowWallpaper() { |
| 578 | return false; |
| 579 | } |
| 580 | |
| 581 | @Override |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 582 | public int getBackgroundColor() { |
| 583 | return 0; |
| 584 | } |
| 585 | |
| 586 | @Override |
| 587 | public void startAnimation(SurfaceControl animationLeash, Transaction t, |
| 588 | OnAnimationFinishedCallback finishCallback) { |
Winson Chung | 65a0586 | 2018-04-12 17:14:50 -0700 | [diff] [blame] | 589 | // Restore z-layering, position and stack crop until client has a chance to modify it. |
| 590 | t.setLayer(animationLeash, mTask.getPrefixOrderIndex()); |
Winson Chung | d41f71d | 2018-03-16 15:26:07 -0700 | [diff] [blame] | 591 | t.setPosition(animationLeash, mPosition.x, mPosition.y); |
Winson Chung | 65a0586 | 2018-04-12 17:14:50 -0700 | [diff] [blame] | 592 | mTmpRect.set(mBounds); |
| 593 | mTmpRect.offsetTo(0, 0); |
| 594 | t.setWindowCrop(animationLeash, mTmpRect); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 595 | mCapturedLeash = animationLeash; |
| 596 | mCapturedFinishCallback = finishCallback; |
| 597 | } |
| 598 | |
| 599 | @Override |
| 600 | public void onAnimationCancelled(SurfaceControl animationLeash) { |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 601 | cancelAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION, "taskAnimationAdapterCanceled"); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | @Override |
| 605 | public long getDurationHint() { |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | @Override |
| 610 | public long getStatusBarTransitionsStartTime() { |
| 611 | return SystemClock.uptimeMillis(); |
| 612 | } |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 613 | |
| 614 | @Override |
| 615 | public void dump(PrintWriter pw, String prefix) { |
| 616 | pw.print(prefix); pw.println("task=" + mTask); |
| 617 | if (mTarget != null) { |
| 618 | pw.print(prefix); pw.println("Target:"); |
| 619 | mTarget.dump(pw, prefix + " "); |
| 620 | } else { |
| 621 | pw.print(prefix); pw.println("Target: null"); |
| 622 | } |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 623 | pw.println("mIsRecentTaskInvisible=" + mIsRecentTaskInvisible); |
| 624 | pw.println("mPosition=" + mPosition); |
| 625 | pw.println("mBounds=" + mBounds); |
| 626 | pw.println("mIsRecentTaskInvisible=" + mIsRecentTaskInvisible); |
Jorim Jaggi | f75d161 | 2018-02-27 15:05:21 +0100 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | @Override |
| 630 | public void writeToProto(ProtoOutputStream proto) { |
| 631 | final long token = proto.start(REMOTE); |
| 632 | if (mTarget != null) { |
| 633 | mTarget.writeToProto(proto, TARGET); |
| 634 | } |
| 635 | proto.end(token); |
| 636 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | public void dump(PrintWriter pw, String prefix) { |
| 640 | final String innerPrefix = prefix + " "; |
| 641 | pw.print(prefix); pw.println(RecentsAnimationController.class.getSimpleName() + ":"); |
| 642 | pw.print(innerPrefix); pw.println("mPendingStart=" + mPendingStart); |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 643 | pw.print(innerPrefix); pw.println("mCanceled=" + mCanceled); |
| 644 | pw.print(innerPrefix); pw.println("mInputConsumerEnabled=" + mInputConsumerEnabled); |
| 645 | pw.print(innerPrefix); pw.println("mSplitScreenMinimized=" + mSplitScreenMinimized); |
Winson Chung | 3e2980e | 2018-03-29 17:28:57 -0700 | [diff] [blame] | 646 | pw.print(innerPrefix); pw.println("mTargetAppToken=" + mTargetAppToken); |
Winson Chung | c6c3f85 | 2018-04-09 15:41:03 -0700 | [diff] [blame] | 647 | pw.print(innerPrefix); pw.println("isTargetOverWallpaper=" + isTargetOverWallpaper()); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 648 | } |
| 649 | } |