blob: b9618791b848a37467f95122a1d197b5f89446e5 [file] [log] [blame]
Craig Mautnerc00204b2013-03-05 15:02:14 -08001/*
2 * Copyright (C) 2013 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
17package com.android.server.wm;
18
Wale Ogunwale3797c222015-10-27 14:21:58 -070019import android.app.ActivityManager.StackId;
Wale Ogunwale60454db2015-01-23 16:05:07 -080020import android.content.res.Configuration;
Craig Mautner05d29032013-05-03 13:40:13 -070021import android.graphics.Rect;
Craig Mautnerf0ac5c82013-06-24 11:21:57 -070022import android.os.Debug;
Craig Mautner2c2549c2013-11-12 08:31:15 -080023import android.util.EventLog;
Craig Mautnerf0ac5c82013-06-24 11:21:57 -070024import android.util.Slog;
Filip Gruszczynskiebcc8752015-08-25 16:51:05 -070025import android.util.SparseArray;
Wale Ogunwalee4a0c572015-06-30 08:40:31 -070026import android.view.DisplayInfo;
Wale Ogunwale94744212015-09-21 19:01:47 -070027import android.view.Surface;
Filip Gruszczynski54977fe2015-10-19 17:26:45 -070028
Craig Mautner2c2549c2013-11-12 08:31:15 -080029import com.android.server.EventLogTags;
Craig Mautner05d29032013-05-03 13:40:13 -070030
Craig Mautner00af9fe2013-03-25 09:13:41 -070031import java.io.PrintWriter;
Craig Mautnerc00204b2013-03-05 15:02:14 -080032import java.util.ArrayList;
33
Jorim Jaggi61f39a72015-10-29 16:54:18 +010034import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
35import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
36import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
37import static android.view.WindowManager.DOCKED_BOTTOM;
38import static android.view.WindowManager.DOCKED_INVALID;
39import static android.view.WindowManager.DOCKED_LEFT;
40import static android.view.WindowManager.DOCKED_RIGHT;
41import static android.view.WindowManager.DOCKED_TOP;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080042import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_MOVEMENT;
Jorim Jaggi61f39a72015-10-29 16:54:18 +010043import static com.android.server.wm.WindowManagerService.H.RESIZE_STACK;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080044import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Jorim Jaggi61f39a72015-10-29 16:54:18 +010045
Wale Ogunwalee4a0c572015-06-30 08:40:31 -070046public class TaskStack implements DimLayer.DimLayerUser {
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -070047
48 // If the stack should be resized to fullscreen.
49 private static final boolean FULLSCREEN = true;
50
Craig Mautner00af9fe2013-03-25 09:13:41 -070051 /** Unique identifier */
Craig Mautnerc00204b2013-03-05 15:02:14 -080052 final int mStackId;
Craig Mautner00af9fe2013-03-25 09:13:41 -070053
Craig Mautner05d29032013-05-03 13:40:13 -070054 /** The service */
55 private final WindowManagerService mService;
56
Craig Mautner00af9fe2013-03-25 09:13:41 -070057 /** The display this stack sits under. */
Craig Mautnerdf88d732014-01-27 09:21:32 -080058 private DisplayContent mDisplayContent;
Craig Mautner00af9fe2013-03-25 09:13:41 -070059
60 /** The Tasks that define this stack. Oldest Tasks are at the bottom. The ordering must match
61 * mTaskHistory in the ActivityStack with the same mStackId */
Wale Ogunwalee4a0c572015-06-30 08:40:31 -070062 private final ArrayList<Task> mTasks = new ArrayList<>();
Craig Mautner00af9fe2013-03-25 09:13:41 -070063
Craig Mautnerb660b9d2014-02-13 10:59:16 -080064 /** For comparison with DisplayContent bounds. */
65 private Rect mTmpRect = new Rect();
Wale Ogunwalee45899a2015-10-01 11:30:34 -070066 private Rect mTmpRect2 = new Rect();
Craig Mautnerb660b9d2014-02-13 10:59:16 -080067
68 /** Content limits relative to the DisplayContent this sits in. */
69 private Rect mBounds = new Rect();
70
71 /** Whether mBounds is fullscreen */
72 private boolean mFullscreen = true;
Craig Mautnerc00204b2013-03-05 15:02:14 -080073
Wale Ogunwale94744212015-09-21 19:01:47 -070074 // Device rotation as of the last time {@link #mBounds} was set.
75 int mRotation;
76
Craig Mautner05d29032013-05-03 13:40:13 -070077 /** Support for non-zero {@link android.view.animation.Animation#getBackgroundColor()} */
Craig Mautnerdf88d732014-01-27 09:21:32 -080078 DimLayer mAnimationBackgroundSurface;
Craig Mautner05d29032013-05-03 13:40:13 -070079
80 /** The particular window with an Animation with non-zero background color. */
81 WindowStateAnimator mAnimationBackgroundAnimator;
82
Craig Mautnerdc548482014-02-05 13:35:24 -080083 /** Application tokens that are exiting, but still on screen for animations. */
84 final AppTokenList mExitingAppTokens = new AppTokenList();
85
Craig Mautner95da1082014-02-24 17:54:35 -080086 /** Detach this stack from its display when animation completes. */
87 boolean mDeferDetach;
88
Craig Mautnerdf88d732014-01-27 09:21:32 -080089 TaskStack(WindowManagerService service, int stackId) {
Craig Mautner05d29032013-05-03 13:40:13 -070090 mService = service;
Craig Mautnerc00204b2013-03-05 15:02:14 -080091 mStackId = stackId;
Wale Ogunwalee4a0c572015-06-30 08:40:31 -070092 EventLog.writeEvent(EventLogTags.WM_STACK_CREATED, stackId);
Craig Mautnerc00204b2013-03-05 15:02:14 -080093 }
94
95 DisplayContent getDisplayContent() {
96 return mDisplayContent;
97 }
98
Craig Mautnerd9a22882013-03-16 15:00:36 -070099 ArrayList<Task> getTasks() {
100 return mTasks;
101 }
102
Craig Mautnerb660b9d2014-02-13 10:59:16 -0800103 void resizeWindows() {
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800104 for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700105 mTasks.get(taskNdx).resizeWindows();
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800106 }
Craig Mautnerd5d5d0f2013-04-03 15:08:21 -0700107 }
108
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700109 /**
110 * Set the bounds of the stack and its containing tasks.
Filip Gruszczynskiebcc8752015-08-25 16:51:05 -0700111 * @param stackBounds New stack bounds. Passing in null sets the bounds to fullscreen.
Filip Gruszczynskiebcc8752015-08-25 16:51:05 -0700112 * @param configs Configuration for individual tasks, keyed by task id.
113 * @param taskBounds Bounds for individual tasks, keyed by task id.
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700114 * @return True if the stack bounds was changed.
115 * */
Wale Ogunwalea6e902e2015-09-21 18:37:15 -0700116 boolean setBounds(
117 Rect stackBounds, SparseArray<Configuration> configs, SparseArray<Rect> taskBounds) {
Filip Gruszczynskiebcc8752015-08-25 16:51:05 -0700118 if (!setBounds(stackBounds)) {
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700119 return false;
120 }
121
122 // Update bounds of containing tasks.
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700123 for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
124 final Task task = mTasks.get(taskNdx);
Filip Gruszczynskiebcc8752015-08-25 16:51:05 -0700125 Configuration config = configs.get(task.mTaskId);
126 if (config != null) {
127 Rect bounds = taskBounds.get(task.mTaskId);
Chong Zhangb15758a2015-11-17 12:12:03 -0800128 if (!task.isResizeable() && task.isDockedInEffect()) {
129 // This is a non-resizeable task that's docked (or side-by-side to the docked
130 // stack). It might have been scrolled previously, and after the stack resizing,
131 // it might no longer fully cover the stack area.
132 // Save the old bounds and re-apply the scroll. This adjusts the bounds to
133 // fit the new stack bounds.
134 task.getBounds(mTmpRect);
135 task.setBounds(bounds, config);
136 task.scrollLocked(mTmpRect);
137 } else {
138 task.setBounds(bounds, config);
139 }
Filip Gruszczynskiebcc8752015-08-25 16:51:05 -0700140 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800141 Slog.wtf(TAG_WM, "No config for task: " + task + ", is there a mismatch with AM?");
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700142 }
143 }
144 return true;
145 }
146
Wale Ogunwaleb4ec0a32015-12-14 10:31:43 -0800147 boolean isFullscreenBounds(Rect bounds) {
148 if (mDisplayContent == null || bounds == null) {
149 return true;
150 }
151 mDisplayContent.getLogicalDisplayRect(mTmpRect);
152 return mTmpRect.equals(bounds);
153 }
154
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700155 private boolean setBounds(Rect bounds) {
Craig Mautnerb660b9d2014-02-13 10:59:16 -0800156 boolean oldFullscreen = mFullscreen;
Wale Ogunwale94744212015-09-21 19:01:47 -0700157 int rotation = Surface.ROTATION_0;
Craig Mautnerb660b9d2014-02-13 10:59:16 -0800158 if (mDisplayContent != null) {
159 mDisplayContent.getLogicalDisplayRect(mTmpRect);
Wale Ogunwale94744212015-09-21 19:01:47 -0700160 rotation = mDisplayContent.getDisplayInfo().rotation;
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800161 if (bounds == null) {
162 bounds = mTmpRect;
163 mFullscreen = true;
164 } else {
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800165 mFullscreen = mTmpRect.equals(bounds);
166 }
Craig Mautnerb660b9d2014-02-13 10:59:16 -0800167 }
168
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800169 if (bounds == null) {
Wale Ogunwale4a02d812015-02-12 23:01:38 -0800170 // Can't set to fullscreen if we don't have a display to get bounds from...
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800171 return false;
172 }
Wale Ogunwale94744212015-09-21 19:01:47 -0700173 if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) {
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800174 return false;
175 }
176
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700177 if (mDisplayContent != null) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800178 mDisplayContent.mDimLayerController.updateDimLayer(this);
Filip Gruszczynski57b6cce2015-10-06 09:50:51 -0700179 mAnimationBackgroundSurface.setBounds(bounds);
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700180 }
181
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800182 mBounds.set(bounds);
Wale Ogunwale94744212015-09-21 19:01:47 -0700183 mRotation = rotation;
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800184 return true;
185 }
186
Wale Ogunwalef175e8a2015-09-29 11:07:06 -0700187 /** Bounds of the stack without adjusting for other factors in the system like visibility
188 * of docked stack.
189 * Most callers should be using {@link #getBounds} as it take into consideration other system
190 * factors. */
191 void getRawBounds(Rect out) {
Craig Mautnerb660b9d2014-02-13 10:59:16 -0800192 out.set(mBounds);
193 }
194
Wale Ogunwalef175e8a2015-09-29 11:07:06 -0700195 /** Return true if the current bound can get outputted to the rest of the system as-is. */
196 private boolean useCurrentBounds() {
197 if (mFullscreen
Wale Ogunwale3797c222015-10-27 14:21:58 -0700198 || !StackId.isResizeableByDockedStack(mStackId)
Wale Ogunwalef175e8a2015-09-29 11:07:06 -0700199 || mDisplayContent == null
200 || mDisplayContent.getDockedStackLocked() != null) {
201 return true;
202 }
203 return false;
204 }
205
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700206 public void getBounds(Rect out) {
Wale Ogunwalef175e8a2015-09-29 11:07:06 -0700207 if (useCurrentBounds()) {
208 // No need to adjust the output bounds if fullscreen or the docked stack is visible
209 // since it is already what we want to represent to the rest of the system.
210 out.set(mBounds);
211 return;
212 }
213
214 // The bounds has been adjusted to accommodate for a docked stack, but the docked stack
215 // is not currently visible. Go ahead a represent it as fullscreen to the rest of the
216 // system.
217 mDisplayContent.getLogicalDisplayRect(out);
218 }
219
Chong Zhang4c9ba52a2015-11-10 18:36:33 -0800220 /** Bounds of the stack with other system factors taken into consideration. */
221 @Override
222 public void getDimBounds(Rect out) {
223 getBounds(out);
224 }
225
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700226 void updateDisplayInfo(Rect bounds) {
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700227 if (mDisplayContent != null) {
Wale Ogunwale1ed0d892015-09-28 13:27:44 -0700228 for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
229 mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);
230 }
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700231 if (bounds != null) {
232 setBounds(bounds);
Wale Ogunwale94744212015-09-21 19:01:47 -0700233 } else if (mFullscreen) {
234 setBounds(null);
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700235 } else {
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700236 mTmpRect2.set(mBounds);
Wale Ogunwale94744212015-09-21 19:01:47 -0700237 mDisplayContent.rotateBounds(
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700238 mRotation, mDisplayContent.getDisplayInfo().rotation, mTmpRect2);
239 if (setBounds(mTmpRect2)) {
Wale Ogunwale1ed0d892015-09-28 13:27:44 -0700240 // Post message to inform activity manager of the bounds change simulating
241 // a one-way call. We do this to prevent a deadlock between window manager
242 // lock and activity manager lock been held.
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700243 mService.mH.sendMessage(mService.mH.obtainMessage(
244 RESIZE_STACK, mStackId, 0 /*allowResizeInDockedMode*/, mBounds));
Wale Ogunwale1ed0d892015-09-28 13:27:44 -0700245 }
Wale Ogunwale4a02d812015-02-12 23:01:38 -0800246 }
Wale Ogunwale9d3de4c2015-02-01 16:49:44 -0800247 }
248 }
249
Craig Mautner1bf2b872014-02-05 15:37:40 -0800250 boolean isAnimating() {
251 for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
252 final ArrayList<AppWindowToken> activities = mTasks.get(taskNdx).mAppTokens;
253 for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
254 final ArrayList<WindowState> windows = activities.get(activityNdx).allAppWindows;
255 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
Craig Mautnerbc2a6df2014-06-13 15:08:48 -0700256 final WindowStateAnimator winAnimator = windows.get(winNdx).mWinAnimator;
Craig Mautner7c9ee192014-08-14 16:08:26 -0700257 if (winAnimator.isAnimating() || winAnimator.mWin.mExiting) {
Craig Mautner1bf2b872014-02-05 15:37:40 -0800258 return true;
259 }
260 }
261 }
262 }
263 return false;
264 }
265
Wale Ogunwale3fcb4a82015-04-06 14:00:13 -0700266 void addTask(Task task, boolean toTop) {
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -0700267 addTask(task, toTop, task.showForAllUsers());
Wale Ogunwale3fcb4a82015-04-06 14:00:13 -0700268 }
269
Craig Mautner00af9fe2013-03-25 09:13:41 -0700270 /**
271 * Put a Task in this stack. Used for adding and moving.
272 * @param task The task to add.
273 * @param toTop Whether to add it to the top or bottom.
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -0700274 * @param showForAllUsers Whether to show the task regardless of the current user.
Craig Mautner00af9fe2013-03-25 09:13:41 -0700275 */
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -0700276 void addTask(Task task, boolean toTop, boolean showForAllUsers) {
Wale Ogunwaleddc1cb22015-07-25 19:23:04 -0700277 positionTask(task, toTop ? mTasks.size() : 0, showForAllUsers);
278 }
279
280 void positionTask(Task task, int position, boolean showForAllUsers) {
281 final boolean canShowTask =
282 showForAllUsers || mService.isCurrentProfileLocked(task.mUserId);
283 mTasks.remove(task);
284 int stackSize = mTasks.size();
285 int minPosition = 0;
286 int maxPosition = stackSize;
287
288 if (canShowTask) {
289 minPosition = computeMinPosition(minPosition, stackSize);
Craig Mautnerac6f8432013-07-17 13:24:59 -0700290 } else {
Wale Ogunwaleddc1cb22015-07-25 19:23:04 -0700291 maxPosition = computeMaxPosition(maxPosition);
Craig Mautnerac6f8432013-07-17 13:24:59 -0700292 }
Wale Ogunwaleddc1cb22015-07-25 19:23:04 -0700293 // Reset position based on minimum/maximum possible positions.
294 position = Math.min(Math.max(position, minPosition), maxPosition);
295
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800296 if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM,
Wale Ogunwaleddc1cb22015-07-25 19:23:04 -0700297 "positionTask: task=" + task + " position=" + position);
298 mTasks.add(position, task);
Craig Mautnerac6f8432013-07-17 13:24:59 -0700299
Craig Mautner967212c2013-04-13 21:10:58 -0700300 task.mStack = this;
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700301 task.updateDisplayInfo(mDisplayContent);
Wale Ogunwaleddc1cb22015-07-25 19:23:04 -0700302 boolean toTop = position == mTasks.size() - 1;
raysb.kim00a27252014-11-11 08:38:21 +0900303 if (toTop) {
304 mDisplayContent.moveStack(this, true);
305 }
Wale Ogunwaleddc1cb22015-07-25 19:23:04 -0700306 EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, task.mTaskId, toTop ? 1 : 0, position);
307 }
308
309 /** Calculate the minimum possible position for a task that can be shown to the user.
310 * The minimum position will be above all other tasks that can't be shown.
311 * @param minPosition The minimum position the caller is suggesting.
312 * We will start adjusting up from here.
313 * @param size The size of the current task list.
314 */
315 private int computeMinPosition(int minPosition, int size) {
316 while (minPosition < size) {
317 final Task tmpTask = mTasks.get(minPosition);
318 final boolean canShowTmpTask =
319 tmpTask.showForAllUsers()
320 || mService.isCurrentProfileLocked(tmpTask.mUserId);
321 if (canShowTmpTask) {
322 break;
323 }
324 minPosition++;
325 }
326 return minPosition;
327 }
328
329 /** Calculate the maximum possible position for a task that can't be shown to the user.
330 * The maximum position will be below all other tasks that can be shown.
331 * @param maxPosition The maximum position the caller is suggesting.
332 * We will start adjusting down from here.
333 */
334 private int computeMaxPosition(int maxPosition) {
335 while (maxPosition > 0) {
336 final Task tmpTask = mTasks.get(maxPosition - 1);
337 final boolean canShowTmpTask =
338 tmpTask.showForAllUsers()
339 || mService.isCurrentProfileLocked(tmpTask.mUserId);
340 if (!canShowTmpTask) {
341 break;
342 }
343 maxPosition--;
344 }
345 return maxPosition;
Craig Mautnerc00204b2013-03-05 15:02:14 -0800346 }
347
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800348 void moveTaskToTop(Task task) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800349 if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "moveTaskToTop: task=" + task + " Callers="
Craig Mautnerf0ac5c82013-06-24 11:21:57 -0700350 + Debug.getCallers(6));
Craig Mautnerd9a22882013-03-16 15:00:36 -0700351 mTasks.remove(task);
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800352 addTask(task, true);
Craig Mautnerd9a22882013-03-16 15:00:36 -0700353 }
354
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800355 void moveTaskToBottom(Task task) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800356 if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "moveTaskToBottom: task=" + task);
Craig Mautnerd9a22882013-03-16 15:00:36 -0700357 mTasks.remove(task);
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800358 addTask(task, false);
Craig Mautnerd9a22882013-03-16 15:00:36 -0700359 }
360
Craig Mautner00af9fe2013-03-25 09:13:41 -0700361 /**
Craig Mautner04a0ea62014-01-13 12:51:26 -0800362 * Delete a Task from this stack. If it is the last Task in the stack, move this stack to the
363 * back.
Craig Mautner00af9fe2013-03-25 09:13:41 -0700364 * @param task The Task to delete.
Craig Mautner00af9fe2013-03-25 09:13:41 -0700365 */
Craig Mautnerde4ef022013-04-07 19:01:33 -0700366 void removeTask(Task task) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800367 if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "removeTask: task=" + task);
Craig Mautnerde4ef022013-04-07 19:01:33 -0700368 mTasks.remove(task);
Craig Mautnerdf88d732014-01-27 09:21:32 -0800369 if (mDisplayContent != null) {
Craig Mautnerdf88d732014-01-27 09:21:32 -0800370 if (mTasks.isEmpty()) {
371 mDisplayContent.moveStack(this, false);
372 }
373 mDisplayContent.layoutNeeded = true;
Craig Mautner04a0ea62014-01-13 12:51:26 -0800374 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800375 for (int appNdx = mExitingAppTokens.size() - 1; appNdx >= 0; --appNdx) {
376 final AppWindowToken wtoken = mExitingAppTokens.get(appNdx);
Craig Mautner83162a92015-01-26 14:43:30 -0800377 if (wtoken.mTask == task) {
Craig Mautnere3119b72015-01-20 15:02:36 -0800378 wtoken.mIsExiting = false;
379 mExitingAppTokens.remove(appNdx);
380 }
381 }
Craig Mautnerc00204b2013-03-05 15:02:14 -0800382 }
383
Craig Mautnerdf88d732014-01-27 09:21:32 -0800384 void attachDisplayContent(DisplayContent displayContent) {
385 if (mDisplayContent != null) {
386 throw new IllegalStateException("attachDisplayContent: Already attached");
Craig Mautner4a1cb222013-12-04 16:14:06 -0800387 }
Craig Mautnerdf88d732014-01-27 09:21:32 -0800388
389 mDisplayContent = displayContent;
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700390 mAnimationBackgroundSurface = new DimLayer(mService, this, mDisplayContent.getDisplayId());
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700391
392 Rect bounds = null;
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700393 final TaskStack dockedStack = mService.mStackIdToStack.get(DOCKED_STACK_ID);
Wale Ogunwale3797c222015-10-27 14:21:58 -0700394 if (mStackId == DOCKED_STACK_ID
395 || (dockedStack != null && StackId.isResizeableByDockedStack(mStackId))) {
396 // The existence of a docked stack affects the size of other static stack created since
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700397 // the docked stack occupies a dedicated region on screen.
398 bounds = new Rect();
399 displayContent.getLogicalDisplayRect(mTmpRect);
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700400 mTmpRect2.setEmpty();
401 if (dockedStack != null) {
402 dockedStack.getRawBounds(mTmpRect2);
403 }
Jorim Jaggi9ea2f7b2015-11-23 18:08:28 -0800404 final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700405 == DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
406 getStackDockedModeBounds(mTmpRect, bounds, mStackId, mTmpRect2,
Jorim Jaggi1fcbab62015-11-04 16:39:50 +0100407 mDisplayContent.mDividerControllerLocked.getContentWidth(),
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700408 dockedOnTopOrLeft);
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700409 }
410
411 updateDisplayInfo(bounds);
412
413 if (mStackId == DOCKED_STACK_ID) {
414 // Attaching a docked stack to the display affects the size of all other static
415 // stacks since the docked stack occupies a dedicated region on screen.
416 // Resize existing static stacks so they are pushed to the side of the docked stack.
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700417 resizeNonDockedStacks(!FULLSCREEN, mBounds);
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700418 }
419 }
420
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700421 void getStackDockedModeBoundsLocked(Rect outBounds) {
Wale Ogunwale3797c222015-10-27 14:21:58 -0700422 if (!StackId.isResizeableByDockedStack(mStackId) || mDisplayContent == null) {
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700423 outBounds.set(mBounds);
424 return;
425 }
426
Filip Gruszczynski54977fe2015-10-19 17:26:45 -0700427 final TaskStack dockedStack = mService.mStackIdToStack.get(DOCKED_STACK_ID);
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700428 if (dockedStack == null) {
429 // Not sure why you are calling this method when there is no docked stack...
430 throw new IllegalStateException(
431 "Calling getStackDockedModeBoundsLocked() when there is no docked stack.");
432 }
Filip Gruszczynski54977fe2015-10-19 17:26:45 -0700433 if (!dockedStack.isVisibleLocked()) {
434 // The docked stack is being dismissed, but we caught before it finished being
435 // dismissed. In that case we want to treat it as if it is not occupying any space and
436 // let others occupy the whole display.
437 mDisplayContent.getLogicalDisplayRect(mTmpRect);
438 return;
439 }
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700440
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700441 final int dockedSide = dockedStack.getDockSide();
442 if (dockedSide == DOCKED_INVALID) {
443 // Not sure how you got here...Only thing we can do is return current bounds.
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800444 Slog.e(TAG_WM, "Failed to get valid docked side for docked stack=" + dockedStack);
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700445 outBounds.set(mBounds);
446 return;
447 }
448
449 mDisplayContent.getLogicalDisplayRect(mTmpRect);
450 dockedStack.getRawBounds(mTmpRect2);
Jorim Jaggi61f39a72015-10-29 16:54:18 +0100451 final boolean dockedOnTopOrLeft = dockedSide == DOCKED_TOP
452 || dockedSide == DOCKED_LEFT;
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700453 getStackDockedModeBounds(mTmpRect, outBounds, mStackId, mTmpRect2,
Jorim Jaggi1fcbab62015-11-04 16:39:50 +0100454 mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft);
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700455
456 }
457
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700458 /**
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700459 * Outputs the bounds a stack should be given the presence of a docked stack on the display.
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700460 * @param displayRect The bounds of the display the docked stack is on.
461 * @param outBounds Output bounds that should be used for the stack.
462 * @param stackId Id of stack we are calculating the bounds for.
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700463 * @param dockedBounds Bounds of the docked stack.
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700464 * @param dockDividerWidth We need to know the width of the divider make to the output bounds
465 * close to the side of the dock.
466 * @param dockOnTopOrLeft If the docked stack is on the top or left side of the screen.
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700467 */
Jorim Jaggi9ea2f7b2015-11-23 18:08:28 -0800468 private void getStackDockedModeBounds(
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700469 Rect displayRect, Rect outBounds, int stackId, Rect dockedBounds, int dockDividerWidth,
470 boolean dockOnTopOrLeft) {
Filip Gruszczynski466f3212015-09-21 17:57:57 -0700471 final boolean dockedStack = stackId == DOCKED_STACK_ID;
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700472 final boolean splitHorizontally = displayRect.width() > displayRect.height();
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700473
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700474 outBounds.set(displayRect);
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700475 if (dockedStack) {
Jorim Jaggi9ea2f7b2015-11-23 18:08:28 -0800476 if (mService.mDockedStackCreateBounds != null) {
477 outBounds.set(mService.mDockedStackCreateBounds);
478 return;
479 }
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700480 // The initial bounds of the docked stack when it is created half the screen space and
481 // its bounds can be adjusted after that. The bounds of all other stacks are adjusted
482 // to occupy whatever screen space the docked stack isn't occupying.
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700483 if (dockOnTopOrLeft) {
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700484 if (splitHorizontally) {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700485 outBounds.right = displayRect.centerX() - dockDividerWidth / 2;
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700486 } else {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700487 outBounds.bottom = displayRect.centerY() - dockDividerWidth / 2;
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700488 }
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700489 } else {
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700490 if (splitHorizontally) {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700491 outBounds.left = displayRect.centerX() + dockDividerWidth / 2;
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700492 } else {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700493 outBounds.top = displayRect.centerY() + dockDividerWidth / 2;
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700494 }
495 }
496 return;
497 }
498
499 // Other stacks occupy whatever space is left by the docked stack.
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700500 if (!dockOnTopOrLeft) {
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700501 if (splitHorizontally) {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700502 outBounds.right = dockedBounds.left - dockDividerWidth;
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700503 } else {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700504 outBounds.bottom = dockedBounds.top - dockDividerWidth;
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700505 }
506 } else {
507 if (splitHorizontally) {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700508 outBounds.left = dockedBounds.right + dockDividerWidth;
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700509 } else {
Filip Gruszczynskiba47f812015-10-28 16:11:55 -0700510 outBounds.top = dockedBounds.bottom + dockDividerWidth;
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700511 }
512 }
513 }
514
515 /** Resizes all non-docked stacks in the system to either fullscreen or the appropriate size
516 * based on the presence of a docked stack.
517 * @param fullscreen If true the stacks will be resized to fullscreen, else they will be
518 * resized to the appropriate size based on the presence of a docked stack.
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700519 * @param dockedBounds Bounds of the docked stack.
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700520 */
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700521 private void resizeNonDockedStacks(boolean fullscreen, Rect dockedBounds) {
522 // Not using mTmpRect because we are posting the object in a message.
523 final Rect bounds = new Rect();
524 mDisplayContent.getLogicalDisplayRect(bounds);
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700525 if (!fullscreen) {
Jorim Jaggi9ea2f7b2015-11-23 18:08:28 -0800526 final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700527 == DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
528 getStackDockedModeBounds(bounds, bounds, FULLSCREEN_WORKSPACE_STACK_ID, dockedBounds,
Jorim Jaggi1fcbab62015-11-04 16:39:50 +0100529 mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft);
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700530 }
531
532 final int count = mService.mStackIdToStack.size();
533 for (int i = 0; i < count; i++) {
534 final TaskStack otherStack = mService.mStackIdToStack.valueAt(i);
535 final int otherStackId = otherStack.mStackId;
Wale Ogunwale3856bf72015-11-20 09:36:46 -0800536 if (StackId.isResizeableByDockedStack(otherStackId)
537 && !otherStack.mBounds.equals(bounds)) {
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700538 mService.mH.sendMessage(
Wale Ogunwaleffc11bb2015-10-10 13:05:45 -0700539 mService.mH.obtainMessage(RESIZE_STACK, otherStackId,
Wale Ogunwale3856bf72015-11-20 09:36:46 -0800540 1 /*allowResizeInDockedMode*/, fullscreen ? null : bounds));
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700541 }
542 }
Craig Mautnerdf88d732014-01-27 09:21:32 -0800543 }
544
Craig Mautnerdc548482014-02-05 13:35:24 -0800545 void detachDisplay() {
Craig Mautnerdf88d732014-01-27 09:21:32 -0800546 EventLog.writeEvent(EventLogTags.WM_STACK_REMOVED, mStackId);
Craig Mautnerbc2a6df2014-06-13 15:08:48 -0700547
548 boolean doAnotherLayoutPass = false;
Craig Mautnerdc548482014-02-05 13:35:24 -0800549 for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
Craig Mautnerbc2a6df2014-06-13 15:08:48 -0700550 final AppTokenList appWindowTokens = mTasks.get(taskNdx).mAppTokens;
551 for (int appNdx = appWindowTokens.size() - 1; appNdx >= 0; --appNdx) {
552 final WindowList appWindows = appWindowTokens.get(appNdx).allAppWindows;
553 for (int winNdx = appWindows.size() - 1; winNdx >= 0; --winNdx) {
Filip Gruszczynskid66af6a2015-08-31 08:57:24 -0700554 // We are in the middle of changing the state of displays/stacks/tasks. We need
555 // to finish that, before we let layout interfere with it.
Filip Gruszczynski49b80af2015-09-24 09:04:26 -0700556 mService.removeWindowLocked(appWindows.get(winNdx));
Craig Mautnerbc2a6df2014-06-13 15:08:48 -0700557 doAnotherLayoutPass = true;
558 }
559 }
Craig Mautnerdc548482014-02-05 13:35:24 -0800560 }
Craig Mautnerbc2a6df2014-06-13 15:08:48 -0700561 if (doAnotherLayoutPass) {
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700562 mService.mWindowPlacerLocked.requestTraversal();
Craig Mautnerbc2a6df2014-06-13 15:08:48 -0700563 }
564
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700565 if (mStackId == DOCKED_STACK_ID) {
566 // Docked stack was detached from the display, so we no longer need to restrict the
567 // region of the screen other static stacks occupy. Go ahead and make them fullscreen.
Wale Ogunwalee45899a2015-10-01 11:30:34 -0700568 resizeNonDockedStacks(FULLSCREEN, null);
Wale Ogunwaleb34a7ad2015-08-14 11:05:30 -0700569 }
570
Craig Mautner00a66752015-03-23 14:00:47 -0700571 close();
Craig Mautner00af9fe2013-03-25 09:13:41 -0700572 }
573
Craig Mautner05d29032013-05-03 13:40:13 -0700574 void resetAnimationBackgroundAnimator() {
575 mAnimationBackgroundAnimator = null;
576 mAnimationBackgroundSurface.hide();
577 }
578
Craig Mautner05d29032013-05-03 13:40:13 -0700579 void setAnimationBackground(WindowStateAnimator winAnimator, int color) {
580 int animLayer = winAnimator.mAnimLayer;
581 if (mAnimationBackgroundAnimator == null
582 || animLayer < mAnimationBackgroundAnimator.mAnimLayer) {
583 mAnimationBackgroundAnimator = winAnimator;
584 animLayer = mService.adjustAnimationBackground(winAnimator);
585 mAnimationBackgroundSurface.show(animLayer - WindowManagerService.LAYER_OFFSET_DIM,
586 ((color >> 24) & 0xff) / 255f, 0);
587 }
588 }
589
Wale Ogunwale498e8c92015-02-13 09:42:46 -0800590 void switchUser() {
Craig Mautnerac6f8432013-07-17 13:24:59 -0700591 int top = mTasks.size();
592 for (int taskNdx = 0; taskNdx < top; ++taskNdx) {
593 Task task = mTasks.get(taskNdx);
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -0700594 if (mService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) {
Craig Mautnerac6f8432013-07-17 13:24:59 -0700595 mTasks.remove(taskNdx);
596 mTasks.add(task);
597 --top;
598 }
599 }
600 }
601
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800602 void close() {
Craig Mautner00a66752015-03-23 14:00:47 -0700603 if (mAnimationBackgroundSurface != null) {
604 mAnimationBackgroundSurface.destroySurface();
605 mAnimationBackgroundSurface = null;
606 }
Filip Gruszczynski26ed2652015-08-10 11:02:53 -0700607 mDisplayContent = null;
Craig Mautnerbdc748af2013-12-02 14:08:25 -0800608 }
609
Craig Mautner00af9fe2013-03-25 09:13:41 -0700610 public void dump(String prefix, PrintWriter pw) {
611 pw.print(prefix); pw.print("mStackId="); pw.println(mStackId);
Craig Mautner95da1082014-02-24 17:54:35 -0800612 pw.print(prefix); pw.print("mDeferDetach="); pw.println(mDeferDetach);
Wale Ogunwale56b88af2015-12-01 07:21:59 -0800613 pw.print(prefix); pw.print("mFullscreen="); pw.println(mFullscreen);
614 pw.print(prefix); pw.print("mBounds="); pw.println(mBounds.toShortString());
Craig Mautner00af9fe2013-03-25 09:13:41 -0700615 for (int taskNdx = 0; taskNdx < mTasks.size(); ++taskNdx) {
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700616 pw.print(prefix);
617 mTasks.get(taskNdx).printTo(prefix + " ", pw);
Craig Mautner00af9fe2013-03-25 09:13:41 -0700618 }
Craig Mautner05d29032013-05-03 13:40:13 -0700619 if (mAnimationBackgroundSurface.isDimming()) {
620 pw.print(prefix); pw.println("mWindowAnimationBackgroundSurface:");
621 mAnimationBackgroundSurface.printTo(prefix + " ", pw);
622 }
Craig Mautnerdc548482014-02-05 13:35:24 -0800623 if (!mExitingAppTokens.isEmpty()) {
624 pw.println();
625 pw.println(" Exiting application tokens:");
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700626 for (int i = mExitingAppTokens.size() - 1; i >= 0; i--) {
Craig Mautnerdc548482014-02-05 13:35:24 -0800627 WindowToken token = mExitingAppTokens.get(i);
628 pw.print(" Exiting App #"); pw.print(i);
629 pw.print(' '); pw.print(token);
630 pw.println(':');
631 token.dump(pw, " ");
632 }
633 }
Craig Mautner00af9fe2013-03-25 09:13:41 -0700634 }
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700635
Wale Ogunwalef175e8a2015-09-29 11:07:06 -0700636 /** Fullscreen status of the stack without adjusting for other factors in the system like
637 * visibility of docked stack.
638 * Most callers should be using {@link #isFullscreen} as it take into consideration other
639 * system factors. */
640 boolean getRawFullscreen() {
641 return mFullscreen;
642 }
643
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700644 @Override
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700645 public boolean isFullscreen() {
Wale Ogunwalef175e8a2015-09-29 11:07:06 -0700646 if (useCurrentBounds()) {
647 return mFullscreen;
648 }
649 // The bounds has been adjusted to accommodate for a docked stack, but the docked stack
650 // is not currently visible. Go ahead a represent it as fullscreen to the rest of the
651 // system.
652 return true;
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700653 }
654
655 @Override
656 public DisplayInfo getDisplayInfo() {
657 return mDisplayContent.getDisplayInfo();
658 }
659
660 @Override
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700661 public String toString() {
662 return "{stackId=" + mStackId + " tasks=" + mTasks + "}";
663 }
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700664
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700665 @Override
666 public String toShortString() {
667 return "Stack=" + mStackId;
668 }
669
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700670 /**
Chong Zhangc806d902015-11-30 09:44:27 -0800671 * For docked workspace (or workspace that's side-by-side to the docked), provides
672 * information which side of the screen was the dock anchored.
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700673 */
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700674 int getDockSide() {
Chong Zhangc806d902015-11-30 09:44:27 -0800675 if (mStackId != DOCKED_STACK_ID && !StackId.isResizeableByDockedStack(mStackId)) {
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700676 return DOCKED_INVALID;
677 }
678 if (mDisplayContent == null) {
679 return DOCKED_INVALID;
680 }
681 mDisplayContent.getLogicalDisplayRect(mTmpRect);
682 final int orientation = mService.mCurConfiguration.orientation;
683 if (orientation == Configuration.ORIENTATION_PORTRAIT) {
684 // Portrait mode, docked either at the top or the bottom.
Filip Gruszczynski466f3212015-09-21 17:57:57 -0700685 if (mBounds.top - mTmpRect.top < mTmpRect.bottom - mBounds.bottom) {
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700686 return DOCKED_TOP;
687 } else {
688 return DOCKED_BOTTOM;
689 }
690 } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
691 // Landscape mode, docked either on the left or on the right.
Filip Gruszczynski466f3212015-09-21 17:57:57 -0700692 if (mBounds.left - mTmpRect.left < mTmpRect.right - mBounds.right) {
Filip Gruszczynski923f8262015-09-17 17:41:13 -0700693 return DOCKED_LEFT;
694 } else {
695 return DOCKED_RIGHT;
696 }
697 } else {
698 return DOCKED_INVALID;
699 }
700 }
Filip Gruszczynski3ddc5d62015-09-23 15:01:30 -0700701
702 boolean isVisibleLocked() {
Chong Zhang75b37202015-12-04 14:16:36 -0800703 final boolean keyguardOn = mService.mPolicy.isKeyguardShowingOrOccluded();
704 if (keyguardOn && !StackId.isAllowedOverLockscreen(mStackId)) {
705 return false;
706 }
Filip Gruszczynski3ddc5d62015-09-23 15:01:30 -0700707 for (int i = mTasks.size() - 1; i >= 0; i--) {
708 Task task = mTasks.get(i);
709 for (int j = task.mAppTokens.size() - 1; j >= 0; j--) {
710 if (!task.mAppTokens.get(j).hidden) {
711 return true;
712 }
713 }
714 }
715 return false;
716 }
Craig Mautnerc00204b2013-03-05 15:02:14 -0800717}