blob: 651b29a194696e3e6e6b26c745d1b5adbc4b3955 [file] [log] [blame]
Winson Chung303e1ff2014-03-07 15:06:19 -08001/*
2 * Copyright (C) 2014 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.systemui.recents.views;
18
Filip Gruszczynski170192a2015-08-16 17:46:34 -070019import android.app.ActivityManager;
Winson Chung303e1ff2014-03-07 15:06:19 -080020import android.app.ActivityOptions;
Winson Chung9f9679d2014-04-11 16:49:09 -070021import android.app.TaskStackBuilder;
Winson Chung303e1ff2014-03-07 15:06:19 -080022import android.content.Context;
23import android.content.Intent;
24import android.graphics.Bitmap;
25import android.graphics.Canvas;
26import android.graphics.Rect;
Winson Chung9f9679d2014-04-11 16:49:09 -070027import android.net.Uri;
Jorim Jaggi6e18e002015-06-02 17:07:39 -070028import android.os.Bundle;
29import android.os.IRemoteCallback;
30import android.os.RemoteException;
Kenny Guy94a07ac2014-08-07 15:34:38 +010031import android.os.UserHandle;
Winson Chung9f9679d2014-04-11 16:49:09 -070032import android.provider.Settings;
Winson Chung8e548f72014-06-24 14:40:53 -070033import android.util.AttributeSet;
Jorim Jaggi6e18e002015-06-02 17:07:39 -070034import android.util.Log;
Filip Gruszczynski170192a2015-08-16 17:46:34 -070035import android.util.SparseArray;
36import android.view.AppTransitionAnimationSpec;
Winson Chungecd9b302014-04-16 17:07:18 -070037import android.view.LayoutInflater;
Winson Chung303e1ff2014-03-07 15:06:19 -080038import android.view.View;
Winson Chung653f70c22014-05-19 14:49:42 -070039import android.view.WindowInsets;
Jorim Jaggi6e18e002015-06-02 17:07:39 -070040import android.view.WindowManagerGlobal;
Winson Chung303e1ff2014-03-07 15:06:19 -080041import android.widget.FrameLayout;
Jorim Jaggi88f3db92015-06-02 16:29:40 -070042
Winson Chung5c9f4b92015-06-25 16:16:46 -070043import com.android.internal.logging.MetricsLogger;
Winson Chungd16c5652015-01-26 16:11:07 -080044import com.android.systemui.R;
Winson Chung303e1ff2014-03-07 15:06:19 -080045import com.android.systemui.recents.Constants;
Winson Chungaee097c2015-04-02 18:16:02 -070046import com.android.systemui.recents.RecentsAppWidgetHostView;
Winson Chung303e1ff2014-03-07 15:06:19 -080047import com.android.systemui.recents.RecentsConfiguration;
Winson Chung1f24c7e2014-07-11 17:06:48 -070048import com.android.systemui.recents.misc.SystemServicesProxy;
Winson Chungf1fbd772014-06-24 18:06:58 -070049import com.android.systemui.recents.model.RecentsPackageMonitor;
50import com.android.systemui.recents.model.RecentsTaskLoader;
Winson Chung303e1ff2014-03-07 15:06:19 -080051import com.android.systemui.recents.model.Task;
52import com.android.systemui.recents.model.TaskStack;
53
54import java.util.ArrayList;
Winson Chung6ac8bd62015-01-07 16:38:35 -080055import java.util.List;
Winson Chung303e1ff2014-03-07 15:06:19 -080056
Winson Chung303e1ff2014-03-07 15:06:19 -080057/**
58 * This view is the the top level layout that contains TaskStacks (which are laid out according
59 * to their SpaceNode bounds.
60 */
Winson Chung9f49df92014-05-07 18:08:34 -070061public class RecentsView extends FrameLayout implements TaskStackView.TaskStackViewCallbacks,
62 RecentsPackageMonitor.PackageCallbacks {
Winson Chung47c4c692014-03-17 10:17:11 -070063
Jorim Jaggi6e18e002015-06-02 17:07:39 -070064 private static final String TAG = "RecentsView";
65
Filip Gruszczynski170192a2015-08-16 17:46:34 -070066 private static final boolean ADD_HEADER_BITMAP = true;
67
Winson Chung47c4c692014-03-17 10:17:11 -070068 /** The RecentsView callbacks */
69 public interface RecentsViewCallbacks {
Winson Chung7aceb9a2014-07-03 13:38:01 -070070 public void onTaskViewClicked();
Winson Chung4e96eb72014-09-17 15:16:09 +020071 public void onTaskLaunchFailed();
Winson Chung7aceb9a2014-07-03 13:38:01 -070072 public void onAllTaskViewsDismissed();
Winson Chungcdbbb7e2014-06-24 12:11:49 -070073 public void onExitToHomeAnimationTriggered();
Jason Monk18f99d92014-09-11 13:36:42 -040074 public void onScreenPinningRequest();
Skuhneece738b2015-03-17 15:02:18 -070075 public void onTaskResize(Task t);
Jorim Jaggi6e18e002015-06-02 17:07:39 -070076 public void runAfterPause(Runnable r);
Winson Chung47c4c692014-03-17 10:17:11 -070077 }
78
Winson Chungd42a6cf2014-06-03 16:24:04 -070079 RecentsConfiguration mConfig;
80 LayoutInflater mInflater;
Winson Chungdcfa7972014-07-22 12:27:13 -070081 DebugOverlayView mDebugOverlay;
Winson Chungd16c5652015-01-26 16:11:07 -080082 RecentsViewLayoutAlgorithm mLayoutAlgorithm;
Winson Chungd42a6cf2014-06-03 16:24:04 -070083
Winson Chungdcfa7972014-07-22 12:27:13 -070084 ArrayList<TaskStack> mStacks;
Winson Chung93847da2015-02-03 10:26:22 -080085 List<TaskStackView> mTaskStackViews = new ArrayList<>();
Winson Chungaee097c2015-04-02 18:16:02 -070086 RecentsAppWidgetHostView mSearchBar;
Winson Chung47c4c692014-03-17 10:17:11 -070087 RecentsViewCallbacks mCb;
Winson Chung303e1ff2014-03-07 15:06:19 -080088
89 public RecentsView(Context context) {
90 super(context);
Winson Chung8e548f72014-06-24 14:40:53 -070091 }
92
93 public RecentsView(Context context, AttributeSet attrs) {
94 this(context, attrs, 0);
95 }
96
97 public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
98 this(context, attrs, defStyleAttr, 0);
99 }
100
101 public RecentsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
102 super(context, attrs, defStyleAttr, defStyleRes);
Winson Chungd42a6cf2014-06-03 16:24:04 -0700103 mConfig = RecentsConfiguration.getInstance();
Winson Chungecd9b302014-04-16 17:07:18 -0700104 mInflater = LayoutInflater.from(context);
Winson Chungd16c5652015-01-26 16:11:07 -0800105 mLayoutAlgorithm = new RecentsViewLayoutAlgorithm(mConfig);
106 }
107
Winson Chung47c4c692014-03-17 10:17:11 -0700108 /** Sets the callbacks */
109 public void setCallbacks(RecentsViewCallbacks cb) {
110 mCb = cb;
111 }
112
Winson Chungdcfa7972014-07-22 12:27:13 -0700113 /** Sets the debug overlay */
114 public void setDebugOverlay(DebugOverlayView overlay) {
115 mDebugOverlay = overlay;
116 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800117
Winson Chungdcfa7972014-07-22 12:27:13 -0700118 /** Set/get the bsp root node */
119 public void setTaskStacks(ArrayList<TaskStack> stacks) {
Winson Chungb0a28ea2014-10-28 15:21:35 -0700120 int numStacks = stacks.size();
121
Winson Chungb0a28ea2014-10-28 15:21:35 -0700122 // Remove all/extra stack views
123 int numTaskStacksToKeep = 0; // Keep no tasks if we are recreating the layout
124 if (mConfig.launchedReuseTaskStackViews) {
Winson Chung93847da2015-02-03 10:26:22 -0800125 numTaskStacksToKeep = Math.min(mTaskStackViews.size(), numStacks);
Winson Chungb0a28ea2014-10-28 15:21:35 -0700126 }
Winson Chung93847da2015-02-03 10:26:22 -0800127 for (int i = mTaskStackViews.size() - 1; i >= numTaskStacksToKeep; i--) {
128 removeView(mTaskStackViews.remove(i));
Winson Chungb0a28ea2014-10-28 15:21:35 -0700129 }
130
131 // Update the stack views that we are keeping
132 for (int i = 0; i < numTaskStacksToKeep; i++) {
Winson Chung93847da2015-02-03 10:26:22 -0800133 TaskStackView tsv = mTaskStackViews.get(i);
Winson Chungbc571a92014-11-19 17:09:03 -0800134 // If onRecentsHidden is not triggered, we need to the stack view again here
135 tsv.reset();
136 tsv.setStack(stacks.get(i));
Winson Chungb0a28ea2014-10-28 15:21:35 -0700137 }
138
139 // Add remaining/recreate stack views
Winson Chungdcfa7972014-07-22 12:27:13 -0700140 mStacks = stacks;
Winson Chung93847da2015-02-03 10:26:22 -0800141 for (int i = mTaskStackViews.size(); i < numStacks; i++) {
Winson Chungb0a28ea2014-10-28 15:21:35 -0700142 TaskStack stack = stacks.get(i);
Winson Chung303e1ff2014-03-07 15:06:19 -0800143 TaskStackView stackView = new TaskStackView(getContext(), stack);
144 stackView.setCallbacks(this);
145 addView(stackView);
Winson Chung93847da2015-02-03 10:26:22 -0800146 mTaskStackViews.add(stackView);
Winson Chung303e1ff2014-03-07 15:06:19 -0800147 }
Winson Chung02d49272014-08-29 13:57:29 -0700148
Winson Chungb0a28ea2014-10-28 15:21:35 -0700149 // Enable debug mode drawing on all the stacks if necessary
150 if (mConfig.debugModeEnabled) {
Winson Chung93847da2015-02-03 10:26:22 -0800151 for (int i = mTaskStackViews.size() - 1; i >= 0; i--) {
152 TaskStackView stackView = mTaskStackViews.get(i);
Winson Chungd16c5652015-01-26 16:11:07 -0800153 stackView.setDebugOverlay(mDebugOverlay);
Winson Chungb0a28ea2014-10-28 15:21:35 -0700154 }
155 }
156
Winson Chungb0a28ea2014-10-28 15:21:35 -0700157 // Trigger a new layout
158 requestLayout();
Winson Chung19fc1172014-07-31 18:40:03 -0700159 }
160
Winson Chungd16c5652015-01-26 16:11:07 -0800161 /** Gets the list of task views */
162 List<TaskStackView> getTaskStackViews() {
Winson Chung93847da2015-02-03 10:26:22 -0800163 return mTaskStackViews;
Winson Chungd16c5652015-01-26 16:11:07 -0800164 }
165
Skuhne8aa7d162015-03-20 13:40:53 -0700166 /** Gets the next task in the stack - or if the last - the top task */
167 public Task getNextTaskOrTopTask(Task taskToSearch) {
Chong Zhang0fa656b2015-08-31 15:17:21 -0700168 Task returnTask = null;
Skuhne8aa7d162015-03-20 13:40:53 -0700169 boolean found = false;
170 List<TaskStackView> stackViews = getTaskStackViews();
171 int stackCount = stackViews.size();
172 for (int i = stackCount - 1; i >= 0; --i) {
173 TaskStack stack = stackViews.get(i).getStack();
174 ArrayList<Task> taskList = stack.getTasks();
175 // Iterate the stack views and try and find the focused task
176 for (int j = taskList.size() - 1; j >= 0; --j) {
177 Task task = taskList.get(j);
178 // Return the next task in the line.
179 if (found)
180 return task;
181 // Remember the first possible task as the top task.
182 if (returnTask == null)
183 returnTask = task;
184 if (task == taskToSearch)
185 found = true;
186 }
187 }
188 return returnTask;
189 }
190
Winson Chung1e8d71b2014-05-16 17:05:22 -0700191 /** Launches the focused task from the first stack if possible */
192 public boolean launchFocusedTask() {
193 // Get the first stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800194 List<TaskStackView> stackViews = getTaskStackViews();
195 int stackCount = stackViews.size();
196 for (int i = 0; i < stackCount; i++) {
197 TaskStackView stackView = stackViews.get(i);
198 TaskStack stack = stackView.getStack();
199 // Iterate the stack views and try and find the focused task
200 List<TaskView> taskViews = stackView.getTaskViews();
201 int taskViewCount = taskViews.size();
202 for (int j = 0; j < taskViewCount; j++) {
203 TaskView tv = taskViews.get(j);
204 Task task = tv.getTask();
205 if (tv.isFocusedTask()) {
Chong Zhang0fa656b2015-08-31 15:17:21 -0700206 onTaskViewClicked(stackView, tv, stack, task, false, false, null);
Winson Chungd16c5652015-01-26 16:11:07 -0800207 return true;
Winson Chung1e8d71b2014-05-16 17:05:22 -0700208 }
209 }
210 }
Winson Chung1e8d71b2014-05-16 17:05:22 -0700211 return false;
212 }
213
Skuhne8aa7d162015-03-20 13:40:53 -0700214 /** Launches a given task. */
Chong Zhang0fa656b2015-08-31 15:17:21 -0700215 public boolean launchTask(Task task, Rect taskBounds) {
Skuhne8aa7d162015-03-20 13:40:53 -0700216 // Get the first stack view
217 List<TaskStackView> stackViews = getTaskStackViews();
218 int stackCount = stackViews.size();
219 for (int i = 0; i < stackCount; i++) {
220 TaskStackView stackView = stackViews.get(i);
221 TaskStack stack = stackView.getStack();
222 // Iterate the stack views and try and find the given task.
223 List<TaskView> taskViews = stackView.getTaskViews();
224 int taskViewCount = taskViews.size();
225 for (int j = 0; j < taskViewCount; j++) {
226 TaskView tv = taskViews.get(j);
227 if (tv.getTask() == task) {
Chong Zhang0fa656b2015-08-31 15:17:21 -0700228 onTaskViewClicked(stackView, tv, stack, task, false, true, taskBounds);
Skuhne8aa7d162015-03-20 13:40:53 -0700229 return true;
230 }
231 }
232 }
233 return false;
234 }
235
Winson Chungdcfa7972014-07-22 12:27:13 -0700236 /** Launches the task that Recents was launched from, if possible */
237 public boolean launchPreviousTask() {
Winson Chung47c4c692014-03-17 10:17:11 -0700238 // Get the first stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800239 List<TaskStackView> stackViews = getTaskStackViews();
240 int stackCount = stackViews.size();
241 for (int i = 0; i < stackCount; i++) {
242 TaskStackView stackView = stackViews.get(i);
243 TaskStack stack = stackView.getStack();
244 ArrayList<Task> tasks = stack.getTasks();
Winson Chung47c4c692014-03-17 10:17:11 -0700245
Winson Chungd16c5652015-01-26 16:11:07 -0800246 // Find the launch task in the stack
247 if (!tasks.isEmpty()) {
248 int taskCount = tasks.size();
249 for (int j = 0; j < taskCount; j++) {
250 if (tasks.get(j).isLaunchTarget) {
251 Task task = tasks.get(j);
252 TaskView tv = stackView.getChildViewForTask(task);
Chong Zhang0fa656b2015-08-31 15:17:21 -0700253 onTaskViewClicked(stackView, tv, stack, task, false, false, null);
Winson Chungd16c5652015-01-26 16:11:07 -0800254 return true;
Winson Chung303e1ff2014-03-07 15:06:19 -0800255 }
256 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800257 }
258 }
259 return false;
260 }
261
Winson Chung24cf1522014-05-29 12:03:33 -0700262 /** Requests all task stacks to start their enter-recents animation */
Winson Chung969f5862014-06-16 17:08:24 -0700263 public void startEnterRecentsAnimation(ViewAnimation.TaskViewEnterContext ctx) {
Winson Chung740c3ac2014-11-12 16:14:38 -0800264 // We have to increment/decrement the post animation trigger in case there are no children
265 // to ensure that it runs
266 ctx.postAnimationTrigger.increment();
267
Winson Chungd16c5652015-01-26 16:11:07 -0800268 List<TaskStackView> stackViews = getTaskStackViews();
269 int stackCount = stackViews.size();
270 for (int i = 0; i < stackCount; i++) {
271 TaskStackView stackView = stackViews.get(i);
272 stackView.startEnterRecentsAnimation(ctx);
Winson Chung24cf1522014-05-29 12:03:33 -0700273 }
Winson Chung740c3ac2014-11-12 16:14:38 -0800274 ctx.postAnimationTrigger.decrement();
Winson Chung24cf1522014-05-29 12:03:33 -0700275 }
276
Winson Chungd42a6cf2014-06-03 16:24:04 -0700277 /** Requests all task stacks to start their exit-recents animation */
Winson Chung969f5862014-06-16 17:08:24 -0700278 public void startExitToHomeAnimation(ViewAnimation.TaskViewExitContext ctx) {
Winson Chunga91c2932014-11-07 15:02:38 -0800279 // We have to increment/decrement the post animation trigger in case there are no children
280 // to ensure that it runs
281 ctx.postAnimationTrigger.increment();
Winson Chungd16c5652015-01-26 16:11:07 -0800282 List<TaskStackView> stackViews = getTaskStackViews();
283 int stackCount = stackViews.size();
284 for (int i = 0; i < stackCount; i++) {
285 TaskStackView stackView = stackViews.get(i);
286 stackView.startExitToHomeAnimation(ctx);
Winson Chungd42a6cf2014-06-03 16:24:04 -0700287 }
Winson Chunga91c2932014-11-07 15:02:38 -0800288 ctx.postAnimationTrigger.decrement();
Winson Chungd42a6cf2014-06-03 16:24:04 -0700289
Winson Chung969f5862014-06-16 17:08:24 -0700290 // Notify of the exit animation
Winson Chungcdbbb7e2014-06-24 12:11:49 -0700291 mCb.onExitToHomeAnimationTriggered();
Winson Chungd42a6cf2014-06-03 16:24:04 -0700292 }
293
Winson Chungf7bca432014-04-30 17:11:13 -0700294 /** Adds the search bar */
Winson Chungaee097c2015-04-02 18:16:02 -0700295 public void setSearchBar(RecentsAppWidgetHostView searchBar) {
Winson Chungaf3bb692015-06-03 17:31:39 -0700296 // Remove the previous search bar if one exists
297 if (mSearchBar != null && indexOfChild(mSearchBar) > -1) {
298 removeView(mSearchBar);
299 }
300 // Add the new search bar
301 if (searchBar != null) {
302 mSearchBar = searchBar;
303 addView(mSearchBar);
Winson Chungf7bca432014-04-30 17:11:13 -0700304 }
Winson Chungecd9b302014-04-16 17:07:18 -0700305 }
306
Winson Chung772b6b12014-07-03 15:54:02 -0700307 /** Returns whether there is currently a search bar */
Winson Chungaee097c2015-04-02 18:16:02 -0700308 public boolean hasValidSearchBar() {
309 return mSearchBar != null && !mSearchBar.isReinflateRequired();
Winson Chung772b6b12014-07-03 15:54:02 -0700310 }
311
312 /** Sets the visibility of the search bar */
313 public void setSearchBarVisibility(int visibility) {
314 if (mSearchBar != null) {
315 mSearchBar.setVisibility(visibility);
Winson Chung012ef362014-07-31 18:36:25 -0700316 // Always bring the search bar to the top
317 mSearchBar.bringToFront();
Winson Chung772b6b12014-07-03 15:54:02 -0700318 }
319 }
320
Winson Chungf7bca432014-04-30 17:11:13 -0700321 /**
322 * This is called with the full size of the window since we are handling our own insets.
323 */
Winson Chung303e1ff2014-03-07 15:06:19 -0800324 @Override
325 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
326 int width = MeasureSpec.getSize(widthMeasureSpec);
327 int height = MeasureSpec.getSize(heightMeasureSpec);
Winson Chungbd912972014-03-18 14:36:35 -0700328
Winson Chungf7bca432014-04-30 17:11:13 -0700329 // Get the search bar bounds and measure the search bar layout
Winson Chungaf3bb692015-06-03 17:31:39 -0700330 Rect searchBarSpaceBounds = new Rect();
Winson Chungecd9b302014-04-16 17:07:18 -0700331 if (mSearchBar != null) {
Winson Chungdcfa7972014-07-22 12:27:13 -0700332 mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
Winson Chungf7bca432014-04-30 17:11:13 -0700333 mSearchBar.measure(
334 MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
335 MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY));
Winson Chungecd9b302014-04-16 17:07:18 -0700336 }
337
Winson Chungf7bca432014-04-30 17:11:13 -0700338 Rect taskStackBounds = new Rect();
Winson Chungd16c5652015-01-26 16:11:07 -0800339 mConfig.getAvailableTaskStackBounds(width, height, mConfig.systemInsets.top,
Winson Chungaf3bb692015-06-03 17:31:39 -0700340 mConfig.systemInsets.right, searchBarSpaceBounds, taskStackBounds);
Winson Chung303e1ff2014-03-07 15:06:19 -0800341
Winson Chungd16c5652015-01-26 16:11:07 -0800342 // Measure each TaskStackView with the full width and height of the window since the
Winson Chungdcfa7972014-07-22 12:27:13 -0700343 // transition view is a child of that stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800344 List<TaskStackView> stackViews = getTaskStackViews();
345 List<Rect> stackViewsBounds = mLayoutAlgorithm.computeStackRects(stackViews,
346 taskStackBounds);
347 int stackCount = stackViews.size();
348 for (int i = 0; i < stackCount; i++) {
349 TaskStackView stackView = stackViews.get(i);
350 if (stackView.getVisibility() != GONE) {
351 // We are going to measure the TaskStackView with the whole RecentsView dimensions,
352 // but the actual stack is going to be inset to the bounds calculated by the layout
353 // algorithm
354 stackView.setStackInsetRect(stackViewsBounds.get(i));
355 stackView.measure(widthMeasureSpec, heightMeasureSpec);
Winson Chung303e1ff2014-03-07 15:06:19 -0800356 }
357 }
358
359 setMeasuredDimension(width, height);
360 }
361
Winson Chungf7bca432014-04-30 17:11:13 -0700362 /**
363 * This is called with the full size of the window since we are handling our own insets.
364 */
Winson Chung303e1ff2014-03-07 15:06:19 -0800365 @Override
366 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
Winson Chungf7bca432014-04-30 17:11:13 -0700367 // Get the search bar bounds so that we lay it out
Winson Chungecd9b302014-04-16 17:07:18 -0700368 if (mSearchBar != null) {
Winson Chungf7bca432014-04-30 17:11:13 -0700369 Rect searchBarSpaceBounds = new Rect();
Winson Chungdcfa7972014-07-22 12:27:13 -0700370 mConfig.getSearchBarBounds(getMeasuredWidth(), getMeasuredHeight(),
371 mConfig.systemInsets.top, searchBarSpaceBounds);
372 mSearchBar.layout(searchBarSpaceBounds.left, searchBarSpaceBounds.top,
373 searchBarSpaceBounds.right, searchBarSpaceBounds.bottom);
Winson Chungecd9b302014-04-16 17:07:18 -0700374 }
375
Chong Zhang0fa656b2015-08-31 15:17:21 -0700376 // Layout each TaskStackView with the full width and height of the window since the
Winson Chungdcfa7972014-07-22 12:27:13 -0700377 // transition view is a child of that stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800378 List<TaskStackView> stackViews = getTaskStackViews();
379 int stackCount = stackViews.size();
380 for (int i = 0; i < stackCount; i++) {
381 TaskStackView stackView = stackViews.get(i);
382 if (stackView.getVisibility() != GONE) {
383 stackView.layout(left, top, left + stackView.getMeasuredWidth(),
384 top + stackView.getMeasuredHeight());
Winson Chung303e1ff2014-03-07 15:06:19 -0800385 }
386 }
387 }
388
Winson Chung8eaeb7d2014-06-25 15:10:59 -0700389 @Override
Winson Chung8eaeb7d2014-06-25 15:10:59 -0700390 public WindowInsets onApplyWindowInsets(WindowInsets insets) {
Winson Chung8eaeb7d2014-06-25 15:10:59 -0700391 // Update the configuration with the latest system insets and trigger a relayout
392 mConfig.updateSystemInsets(insets.getSystemWindowInsets());
393 requestLayout();
Winson Chungdcfa7972014-07-22 12:27:13 -0700394 return insets.consumeSystemWindowInsets();
Winson Chung8eaeb7d2014-06-25 15:10:59 -0700395 }
396
Winson Chunga26fb782014-06-12 17:52:39 -0700397 /** Notifies each task view of the user interaction. */
398 public void onUserInteraction() {
399 // Get the first stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800400 List<TaskStackView> stackViews = getTaskStackViews();
401 int stackCount = stackViews.size();
402 for (int i = 0; i < stackCount; i++) {
403 TaskStackView stackView = stackViews.get(i);
404 stackView.onUserInteraction();
Winson Chunga26fb782014-06-12 17:52:39 -0700405 }
406 }
407
Winson Chung1e8d71b2014-05-16 17:05:22 -0700408 /** Focuses the next task in the first stack view */
409 public void focusNextTask(boolean forward) {
410 // Get the first stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800411 List<TaskStackView> stackViews = getTaskStackViews();
412 if (!stackViews.isEmpty()) {
413 stackViews.get(0).focusNextTask(forward, true);
Winson Chung1e8d71b2014-05-16 17:05:22 -0700414 }
Winson Chunga0e88b52014-08-11 19:25:42 -0700415 }
Winson Chung1e8d71b2014-05-16 17:05:22 -0700416
Winson Chunga0e88b52014-08-11 19:25:42 -0700417 /** Dismisses the focused task. */
418 public void dismissFocusedTask() {
419 // Get the first stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800420 List<TaskStackView> stackViews = getTaskStackViews();
421 if (!stackViews.isEmpty()) {
422 stackViews.get(0).dismissFocusedTask();
Winson Chung1e8d71b2014-05-16 17:05:22 -0700423 }
424 }
425
Winson Chung303e1ff2014-03-07 15:06:19 -0800426 /** Unfilters any filtered stacks */
427 public boolean unfilterFilteredStacks() {
Winson Chungdcfa7972014-07-22 12:27:13 -0700428 if (mStacks != null) {
Winson Chung303e1ff2014-03-07 15:06:19 -0800429 // Check if there are any filtered stacks and unfilter them before we back out of Recents
430 boolean stacksUnfiltered = false;
Winson Chungdcfa7972014-07-22 12:27:13 -0700431 int numStacks = mStacks.size();
432 for (int i = 0; i < numStacks; i++) {
433 TaskStack stack = mStacks.get(i);
Winson Chung303e1ff2014-03-07 15:06:19 -0800434 if (stack.hasFilteredTasks()) {
435 stack.unfilterTasks();
436 stacksUnfiltered = true;
437 }
438 }
439 return stacksUnfiltered;
440 }
441 return false;
442 }
443
Jorim Jaggi900fb482015-06-02 15:07:33 -0700444 public void disableLayersForOneFrame() {
445 List<TaskStackView> stackViews = getTaskStackViews();
446 for (int i = 0; i < stackViews.size(); i++) {
447 stackViews.get(i).disableLayersForOneFrame();
448 }
449 }
450
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700451 private void postDrawHeaderThumbnailTransitionRunnable(final TaskStackView view,
452 final TaskView clickedView, final int offsetX, final int offsetY,
453 final float stackScroll,
Jorim Jaggi6e18e002015-06-02 17:07:39 -0700454 final ActivityOptions.OnAnimationStartedListener animStartedListener) {
455 Runnable r = new Runnable() {
456 @Override
457 public void run() {
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700458 overrideDrawHeaderThumbnailTransition(view, clickedView, offsetX, offsetY,
459 stackScroll, animStartedListener);
Jorim Jaggi6e18e002015-06-02 17:07:39 -0700460
Jorim Jaggi6e18e002015-06-02 17:07:39 -0700461 }
462 };
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700463
Jorim Jaggi6e18e002015-06-02 17:07:39 -0700464 mCb.runAfterPause(r);
465 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700466
467 private void overrideDrawHeaderThumbnailTransition(TaskStackView stackView,
468 TaskView clickedTask, int offsetX, int offsetY, float stackScroll,
469 final ActivityOptions.OnAnimationStartedListener animStartedListener) {
470 List<AppTransitionAnimationSpec> specs = getAppTransitionAnimationSpecs(stackView,
471 clickedTask, offsetX, offsetY, stackScroll);
472 if (specs == null) {
473 return;
474 }
475
476 IRemoteCallback.Stub callback = new IRemoteCallback.Stub() {
477 @Override
478 public void sendResult(Bundle data) throws RemoteException {
479 post(new Runnable() {
480 @Override
481 public void run() {
482 if (animStartedListener != null) {
483 animStartedListener.onAnimationStarted();
484 }
485 }
486 });
487 }
488 };
489
490 AppTransitionAnimationSpec[] specsArray =
491 new AppTransitionAnimationSpec[specs.size()];
492 try {
493 WindowManagerGlobal.getWindowManagerService().overridePendingAppTransitionMultiThumb(
494 specs.toArray(specsArray), callback, true /* scaleUp */);
495
496 } catch (RemoteException e) {
497 Log.w(TAG, "Error overriding app transition", e);
498 }
499 }
500
501 private List<AppTransitionAnimationSpec> getAppTransitionAnimationSpecs(TaskStackView stackView,
502 TaskView clickedTask, int offsetX, int offsetY, float stackScroll) {
503 final int targetStackId = clickedTask.getTask().key.stackId;
504 if (targetStackId != ActivityManager.FREEFORM_WORKSPACE_STACK_ID
505 && targetStackId != ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID) {
506 return null;
507 }
508 // If this is a full screen stack, the transition will be towards the single, full screen
509 // task. We only need the transition spec for this task.
510 List<AppTransitionAnimationSpec> specs = new ArrayList<>();
511 if (targetStackId == ActivityManager.FULLSCREEN_WORKSPACE_STACK_ID) {
512 specs.add(createThumbnailHeaderAnimationSpec(
513 stackView, offsetX, offsetY, stackScroll, clickedTask,
514 clickedTask.getTask().key.id, ADD_HEADER_BITMAP));
515 return specs;
516 }
517 // This is a free form stack or full screen stack, so there will be multiple windows
518 // animating from thumbnails. We need transition animation specs for all of them.
519
520 // We will use top and bottom task views as a base for tasks, that aren't visible on the
521 // screen. This is necessary for cascade recents list, where some of the tasks might be
522 // hidden.
523 List<TaskView> taskViews = stackView.getTaskViews();
524 int childCount = taskViews.size();
525 TaskView topChild = taskViews.get(0);
526 TaskView bottomChild = taskViews.get(childCount - 1);
527 SparseArray<TaskView> taskViewsByTaskId = new SparseArray<>();
528 for (int i = 0; i < childCount; i++) {
529 TaskView taskView = taskViews.get(i);
530 taskViewsByTaskId.put(taskView.getTask().key.id, taskView);
531 }
532
533 TaskStack stack = stackView.getStack();
534 // We go through all tasks now and for each generate transition animation spec. If there is
535 // a view associated with a task, we use that view as a base for the animation. If there
536 // isn't, we use bottom or top view, depending on which one would be closer to the task
537 // view if it existed.
538 ArrayList<Task> tasks = stack.getTasks();
539 boolean passedClickedTask = false;
540 for (int i = 0, n = tasks.size(); i < n; i++) {
541 Task task = tasks.get(i);
542 TaskView taskView = taskViewsByTaskId.get(task.key.id);
543 if (taskView != null) {
544 specs.add(createThumbnailHeaderAnimationSpec(stackView, offsetX, offsetY,
545 stackScroll, taskView, taskView.getTask().key.id, ADD_HEADER_BITMAP));
546 if (taskView == clickedTask) {
547 passedClickedTask = true;
548 }
549 } else {
550 taskView = passedClickedTask ? bottomChild : topChild;
551 specs.add(createThumbnailHeaderAnimationSpec(stackView, offsetX, offsetY,
552 stackScroll, taskView, task.key.id, !ADD_HEADER_BITMAP));
553 }
554 }
555
556 return specs;
557 }
558
559 private AppTransitionAnimationSpec createThumbnailHeaderAnimationSpec(TaskStackView stackView,
560 int offsetX, int offsetY, float stackScroll, TaskView tv, int taskId,
561 boolean addHeaderBitmap) {
562 // Disable any focused state before we draw the header
563 // Upfront the processing of the thumbnail
564 if (tv.isFocusedTask()) {
565 tv.unsetFocusedTask();
566 }
567 TaskViewTransform transform = new TaskViewTransform();
568 transform = stackView.getStackAlgorithm().getStackTransform(tv.mTask, stackScroll,
569 transform, null);
570
571 float scale = tv.getScaleX();
572 int fromHeaderWidth = (int) (tv.mHeaderView.getMeasuredWidth() * scale);
573 int fromHeaderHeight = (int) (tv.mHeaderView.getMeasuredHeight() * scale);
574
575 Bitmap b = null;
576 if (addHeaderBitmap) {
577 b = Bitmap.createBitmap(fromHeaderWidth, fromHeaderHeight,
578 Bitmap.Config.ARGB_8888);
579
580 if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) {
581 b.eraseColor(0xFFff0000);
582 } else {
583 Canvas c = new Canvas(b);
584 c.scale(tv.getScaleX(), tv.getScaleY());
585 tv.mHeaderView.draw(c);
586 c.setBitmap(null);
587
588 }
589 b = b.createAshmemBitmap();
590 }
591
592 int[] pts = new int[2];
593 tv.getLocationOnScreen(pts);
594
595 final int left = pts[0] + offsetX;
596 final int top = pts[1] + offsetY;
597 final Rect rect = new Rect(left, top, left + transform.rect.width(),
598 top + transform.rect.height());
599
600 return new AppTransitionAnimationSpec(taskId, b, rect);
601 }
602
Winson Chung47c4c692014-03-17 10:17:11 -0700603 /**** TaskStackView.TaskStackCallbacks Implementation ****/
Winson Chung303e1ff2014-03-07 15:06:19 -0800604
605 @Override
Winson Chung7aceb9a2014-07-03 13:38:01 -0700606 public void onTaskViewClicked(final TaskStackView stackView, final TaskView tv,
Chong Zhang0fa656b2015-08-31 15:17:21 -0700607 final TaskStack stack, final Task task, final boolean lockToTask,
608 final boolean boundsValid, final Rect bounds) {
Jorim Jaggi88f3db92015-06-02 16:29:40 -0700609
Winson Chung47c4c692014-03-17 10:17:11 -0700610 // Notify any callbacks of the launching of a new task
611 if (mCb != null) {
Winson Chung7aceb9a2014-07-03 13:38:01 -0700612 mCb.onTaskViewClicked();
Winson Chung47c4c692014-03-17 10:17:11 -0700613 }
614
Winson Chunge0e45bc2014-06-17 17:56:17 -0700615 // Upfront the processing of the thumbnail
Winson Chungffa2ec62014-07-03 15:54:42 -0700616 TaskViewTransform transform = new TaskViewTransform();
Jorim Jaggicb557032014-09-16 23:09:24 +0200617 View sourceView;
Winson Chunge0e45bc2014-06-17 17:56:17 -0700618 int offsetX = 0;
619 int offsetY = 0;
Winson Chung012ef362014-07-31 18:36:25 -0700620 float stackScroll = stackView.getScroller().getStackScroll();
Winson Chunge0e45bc2014-06-17 17:56:17 -0700621 if (tv == null) {
622 // If there is no actual task view, then use the stack view as the source view
623 // and then offset to the expected transform rect, but bound this to just
624 // outside the display rect (to ensure we don't animate from too far away)
625 sourceView = stackView;
Winson Chunge0e45bc2014-06-17 17:56:17 -0700626 offsetX = transform.rect.left;
Winson Chunge41ab842014-08-07 15:55:37 -0700627 offsetY = mConfig.displayRect.height();
Winson Chunge0e45bc2014-06-17 17:56:17 -0700628 } else {
Jorim Jaggicb557032014-09-16 23:09:24 +0200629 sourceView = tv.mThumbnailView;
Winson Chunge0e45bc2014-06-17 17:56:17 -0700630 }
631
632 // Compute the thumbnail to scale up from
Winson Chung1f24c7e2014-07-11 17:06:48 -0700633 final SystemServicesProxy ssp =
634 RecentsTaskLoader.getInstance().getSystemServicesProxy();
Winson Chunge0e45bc2014-06-17 17:56:17 -0700635 ActivityOptions opts = null;
Chong Zhang0fa656b2015-08-31 15:17:21 -0700636 ActivityOptions.OnAnimationStartedListener animStartedListener = null;
Winson Chung2e7f3bd2014-09-05 13:17:22 +0200637 if (task.thumbnail != null && task.thumbnail.getWidth() > 0 &&
638 task.thumbnail.getHeight() > 0) {
Winson Chung1f24c7e2014-07-11 17:06:48 -0700639 if (lockToTask) {
640 animStartedListener = new ActivityOptions.OnAnimationStartedListener() {
641 boolean mTriggered = false;
642 @Override
643 public void onAnimationStarted() {
644 if (!mTriggered) {
645 postDelayed(new Runnable() {
646 @Override
647 public void run() {
Jason Monk18f99d92014-09-11 13:36:42 -0400648 mCb.onScreenPinningRequest();
Winson Chung1f24c7e2014-07-11 17:06:48 -0700649 }
650 }, 350);
651 mTriggered = true;
652 }
653 }
654 };
655 }
Filip Gruszczynski170192a2015-08-16 17:46:34 -0700656 postDrawHeaderThumbnailTransitionRunnable(stackView, tv, offsetX, offsetY, stackScroll,
657 animStartedListener);
Winson Chungd16c5652015-01-26 16:11:07 -0800658 if (mConfig.multiStackEnabled) {
659 opts = ActivityOptions.makeCustomAnimation(sourceView.getContext(),
660 R.anim.recents_from_unknown_enter,
661 R.anim.recents_from_unknown_exit,
662 sourceView.getHandler(), animStartedListener);
663 } else {
664 opts = ActivityOptions.makeThumbnailAspectScaleUpAnimation(sourceView,
Jorim Jaggi6e18e002015-06-02 17:07:39 -0700665 Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8).createAshmemBitmap(),
666 offsetX, offsetY, transform.rect.width(), transform.rect.height(),
Winson Chungd16c5652015-01-26 16:11:07 -0800667 sourceView.getHandler(), animStartedListener);
668 }
Chong Zhang0fa656b2015-08-31 15:17:21 -0700669 } else {
670 opts = ActivityOptions.makeBasic();
Winson Chunge0e45bc2014-06-17 17:56:17 -0700671 }
Chong Zhang0fa656b2015-08-31 15:17:21 -0700672 if (boundsValid) {
673 opts.setBounds(bounds);
674 }
Winson Chunge0e45bc2014-06-17 17:56:17 -0700675 final ActivityOptions launchOpts = opts;
Chong Zhang0fa656b2015-08-31 15:17:21 -0700676 final boolean screenPinningRequested = (animStartedListener == null) && lockToTask;
Winson Chung303e1ff2014-03-07 15:06:19 -0800677 final Runnable launchRunnable = new Runnable() {
678 @Override
679 public void run() {
Winson Chung4be04452014-03-24 17:22:30 -0700680 if (task.isActive) {
681 // Bring an active task to the foreground
Craig Mautnerdc00cbe2014-07-20 17:48:47 -0700682 ssp.moveTaskToFront(task.key.id, launchOpts);
Winson Chung4be04452014-03-24 17:22:30 -0700683 } else {
Winson Chung4e96eb72014-09-17 15:16:09 +0200684 if (ssp.startActivityFromRecents(getContext(), task.key.id,
685 task.activityLabel, launchOpts)) {
Chong Zhang0fa656b2015-08-31 15:17:21 -0700686 if (screenPinningRequested) {
Jason Monk18f99d92014-09-11 13:36:42 -0400687 mCb.onScreenPinningRequest();
Winson Chung4be04452014-03-24 17:22:30 -0700688 }
Winson Chung4e96eb72014-09-17 15:16:09 +0200689 } else {
690 // Dismiss the task and return the user to home if we fail to
691 // launch the task
692 onTaskViewDismissed(task);
693 if (mCb != null) {
694 mCb.onTaskLaunchFailed();
695 }
Winson Chung5c9f4b92015-06-25 16:16:46 -0700696
697 // Keep track of failed launches
698 MetricsLogger.count(getContext(), "overview_task_launch_failed", 1);
Winson Chung4be04452014-03-24 17:22:30 -0700699 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800700 }
701 }
702 };
703
Winson Chung5c9f4b92015-06-25 16:16:46 -0700704 // Keep track of the index of the task launch
705 int taskIndexFromFront = 0;
706 int taskIndex = stack.indexOfTask(task);
707 if (taskIndex > -1) {
708 taskIndexFromFront = stack.getTaskCount() - taskIndex - 1;
709 }
710 MetricsLogger.histogram(getContext(), "overview_task_launch_index", taskIndexFromFront);
711
Winson Chung303e1ff2014-03-07 15:06:19 -0800712 // Launch the app right away if there is no task view, otherwise, animate the icon out first
Winson Chung814086d2014-05-07 15:01:14 -0700713 if (tv == null) {
Winson Chunga91c2932014-11-07 15:02:38 -0800714 launchRunnable.run();
Winson Chung303e1ff2014-03-07 15:06:19 -0800715 } else {
Winson Chunge1e20e12015-06-02 14:11:49 -0700716 if (task.group != null && !task.group.isFrontMostTask(task)) {
Winson Chunga4ccb862014-08-22 15:26:27 -0700717 // For affiliated tasks that are behind other tasks, we must animate the front cards
718 // out of view before starting the task transition
Winson Chungebfc6982014-08-26 12:25:34 -0700719 stackView.startLaunchTaskAnimation(tv, launchRunnable, lockToTask);
Winson Chunga4ccb862014-08-22 15:26:27 -0700720 } else {
721 // Otherwise, we can start the task transition immediately
Winson Chungebfc6982014-08-26 12:25:34 -0700722 stackView.startLaunchTaskAnimation(tv, null, lockToTask);
Winson Chunga91c2932014-11-07 15:02:38 -0800723 launchRunnable.run();
Winson Chunga4ccb862014-08-22 15:26:27 -0700724 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800725 }
726 }
Winson Chung9f9679d2014-04-11 16:49:09 -0700727
728 @Override
Winson Chung7aceb9a2014-07-03 13:38:01 -0700729 public void onTaskViewAppInfoClicked(Task t) {
Winson Chung9f9679d2014-04-11 16:49:09 -0700730 // Create a new task stack with the application info details activity
731 Intent baseIntent = t.key.baseIntent;
732 Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
733 Uri.fromParts("package", baseIntent.getComponent().getPackageName(), null));
734 intent.setComponent(intent.resolveActivity(getContext().getPackageManager()));
735 TaskStackBuilder.create(getContext())
Kenny Guy94a07ac2014-08-07 15:34:38 +0100736 .addNextIntentWithParentStack(intent).startActivities(null,
Winson Chunga4ccb862014-08-22 15:26:27 -0700737 new UserHandle(t.key.userId));
Winson Chung9f9679d2014-04-11 16:49:09 -0700738 }
Winson Chung9f49df92014-05-07 18:08:34 -0700739
Winson Chung5393dff2014-05-08 14:25:43 -0700740 @Override
Winson Chung7aceb9a2014-07-03 13:38:01 -0700741 public void onTaskViewDismissed(Task t) {
Winson Chung5393dff2014-05-08 14:25:43 -0700742 // Remove any stored data from the loader. We currently don't bother notifying the views
Winson Chung7aceb9a2014-07-03 13:38:01 -0700743 // that the data has been unloaded because at the point we call onTaskViewDismissed(), the views
Winson Chung5393dff2014-05-08 14:25:43 -0700744 // either don't need to be updated, or have already been removed.
745 RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
746 loader.deleteTaskData(t, false);
747
748 // Remove the old task from activity manager
Winson Chung2cf8b222015-01-20 11:44:05 -0800749 loader.getSystemServicesProxy().removeTask(t.key.id);
Winson Chung5393dff2014-05-08 14:25:43 -0700750 }
751
Winson Chung8e548f72014-06-24 14:40:53 -0700752 @Override
Winson Chung6ac8bd62015-01-07 16:38:35 -0800753 public void onAllTaskViewsDismissed(ArrayList<Task> removedTasks) {
754 if (removedTasks != null) {
755 int taskCount = removedTasks.size();
756 for (int i = 0; i < taskCount; i++) {
757 onTaskViewDismissed(removedTasks.get(i));
758 }
759 }
760
Winson Chung7aceb9a2014-07-03 13:38:01 -0700761 mCb.onAllTaskViewsDismissed();
Winson Chung5c9f4b92015-06-25 16:16:46 -0700762
763 // Keep track of all-deletions
764 MetricsLogger.count(getContext(), "overview_task_all_dismissed", 1);
Winson Chungd7b2cb12014-06-26 15:08:50 -0700765 }
766
Winson Chungb0a28ea2014-10-28 15:21:35 -0700767 /** Final callback after Recents is finally hidden. */
768 public void onRecentsHidden() {
769 // Notify each task stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800770 List<TaskStackView> stackViews = getTaskStackViews();
771 int stackCount = stackViews.size();
772 for (int i = 0; i < stackCount; i++) {
773 TaskStackView stackView = stackViews.get(i);
774 stackView.onRecentsHidden();
Winson Chungb0a28ea2014-10-28 15:21:35 -0700775 }
776 }
777
Winson Chungd7b2cb12014-06-26 15:08:50 -0700778 @Override
Winson Chung8e548f72014-06-24 14:40:53 -0700779 public void onTaskStackFilterTriggered() {
780 // Hide the search bar
781 if (mSearchBar != null) {
782 mSearchBar.animate()
783 .alpha(0f)
784 .setStartDelay(0)
785 .setInterpolator(mConfig.fastOutSlowInInterpolator)
786 .setDuration(mConfig.filteringCurrentViewsAnimDuration)
787 .withLayer()
788 .start();
789 }
790 }
791
792 @Override
793 public void onTaskStackUnfilterTriggered() {
794 // Show the search bar
795 if (mSearchBar != null) {
796 mSearchBar.animate()
797 .alpha(1f)
798 .setStartDelay(0)
799 .setInterpolator(mConfig.fastOutSlowInInterpolator)
800 .setDuration(mConfig.filteringNewViewsAnimDuration)
801 .withLayer()
802 .start();
803 }
804 }
805
Winson Chungd16c5652015-01-26 16:11:07 -0800806 @Override
Skuhneece738b2015-03-17 15:02:18 -0700807 public void onTaskResize(Task t) {
Winson Chungd16c5652015-01-26 16:11:07 -0800808 if (mCb != null) {
Skuhneece738b2015-03-17 15:02:18 -0700809 mCb.onTaskResize(t);
Winson Chungd16c5652015-01-26 16:11:07 -0800810 }
811 }
812
Winson Chung9f49df92014-05-07 18:08:34 -0700813 /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/
814
815 @Override
Winson Chung04400672014-10-17 14:53:30 -0700816 public void onPackagesChanged(RecentsPackageMonitor monitor, String packageName, int userId) {
Winson Chung9f49df92014-05-07 18:08:34 -0700817 // Propagate this event down to each task stack view
Winson Chungd16c5652015-01-26 16:11:07 -0800818 List<TaskStackView> stackViews = getTaskStackViews();
819 int stackCount = stackViews.size();
820 for (int i = 0; i < stackCount; i++) {
821 TaskStackView stackView = stackViews.get(i);
822 stackView.onPackagesChanged(monitor, packageName, userId);
Winson Chung9f49df92014-05-07 18:08:34 -0700823 }
824 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800825}