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