Merge "Append organized child task info for task created by organizer"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a69a548e40
@@ -1693,6 +1693,13 @@ public class ActivityManager {
|
||||
@Deprecated
|
||||
public int affiliatedTaskId;
|
||||
|
||||
/**
|
||||
* Information of organized child tasks.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public ArrayList<RecentTaskInfo> childrenTaskInfos = new ArrayList<>();
|
||||
|
||||
public RecentTaskInfo() {
|
||||
}
|
||||
|
||||
@@ -1708,6 +1715,7 @@ public class ActivityManager {
|
||||
public void readFromParcel(Parcel source) {
|
||||
id = source.readInt();
|
||||
persistentId = source.readInt();
|
||||
childrenTaskInfos = source.readArrayList(RecentTaskInfo.class.getClassLoader());
|
||||
super.readFromParcel(source);
|
||||
}
|
||||
|
||||
@@ -1715,6 +1723,7 @@ public class ActivityManager {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(id);
|
||||
dest.writeInt(persistentId);
|
||||
dest.writeList(childrenTaskInfos);
|
||||
super.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -1874,11 +1874,23 @@ class RecentTasks {
|
||||
* Creates a new RecentTaskInfo from a Task.
|
||||
*/
|
||||
ActivityManager.RecentTaskInfo createRecentTaskInfo(Task tr, boolean stripExtras) {
|
||||
ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
|
||||
final ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo();
|
||||
tr.fillTaskInfo(rti, stripExtras);
|
||||
// Fill in some deprecated values
|
||||
// Fill in some deprecated values.
|
||||
rti.id = rti.isRunning ? rti.taskId : INVALID_TASK_ID;
|
||||
rti.persistentId = rti.taskId;
|
||||
|
||||
// Fill in organized child task info for the task created by organizer.
|
||||
if (tr.mCreatedByOrganizer) {
|
||||
for (int i = tr.getChildCount() - 1; i >= 0; i--) {
|
||||
final Task childTask = tr.getChildAt(i).asTask();
|
||||
if (childTask != null && childTask.isOrganized()) {
|
||||
final ActivityManager.RecentTaskInfo cti = new ActivityManager.RecentTaskInfo();
|
||||
childTask.fillTaskInfo(cti);
|
||||
rti.childrenTaskInfos.add(cti);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rti;
|
||||
}
|
||||
|
||||
|
||||
@@ -473,6 +473,28 @@ public class RecentTasksTest extends WindowTestsBase {
|
||||
true /* getTasksAllowed */, TEST_USER_0_ID, 0).getList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppendOrganizedChildTaskInfo() {
|
||||
final Task root = createTaskBuilder(".CreatedByOrganizerRoot").build();
|
||||
root.mCreatedByOrganizer = true;
|
||||
// Add organized and non-organized child.
|
||||
final Task child1 = createTaskBuilder(".Task1").setParentTask(root).build();
|
||||
final Task child2 = createTaskBuilder(".Task2").setParentTask(root).build();
|
||||
doReturn(true).when(child1).isOrganized();
|
||||
doReturn(false).when(child2).isOrganized();
|
||||
mRecentTasks.add(root);
|
||||
|
||||
doNothing().when(mRecentTasks).loadUserRecentsLocked(anyInt());
|
||||
doReturn(true).when(mRecentTasks).isUserRunning(anyInt(), anyInt());
|
||||
final List<RecentTaskInfo> infos = mRecentTasks.getRecentTasks(MAX_VALUE, 0 /* flags */,
|
||||
true /* getTasksAllowed */, TEST_USER_0_ID, 0 /* callingUid */).getList();
|
||||
|
||||
// Make sure only organized child will be appended.
|
||||
final List<RecentTaskInfo> childrenTaskInfos = infos.get(0).childrenTaskInfos;
|
||||
assertEquals(childrenTaskInfos.size(), 1);
|
||||
assertEquals(childrenTaskInfos.get(0).taskId, child1.mTaskId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddTasksHomeClearUntrackedTasks_expectFinish() {
|
||||
// There may be multiple tasks with the same base intent by flags (FLAG_ACTIVITY_NEW_TASK |
|
||||
|
||||
Reference in New Issue
Block a user