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 | |
| 19 | import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; |
| 20 | import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; |
| 21 | import static android.view.RemoteAnimationTarget.MODE_CLOSING; |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 22 | import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 23 | import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
| 24 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 25 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 26 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 27 | import android.app.ActivityManager.TaskSnapshot; |
| 28 | import android.app.WindowConfiguration; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 29 | import android.graphics.Point; |
| 30 | import android.graphics.Rect; |
| 31 | import android.os.Binder; |
| 32 | import android.os.RemoteException; |
| 33 | import android.os.SystemClock; |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 34 | import android.util.ArraySet; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 35 | import android.util.Log; |
| 36 | import android.util.Slog; |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 37 | import android.util.SparseBooleanArray; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 38 | import android.view.IRecentsAnimationController; |
| 39 | import android.view.IRecentsAnimationRunner; |
| 40 | import android.view.RemoteAnimationTarget; |
| 41 | import android.view.SurfaceControl; |
| 42 | import android.view.SurfaceControl.Transaction; |
| 43 | import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 44 | import com.google.android.collect.Sets; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 45 | import java.io.PrintWriter; |
| 46 | import java.util.ArrayList; |
| 47 | |
| 48 | /** |
| 49 | * Controls a single instance of the remote driven recents animation. In particular, this allows |
| 50 | * the calling SystemUI to animate the visible task windows as a part of the transition. The remote |
| 51 | * runner is provided an animation controller which allows it to take screenshots and to notify |
| 52 | * window manager when the animation is completed. In addition, window manager may also notify the |
| 53 | * app if it requires the animation to be canceled at any time (ie. due to timeout, etc.) |
| 54 | */ |
| 55 | public class RecentsAnimationController { |
| 56 | private static final String TAG = TAG_WITH_CLASS_NAME ? "RecentsAnimationController" : TAG_WM; |
| 57 | private static final boolean DEBUG = false; |
| 58 | |
| 59 | private final WindowManagerService mService; |
| 60 | private final IRecentsAnimationRunner mRunner; |
| 61 | private final RecentsAnimationCallbacks mCallbacks; |
| 62 | private final ArrayList<TaskAnimationAdapter> mPendingAnimations = new ArrayList<>(); |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 63 | private final int mDisplayId; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 64 | |
| 65 | // The recents component app token that is shown behind the visibile tasks |
| 66 | private AppWindowToken mHomeAppToken; |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 67 | private Rect mMinimizedHomeBounds = new Rect(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 68 | |
| 69 | // We start the RecentsAnimationController in a pending-start state since we need to wait for |
| 70 | // the wallpaper/activity to draw before we can give control to the handler to start animating |
| 71 | // the visible task surfaces |
| 72 | private boolean mPendingStart = true; |
| 73 | |
| 74 | // Set when the animation has been canceled |
| 75 | private boolean mCanceled = false; |
| 76 | |
| 77 | // Whether or not the input consumer is enabled. The input consumer must be both registered and |
| 78 | // enabled for it to start intercepting touch events. |
| 79 | private boolean mInputConsumerEnabled; |
| 80 | |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 81 | private Rect mTmpRect = new Rect(); |
| 82 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 83 | public interface RecentsAnimationCallbacks { |
| 84 | void onAnimationFinished(boolean moveHomeToTop); |
| 85 | } |
| 86 | |
| 87 | private final IRecentsAnimationController mController = |
| 88 | new IRecentsAnimationController.Stub() { |
| 89 | |
| 90 | @Override |
| 91 | public TaskSnapshot screenshotTask(int taskId) { |
| 92 | if (DEBUG) Log.d(TAG, "screenshotTask(" + taskId + "): mCanceled=" + mCanceled); |
| 93 | long token = Binder.clearCallingIdentity(); |
| 94 | try { |
| 95 | synchronized (mService.getWindowManagerLock()) { |
| 96 | if (mCanceled) { |
| 97 | return null; |
| 98 | } |
| 99 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 100 | final TaskAnimationAdapter adapter = mPendingAnimations.get(i); |
| 101 | final Task task = adapter.mTask; |
| 102 | if (task.mTaskId == taskId) { |
Winson Chung | 23aa7b1 | 2018-02-01 11:41:43 -0800 | [diff] [blame] | 103 | final TaskSnapshotController snapshotController = |
| 104 | mService.mTaskSnapshotController; |
| 105 | final ArraySet<Task> tasks = Sets.newArraySet(task); |
| 106 | snapshotController.snapshotTasks(tasks); |
| 107 | snapshotController.addSkipClosingAppSnapshotTasks(tasks); |
| 108 | return snapshotController.getSnapshot(taskId, 0 /* userId */, |
| 109 | false /* restoreFromDisk */, false /* reducedResolution */); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 110 | } |
| 111 | } |
| 112 | return null; |
| 113 | } |
| 114 | } finally { |
| 115 | Binder.restoreCallingIdentity(token); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public void finish(boolean moveHomeToTop) { |
| 121 | if (DEBUG) Log.d(TAG, "finish(" + moveHomeToTop + "): mCanceled=" + mCanceled); |
| 122 | long token = Binder.clearCallingIdentity(); |
| 123 | try { |
| 124 | synchronized (mService.getWindowManagerLock()) { |
| 125 | if (mCanceled) { |
| 126 | return; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | // Note, the callback will handle its own synchronization, do not lock on WM lock |
| 131 | // prior to calling the callback |
| 132 | mCallbacks.onAnimationFinished(moveHomeToTop); |
| 133 | } finally { |
| 134 | Binder.restoreCallingIdentity(token); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | @Override |
Jorim Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame^] | 139 | public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) |
| 140 | throws RemoteException { |
| 141 | long token = Binder.clearCallingIdentity(); |
| 142 | try { |
| 143 | synchronized (mService.getWindowManagerLock()) { |
| 144 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 145 | mPendingAnimations.get(i).mTask.setCanAffectSystemUiFlags(behindSystemBars); |
| 146 | } |
| 147 | mService.mWindowPlacerLocked.requestTraversal(); |
| 148 | } |
| 149 | } finally { |
| 150 | Binder.restoreCallingIdentity(token); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | @Override |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 155 | public void setInputConsumerEnabled(boolean enabled) { |
| 156 | if (DEBUG) Log.d(TAG, "setInputConsumerEnabled(" + enabled + "): mCanceled=" |
| 157 | + mCanceled); |
| 158 | long token = Binder.clearCallingIdentity(); |
| 159 | try { |
| 160 | synchronized (mService.getWindowManagerLock()) { |
| 161 | if (mCanceled) { |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | mInputConsumerEnabled = enabled; |
| 166 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
| 167 | mService.scheduleAnimationLocked(); |
| 168 | } |
| 169 | } finally { |
| 170 | Binder.restoreCallingIdentity(token); |
| 171 | } |
| 172 | } |
| 173 | }; |
| 174 | |
| 175 | /** |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 176 | * @param remoteAnimationRunner The remote runner which should be notified when the animation is |
| 177 | * ready to start or has been canceled |
| 178 | * @param callbacks Callbacks to be made when the animation finishes |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 179 | */ |
| 180 | RecentsAnimationController(WindowManagerService service, |
| 181 | IRecentsAnimationRunner remoteAnimationRunner, RecentsAnimationCallbacks callbacks, |
| 182 | int displayId) { |
| 183 | mService = service; |
| 184 | mRunner = remoteAnimationRunner; |
| 185 | mCallbacks = callbacks; |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 186 | mDisplayId = displayId; |
| 187 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 188 | |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 189 | /** |
| 190 | * Initializes the recents animation controller. This is a separate call from the constructor |
| 191 | * because it may call cancelAnimation() which needs to properly clean up the controller |
| 192 | * in the window manager. |
| 193 | */ |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 194 | public void initialize(SparseBooleanArray recentTaskIds) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 195 | // Make leashes for each of the visible tasks and add it to the recents animation to be |
| 196 | // started |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 197 | final DisplayContent dc = mService.mRoot.getDisplayContent(mDisplayId); |
| 198 | final ArrayList<Task> visibleTasks = dc.getVisibleTasks(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 199 | final int taskCount = visibleTasks.size(); |
| 200 | for (int i = 0; i < taskCount; i++) { |
| 201 | final Task task = visibleTasks.get(i); |
| 202 | final WindowConfiguration config = task.getWindowConfiguration(); |
| 203 | if (config.tasksAreFloating() |
| 204 | || config.getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY |
| 205 | || config.getActivityType() == ACTIVITY_TYPE_HOME) { |
| 206 | continue; |
| 207 | } |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 208 | addAnimation(task, !recentTaskIds.get(task.mTaskId)); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 211 | // Skip the animation if there is nothing to animate |
| 212 | if (mPendingAnimations.isEmpty()) { |
| 213 | cancelAnimation(); |
| 214 | return; |
| 215 | } |
| 216 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 217 | // Adjust the wallpaper visibility for the showing home activity |
| 218 | final AppWindowToken recentsComponentAppToken = |
| 219 | dc.getHomeStack().getTopChild().getTopFullscreenAppToken(); |
| 220 | if (recentsComponentAppToken != null) { |
| 221 | if (DEBUG) Log.d(TAG, "setHomeApp(" + recentsComponentAppToken.getName() + ")"); |
| 222 | mHomeAppToken = recentsComponentAppToken; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 223 | if (recentsComponentAppToken.windowsCanBeWallpaperTarget()) { |
| 224 | dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 225 | dc.setLayoutNeeded(); |
| 226 | } |
| 227 | } |
| 228 | |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 229 | // Save the minimized home height |
| 230 | dc.getDockedDividerController().getHomeStackBoundsInDockedMode(mMinimizedHomeBounds); |
| 231 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 232 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 233 | } |
| 234 | |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 235 | private void addAnimation(Task task, boolean isRecentTaskInvisible) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 236 | if (DEBUG) Log.d(TAG, "addAnimation(" + task.getName() + ")"); |
| 237 | final SurfaceAnimator anim = new SurfaceAnimator(task, null /* animationFinishedCallback */, |
Chavi Weingarten | b736e32 | 2018-02-23 00:27:54 +0000 | [diff] [blame] | 238 | mService); |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 239 | final TaskAnimationAdapter taskAdapter = new TaskAnimationAdapter(task, |
| 240 | isRecentTaskInvisible); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 241 | anim.startAnimation(task.getPendingTransaction(), taskAdapter, false /* hidden */); |
| 242 | task.commitPendingTransaction(); |
| 243 | mPendingAnimations.add(taskAdapter); |
| 244 | } |
| 245 | |
| 246 | void startAnimation() { |
Winson Chung | ddf6297 | 2018-02-12 11:10:04 -0800 | [diff] [blame] | 247 | if (DEBUG) Log.d(TAG, "startAnimation(): mPendingStart=" + mPendingStart |
| 248 | + " mCanceled=" + mCanceled); |
| 249 | if (!mPendingStart || mCanceled) { |
| 250 | // Skip starting if we've already started or canceled the animation |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 251 | return; |
| 252 | } |
| 253 | try { |
| 254 | final RemoteAnimationTarget[] appAnimations = |
| 255 | new RemoteAnimationTarget[mPendingAnimations.size()]; |
| 256 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 257 | appAnimations[i] = mPendingAnimations.get(i).createRemoteAnimationApp(); |
| 258 | } |
| 259 | mPendingStart = false; |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 260 | |
| 261 | final Rect minimizedHomeBounds = |
| 262 | mHomeAppToken != null && mHomeAppToken.inSplitScreenSecondaryWindowingMode() |
| 263 | ? mMinimizedHomeBounds : null; |
| 264 | final Rect contentInsets = |
| 265 | mHomeAppToken != null && mHomeAppToken.findMainWindow() != null |
| 266 | ? mHomeAppToken.findMainWindow().mContentInsets : null; |
| 267 | mRunner.onAnimationStart_New(mController, appAnimations, contentInsets, |
| 268 | minimizedHomeBounds); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 269 | } catch (RemoteException e) { |
| 270 | Slog.e(TAG, "Failed to start recents animation", e); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | void cancelAnimation() { |
| 275 | if (DEBUG) Log.d(TAG, "cancelAnimation()"); |
Winson Chung | 65fc89a | 2018-02-28 08:32:12 -0800 | [diff] [blame] | 276 | synchronized (mService.getWindowManagerLock()) { |
| 277 | if (mCanceled) { |
| 278 | // We've already canceled the animation |
| 279 | return; |
| 280 | } |
| 281 | mCanceled = true; |
| 282 | try { |
| 283 | mRunner.onAnimationCanceled(); |
| 284 | } catch (RemoteException e) { |
| 285 | Slog.e(TAG, "Failed to cancel recents animation", e); |
| 286 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 287 | } |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 288 | // Clean up and return to the previous app |
Winson Chung | 65fc89a | 2018-02-28 08:32:12 -0800 | [diff] [blame] | 289 | // Don't hold the WM lock here as it calls back to AM/RecentsAnimation |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 290 | mCallbacks.onAnimationFinished(false /* moveHomeToTop */); |
| 291 | } |
| 292 | |
| 293 | void cleanupAnimation() { |
| 294 | if (DEBUG) Log.d(TAG, "cleanupAnimation(): mPendingAnimations=" |
| 295 | + mPendingAnimations.size()); |
| 296 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 297 | final TaskAnimationAdapter adapter = mPendingAnimations.get(i); |
Jorim Jaggi | 50bf59c | 2018-03-09 17:29:48 +0100 | [diff] [blame^] | 298 | adapter.mTask.setCanAffectSystemUiFlags(true); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 299 | adapter.mCapturedFinishCallback.onAnimationFinished(adapter); |
| 300 | } |
| 301 | mPendingAnimations.clear(); |
| 302 | |
| 303 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 304 | mService.destroyInputConsumer(INPUT_CONSUMER_RECENTS_ANIMATION); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | void checkAnimationReady(WallpaperController wallpaperController) { |
| 308 | if (mPendingStart) { |
| 309 | final boolean wallpaperReady = !isHomeAppOverWallpaper() |
| 310 | || (wallpaperController.getWallpaperTarget() != null |
| 311 | && wallpaperController.wallpaperTransitionReady()); |
| 312 | if (wallpaperReady) { |
| 313 | mService.getRecentsAnimationController().startAnimation(); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | boolean isWallpaperVisible(WindowState w) { |
| 319 | return w != null && w.mAppToken != null && mHomeAppToken == w.mAppToken |
| 320 | && isHomeAppOverWallpaper(); |
| 321 | } |
| 322 | |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 323 | boolean hasInputConsumerForApp(AppWindowToken appToken) { |
| 324 | return mInputConsumerEnabled && isAnimatingApp(appToken); |
| 325 | } |
| 326 | |
| 327 | boolean updateInputConsumerForApp(InputConsumerImpl recentsAnimationInputConsumer, |
| 328 | boolean hasFocus) { |
| 329 | // Update the input consumer touchable region to match the home app main window |
| 330 | final WindowState homeAppMainWindow = mHomeAppToken != null |
| 331 | ? mHomeAppToken.findMainWindow() |
| 332 | : null; |
| 333 | if (homeAppMainWindow != null) { |
| 334 | homeAppMainWindow.getBounds(mTmpRect); |
| 335 | recentsAnimationInputConsumer.mWindowHandle.hasFocus = hasFocus; |
| 336 | recentsAnimationInputConsumer.mWindowHandle.touchableRegion.set(mTmpRect); |
| 337 | return true; |
| 338 | } |
| 339 | return false; |
| 340 | } |
| 341 | |
| 342 | private boolean isHomeAppOverWallpaper() { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 343 | if (mHomeAppToken == null) { |
| 344 | return false; |
| 345 | } |
| 346 | return mHomeAppToken.windowsCanBeWallpaperTarget(); |
| 347 | } |
| 348 | |
Winson Chung | a89ffed | 2018-01-25 17:46:11 +0000 | [diff] [blame] | 349 | private boolean isAnimatingApp(AppWindowToken appToken) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 350 | for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { |
| 351 | final Task task = mPendingAnimations.get(i).mTask; |
| 352 | for (int j = task.getChildCount() - 1; j >= 0; j--) { |
| 353 | final AppWindowToken app = task.getChildAt(j); |
| 354 | if (app == appToken) { |
| 355 | return true; |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | return false; |
| 360 | } |
| 361 | |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 362 | private class TaskAnimationAdapter implements AnimationAdapter { |
| 363 | |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 364 | private final Task mTask; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 365 | private SurfaceControl mCapturedLeash; |
| 366 | private OnAnimationFinishedCallback mCapturedFinishCallback; |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 367 | private final boolean mIsRecentTaskInvisible; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 368 | |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 369 | TaskAnimationAdapter(Task task, boolean isRecentTaskInvisible) { |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 370 | mTask = task; |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 371 | mIsRecentTaskInvisible = isRecentTaskInvisible; |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | RemoteAnimationTarget createRemoteAnimationApp() { |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 375 | final Point position = new Point(); |
| 376 | final Rect bounds = new Rect(); |
| 377 | final WindowContainer container = mTask.getParent(); |
| 378 | container.getRelativePosition(position); |
| 379 | container.getBounds(bounds); |
| 380 | final WindowState mainWindow = mTask.getTopVisibleAppMainWindow(); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 381 | return new RemoteAnimationTarget(mTask.mTaskId, MODE_CLOSING, mCapturedLeash, |
Winson Chung | 584d652 | 2018-02-07 23:57:38 +0000 | [diff] [blame] | 382 | !mTask.fillsParent(), mainWindow.mWinAnimator.mLastClipRect, |
| 383 | mainWindow.mContentInsets, mTask.getPrefixOrderIndex(), position, bounds, |
Vadim Tryshev | 593e956 | 2018-03-08 17:15:45 -0800 | [diff] [blame] | 384 | mTask.getWindowConfiguration(), mIsRecentTaskInvisible); |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | @Override |
| 388 | public boolean getDetachWallpaper() { |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | @Override |
Jorim Jaggi | 82c1786 | 2018-02-21 17:50:18 +0100 | [diff] [blame] | 393 | public boolean getShowWallpaper() { |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | @Override |
Winson Chung | e2d7217 | 2018-01-25 17:46:20 +0000 | [diff] [blame] | 398 | public int getBackgroundColor() { |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public void startAnimation(SurfaceControl animationLeash, Transaction t, |
| 404 | OnAnimationFinishedCallback finishCallback) { |
| 405 | mCapturedLeash = animationLeash; |
| 406 | mCapturedFinishCallback = finishCallback; |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public void onAnimationCancelled(SurfaceControl animationLeash) { |
| 411 | cancelAnimation(); |
| 412 | } |
| 413 | |
| 414 | @Override |
| 415 | public long getDurationHint() { |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public long getStatusBarTransitionsStartTime() { |
| 421 | return SystemClock.uptimeMillis(); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | public void dump(PrintWriter pw, String prefix) { |
| 426 | final String innerPrefix = prefix + " "; |
| 427 | pw.print(prefix); pw.println(RecentsAnimationController.class.getSimpleName() + ":"); |
| 428 | pw.print(innerPrefix); pw.println("mPendingStart=" + mPendingStart); |
| 429 | pw.print(innerPrefix); pw.println("mHomeAppToken=" + mHomeAppToken); |
| 430 | } |
| 431 | } |