Loading core/java/android/app/ActivityManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -509,6 +509,12 @@ public class ActivityManager { */ public int stackId; /** * The id the of the user the task was running as. * @hide */ public int userId; public RecentTaskInfo() { } Loading @@ -531,6 +537,7 @@ public class ActivityManager { TextUtils.writeToParcel(description, dest, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); dest.writeInt(stackId); dest.writeInt(userId); } public void readFromParcel(Parcel source) { Loading @@ -544,6 +551,7 @@ public class ActivityManager { origActivity = ComponentName.readFromParcel(source); description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); stackId = source.readInt(); userId = source.readInt(); } public static final Creator<RecentTaskInfo> CREATOR Loading Loading @@ -574,6 +582,13 @@ public class ActivityManager { */ public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002; /** * Provides a list that also contains recent tasks for user * and related users. * @hide */ public static final int RECENT_INCLUDE_RELATED = 0x0004; /** * Return a list of the tasks that the user has recently launched, with * the most recent being first and older ones after in order. Loading packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java +5 −3 Original line number Diff line number Diff line Loading @@ -367,8 +367,9 @@ public class RecentTasksLoader implements View.OnTouchListener { public TaskDescription loadFirstTask() { final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser( 1, ActivityManager.RECENT_IGNORE_UNAVAILABLE, UserHandle.CURRENT.getIdentifier()); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser(1, ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier()); TaskDescription item = null; if (recentTasks.size() > 0) { ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(0); Loading Loading @@ -439,7 +440,8 @@ public class RecentTasksLoader implements View.OnTouchListener { mContext.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE); am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED); int numTasks = recentTasks.size(); ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm, 0); Loading packages/SystemUI/src/com/android/systemui/recent/Recents.java +4 −2 Original line number Diff line number Diff line Loading @@ -359,7 +359,8 @@ public class Recents extends SystemUI implements RecentsComponent { Bitmap loadFirstTaskThumbnail() { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(1, ActivityManager.RECENT_IGNORE_UNAVAILABLE, UserHandle.CURRENT.getIdentifier()); ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier()); for (ActivityManager.RecentTaskInfo t : tasks) { // Skip tasks in the home stack if (am.isInHomeStack(t.persistentId)) { Loading @@ -376,7 +377,8 @@ public class Recents extends SystemUI implements RecentsComponent { boolean hasFirstTask() { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(1, ActivityManager.RECENT_IGNORE_UNAVAILABLE, UserHandle.CURRENT.getIdentifier()); ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier()); for (ActivityManager.RecentTaskInfo t : tasks) { // Skip tasks in the home stack if (am.isInHomeStack(t.persistentId)) { Loading packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,8 @@ public class RecentsActivity extends Activity { final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(2, ActivityManager.RECENT_WITH_EXCLUDED | ActivityManager.RECENT_IGNORE_UNAVAILABLE); ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED); if (recentTasks.size() > 1 && mRecentsPanel.simulateClick(recentTasks.get(1).persistentId)) { // recents panel will take care of calling show(false) through simulateClick Loading services/core/java/com/android/server/am/ActivityManagerService.java +22 −3 Original line number Diff line number Diff line Loading @@ -6856,10 +6856,19 @@ public final class ActivityManagerService extends ActivityManagerNative ArrayList<ActivityManager.RecentTaskInfo> res = new ArrayList<ActivityManager.RecentTaskInfo>( maxNum < N ? maxNum : N); final Set<Integer> includedUsers; if ((flags & ActivityManager.RECENT_INCLUDE_RELATED) != 0) { includedUsers = getRelatedUsersLocked(userId); } else { includedUsers = new HashSet<Integer>(); } includedUsers.add(Integer.valueOf(userId)); for (int i=0; i<N && maxNum > 0; i++) { TaskRecord tr = mRecentTasks.get(i); // Only add calling user's recent tasks if (tr.userId != userId) continue; // Only add calling user or related users recent tasks if (!includedUsers.contains(Integer.valueOf(tr.userId))) continue; // Return the entry if desired by the caller. We always return // the first entry, because callers always expect this to be the // foreground app. We may filter others if the caller has Loading @@ -6883,6 +6892,7 @@ public final class ActivityManagerService extends ActivityManagerNative rti.origActivity = tr.origActivity; rti.description = tr.lastDescription; rti.stackId = tr.stack.mStackId; rti.userId = tr.userId; if ((flags&ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) { // Check whether this activity is currently available. Loading Loading @@ -16262,6 +16272,15 @@ public final class ActivityManagerService extends ActivityManagerNative mRelatedUserIds = relatedUserIds; } private Set getRelatedUsersLocked(int userId) { Set userIds = new HashSet<Integer>(); final List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(userId); for (UserInfo user : relatedUsers) { userIds.add(Integer.valueOf(user.id)); } return userIds; } @Override public boolean switchUser(final int userId) { return startUser(userId, /* foregound */ true); Loading
core/java/android/app/ActivityManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -509,6 +509,12 @@ public class ActivityManager { */ public int stackId; /** * The id the of the user the task was running as. * @hide */ public int userId; public RecentTaskInfo() { } Loading @@ -531,6 +537,7 @@ public class ActivityManager { TextUtils.writeToParcel(description, dest, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); dest.writeInt(stackId); dest.writeInt(userId); } public void readFromParcel(Parcel source) { Loading @@ -544,6 +551,7 @@ public class ActivityManager { origActivity = ComponentName.readFromParcel(source); description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); stackId = source.readInt(); userId = source.readInt(); } public static final Creator<RecentTaskInfo> CREATOR Loading Loading @@ -574,6 +582,13 @@ public class ActivityManager { */ public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002; /** * Provides a list that also contains recent tasks for user * and related users. * @hide */ public static final int RECENT_INCLUDE_RELATED = 0x0004; /** * Return a list of the tasks that the user has recently launched, with * the most recent being first and older ones after in order. Loading
packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java +5 −3 Original line number Diff line number Diff line Loading @@ -367,8 +367,9 @@ public class RecentTasksLoader implements View.OnTouchListener { public TaskDescription loadFirstTask() { final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser( 1, ActivityManager.RECENT_IGNORE_UNAVAILABLE, UserHandle.CURRENT.getIdentifier()); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasksForUser(1, ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier()); TaskDescription item = null; if (recentTasks.size() > 0) { ActivityManager.RecentTaskInfo recentInfo = recentTasks.get(0); Loading Loading @@ -439,7 +440,8 @@ public class RecentTasksLoader implements View.OnTouchListener { mContext.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE); am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED); int numTasks = recentTasks.size(); ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME).resolveActivityInfo(pm, 0); Loading
packages/SystemUI/src/com/android/systemui/recent/Recents.java +4 −2 Original line number Diff line number Diff line Loading @@ -359,7 +359,8 @@ public class Recents extends SystemUI implements RecentsComponent { Bitmap loadFirstTaskThumbnail() { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(1, ActivityManager.RECENT_IGNORE_UNAVAILABLE, UserHandle.CURRENT.getIdentifier()); ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier()); for (ActivityManager.RecentTaskInfo t : tasks) { // Skip tasks in the home stack if (am.isInHomeStack(t.persistentId)) { Loading @@ -376,7 +377,8 @@ public class Recents extends SystemUI implements RecentsComponent { boolean hasFirstTask() { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RecentTaskInfo> tasks = am.getRecentTasksForUser(1, ActivityManager.RECENT_IGNORE_UNAVAILABLE, UserHandle.CURRENT.getIdentifier()); ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED, UserHandle.CURRENT.getIdentifier()); for (ActivityManager.RecentTaskInfo t : tasks) { // Skip tasks in the home stack if (am.isInHomeStack(t.persistentId)) { Loading
packages/SystemUI/src/com/android/systemui/recent/RecentsActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,8 @@ public class RecentsActivity extends Activity { final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(2, ActivityManager.RECENT_WITH_EXCLUDED | ActivityManager.RECENT_IGNORE_UNAVAILABLE); ActivityManager.RECENT_IGNORE_UNAVAILABLE | ActivityManager.RECENT_INCLUDE_RELATED); if (recentTasks.size() > 1 && mRecentsPanel.simulateClick(recentTasks.get(1).persistentId)) { // recents panel will take care of calling show(false) through simulateClick Loading
services/core/java/com/android/server/am/ActivityManagerService.java +22 −3 Original line number Diff line number Diff line Loading @@ -6856,10 +6856,19 @@ public final class ActivityManagerService extends ActivityManagerNative ArrayList<ActivityManager.RecentTaskInfo> res = new ArrayList<ActivityManager.RecentTaskInfo>( maxNum < N ? maxNum : N); final Set<Integer> includedUsers; if ((flags & ActivityManager.RECENT_INCLUDE_RELATED) != 0) { includedUsers = getRelatedUsersLocked(userId); } else { includedUsers = new HashSet<Integer>(); } includedUsers.add(Integer.valueOf(userId)); for (int i=0; i<N && maxNum > 0; i++) { TaskRecord tr = mRecentTasks.get(i); // Only add calling user's recent tasks if (tr.userId != userId) continue; // Only add calling user or related users recent tasks if (!includedUsers.contains(Integer.valueOf(tr.userId))) continue; // Return the entry if desired by the caller. We always return // the first entry, because callers always expect this to be the // foreground app. We may filter others if the caller has Loading @@ -6883,6 +6892,7 @@ public final class ActivityManagerService extends ActivityManagerNative rti.origActivity = tr.origActivity; rti.description = tr.lastDescription; rti.stackId = tr.stack.mStackId; rti.userId = tr.userId; if ((flags&ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) { // Check whether this activity is currently available. Loading Loading @@ -16262,6 +16272,15 @@ public final class ActivityManagerService extends ActivityManagerNative mRelatedUserIds = relatedUserIds; } private Set getRelatedUsersLocked(int userId) { Set userIds = new HashSet<Integer>(); final List<UserInfo> relatedUsers = getUserManagerLocked().getRelatedUsers(userId); for (UserInfo user : relatedUsers) { userIds.add(Integer.valueOf(user.id)); } return userIds; } @Override public boolean switchUser(final int userId) { return startUser(userId, /* foregound */ true);