Fixing issue with excluded task showing when docking.
- On multi-window state changes, we should not include the front most excluded task when fetching the task list. This CL also clarifies which tasks are included and excluded. Bug: 28452689 Change-Id: Ia30eaf75382286a9d4ee5a5b11013dddf8e4ac82
This commit is contained in:
@@ -364,7 +364,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
||||
RecentsActivityLaunchState launchState = config.getLaunchState();
|
||||
if (!loadPlan.hasTasks()) {
|
||||
loader.preloadTasks(loadPlan, launchState.launchedToTaskId,
|
||||
launchState.launchedFromHome);
|
||||
!launchState.launchedFromHome);
|
||||
}
|
||||
|
||||
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
|
||||
@@ -453,7 +453,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
||||
RecentsActivityLaunchState launchState = config.getLaunchState();
|
||||
RecentsTaskLoader loader = Recents.getTaskLoader();
|
||||
RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
|
||||
loader.preloadTasks(loadPlan, -1 /* runningTaskId */, false /* isHomeStackVisible */);
|
||||
loader.preloadTasks(loadPlan, -1 /* runningTaskId */,
|
||||
false /* includeFrontMostExcludedTask */);
|
||||
|
||||
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
|
||||
loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
|
||||
|
||||
@@ -112,7 +112,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
|
||||
// Load the next task only if we aren't svelte
|
||||
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
||||
loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
|
||||
loader.preloadTasks(plan, -1, false /* includeFrontMostExcludedTask */);
|
||||
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
|
||||
// This callback is made when a new activity is launched and the old one is paused
|
||||
// so ignore the current activity and try and preload the thumbnail for the
|
||||
@@ -189,7 +189,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
// We can use a new plan since the caches will be the same.
|
||||
RecentsTaskLoader loader = Recents.getTaskLoader();
|
||||
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
||||
loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
|
||||
loader.preloadTasks(plan, -1, false /* includeFrontMostExcludedTask */);
|
||||
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
|
||||
launchOpts.numVisibleTasks = loader.getIconCacheSize();
|
||||
launchOpts.numVisibleTaskThumbnails = loader.getThumbnailCacheSize();
|
||||
@@ -366,8 +366,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
|
||||
RecentsTaskLoader loader = Recents.getTaskLoader();
|
||||
sInstanceLoadPlan = loader.createLoadPlan(mContext);
|
||||
sInstanceLoadPlan.preloadRawTasks(isHomeStackVisible.value);
|
||||
loader.preloadTasks(sInstanceLoadPlan, runningTask.id, isHomeStackVisible.value);
|
||||
sInstanceLoadPlan.preloadRawTasks(!isHomeStackVisible.value);
|
||||
loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible.value);
|
||||
TaskStack stack = sInstanceLoadPlan.getTaskStack();
|
||||
if (stack.getTaskCount() > 0) {
|
||||
// Only preload the icon (but not the thumbnail since it may not have been taken for
|
||||
@@ -401,7 +401,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
SystemServicesProxy ssp = Recents.getSystemServices();
|
||||
RecentsTaskLoader loader = Recents.getTaskLoader();
|
||||
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
||||
loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
|
||||
loader.preloadTasks(plan, -1, false /* includeFrontMostExcludedTask */);
|
||||
TaskStack focusedStack = plan.getTaskStack();
|
||||
|
||||
// Return early if there are no tasks in the focused stack
|
||||
@@ -453,7 +453,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
SystemServicesProxy ssp = Recents.getSystemServices();
|
||||
RecentsTaskLoader loader = Recents.getTaskLoader();
|
||||
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
|
||||
loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
|
||||
loader.preloadTasks(plan, -1, false /* includeFrontMostExcludedTask */);
|
||||
TaskStack focusedStack = plan.getTaskStack();
|
||||
|
||||
// Return early if there are no tasks in the focused stack
|
||||
@@ -818,7 +818,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
sInstanceLoadPlan = loader.createLoadPlan(mContext);
|
||||
}
|
||||
if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
|
||||
loader.preloadTasks(sInstanceLoadPlan, runningTask.id, isHomeStackVisible);
|
||||
loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible);
|
||||
}
|
||||
|
||||
TaskStack stack = sInstanceLoadPlan.getTaskStack();
|
||||
|
||||
@@ -253,11 +253,12 @@ public class SystemServicesProxy {
|
||||
/**
|
||||
* Returns a list of the recents tasks.
|
||||
*
|
||||
* @param isHomeStackVisible whether or not the home stack is currently visible. If it is
|
||||
* visible, then we ignore all excluded tasks (even the first one).
|
||||
* @param includeFrontMostExcludedTask if set, will ensure that the front most excluded task
|
||||
* will be visible, otherwise no excluded tasks will be
|
||||
* visible.
|
||||
*/
|
||||
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int numLatestTasks, int userId,
|
||||
boolean isHomeStackVisible, ArraySet<Integer> quietProfileIds) {
|
||||
boolean includeFrontMostExcludedTask, ArraySet<Integer> quietProfileIds) {
|
||||
if (mAm == null) return null;
|
||||
|
||||
// If we are mocking, then create some recent tasks
|
||||
@@ -295,13 +296,16 @@ public class SystemServicesProxy {
|
||||
// Remove home/recents/excluded tasks
|
||||
int minNumTasksToQuery = 10;
|
||||
int numTasksToQuery = Math.max(minNumTasksToQuery, numLatestTasks);
|
||||
List<ActivityManager.RecentTaskInfo> tasks = mAm.getRecentTasksForUser(numTasksToQuery,
|
||||
ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS |
|
||||
int flags = ActivityManager.RECENT_IGNORE_HOME_STACK_TASKS |
|
||||
ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK |
|
||||
ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS |
|
||||
ActivityManager.RECENT_IGNORE_UNAVAILABLE |
|
||||
ActivityManager.RECENT_INCLUDE_PROFILES |
|
||||
ActivityManager.RECENT_WITH_EXCLUDED, userId);
|
||||
ActivityManager.RECENT_INCLUDE_PROFILES;
|
||||
if (includeFrontMostExcludedTask) {
|
||||
flags |= ActivityManager.RECENT_WITH_EXCLUDED;
|
||||
}
|
||||
List<ActivityManager.RecentTaskInfo> tasks = mAm.getRecentTasksForUser(numTasksToQuery,
|
||||
flags, userId);
|
||||
|
||||
// Break early if we can't get a valid set of tasks
|
||||
if (tasks == null) {
|
||||
@@ -316,18 +320,20 @@ public class SystemServicesProxy {
|
||||
// NOTE: The order of these checks happens in the expected order of the traversal of the
|
||||
// tasks
|
||||
|
||||
// Check the first non-recents task, include this task even if it is marked as excluded
|
||||
// from recents if we are currently in the app. In other words, only remove excluded
|
||||
// tasks if it is not the first active task, and not in the blacklist.
|
||||
// Remove the task if it is blacklisted
|
||||
if (sRecentsBlacklist.contains(t.realActivity.getClassName())) {
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
// Remove the task if it is marked as excluded, unless it is the first most task and we
|
||||
// are requested to include it
|
||||
boolean isExcluded = (t.baseIntent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
== Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
|
||||
boolean isBlackListed = sRecentsBlacklist.contains(t.realActivity.getClassName());
|
||||
// Filter out recent tasks from managed profiles which are in quiet mode.
|
||||
isExcluded |= quietProfileIds.contains(t.userId);
|
||||
if (isBlackListed || (isExcluded && (isHomeStackVisible || !isFirstValidTask))) {
|
||||
if (isExcluded && (!isFirstValidTask || !includeFrontMostExcludedTask)) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
isFirstValidTask = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,12 +100,12 @@ public class RecentsTaskLoadPlan {
|
||||
* An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent
|
||||
* to most-recent order.
|
||||
*/
|
||||
public synchronized void preloadRawTasks(boolean isHomeStackVisible) {
|
||||
public synchronized void preloadRawTasks(boolean includeFrontMostExcludedTask) {
|
||||
int currentUserId = UserHandle.USER_CURRENT;
|
||||
updateCurrentQuietProfilesCache(currentUserId);
|
||||
SystemServicesProxy ssp = Recents.getSystemServices();
|
||||
mRawTasks = ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(),
|
||||
currentUserId, isHomeStackVisible, mCurrentQuietProfiles);
|
||||
currentUserId, includeFrontMostExcludedTask, mCurrentQuietProfiles);
|
||||
|
||||
// Since the raw tasks are given in most-recent to least-recent order, we need to reverse it
|
||||
Collections.reverse(mRawTasks);
|
||||
@@ -121,11 +121,11 @@ public class RecentsTaskLoadPlan {
|
||||
* - least-recent to most-recent freeform tasks
|
||||
*/
|
||||
public synchronized void preloadPlan(RecentsTaskLoader loader, int runningTaskId,
|
||||
boolean isHomeStackVisible) {
|
||||
boolean includeFrontMostExcludedTask) {
|
||||
Resources res = mContext.getResources();
|
||||
ArrayList<Task> allTasks = new ArrayList<>();
|
||||
if (mRawTasks == null) {
|
||||
preloadRawTasks(isHomeStackVisible);
|
||||
preloadRawTasks(includeFrontMostExcludedTask);
|
||||
}
|
||||
|
||||
SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
|
||||
|
||||
@@ -334,8 +334,8 @@ public class RecentsTaskLoader {
|
||||
|
||||
/** Preloads recents tasks using the specified plan to store the output. */
|
||||
public void preloadTasks(RecentsTaskLoadPlan plan, int runningTaskId,
|
||||
boolean isHomeStackVisible) {
|
||||
plan.preloadPlan(this, runningTaskId, isHomeStackVisible);
|
||||
boolean includeFrontMostExcludedTask) {
|
||||
plan.preloadPlan(this, runningTaskId, includeFrontMostExcludedTask);
|
||||
}
|
||||
|
||||
/** Begins loading the heavy task data according to the specified options. */
|
||||
|
||||
@@ -180,7 +180,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
|
||||
RecentsConfiguration config = Recents.getConfiguration();
|
||||
RecentsActivityLaunchState launchState = config.getLaunchState();
|
||||
if (!plan.hasTasks()) {
|
||||
loader.preloadTasks(plan, -1, launchState.launchedFromHome);
|
||||
loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
|
||||
}
|
||||
mLaunchedFromHome = launchState.launchedFromHome;
|
||||
TaskStack stack = plan.getTaskStack();
|
||||
|
||||
@@ -63,7 +63,7 @@ public class RecentsTvImpl extends RecentsImpl{
|
||||
sInstanceLoadPlan = loader.createLoadPlan(mContext);
|
||||
}
|
||||
if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
|
||||
loader.preloadTasks(sInstanceLoadPlan, runningTask.id, isHomeStackVisible);
|
||||
loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible);
|
||||
}
|
||||
TaskStack stack = sInstanceLoadPlan.getTaskStack();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user