Merge "Disabling movement of entire affiliated task set." into nyc-dev
This commit is contained in:
@@ -41,6 +41,7 @@ import android.view.WindowManager.LayoutParams;
|
|||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.systemui.Interpolators;
|
import com.android.systemui.Interpolators;
|
||||||
|
import com.android.systemui.Prefs;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.recents.events.EventBus;
|
import com.android.systemui.recents.events.EventBus;
|
||||||
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
|
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
|
||||||
@@ -166,6 +167,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
// When the screen turns off, dismiss Recents to Home
|
// When the screen turns off, dismiss Recents to Home
|
||||||
dismissRecentsToHomeIfVisible(false);
|
dismissRecentsToHomeIfVisible(false);
|
||||||
|
} else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
|
||||||
|
// For the time being, if the time changes, then invalidate the
|
||||||
|
// last-stack-active-time, this ensures that we will just show the last N tasks
|
||||||
|
// the next time that Recents loads, but prevents really old tasks from showing
|
||||||
|
// up if the task time is set forward.
|
||||||
|
Prefs.putLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -311,6 +319,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
// Register the broadcast receiver to handle messages when the screen is turned off
|
// Register the broadcast receiver to handle messages when the screen is turned off
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
registerReceiver(mSystemBroadcastReceiver, filter);
|
registerReceiver(mSystemBroadcastReceiver, filter);
|
||||||
|
|
||||||
getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION);
|
getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION);
|
||||||
|
|||||||
@@ -140,39 +140,10 @@ public class RecentsTaskLoadPlan {
|
|||||||
lastStackActiveTime = 0;
|
lastStackActiveTime = 0;
|
||||||
}
|
}
|
||||||
long newLastStackActiveTime = -1;
|
long newLastStackActiveTime = -1;
|
||||||
long prevLastActiveTime = lastStackActiveTime;
|
|
||||||
int taskCount = mRawTasks.size();
|
int taskCount = mRawTasks.size();
|
||||||
for (int i = 0; i < taskCount; i++) {
|
for (int i = 0; i < taskCount; i++) {
|
||||||
ActivityManager.RecentTaskInfo t = mRawTasks.get(i);
|
ActivityManager.RecentTaskInfo t = mRawTasks.get(i);
|
||||||
|
|
||||||
/*
|
|
||||||
* Affiliated tasks are returned in a specific order from ActivityManager but without a
|
|
||||||
* lastActiveTime since it hasn't yet been started. However, we later sort the task list
|
|
||||||
* by lastActiveTime, which rearranges the tasks. For now, we need to workaround this
|
|
||||||
* by updating the lastActiveTime of this task to the lastActiveTime of the task it is
|
|
||||||
* affiliated with, in the same order that we encounter it in the original list (just
|
|
||||||
* its index in the task group for the task it is affiliated with).
|
|
||||||
*
|
|
||||||
* If the parent task is not available, then we will use the last active time of the
|
|
||||||
* previous task as a base point (since the task itself may not have an active time)
|
|
||||||
* for the entire affiliated group.
|
|
||||||
*/
|
|
||||||
if (t.persistentId != t.affiliatedTaskId) {
|
|
||||||
Task.TaskKey parentTask = affiliatedTasks.get(t.affiliatedTaskId);
|
|
||||||
long parentTaskLastActiveTime = parentTask != null
|
|
||||||
? parentTask.lastActiveTime
|
|
||||||
: prevLastActiveTime;
|
|
||||||
if (RecentsDebugFlags.Static.EnableAffiliatedTaskGroups) {
|
|
||||||
t.lastActiveTime = parentTaskLastActiveTime +
|
|
||||||
affiliatedTaskCounts.get(t.affiliatedTaskId, 0) + 1;
|
|
||||||
} else {
|
|
||||||
if (t.lastActiveTime == 0) {
|
|
||||||
t.lastActiveTime = parentTaskLastActiveTime -
|
|
||||||
affiliatedTaskCounts.get(t.affiliatedTaskId, 0) - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compose the task key
|
// Compose the task key
|
||||||
Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent,
|
Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent,
|
||||||
t.userId, t.firstActiveTime, t.lastActiveTime);
|
t.userId, t.firstActiveTime, t.lastActiveTime);
|
||||||
@@ -180,9 +151,14 @@ public class RecentsTaskLoadPlan {
|
|||||||
// This task is only shown in the stack if it statisfies the historical time or min
|
// This task is only shown in the stack if it statisfies the historical time or min
|
||||||
// number of tasks constraints. Freeform tasks are also always shown.
|
// number of tasks constraints. Freeform tasks are also always shown.
|
||||||
boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
|
boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
|
||||||
boolean isStackTask = isFreeformTask || (!isHistoricalTask(t) ||
|
boolean isStackTask = isFreeformTask || !isHistoricalTask(t) ||
|
||||||
(t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS)));
|
(t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS));
|
||||||
boolean isLaunchTarget = taskKey.id == runningTaskId;
|
boolean isLaunchTarget = taskKey.id == runningTaskId;
|
||||||
|
|
||||||
|
// The last stack active time is the baseline for which we show visible tasks. Since
|
||||||
|
// the system will store all the tasks, we don't want to show the tasks prior to the
|
||||||
|
// last visible ones, otherwise, as you dismiss them, the previous tasks may satisfy
|
||||||
|
// the other stack-task constraints.
|
||||||
if (isStackTask && newLastStackActiveTime < 0) {
|
if (isStackTask && newLastStackActiveTime < 0) {
|
||||||
newLastStackActiveTime = t.lastActiveTime;
|
newLastStackActiveTime = t.lastActiveTime;
|
||||||
}
|
}
|
||||||
@@ -211,7 +187,6 @@ public class RecentsTaskLoadPlan {
|
|||||||
allTasks.add(task);
|
allTasks.add(task);
|
||||||
affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
|
affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
|
||||||
affiliatedTasks.put(taskKey.id, taskKey);
|
affiliatedTasks.put(taskKey.id, taskKey);
|
||||||
prevLastActiveTime = t.lastActiveTime;
|
|
||||||
}
|
}
|
||||||
if (newLastStackActiveTime != -1) {
|
if (newLastStackActiveTime != -1) {
|
||||||
Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
|
Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ public class Task {
|
|||||||
@ViewDebug.ExportedProperty(deepExport=true, prefix="key_")
|
@ViewDebug.ExportedProperty(deepExport=true, prefix="key_")
|
||||||
public TaskKey key;
|
public TaskKey key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The temporary sort index in the stack, used when ordering the stack.
|
||||||
|
*/
|
||||||
|
public int temporarySortIndexInStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The group will be computed separately from the initialization of the task
|
* The group will be computed separately from the initialization of the task
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ public class TaskKeyLruCache<V> {
|
|||||||
final V getAndInvalidateIfModified(Task.TaskKey key) {
|
final V getAndInvalidateIfModified(Task.TaskKey key) {
|
||||||
Task.TaskKey lastKey = mKeys.get(key.id);
|
Task.TaskKey lastKey = mKeys.get(key.id);
|
||||||
if (lastKey != null) {
|
if (lastKey != null) {
|
||||||
if ((lastKey.stackId != key.stackId) || (lastKey.lastActiveTime < key.lastActiveTime)) {
|
if ((lastKey.stackId != key.stackId) ||
|
||||||
|
(lastKey.lastActiveTime != key.lastActiveTime)) {
|
||||||
// The task has updated (been made active since the last time it was put into the
|
// The task has updated (been made active since the last time it was put into the
|
||||||
// LRU cache) or the stack id for the task has changed, invalidate that cache item
|
// LRU cache) or the stack id for the task has changed, invalidate that cache item
|
||||||
remove(key);
|
remove(key);
|
||||||
|
|||||||
@@ -517,16 +517,8 @@ public class TaskStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A comparator that sorts tasks by their last active time
|
// A comparator that sorts tasks by their freeform state
|
||||||
private Comparator<Task> LAST_ACTIVE_TIME_COMPARATOR = new Comparator<Task>() {
|
private Comparator<Task> FREEFORM_COMPARATOR = new Comparator<Task>() {
|
||||||
@Override
|
|
||||||
public int compare(Task o1, Task o2) {
|
|
||||||
return Long.compare(o1.key.lastActiveTime, o2.key.lastActiveTime);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// A comparator that sorts tasks by their last active time and freeform state
|
|
||||||
private Comparator<Task> FREEFORM_LAST_ACTIVE_TIME_COMPARATOR = new Comparator<Task>() {
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Task o1, Task o2) {
|
public int compare(Task o1, Task o2) {
|
||||||
if (o1.isFreeformTask() && !o2.isFreeformTask()) {
|
if (o1.isFreeformTask() && !o2.isFreeformTask()) {
|
||||||
@@ -534,7 +526,7 @@ public class TaskStack {
|
|||||||
} else if (o2.isFreeformTask() && !o1.isFreeformTask()) {
|
} else if (o2.isFreeformTask() && !o1.isFreeformTask()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return Long.compare(o1.key.lastActiveTime, o2.key.lastActiveTime);
|
return Long.compare(o1.temporarySortIndexInStack, o2.temporarySortIndexInStack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -696,7 +688,10 @@ public class TaskStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort all the tasks to ensure they are ordered correctly
|
// Sort all the tasks to ensure they are ordered correctly
|
||||||
Collections.sort(allTasks, FREEFORM_LAST_ACTIVE_TIME_COMPARATOR);
|
for (int i = allTasks.size() - 1; i >= 0; i--) {
|
||||||
|
allTasks.get(i).temporarySortIndexInStack = i;
|
||||||
|
}
|
||||||
|
Collections.sort(allTasks, FREEFORM_COMPARATOR);
|
||||||
|
|
||||||
mStackTaskList.set(allTasks);
|
mStackTaskList.set(allTasks);
|
||||||
mRawTaskList = allTasks;
|
mRawTaskList = allTasks;
|
||||||
@@ -769,12 +764,11 @@ public class TaskStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes a set of all the active and historical tasks ordered by their last active time.
|
* Computes a set of all the active and historical tasks.
|
||||||
*/
|
*/
|
||||||
public ArrayList<Task> computeAllTasksList() {
|
public ArrayList<Task> computeAllTasksList() {
|
||||||
ArrayList<Task> tasks = new ArrayList<>();
|
ArrayList<Task> tasks = new ArrayList<>();
|
||||||
tasks.addAll(mStackTaskList.getTasks());
|
tasks.addAll(mStackTaskList.getTasks());
|
||||||
Collections.sort(tasks, LAST_ACTIVE_TIME_COMPARATOR);
|
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ class RecentTasks extends ArrayList<TaskRecord> {
|
|||||||
private static final int MAX_RECENT_BITMAPS = 3;
|
private static final int MAX_RECENT_BITMAPS = 3;
|
||||||
private static final int DEFAULT_INITIAL_CAPACITY = 5;
|
private static final int DEFAULT_INITIAL_CAPACITY = 5;
|
||||||
|
|
||||||
|
// Whether or not to move all affiliated tasks to the front when one of the tasks is launched
|
||||||
|
private static final boolean MOVE_AFFILIATED_TASKS_TO_FRONT = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save recent tasks information across reboots.
|
* Save recent tasks information across reboots.
|
||||||
*/
|
*/
|
||||||
@@ -513,7 +516,7 @@ class RecentTasks extends ArrayList<TaskRecord> {
|
|||||||
if (task.inRecents) {
|
if (task.inRecents) {
|
||||||
int taskIndex = indexOf(task);
|
int taskIndex = indexOf(task);
|
||||||
if (taskIndex >= 0) {
|
if (taskIndex >= 0) {
|
||||||
if (!isAffiliated) {
|
if (!isAffiliated || MOVE_AFFILIATED_TASKS_TO_FRONT) {
|
||||||
// Simple case: this is not an affiliated task, so we just move it to the front.
|
// Simple case: this is not an affiliated task, so we just move it to the front.
|
||||||
remove(taskIndex);
|
remove(taskIndex);
|
||||||
add(0, task);
|
add(0, task);
|
||||||
|
|||||||
Reference in New Issue
Block a user